Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/SoftEtherVPN/SoftEtherVPN_Stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordnobori <da.git@softether.co.jp>2023-06-30 06:19:06 +0300
committerdnobori <da.git@softether.co.jp>2023-06-30 06:19:06 +0300
commit89939eb52f1f40e4f75c76e8d5eca019de103532 (patch)
treee51d227e06363817463efa2650e97d07290aed34 /src/Mayaqua/Unix.c
parent7d831acbfb967bdbbb17c9e579abdda380644148 (diff)
v4.42-9798-rtmv4.42-9798-rtm
Diffstat (limited to 'src/Mayaqua/Unix.c')
-rw-r--r--src/Mayaqua/Unix.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/Mayaqua/Unix.c b/src/Mayaqua/Unix.c
index ff84d35d..c988ea26 100644
--- a/src/Mayaqua/Unix.c
+++ b/src/Mayaqua/Unix.c
@@ -2114,6 +2114,68 @@ void UnixGetSystemTime(SYSTEMTIME *system_time)
pthread_mutex_unlock(&get_time_lock);
}
+UINT64 UnixGetHighresTickNano64(bool raw)
+{
+#if defined(OS_WIN32) || defined(CLOCK_REALTIME) || defined(CLOCK_MONOTONIC) || defined(CLOCK_HIGHRES)
+ struct timespec t;
+ UINT64 ret;
+ static bool akirame = false;
+
+ if (akirame)
+ {
+ return UnixGetTick64() * 1000000ULL;
+ }
+
+ Zero(&t, sizeof(t));
+
+ if (raw == false)
+ {
+ // Function to get the boot time of the system
+ // Be careful. The Implementation is depend on the system.
+#ifdef CLOCK_HIGHRES
+ clock_gettime(CLOCK_HIGHRES, &t);
+#else // CLOCK_HIGHRES
+#ifdef CLOCK_MONOTONIC
+ clock_gettime(CLOCK_MONOTONIC, &t);
+#else // CLOCK_MONOTONIC
+ clock_gettime(CLOCK_REALTIME, &t);
+#endif // CLOCK_MONOTONIC
+#endif // CLOCK_HIGHRES
+ }
+ else
+ {
+ // Function to get the boot time of the system
+ // Be careful. The Implementation is depend on the system.
+#ifdef CLOCK_HIGHRES
+ clock_gettime(CLOCK_HIGHRES, &t);
+#else // CLOCK_HIGHRES
+#ifdef CLOCK_MONOTONIC_RAW
+ clock_gettime(CLOCK_MONOTONIC_RAW, &t);
+#else // CLOCK_MONOTONIC_RAW
+#ifdef CLOCK_MONOTONIC
+ clock_gettime(CLOCK_MONOTONIC, &t);
+#else // CLOCK_MONOTONIC
+ clock_gettime(CLOCK_REALTIME, &t);
+#endif // CLOCK_MONOTONIC
+#endif // CLOCK_MONOTONIC_RAW
+#endif // CLOCK_HIGHRES
+ }
+
+ ret = ((UINT64)((UINT32)t.tv_sec)) * 1000000000LL + (UINT64)t.tv_nsec;
+
+ if (akirame == false && ret == 0)
+ {
+ ret = UnixGetTick64() * 1000000ULL;
+ akirame = true;
+ }
+
+ return ret;
+
+#else
+ return UnixGetTick64() * 1000000ULL;
+#endif
+}
+
// Get the system timer (64bit)
UINT64 UnixGetTick64()
{