misc.h
| 1 | #ifndef MISC_H |
| 2 | #define MISC_H |
| 3 | |
| 4 | #ifdef __unix__ |
| 5 | #define _BSD_SOURCE |
| 6 | #define _DEFAULT_SOURCE |
| 7 | #include <unistd.h> |
| 8 | #endif |
| 9 | #ifdef _WIN32 |
| 10 | #include <windows.h> |
| 11 | #endif |
| 12 | |
| 13 | #include <stdint.h> |
| 14 | #include <string.h> |
| 15 | |
| 16 | #if __STDC_VERSION__ >= 199901L |
| 17 | typedef uintmax_t max_uint_t; |
| 18 | #else |
| 19 | typedef unsigned long max_uint_t; |
| 20 | #endif |
| 21 | |
| 22 | |
| 23 | #if __STDC_VERSION__ >= 201112L |
| 24 | #include <time.h> |
| 25 | #endif |
| 26 | |
| 27 | void sleep_ms(unsigned int milliseconds); |
| 28 | uint32_t ntoh32(uint32_t const net); |
| 29 | |
| 30 | #if __STDC_VERSION__ >= 201112L |
| 31 | struct timespec timespec_diff(const struct timespec* old_ts, const struct timespec* new_ts); |
| 32 | struct timespec timespec_add(const struct timespec* ts_1, const struct timespec* ts_2); |
| 33 | max_uint_t timespec_ms(const struct timespec* ts); |
| 34 | #endif |
| 35 | |
| 36 | #endif /* MISC_H */ |
| 37 |