[*] Refactor "Jiffies" to "Frequency"
This commit is contained in:
parent
2972481066
commit
9ba049d485
@ -35,7 +35,7 @@ namespace Aurora::Time
|
||||
\
|
||||
static inline AuUInt64 GetFrequency() \
|
||||
{ \
|
||||
return oldClockType ## ClockJiffies(); \
|
||||
return oldClockType ## ClockFrequency(); \
|
||||
} \
|
||||
}; \
|
||||
\
|
||||
|
@ -26,7 +26,7 @@ namespace Aurora::Time
|
||||
AUKN_SYM AuUInt64 SteadyClock();
|
||||
|
||||
/**
|
||||
Returns a steady system clock of SteadyClockJiffies() with an undefined epoch.
|
||||
Returns a steady system clock of SteadyClockFrequency() with an undefined epoch.
|
||||
|
||||
These values should be used to drive thread primitives, IO time, and tick delta.
|
||||
On a modern plaform, these shoudln't be affected by the users' calendar or NTP.
|
||||
@ -42,12 +42,12 @@ namespace Aurora::Time
|
||||
/**
|
||||
Retrieves the freqency of jiffies per second
|
||||
*/
|
||||
AUKN_SYM AuUInt64 SteadyClockJiffies();
|
||||
AUKN_SYM AuUInt64 SteadyClockFrequency();
|
||||
|
||||
/**
|
||||
* @brief frequency in jiffies per second
|
||||
*/
|
||||
AUKN_SYM AuUInt64 ThreadClockJiffies();
|
||||
AUKN_SYM AuUInt64 ThreadClockFrequency();
|
||||
|
||||
/**
|
||||
* @brief time spent in userspace and in the kernel under this thread [in jiffies]
|
||||
@ -67,7 +67,7 @@ namespace Aurora::Time
|
||||
/**
|
||||
* @brief frequency in jiffies per second
|
||||
*/
|
||||
AUKN_SYM AuUInt64 ProcessClockJiffies();
|
||||
AUKN_SYM AuUInt64 ProcessClockFrequency();
|
||||
|
||||
/**
|
||||
* @brief time spent in userspace and in the kernel under this process [in jiffies]
|
||||
@ -104,7 +104,7 @@ namespace Aurora::Time
|
||||
/**
|
||||
* @brief frequency
|
||||
*/
|
||||
AUKN_SYM AuUInt64 ThreadUserClockJiffies();
|
||||
AUKN_SYM AuUInt64 ThreadUserClockFrequency();
|
||||
|
||||
/**
|
||||
* @brief
|
||||
@ -124,7 +124,7 @@ namespace Aurora::Time
|
||||
/**
|
||||
* @brief frequency
|
||||
*/
|
||||
AUKN_SYM AuUInt64 ProcessUserClockJiffies();
|
||||
AUKN_SYM AuUInt64 ProcessUserClockFrequency();
|
||||
|
||||
/**
|
||||
* @brief
|
||||
@ -144,7 +144,7 @@ namespace Aurora::Time
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
AUKN_SYM AuUInt64 ThreadKernelClockJiffies();
|
||||
AUKN_SYM AuUInt64 ThreadKernelClockFrequency();
|
||||
|
||||
/**
|
||||
* @brief
|
||||
@ -164,5 +164,5 @@ namespace Aurora::Time
|
||||
/**
|
||||
* @brief frequency
|
||||
*/
|
||||
AUKN_SYM AuUInt64 ProcessKernelClockJiffies();
|
||||
AUKN_SYM AuUInt64 ProcessKernelClockFrequency();
|
||||
}
|
@ -170,7 +170,7 @@ namespace Aurora::RNG
|
||||
return clock(); // [...] resolution of 1 posix clock() tick (this is usually 1,000,000 == CLOCKS_PER_SEC per posix, but it can be 1k)
|
||||
#else
|
||||
static AuUInt64 gTimeHolder;
|
||||
static AuUInt64 gTime = (gTimeHolder = AuTime::SteadyClockJiffies()) >= 10'000'000ull ?
|
||||
static AuUInt64 gTime = (gTimeHolder = AuTime::SteadyClockFrequency()) >= 10'000'000ull ?
|
||||
1 :
|
||||
AuPageRoundUp<AuUInt64>(10'000'000ull, 1024) / gTimeHolder;
|
||||
return AuTime::SteadyClockNS() * gTime / 10'000ull;
|
||||
|
@ -324,7 +324,7 @@ namespace Aurora::Time
|
||||
#if defined(AURORA_IS_MODERNNT_DERIVED) || defined(AURORA_IS_XNU_DERIVED)
|
||||
return _NTLikeQueryCounter();
|
||||
#else
|
||||
return SteadyClockNS() / (1000000000ull / SteadyClockJiffies());
|
||||
return SteadyClockNS() / (1000000000ull / SteadyClockFrequency());
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -366,7 +366,7 @@ namespace Aurora::Time
|
||||
#endif
|
||||
}
|
||||
|
||||
AUKN_SYM AuUInt64 SteadyClockJiffies()
|
||||
AUKN_SYM AuUInt64 SteadyClockFrequency()
|
||||
{
|
||||
static AuUInt64 gFrequency = 0;
|
||||
if (gFrequency != 0)
|
||||
@ -472,7 +472,7 @@ namespace Aurora::Time
|
||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||
|
||||
#define ADD_CLOCK_FAMILY(fn, type, expr, posixId, posixCall) \
|
||||
AUKN_SYM AuUInt64 fn ## ClockJiffies(); \
|
||||
AUKN_SYM AuUInt64 fn ## ClockFrequency(); \
|
||||
\
|
||||
AUKN_SYM AuUInt64 fn ## ClockMS() \
|
||||
{ \
|
||||
@ -520,10 +520,10 @@ namespace Aurora::Time
|
||||
return expr; \
|
||||
} \
|
||||
\
|
||||
return fn ##ClockNS() / (1000000000ull / fn ## ClockJiffies()); \
|
||||
return fn ##ClockNS() / (1000000000ull / fn ## ClockFrequency()); \
|
||||
} \
|
||||
\
|
||||
AUKN_SYM AuUInt64 fn ## ClockJiffies() \
|
||||
AUKN_SYM AuUInt64 fn ## ClockFrequency() \
|
||||
{ \
|
||||
return 1000000000ull / 100u; \
|
||||
}
|
||||
@ -531,7 +531,7 @@ namespace Aurora::Time
|
||||
#elif defined(AURORA_IS_POSIX_DERIVED)
|
||||
|
||||
#define ADD_CLOCK_FAMILY(fn, type, expr, posixId, posixCall) \
|
||||
AUKN_SYM AuUInt64 fn ## ClockJiffies(); \
|
||||
AUKN_SYM AuUInt64 fn ## ClockFrequency(); \
|
||||
\
|
||||
AUKN_SYM AuUInt64 fn ## ClockMS() \
|
||||
{ \
|
||||
@ -562,10 +562,10 @@ namespace Aurora::Time
|
||||
{ \
|
||||
return fn ##ClockNS() / 1000ull; \
|
||||
} \
|
||||
return fn ##ClockNS() / (1000000000ull / fn ## ClockJiffies()); \
|
||||
return fn ##ClockNS() / (1000000000ull / fn ## ClockFrequency()); \
|
||||
} \
|
||||
\
|
||||
AUKN_SYM AuUInt64 fn ## ClockJiffies() \
|
||||
AUKN_SYM AuUInt64 fn ## ClockFrequency() \
|
||||
{ \
|
||||
if (!posixId) \
|
||||
{ \
|
||||
@ -611,7 +611,7 @@ namespace Aurora::Time
|
||||
return 0;
|
||||
}
|
||||
|
||||
AUKN_SYM AuUInt64 fn ## ClockJiffies()
|
||||
AUKN_SYM AuUInt64 fn ## ClockFrequency()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
namespace Aurora::Time
|
||||
{
|
||||
#define ADD_CLOCK(name, enum, jiffies, getNs, getMs) \
|
||||
#define ADD_CLOCK(name, enum, Frequency, getNs, getMs) \
|
||||
struct name ## Clock_t : IClock \
|
||||
{ \
|
||||
EClock GetType() override \
|
||||
@ -20,7 +20,7 @@ namespace Aurora::Time
|
||||
\
|
||||
AuUInt64 GetHertz() override \
|
||||
{ \
|
||||
return jiffies(); \
|
||||
return Frequency(); \
|
||||
} \
|
||||
\
|
||||
AuUInt64 NowNS() override \
|
||||
@ -43,14 +43,14 @@ namespace Aurora::Time
|
||||
|
||||
#define FILE_AND_USR_DIR_STEP (AuMSToNS<AuUInt64>(AuSToMS<AuUInt64>(1)) / 100ull)
|
||||
|
||||
ADD_CLOCK(Steady, eSteady, SteadyClockJiffies, SteadyClockNS, SteadyClockMS);
|
||||
ADD_CLOCK(Steady, eSteady, SteadyClockFrequency, SteadyClockNS, SteadyClockMS);
|
||||
ADD_CLOCK(Wall, eWall, FILE_AND_USR_DIR_STEP + AuUInt64, CurrentClockNS, CurrentClockMS);
|
||||
ADD_CLOCK(Process, eProcessTime, ProcessClockJiffies, ProcessClockNS, ProcessClockMS);
|
||||
ADD_CLOCK(ProcessKernel, eProcessKernelTime, ProcessKernelClockJiffies, ProcessKernelClockNS, ProcessKernelClockMS);
|
||||
ADD_CLOCK(ProcessUser, eProcessUserTime, ProcessUserClockJiffies, ProcessUserClockNS, ProcessUserClockMS);
|
||||
ADD_CLOCK(Thread, eThreadTime, ThreadClockJiffies, ThreadClockNS, ThreadClockMS);
|
||||
ADD_CLOCK(ThreadKernel, eThreadKernelTime, ThreadKernelClockJiffies, ThreadKernelClockNS, ThreadKernelClockMS);
|
||||
ADD_CLOCK(ThreadUser, eThreadUserTime, ThreadUserClockJiffies, ThreadUserClockNS, ThreadUserClockMS);
|
||||
ADD_CLOCK(Process, eProcessTime, ProcessClockFrequency, ProcessClockNS, ProcessClockMS);
|
||||
ADD_CLOCK(ProcessKernel, eProcessKernelTime, ProcessKernelClockFrequency, ProcessKernelClockNS, ProcessKernelClockMS);
|
||||
ADD_CLOCK(ProcessUser, eProcessUserTime, ProcessUserClockFrequency, ProcessUserClockNS, ProcessUserClockMS);
|
||||
ADD_CLOCK(Thread, eThreadTime, ThreadClockFrequency, ThreadClockNS, ThreadClockMS);
|
||||
ADD_CLOCK(ThreadKernel, eThreadKernelTime, ThreadKernelClockFrequency, ThreadKernelClockNS, ThreadKernelClockMS);
|
||||
ADD_CLOCK(ThreadUser, eThreadUserTime, ThreadUserClockFrequency, ThreadUserClockNS, ThreadUserClockMS);
|
||||
|
||||
#undef ADD_CLOCK
|
||||
|
||||
@ -113,15 +113,15 @@ namespace Aurora::Time
|
||||
case EClock::eWall:
|
||||
return FILE_AND_USR_DIR_STEP;
|
||||
case EClock::eSteady:
|
||||
return SteadyClockJiffies();
|
||||
return SteadyClockFrequency();
|
||||
case EClock::eProcessTime:
|
||||
case EClock::eProcessUserTime:
|
||||
case EClock::eProcessKernelTime:
|
||||
return ProcessClockJiffies();
|
||||
return ProcessClockFrequency();
|
||||
case EClock::eThreadTime:
|
||||
case EClock::eThreadUserTime:
|
||||
case EClock::eThreadKernelTime:
|
||||
return ThreadClockJiffies();
|
||||
return ThreadClockFrequency();
|
||||
default:
|
||||
SysPushErrorArg("Invalid clock");
|
||||
return {};
|
||||
|
@ -47,7 +47,7 @@ namespace Aurora::Time
|
||||
static dispatch_time_t DispatchTimeFromAuSteadyAbsNS(AuUInt64 uSteadyTimeABSNS)
|
||||
{
|
||||
AuUInt64 uRet {};
|
||||
uRet = uSteadyTimeABSNS / (1000000000ull / SteadyClockJiffies());
|
||||
uRet = uSteadyTimeABSNS / (1000000000ull / SteadyClockFrequency());
|
||||
uRet &= ~((1ull << 63ull) | (1ull << 62ull));
|
||||
uRet |= (1ull << 63ull);
|
||||
return (dispatch_time_t)uRet;
|
||||
|
Loading…
Reference in New Issue
Block a user