[llvm] Stop including unordered_map (NFC)
[llvm-project.git] / openmp / runtime / test / omp_my_sleep.h
blob138d930ca64084f2f7a2eeecea9821f189434dfb
1 #ifndef MY_SLEEP_H
2 #define MY_SLEEP_H
4 /*! Utility function to have a sleep function with better resolution and
5 * which only stops one thread. */
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <errno.h>
10 #include <time.h>
12 #if defined(_WIN32)
13 # include <windows.h>
14 // Windows version of my_sleep() function
15 static void my_sleep(double sleeptime) {
16 DWORD ms = (DWORD) (sleeptime * 1000.0);
17 Sleep(ms);
21 #else // _WIN32
23 // Unices version of my_sleep() function
24 static void my_sleep(double sleeptime) {
25 struct timespec ts;
26 ts.tv_sec = (time_t)sleeptime;
27 ts.tv_nsec = (long)((sleeptime - (double)ts.tv_sec) * 1E9);
28 nanosleep(&ts, NULL);
31 #endif // _WIN32
33 #endif // MY_SLEEP_H