1afe49f35e1aa93c71cac74aec54bfa79050f756
[dpdk.git] / lib / librte_eal / windows / include / rte_os.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2019 Intel Corporation
3  */
4
5 #ifndef _RTE_OS_H_
6 #define _RTE_OS_H_
7
8 /**
9  * This header should contain any definition
10  * which is not supported natively or named differently in Windows.
11  */
12
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <string.h>
16
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20
21 /* limits.h replacement, value as in <windows.h> */
22 #ifndef PATH_MAX
23 #define PATH_MAX _MAX_PATH
24 #endif
25
26 #ifndef sleep
27 #define sleep(x) Sleep(1000 * (x))
28 #endif
29
30 #ifndef strerror_r
31 #define strerror_r(a, b, c) strerror_s(b, c, a)
32 #endif
33
34 #ifndef strdup
35 /* strdup is deprecated in Microsoft libc and _strdup is preferred */
36 #define strdup(str) _strdup(str)
37 #endif
38
39 #ifndef strtok_r
40 #define strtok_r(str, delim, saveptr) strtok_s(str, delim, saveptr)
41 #endif
42
43 #ifndef index
44 #define index(a, b)     strchr(a, b)
45 #endif
46
47 #ifndef rindex
48 #define rindex(a, b)    strrchr(a, b)
49 #endif
50
51 #ifndef strncasecmp
52 #define strncasecmp(s1, s2, count)        _strnicmp(s1, s2, count)
53 #endif
54
55 #ifndef close
56 #define close _close
57 #endif
58
59 #ifndef unlink
60 #define unlink _unlink
61 #endif
62
63 /* cpu_set macros implementation */
64 #define RTE_CPU_AND(dst, src1, src2) CPU_AND(dst, src1, src2)
65 #define RTE_CPU_OR(dst, src1, src2) CPU_OR(dst, src1, src2)
66 #define RTE_CPU_FILL(set) CPU_FILL(set)
67 #define RTE_CPU_NOT(dst, src) CPU_NOT(dst, src)
68
69 /* as in <windows.h> */
70 typedef long long ssize_t;
71
72 #ifndef RTE_TOOLCHAIN_GCC
73 static inline const char *
74 eal_strerror(int code)
75 {
76         static char buffer[128];
77
78         strerror_s(buffer, sizeof(buffer), code);
79         return buffer;
80 }
81
82 #ifndef strerror
83 #define strerror eal_strerror
84 #endif
85 #endif /* RTE_TOOLCHAIN_GCC */
86
87 #ifdef __cplusplus
88 }
89 #endif
90
91 #endif /* _RTE_OS_H_ */