diff options
Diffstat (limited to 'openbsd-compat/posix_win.h')
-rw-r--r-- | openbsd-compat/posix_win.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/openbsd-compat/posix_win.h b/openbsd-compat/posix_win.h new file mode 100644 index 0000000..a1e0888 --- /dev/null +++ b/openbsd-compat/posix_win.h | |||
@@ -0,0 +1,47 @@ | |||
1 | /* | ||
2 | * Public domain | ||
3 | * | ||
4 | * BSD socket emulation code for Winsock2 | ||
5 | * Brent Cook <bcook@openbsd.org> | ||
6 | */ | ||
7 | |||
8 | #ifndef _COMPAT_POSIX_WIN_H | ||
9 | #define _COMPAT_POSIX_WIN_H | ||
10 | |||
11 | #ifdef _WIN32 | ||
12 | |||
13 | #include <windows.h> | ||
14 | |||
15 | #include <errno.h> | ||
16 | #include <stdarg.h> | ||
17 | #include <stdint.h> | ||
18 | #include <stdio.h> | ||
19 | #include <stdlib.h> | ||
20 | #include <string.h> | ||
21 | |||
22 | #if _MSC_VER >= 1900 | ||
23 | #include <../ucrt/fcntl.h> | ||
24 | #else | ||
25 | #include <../include/fcntl.h> | ||
26 | #endif | ||
27 | |||
28 | #include "types.h" | ||
29 | |||
30 | int posix_open(const char *path, ...); | ||
31 | |||
32 | int posix_close(int fd); | ||
33 | |||
34 | ssize_t posix_read(int fd, void *buf, size_t count); | ||
35 | |||
36 | ssize_t posix_write(int fd, const void *buf, size_t count); | ||
37 | |||
38 | #ifndef NO_REDEF_POSIX_FUNCTIONS | ||
39 | #define open(path, ...) posix_open(path, __VA_ARGS__) | ||
40 | #define close(fd) posix_close(fd) | ||
41 | #define read(fd, buf, count) posix_read(fd, buf, count) | ||
42 | #define write(fd, buf, count) posix_write(fd, buf, count) | ||
43 | #endif | ||
44 | |||
45 | #endif /* _WIN32 */ | ||
46 | |||
47 | #endif /* !_COMPAT_POSIX_WIN_H */ | ||