2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * unistd.h: POSIX emulation for Windows
29 * Known contributors to this file:
30 * Ron Koenderink, 2007
31 * Markus Armbruster, 2007-2013
35 * We can provide POSIX headers that don't exist in Windows, but we
36 * can't augment existing headers. Some stuff that should be in such
37 * headers ends up here, and some in w32misc.h. Can't be helped.
44 * We override system functions by defining them as macros. This
45 * breaks if the system's declaration is included later. Include them
46 * here. Major name space pollution, can't be helped.
57 /* Should be in sys/stat.h */
58 #define mkdir(dir, perm) w32_mkdir((dir), (perm))
59 extern int w32_mkdir(const char *dirname, mode_t perm);
61 /* Should be in sys/stat.h */
64 #define S_IRUSR _S_IREAD
65 #define S_IWUSR _S_IWRITE
66 #define S_IXUSR _S_IEXEC
67 #define S_IRWXU S_IRUSR | S_IWUSR | S_IXUSR
73 #define S_IRWXG S_IRGRP | S_IWGRP | S_IXGRP
79 #define S_IRWXO S_IROTH | S_IWOTH | S_IXOTH
83 /* Should be in fcntl.h */
84 /* HACK, for use with fcntl() on a socket only, see w32sockets.c */
88 extern int fcntl(int fd, int cmd, ...);
90 /* Stuff that actually belongs here */
91 #define close(fd) w32_close_function((fd))
92 extern int (*w32_close_function)(int);
93 #define read(fd, buf, sz) w32_read_function((fd), (buf), (sz))
94 extern int (*w32_read_function)(int, void *, unsigned);
95 #define write(fd, buf, sz) w32_write_function((fd), (buf), (sz))
96 extern int (*w32_write_function)(int, const void *, unsigned);
98 #define ftruncate(fd, length) _chsize((fd), (length))
102 #include_next <unistd.h>
105 #endif /* UNISTD_H */