1 /* SPDX-License-Identifier: BSD-3-Clause */
9 #include <rte_windows.h>
14 * Provides semi-standard OS facilities by convenient names.
18 #define PATH_MAX _MAX_PATH
21 #define strdup(str) _strdup(str)
22 #define strtok_r(str, delim, saveptr) strtok_s(str, delim, saveptr)
23 #ifndef RTE_TOOLCHAIN_GCC
24 #define strcasecmp(s1, s2) _stricmp(s1, s2)
25 #define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count)
28 #define open(path, flags, ...) _open(path, flags, ##__VA_ARGS__)
29 #define read(fd, buf, n) _read(fd, buf, n)
30 #define write(fd, buf, n) _write(fd, buf, n)
31 #define close(fd) _close(fd)
32 #define unlink(path) _unlink(path)
36 #define IPPROTO_IPIP 4
37 #define IPPROTO_GRE 47
38 #ifdef RTE_TOOLCHAIN_GCC
39 #define IPPROTO_SCTP 132
47 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
50 #ifdef RTE_TOOLCHAIN_GCC
55 rte_timespec_get(struct timespec *now, int base)
57 /* 100ns ticks from 1601-01-01 to 1970-01-01 */
58 static const uint64_t EPOCH = 116444736000000000ULL;
59 static const uint64_t TICKS_PER_SEC = 10000000;
60 static const uint64_t NS_PER_TICK = 100;
68 GetSystemTimePreciseAsFileTime(&ft);
69 ticks = ((uint64_t)ft.dwHighDateTime << 32) | ft.dwLowDateTime;
71 now->tv_sec = ticks / TICKS_PER_SEC;
72 now->tv_nsec = (ticks - now->tv_sec * TICKS_PER_SEC) * NS_PER_TICK;
76 #define timespec_get(ts, base) rte_timespec_get(ts, base)
78 #endif /* RTE_TOOLCHAIN_GCC */
80 #endif /* _RTE_OS_SHIM_ */