diff options
Diffstat (limited to 'openbsd-compat/types.h')
-rw-r--r-- | openbsd-compat/types.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/openbsd-compat/types.h b/openbsd-compat/types.h new file mode 100644 index 0000000..cc1da66 --- /dev/null +++ b/openbsd-compat/types.h | |||
@@ -0,0 +1,71 @@ | |||
1 | /* | ||
2 | * Public domain | ||
3 | * sys/types.h compatibility shim | ||
4 | */ | ||
5 | |||
6 | #ifdef _MSC_VER | ||
7 | #if _MSC_VER >= 1900 | ||
8 | #include <../ucrt/sys/types.h> | ||
9 | #else | ||
10 | #include <../include/sys/types.h> | ||
11 | #endif | ||
12 | #endif | ||
13 | |||
14 | #ifndef _COMPAT_TYPES_H | ||
15 | #define _COMPAT_TYPES_H | ||
16 | |||
17 | #include <stdint.h> | ||
18 | |||
19 | #ifdef __MINGW32__ | ||
20 | #include <_bsd_types.h> | ||
21 | typedef uint32_t in_addr_t; | ||
22 | typedef uint32_t uid_t; | ||
23 | #endif | ||
24 | |||
25 | #ifdef _MSC_VER | ||
26 | typedef unsigned char u_char; | ||
27 | typedef unsigned short u_short; | ||
28 | typedef unsigned int u_int; | ||
29 | typedef uint32_t in_addr_t; | ||
30 | typedef uint32_t mode_t; | ||
31 | typedef uint32_t uid_t; | ||
32 | |||
33 | #include <basetsd.h> | ||
34 | typedef SSIZE_T ssize_t; | ||
35 | |||
36 | #ifndef SSIZE_MAX | ||
37 | #ifdef _WIN64 | ||
38 | #define SSIZE_MAX _I64_MAX | ||
39 | #else | ||
40 | #define SSIZE_MAX INT_MAX | ||
41 | #endif | ||
42 | #endif | ||
43 | |||
44 | #endif | ||
45 | |||
46 | #if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__bounded__) | ||
47 | # define __bounded__(x, y, z) | ||
48 | #endif | ||
49 | |||
50 | #ifdef _WIN32 | ||
51 | #define __warn_references(sym,msg) | ||
52 | #else | ||
53 | |||
54 | #ifndef __warn_references | ||
55 | |||
56 | #ifndef __STRING | ||
57 | #define __STRING(x) #x | ||
58 | #endif | ||
59 | |||
60 | #if defined(__GNUC__) && defined (HAS_GNU_WARNING_LONG) | ||
61 | #define __warn_references(sym,msg) \ | ||
62 | __asm__(".section .gnu.warning." __STRING(sym) \ | ||
63 | "\n\t.ascii \"" msg "\"\n\t.text"); | ||
64 | #else | ||
65 | #define __warn_references(sym,msg) | ||
66 | #endif | ||
67 | |||
68 | #endif /* __warn_references */ | ||
69 | #endif /* _WIN32 */ | ||
70 | |||
71 | #endif /* !_COMPAT_TYPES_H */ | ||