xref: /freebsd/contrib/libfido2/openbsd-compat/posix_win.h (revision 6ba2210ee039f2f12878c217bcf058e9c8b26b29)
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 */
48