generic_win_port.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #pragma once
  2. #include <dispatch/dispatch.h>
  3. #include <fcntl.h>
  4. #include <stdint.h>
  5. #include <sys/types.h>
  6. #include <Windows.h>
  7. typedef int kern_return_t;
  8. #ifndef HAVE_PID_T
  9. typedef int pid_t;
  10. #endif
  11. #if defined(_WIN64)
  12. typedef long long ssize_t;
  13. #else
  14. typedef long ssize_t;
  15. #endif
  16. struct mach_timebase_info {
  17. uint32_t numer;
  18. uint32_t denom;
  19. };
  20. typedef struct mach_timebase_info *mach_timebase_info_t;
  21. typedef struct mach_timebase_info mach_timebase_info_data_t;
  22. static inline int32_t
  23. OSAtomicIncrement32(volatile int32_t *var)
  24. {
  25. return __c11_atomic_fetch_add((_Atomic(int)*)var, 1, __ATOMIC_RELAXED)+1;
  26. }
  27. static inline int32_t
  28. OSAtomicIncrement32Barrier(volatile int32_t *var)
  29. {
  30. return __c11_atomic_fetch_add((_Atomic(int)*)var, 1, __ATOMIC_SEQ_CST)+1;
  31. }
  32. static inline int32_t
  33. OSAtomicAdd32(int32_t val, volatile int32_t *var)
  34. {
  35. return __c11_atomic_fetch_add((_Atomic(int)*)var, val, __ATOMIC_RELAXED)+val;
  36. }
  37. WCHAR *
  38. argv_to_command_line(char **argv);
  39. int
  40. asprintf(char **strp, const char *format, ...);
  41. void
  42. filetime_to_timeval(struct timeval *tp, const FILETIME *ft);
  43. pid_t
  44. getpid(void);
  45. int
  46. gettimeofday(struct timeval *tp, void *tzp);
  47. uint64_t
  48. mach_absolute_time(void);
  49. static inline
  50. int
  51. mach_timebase_info(mach_timebase_info_t tbi)
  52. {
  53. tbi->numer = 1;
  54. tbi->denom = 1;
  55. return 0;
  56. }
  57. #ifndef HAVE_MKSTEMP
  58. dispatch_fd_t
  59. mkstemp(char *tmpl);
  60. #endif
  61. void
  62. print_winapi_error(const char *function_name, DWORD error);
  63. intptr_t
  64. random(void);
  65. unsigned int
  66. sleep(unsigned int seconds);
  67. int
  68. usleep(unsigned int usec);