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