sleep.h (666B)
1 #define BASE_SLEEP_TIME 500 2 3 STATIC void msleep(int); 4 5 #if defined(_WIN32) 6 7 #include <windows.h> 8 9 #define NISSY_CANSLEEP true 10 11 STATIC void 12 msleep(int milliseconds) 13 { 14 Sleep(milliseconds); 15 } 16 17 #elif defined(__wasm__) 18 19 #include <emscripten.h> 20 21 #define NISSY_CANSLEEP true 22 23 STATIC void 24 msleep(int milliseconds) 25 { 26 emscripten_sleep(milliseconds); 27 } 28 29 #elif defined(__unix__) 30 31 #include <time.h> 32 33 #define NISSY_CANSLEEP true 34 35 STATIC void 36 msleep(int milliseconds) 37 { 38 struct timespec t; 39 t.tv_sec = milliseconds / 1000; 40 t.tv_nsec = (milliseconds % 1000) * 1000000; 41 nanosleep(&t, NULL); 42 } 43 44 #else 45 46 #define NISSY_CANSLEEP false 47 STATIC void 48 msleep(int milliseconds) 49 { 50 } 51 52 #endif