]> git.pond.sub.org Git - empserver/blobdiff - src/lib/w32/unistd.h
w32: Modernize for MinGW 6.0.0, and clean up
[empserver] / src / lib / w32 / unistd.h
index 2e24d49eb2b3adb6dc6f70a106ce708881f6b815..8e594ad8517bc37629c79e54bc14d75a2f515c29 100644 (file)
@@ -46,7 +46,6 @@
  * here.  Major name space pollution, can't be helped.
  */
 #include <direct.h>
-#include <getopt.h>
 #include <io.h>
 #include <process.h>
 #include <sys/stat.h>
@@ -60,6 +59,7 @@
 extern int w32_mkdir(const char *dirname, mode_t perm);
 
 /* Should be in sys/stat.h */
+#ifdef _MSC_VER
 #ifndef S_IRUSR
 #define S_IRUSR            _S_IREAD
 #define S_IWUSR            _S_IWRITE
@@ -78,22 +78,28 @@ extern int w32_mkdir(const char *dirname, mode_t perm);
 #define S_IXOTH            0
 #define S_IRWXO            S_IROTH | S_IWOTH | S_IXOTH
 #endif
+#endif
 
 /* Should be in fcntl.h */
+/* HACK, for use with fcntl() on a socket only, see w32sockets.c */
 #define O_NONBLOCK  1
-
 #define F_GETFL            1
 #define F_SETFL            2
-
 extern int fcntl(int fd, int cmd, ...);
 
 /* Stuff that actually belongs here */
 #define close(fd) w32_close_function((fd))
 extern int (*w32_close_function)(int);
-#define ftruncate(fd, length) _chsize((fd), (length))
 #define read(fd, buf, sz) w32_read_function((fd), (buf), (sz))
 extern int (*w32_read_function)(int, void *, unsigned);
 #define write(fd, buf, sz) w32_write_function((fd), (buf), (sz))
 extern int (*w32_write_function)(int, const void *, unsigned);
+#ifdef _MSC_VER
+#define ftruncate(fd, length) _chsize((fd), (length))
+#endif
+
+#ifndef _MSC_VER
+#include_next <unistd.h>
+#endif
 
 #endif /* UNISTD_H */