Package list libcryptx-perl / 653122d
fortuna fix Karel Miko 3 years ago
1 changed file(s) with 9 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
7171 static ulong64 _fortuna_current_time(void)
7272 {
7373 ulong64 cur_time;
74 #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L
75 struct timespec ts;
76 clock_gettime(CLOCK_MONOTONIC, &ts);
77 cur_time = (ulong64)(ts.tv_sec) * 1000000 + (ulong64)(ts.tv_nsec) / 1000; /* get microseconds */
78 #elif defined(_WIN32)
74 #if defined(_WIN32)
7975 FILETIME CurrentTime;
8076 ULARGE_INTEGER ul;
8177 GetSystemTimeAsFileTime(&CurrentTime);
8480 cur_time = ul.QuadPart; /* now we have 100ns intervals since 1 January 1601 */
8581 cur_time -= CONST64(116444736000000000); /* subtract 100ns intervals between 1601-1970 */
8682 cur_time /= 10; /* 100ns intervals > microseconds */
83 #elif defined(LTC_CLOCK_GETTIME)
84 struct timespec ts;
85 clock_gettime(CLOCK_MONOTONIC, &ts);
86 cur_time = (ulong64)(ts.tv_sec) * 1000000 + (ulong64)(ts.tv_nsec) / 1000; /* get microseconds */
87 #else
88 struct timeval tv;
89 gettimeofday(&tv, NULL);
90 cur_time = (ulong64)(tv.tv_sec) * 1000000 + (ulong64)(tv.tv_usec); /* get microseconds */
8791 #endif
8892 return cur_time / 100;
8993 }