sleep.h 370 B

123456789101112131415161718
  1. #pragma once
  2. #ifdef _WIN32
  3. #include <windows.h>
  4. static inline void millisleep(long ms)
  5. {
  6. Sleep((DWORD) ms);
  7. }
  8. #else
  9. #define _POSIX_C_SOURCE 200809L
  10. #include <time.h>
  11. static inline void millisleep(long ms)
  12. {
  13. nanosleep(&(struct timespec){ .tv_sec = (ms) / 1000,
  14. .tv_nsec = ((ms) % 1000L) * 1000000 },
  15. NULL);
  16. }
  17. #endif