1616#define EASTL_CHRONO_H
1717
1818#if defined(EA_PRAGMA_ONCE_SUPPORTED)
19- #pragma once
19+ #pragma once
2020#endif
2121
2222#include < EASTL/internal/config.h>
5252 // Nothing to do
5353#elif defined(EA_PLATFORM_APPLE)
5454 #include < mach/mach_time.h>
55- #elif defined(EA_PLATFORM_POSIX) || defined(EA_PLATFORM_MINGW) || defined(EA_PLATFORM_ANDROID)
55+ #elif defined(EA_PLATFORM_POSIX) || defined(EA_PLATFORM_MINGW) || defined(EA_PLATFORM_ANDROID)
5656 // Posix means Linux, Unix, and Macintosh OSX, among others (including Linux-based mobile platforms).
5757 #if defined(EA_PLATFORM_MINGW)
5858 #include < pthread_time.h>
@@ -101,7 +101,7 @@ namespace chrono
101101 namespace Internal
102102 {
103103 // /////////////////////////////////////////////////////////////////////////////
104- // IsRatio
104+ // IsRatio
105105 // /////////////////////////////////////////////////////////////////////////////
106106 template <typename > struct IsRatio : eastl::false_type {};
107107 template <intmax_t N, intmax_t D> struct IsRatio <ratio<N, D>> : eastl::true_type {};
@@ -111,7 +111,7 @@ namespace chrono
111111
112112
113113 // /////////////////////////////////////////////////////////////////////////////
114- // IsDuration
114+ // IsDuration
115115 // /////////////////////////////////////////////////////////////////////////////
116116 template <typename > struct IsDuration : eastl::false_type{};
117117 template <typename Rep, typename Period> struct IsDuration <duration<Rep, Period>> : eastl::true_type{};
@@ -121,7 +121,7 @@ namespace chrono
121121
122122
123123 // /////////////////////////////////////////////////////////////////////////////
124- // RatioGCD
124+ // RatioGCD
125125 // /////////////////////////////////////////////////////////////////////////////
126126 template <class Period1 , class Period2 >
127127 struct RatioGCD
@@ -194,10 +194,10 @@ namespace chrono
194194
195195
196196 // /////////////////////////////////////////////////////////////////////////////
197- // duration_cast
197+ // duration_cast
198198 // /////////////////////////////////////////////////////////////////////////////
199199 template <typename ToDuration, typename Rep, typename Period>
200- inline typename eastl::enable_if<Internal::IsDuration<ToDuration>::value, ToDuration>::type
200+ inline typename eastl::enable_if<Internal::IsDuration<ToDuration>::value, ToDuration>::type
201201 duration_cast (const duration<Rep, Period>& d)
202202 {
203203 typedef typename duration<Rep, Period>::this_type FromDuration;
@@ -206,20 +206,20 @@ namespace chrono
206206
207207
208208 // /////////////////////////////////////////////////////////////////////////////
209- // duration
209+ // duration
210210 // /////////////////////////////////////////////////////////////////////////////
211211 template <class Rep , class Period >
212212 class duration
213213 {
214- Rep mRep ;
214+ Rep mRep ;
215215
216216 public:
217217 typedef Rep rep;
218218 typedef Period period;
219219 typedef duration<Rep, Period> this_type;
220220
221221 #if defined(EA_COMPILER_NO_DEFAULTED_FUNCTIONS)
222- EA_CONSTEXPR duration ()
222+ EA_CONSTEXPR duration ()
223223 : mRep() {}
224224
225225 duration (const duration& other)
@@ -235,7 +235,7 @@ namespace chrono
235235
236236
237237 // /////////////////////////////////////////////////////////////////////////////
238- // conversion constructors
238+ // conversion constructors
239239 // /////////////////////////////////////////////////////////////////////////////
240240 template <class Rep2 >
241241 inline EA_CONSTEXPR explicit duration (
@@ -255,12 +255,12 @@ namespace chrono
255255 : mRep(duration_cast<duration>(d2).count()) {}
256256
257257 // /////////////////////////////////////////////////////////////////////////////
258- // returns the count of ticks
258+ // returns the count of ticks
259259 // /////////////////////////////////////////////////////////////////////////////
260260 EA_CONSTEXPR Rep count () const { return mRep ; }
261261
262262 // /////////////////////////////////////////////////////////////////////////////
263- // static accessors of special duration values
263+ // static accessors of special duration values
264264 // /////////////////////////////////////////////////////////////////////////////
265265 EA_CONSTEXPR inline static duration zero () { return duration (duration_values<Rep>::zero ()); }
266266 EA_CONSTEXPR inline static duration min () { return duration (duration_values<Rep>::min ()); }
@@ -418,7 +418,7 @@ namespace chrono
418418 // /////////////////////////////////////////////////////////////////////////////
419419 // 20.12.6, time_point
420420 // /////////////////////////////////////////////////////////////////////////////
421- template <typename Clock, typename Duration = typename Clock::duration>
421+ template <typename Clock, typename Duration = typename Clock::duration>
422422 class time_point
423423 {
424424 Duration mDuration ;
@@ -440,7 +440,7 @@ namespace chrono
440440
441441 EA_CONSTEXPR Duration time_since_epoch () const { return mDuration ; }
442442
443- time_point& operator +=(const Duration& d) { mDuration += d; return *this ; }
443+ time_point& operator +=(const Duration& d) { mDuration += d; return *this ; }
444444 time_point& operator -=(const Duration& d) { mDuration -= d; return *this ; }
445445
446446 static EA_CONSTEXPR time_point min () { return time_point (Duration::min ()); }
@@ -543,7 +543,7 @@ namespace chrono
543543 namespace Internal
544544 {
545545 #if defined(EA_PLATFORM_MICROSOFT) && !defined(EA_PLATFORM_MINGW)
546- #define EASTL_NS_PER_TICK 1
546+ #define EASTL_NS_PER_TICK 1
547547 #elif defined EA_PLATFORM_SONY
548548 #define EASTL_NS_PER_TICK 1
549549 #elif defined EA_PLATFORM_POSIX
@@ -552,17 +552,17 @@ namespace chrono
552552 #define EASTL_NS_PER_TICK 100
553553 #endif
554554
555- #if defined(EA_PLATFORM_POSIX)
555+ #if defined(EA_PLATFORM_POSIX)
556556 typedef chrono::nanoseconds::period SystemClock_Period;
557557 typedef chrono::nanoseconds::period SteadyClock_Period;
558558 #else
559- typedef eastl::ratio_multiply<eastl::ratio<EASTL_NS_PER_TICK, 1 >, nano>::type SystemClock_Period;
560- typedef eastl::ratio_multiply<eastl::ratio<EASTL_NS_PER_TICK, 1 >, nano>::type SteadyClock_Period;
559+ typedef eastl::ratio_multiply<eastl::ratio<EASTL_NS_PER_TICK, 1 >, nano>::type SystemClock_Period;
560+ typedef eastl::ratio_multiply<eastl::ratio<EASTL_NS_PER_TICK, 1 >, nano>::type SteadyClock_Period;
561561 #endif
562562
563563
564564 // /////////////////////////////////////////////////////////////////////////////
565- // Internal::GetTicks
565+ // Internal::GetTicks
566566 // /////////////////////////////////////////////////////////////////////////////
567567 inline uint64_t GetTicks ()
568568 {
@@ -595,7 +595,7 @@ namespace chrono
595595 mach_timebase_info (&info);
596596 return info;
597597 };
598-
598+
599599 static auto timeInfo = queryTimeInfo ();
600600 uint64_t t = mach_absolute_time ();
601601 t *= timeInfo.numer ;
@@ -625,7 +625,7 @@ namespace chrono
625625
626626
627627 // /////////////////////////////////////////////////////////////////////////////
628- // system_clock
628+ // system_clock
629629 // /////////////////////////////////////////////////////////////////////////////
630630 class system_clock
631631 {
@@ -639,15 +639,15 @@ namespace chrono
639639 EA_CONSTEXPR_OR_CONST static bool is_steady = false ;
640640
641641 // returns a time point representing the current point in time.
642- static time_point now () EA_NOEXCEPT
643- {
644- return time_point (duration (Internal::GetTicks ()));
642+ static time_point now () EA_NOEXCEPT
643+ {
644+ return time_point (duration (Internal::GetTicks ()));
645645 }
646646 };
647647
648648
649649 // /////////////////////////////////////////////////////////////////////////////
650- // steady_clock
650+ // steady_clock
651651 // /////////////////////////////////////////////////////////////////////////////
652652 class steady_clock
653653 {
@@ -661,24 +661,24 @@ namespace chrono
661661 EA_CONSTEXPR_OR_CONST static bool is_steady = true ;
662662
663663 // returns a time point representing the current point in time.
664- static time_point now () EA_NOEXCEPT
665- {
666- return time_point (duration (Internal::GetTicks ()));
664+ static time_point now () EA_NOEXCEPT
665+ {
666+ return time_point (duration (Internal::GetTicks ()));
667667 }
668668 };
669669
670670
671671 // /////////////////////////////////////////////////////////////////////////////
672- // high_resolution_clock
672+ // high_resolution_clock
673673 // /////////////////////////////////////////////////////////////////////////////
674674 typedef system_clock high_resolution_clock;
675675
676676
677- } // namespace chrono
677+ } // namespace chrono
678678
679679
680680 // /////////////////////////////////////////////////////////////////////////////
681- // duration common_type specialization
681+ // duration common_type specialization
682682 // /////////////////////////////////////////////////////////////////////////////
683683 template <typename Rep1, typename Period1, typename Rep2, typename Period2>
684684 struct common_type <chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>
@@ -689,7 +689,7 @@ namespace chrono
689689
690690
691691 // /////////////////////////////////////////////////////////////////////////////
692- // time_point common_type specialization
692+ // time_point common_type specialization
693693 // /////////////////////////////////////////////////////////////////////////////
694694 template <typename Clock, typename Duration1, typename Duration2>
695695 struct common_type <chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>
@@ -699,10 +699,15 @@ namespace chrono
699699
700700
701701 // /////////////////////////////////////////////////////////////////////////////
702- // chrono_literals
702+ // chrono_literals
703703 // /////////////////////////////////////////////////////////////////////////////
704704 #if EASTL_USER_LITERALS_ENABLED && EASTL_INLINE_NAMESPACES_ENABLED
705- EA_DISABLE_VC_WARNING (4455 ) // disable warning C4455: literal suffix identifiers that do not start with an underscore are reserved
705+ // Disabling the Clang/GCC/MSVC warning about using user
706+ // defined literals without a leading '_' as they are reserved
707+ // for standard libary usage.
708+ EA_DISABLE_VC_WARNING (4455 )
709+ EA_DISABLE_CLANG_WARNING(-Wuser-defined -literals)
710+ EA_DISABLE_GCC_WARNING(-Wliteral-suffix)
706711 inline namespace literals
707712 {
708713 inline namespace chrono_literals
@@ -735,7 +740,9 @@ namespace chrono
735740
736741 } // namespace chrono_literals
737742 }// namespace literals
738- EA_RESTORE_VC_WARNING () // warning: 4455
743+ EA_RESTORE_GCC_WARNING () // -Wliteral-suffix
744+ EA_RESTORE_CLANG_WARNING() // -Wuser-defined-literals
745+ EA_RESTORE_VC_WARNING() // warning: 4455
739746 #endif
740747
741748} // namespace eastl
@@ -749,4 +756,4 @@ namespace chrono
749756#endif
750757
751758
752- #endif
759+ #endif
0 commit comments