diff options
author | Brent Cook <busterb@gmail.com> | 2014-07-10 22:06:10 -0500 |
---|---|---|
committer | Brent Cook <bcook@openbsd.org> | 2015-07-21 12:08:18 -0500 |
commit | 5d8a1cf7155130bd8101090d7e1d0c2f90d9b123 (patch) | |
tree | 286f7d12e3647f94bd1e6e8e180a4bf6215a0740 /include/compat/sys | |
parent | 7a4a37cf596697ae96eeb1c555989e6d1a443187 (diff) | |
download | portable-5d8a1cf7155130bd8101090d7e1d0c2f90d9b123.tar.gz portable-5d8a1cf7155130bd8101090d7e1d0c2f90d9b123.tar.bz2 portable-5d8a1cf7155130bd8101090d7e1d0c2f90d9b123.zip |
add initial CMake and Visual Studio build support
This moves the compatibility include files from include to
include/compat so we can use the awful MS C compiler
<../include/> trick to emulate the GNU #include_next extension.
This also removes a few old compat files we do not need anymore.
Diffstat (limited to 'include/compat/sys')
-rw-r--r-- | include/compat/sys/cdefs.h | 31 | ||||
-rw-r--r-- | include/compat/sys/ioctl.h | 11 | ||||
-rw-r--r-- | include/compat/sys/mman.h | 19 | ||||
-rw-r--r-- | include/compat/sys/param.h | 15 | ||||
-rw-r--r-- | include/compat/sys/select.h | 10 | ||||
-rw-r--r-- | include/compat/sys/socket.h | 10 | ||||
-rw-r--r-- | include/compat/sys/stat.h | 95 | ||||
-rw-r--r-- | include/compat/sys/time.h | 16 | ||||
-rw-r--r-- | include/compat/sys/types.h | 43 | ||||
-rw-r--r-- | include/compat/sys/uio.h | 17 |
10 files changed, 267 insertions, 0 deletions
diff --git a/include/compat/sys/cdefs.h b/include/compat/sys/cdefs.h new file mode 100644 index 0000000..21ef031 --- /dev/null +++ b/include/compat/sys/cdefs.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | * Public domain | ||
3 | * sys/cdefs.h compatibility shim | ||
4 | */ | ||
5 | |||
6 | #ifndef LIBCRYPTOCOMPAT_SYS_CDEFS_H | ||
7 | #define LIBCRYPTOCOMPAT_SYS_CDEFS_H | ||
8 | |||
9 | #ifdef _WIN32 | ||
10 | |||
11 | #define __warn_references(sym,msg) | ||
12 | |||
13 | #else | ||
14 | |||
15 | #include_next <sys/cdefs.h> | ||
16 | |||
17 | #ifndef __warn_references | ||
18 | |||
19 | #if defined(__GNUC__) && defined (HAS_GNU_WARNING_LONG) | ||
20 | #define __warn_references(sym,msg) \ | ||
21 | __asm__(".section .gnu.warning." __STRING(sym) \ | ||
22 | " ; .ascii \"" msg "\" ; .text"); | ||
23 | #else | ||
24 | #define __warn_references(sym,msg) | ||
25 | #endif | ||
26 | |||
27 | #endif /* __warn_references */ | ||
28 | |||
29 | #endif /* _WIN32 */ | ||
30 | |||
31 | #endif /* LIBCRYPTOCOMPAT_SYS_CDEFS_H */ | ||
diff --git a/include/compat/sys/ioctl.h b/include/compat/sys/ioctl.h new file mode 100644 index 0000000..a255506 --- /dev/null +++ b/include/compat/sys/ioctl.h | |||
@@ -0,0 +1,11 @@ | |||
1 | /* | ||
2 | * Public domain | ||
3 | * sys/ioctl.h compatibility shim | ||
4 | */ | ||
5 | |||
6 | #ifndef _WIN32 | ||
7 | #include_next <sys/ioctl.h> | ||
8 | #else | ||
9 | #include <win32netcompat.h> | ||
10 | #define ioctl(fd, type, arg) ioctlsocket(fd, type, arg) | ||
11 | #endif | ||
diff --git a/include/compat/sys/mman.h b/include/compat/sys/mman.h new file mode 100644 index 0000000..d9eb6a9 --- /dev/null +++ b/include/compat/sys/mman.h | |||
@@ -0,0 +1,19 @@ | |||
1 | /* | ||
2 | * Public domain | ||
3 | * sys/mman.h compatibility shim | ||
4 | */ | ||
5 | |||
6 | #include_next <sys/mman.h> | ||
7 | |||
8 | #ifndef LIBCRYPTOCOMPAT_MMAN_H | ||
9 | #define LIBCRYPTOCOMPAT_MMAN_H | ||
10 | |||
11 | #ifndef MAP_ANON | ||
12 | #ifdef MAP_ANONYMOUS | ||
13 | #define MAP_ANON MAP_ANONYMOUS | ||
14 | #else | ||
15 | #error "System does not support mapping anonymous pages?" | ||
16 | #endif | ||
17 | #endif | ||
18 | |||
19 | #endif | ||
diff --git a/include/compat/sys/param.h b/include/compat/sys/param.h new file mode 100644 index 0000000..70488f8 --- /dev/null +++ b/include/compat/sys/param.h | |||
@@ -0,0 +1,15 @@ | |||
1 | /* | ||
2 | * Public domain | ||
3 | * sys/param.h compatibility shim | ||
4 | */ | ||
5 | |||
6 | #ifndef LIBCRYPTOCOMPAT_SYS_PARAM_H | ||
7 | #define LIBCRYPTOCOMPAT_SYS_PARAM_H | ||
8 | |||
9 | #ifdef _MSC_VER | ||
10 | #include <winsock2.h> | ||
11 | #else | ||
12 | #include_next <sys/param.h> | ||
13 | #endif | ||
14 | |||
15 | #endif | ||
diff --git a/include/compat/sys/select.h b/include/compat/sys/select.h new file mode 100644 index 0000000..5ca0ea1 --- /dev/null +++ b/include/compat/sys/select.h | |||
@@ -0,0 +1,10 @@ | |||
1 | /* | ||
2 | * Public domain | ||
3 | * sys/select.h compatibility shim | ||
4 | */ | ||
5 | |||
6 | #ifndef _WIN32 | ||
7 | #include_next <sys/select.h> | ||
8 | #else | ||
9 | #include <win32netcompat.h> | ||
10 | #endif | ||
diff --git a/include/compat/sys/socket.h b/include/compat/sys/socket.h new file mode 100644 index 0000000..17e84f1 --- /dev/null +++ b/include/compat/sys/socket.h | |||
@@ -0,0 +1,10 @@ | |||
1 | /* | ||
2 | * Public domain | ||
3 | * sys/socket.h compatibility shim | ||
4 | */ | ||
5 | |||
6 | #ifndef _WIN32 | ||
7 | #include_next <sys/socket.h> | ||
8 | #else | ||
9 | #include <win32netcompat.h> | ||
10 | #endif | ||
diff --git a/include/compat/sys/stat.h b/include/compat/sys/stat.h new file mode 100644 index 0000000..55135d8 --- /dev/null +++ b/include/compat/sys/stat.h | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | * Public domain | ||
3 | * sys/stat.h compatibility shim | ||
4 | */ | ||
5 | |||
6 | #ifndef LIBCRYPTOCOMPAT_SYS_STAT_H | ||
7 | #define LIBCRYPTOCOMPAT_SYS_STAT_H | ||
8 | |||
9 | #ifdef _MSC_VER | ||
10 | #include <windows.h> | ||
11 | #include <../include/sys/stat.h> | ||
12 | |||
13 | /* File type and permission flags for stat() */ | ||
14 | #if !defined(S_IFMT) | ||
15 | # define S_IFMT _S_IFMT /* File type mask */ | ||
16 | #endif | ||
17 | #if !defined(S_IFDIR) | ||
18 | # define S_IFDIR _S_IFDIR /* Directory */ | ||
19 | #endif | ||
20 | #if !defined(S_IFCHR) | ||
21 | # define S_IFCHR _S_IFCHR /* Character device */ | ||
22 | #endif | ||
23 | #if !defined(S_IFFIFO) | ||
24 | # define S_IFFIFO _S_IFFIFO /* Pipe */ | ||
25 | #endif | ||
26 | #if !defined(S_IFREG) | ||
27 | # define S_IFREG _S_IFREG /* Regular file */ | ||
28 | #endif | ||
29 | #if !defined(S_IREAD) | ||
30 | # define S_IREAD _S_IREAD /* Read permission */ | ||
31 | #endif | ||
32 | #if !defined(S_IWRITE) | ||
33 | # define S_IWRITE _S_IWRITE /* Write permission */ | ||
34 | #endif | ||
35 | #if !defined(S_IEXEC) | ||
36 | # define S_IEXEC _S_IEXEC /* Execute permission */ | ||
37 | #endif | ||
38 | #if !defined(S_IFIFO) | ||
39 | # define S_IFIFO _S_IFIFO /* Pipe */ | ||
40 | #endif | ||
41 | #if !defined(S_IFBLK) | ||
42 | # define S_IFBLK 0 /* Block device */ | ||
43 | #endif | ||
44 | #if !defined(S_IFLNK) | ||
45 | # define S_IFLNK 0 /* Link */ | ||
46 | #endif | ||
47 | #if !defined(S_IFSOCK) | ||
48 | # define S_IFSOCK 0 /* Socket */ | ||
49 | #endif | ||
50 | |||
51 | #if defined(_MSC_VER) | ||
52 | # define S_IRUSR S_IREAD /* Read user */ | ||
53 | # define S_IWUSR S_IWRITE /* Write user */ | ||
54 | # define S_IXUSR 0 /* Execute user */ | ||
55 | # define S_IRGRP 0 /* Read group */ | ||
56 | # define S_IWGRP 0 /* Write group */ | ||
57 | # define S_IXGRP 0 /* Execute group */ | ||
58 | # define S_IROTH 0 /* Read others */ | ||
59 | # define S_IWOTH 0 /* Write others */ | ||
60 | # define S_IXOTH 0 /* Execute others */ | ||
61 | #endif | ||
62 | |||
63 | /* File type flags for d_type */ | ||
64 | #define DT_UNKNOWN 0 | ||
65 | #define DT_REG S_IFREG | ||
66 | #define DT_DIR S_IFDIR | ||
67 | #define DT_FIFO S_IFIFO | ||
68 | #define DT_SOCK S_IFSOCK | ||
69 | #define DT_CHR S_IFCHR | ||
70 | #define DT_BLK S_IFBLK | ||
71 | #define DT_LNK S_IFLNK | ||
72 | |||
73 | /* Macros for converting between st_mode and d_type */ | ||
74 | #define IFTODT(mode) ((mode) & S_IFMT) | ||
75 | #define DTTOIF(type) (type) | ||
76 | |||
77 | /* | ||
78 | * File type macros. Note that block devices, sockets and links cannot be | ||
79 | * distinguished on Windows and the macros S_ISBLK, S_ISSOCK and S_ISLNK are | ||
80 | * only defined for compatibility. These macros should always return false | ||
81 | * on Windows. | ||
82 | */ | ||
83 | #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO) | ||
84 | #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) | ||
85 | #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) | ||
86 | #define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) | ||
87 | #define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK) | ||
88 | #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) | ||
89 | #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) | ||
90 | |||
91 | #else | ||
92 | #include_next <sys/stat.h> | ||
93 | #endif | ||
94 | |||
95 | #endif | ||
diff --git a/include/compat/sys/time.h b/include/compat/sys/time.h new file mode 100644 index 0000000..235bc6e --- /dev/null +++ b/include/compat/sys/time.h | |||
@@ -0,0 +1,16 @@ | |||
1 | /* | ||
2 | * Public domain | ||
3 | * sys/time.h compatibility shim | ||
4 | */ | ||
5 | |||
6 | #ifndef LIBCRYPTOCOMPAT_SYS_TIME_H | ||
7 | #define LIBCRYPTOCOMPAT_SYS_TIME_H | ||
8 | |||
9 | #ifdef _MSC_VER | ||
10 | #include <winsock2.h> | ||
11 | int gettimeofday(struct timeval *tp, void *tzp); | ||
12 | #else | ||
13 | #include_next <sys/time.h> | ||
14 | #endif | ||
15 | |||
16 | #endif | ||
diff --git a/include/compat/sys/types.h b/include/compat/sys/types.h new file mode 100644 index 0000000..9929dd5 --- /dev/null +++ b/include/compat/sys/types.h | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | * Public domain | ||
3 | * sys/types.h compatibility shim | ||
4 | */ | ||
5 | |||
6 | #ifndef LIBCRYPTOCOMPAT_SYS_TYPES_H | ||
7 | #define LIBCRYPTOCOMPAT_SYS_TYPES_H | ||
8 | |||
9 | #ifdef _MSC_VER | ||
10 | #include <../include/sys/types.h> | ||
11 | #else | ||
12 | #include_next <sys/types.h> | ||
13 | #endif | ||
14 | |||
15 | #include <stdint.h> | ||
16 | |||
17 | #ifdef __MINGW32__ | ||
18 | #include <_bsd_types.h> | ||
19 | #endif | ||
20 | |||
21 | #ifdef _MSC_VER | ||
22 | typedef unsigned char u_char; | ||
23 | typedef unsigned short u_short; | ||
24 | typedef unsigned int u_int; | ||
25 | |||
26 | #include <basetsd.h> | ||
27 | typedef SSIZE_T ssize_t; | ||
28 | |||
29 | #ifndef SSIZE_MAX | ||
30 | #ifdef _WIN64 | ||
31 | #define SSIZE_MAX _I64_MAX | ||
32 | #else | ||
33 | #define SSIZE_MAX INT_MAX | ||
34 | #endif | ||
35 | #endif | ||
36 | |||
37 | #endif | ||
38 | |||
39 | #if !defined(HAVE_ATTRIBUTE__BOUNDED__) && !defined(__bounded__) | ||
40 | # define __bounded__(x, y, z) | ||
41 | #endif | ||
42 | |||
43 | #endif | ||
diff --git a/include/compat/sys/uio.h b/include/compat/sys/uio.h new file mode 100644 index 0000000..b4aee9e --- /dev/null +++ b/include/compat/sys/uio.h | |||
@@ -0,0 +1,17 @@ | |||
1 | /* | ||
2 | * Public domain | ||
3 | * sys/select.h compatibility shim | ||
4 | */ | ||
5 | |||
6 | #ifndef _WIN32 | ||
7 | #include_next <sys/uio.h> | ||
8 | #else | ||
9 | |||
10 | #include <sys/types.h> | ||
11 | |||
12 | struct iovec { | ||
13 | void *iov_base; | ||
14 | size_t iov_len; | ||
15 | }; | ||
16 | |||
17 | #endif | ||