xref: /freebsd/contrib/libfido2/openbsd-compat/posix_win.h (revision 0afa8e065e14bb8fd338d75690e0238c00167d40)
1*0afa8e06SEd Maste /*
2*0afa8e06SEd Maste  * Public domain
3*0afa8e06SEd Maste  *
4*0afa8e06SEd Maste  * BSD socket emulation code for Winsock2
5*0afa8e06SEd Maste  * Brent Cook <bcook@openbsd.org>
6*0afa8e06SEd Maste  */
7*0afa8e06SEd Maste 
8*0afa8e06SEd Maste #ifndef _COMPAT_POSIX_WIN_H
9*0afa8e06SEd Maste #define _COMPAT_POSIX_WIN_H
10*0afa8e06SEd Maste 
11*0afa8e06SEd Maste #ifdef _WIN32
12*0afa8e06SEd Maste 
13*0afa8e06SEd Maste #include <windows.h>
14*0afa8e06SEd Maste 
15*0afa8e06SEd Maste #include <errno.h>
16*0afa8e06SEd Maste #include <stdarg.h>
17*0afa8e06SEd Maste #include <stdint.h>
18*0afa8e06SEd Maste #include <stdio.h>
19*0afa8e06SEd Maste #include <stdlib.h>
20*0afa8e06SEd Maste #include <string.h>
21*0afa8e06SEd Maste 
22*0afa8e06SEd Maste #if _MSC_VER >= 1900
23*0afa8e06SEd Maste #include <../ucrt/fcntl.h>
24*0afa8e06SEd Maste #else
25*0afa8e06SEd Maste #include <../include/fcntl.h>
26*0afa8e06SEd Maste #endif
27*0afa8e06SEd Maste 
28*0afa8e06SEd Maste #include "types.h"
29*0afa8e06SEd Maste 
30*0afa8e06SEd Maste int posix_open(const char *path, ...);
31*0afa8e06SEd Maste 
32*0afa8e06SEd Maste int posix_close(int fd);
33*0afa8e06SEd Maste 
34*0afa8e06SEd Maste ssize_t posix_read(int fd, void *buf, size_t count);
35*0afa8e06SEd Maste 
36*0afa8e06SEd Maste ssize_t posix_write(int fd, const void *buf, size_t count);
37*0afa8e06SEd Maste 
38*0afa8e06SEd Maste #ifndef NO_REDEF_POSIX_FUNCTIONS
39*0afa8e06SEd Maste #define open(path, ...) posix_open(path, __VA_ARGS__)
40*0afa8e06SEd Maste #define close(fd) posix_close(fd)
41*0afa8e06SEd Maste #define read(fd, buf, count) posix_read(fd, buf, count)
42*0afa8e06SEd Maste #define write(fd, buf, count) posix_write(fd, buf, count)
43*0afa8e06SEd Maste #endif
44*0afa8e06SEd Maste 
45*0afa8e06SEd Maste #endif /* _WIN32 */
46*0afa8e06SEd Maste 
47*0afa8e06SEd Maste #endif /* !_COMPAT_POSIX_WIN_H */
48