Added include protection for unistd.h and sys/time.h.
diff --git a/controls/desktop.c b/controls/desktop.c
index f3df7b0..b26d828 100644
--- a/controls/desktop.c
+++ b/controls/desktop.c
@@ -18,9 +18,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "windef.h"
#include "wingdi.h"
diff --git a/controls/icontitle.c b/controls/icontitle.c
index e24bb3f..68b946b 100644
--- a/controls/icontitle.c
+++ b/controls/icontitle.c
@@ -18,9 +18,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "windef.h"
#include "winbase.h"
diff --git a/dlls/ddraw/direct3d/main.c b/dlls/ddraw/direct3d/main.c
index 61f5fb6..c634565 100644
--- a/dlls/ddraw/direct3d/main.c
+++ b/dlls/ddraw/direct3d/main.c
@@ -19,7 +19,9 @@
#include "config.h"
#include <assert.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
diff --git a/dlls/ddraw/direct3d/mesa.c b/dlls/ddraw/direct3d/mesa.c
index ddbee96..5c2dac9 100644
--- a/dlls/ddraw/direct3d/mesa.c
+++ b/dlls/ddraw/direct3d/mesa.c
@@ -20,7 +20,9 @@
#include "config.h"
#include <assert.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
diff --git a/dlls/dinput/joystick/linux.c b/dlls/dinput/joystick/linux.c
index 79d2e3a..46ea8dc 100644
--- a/dlls/dinput/joystick/linux.c
+++ b/dlls/dinput/joystick/linux.c
@@ -27,8 +27,12 @@
#include <stdio.h>
#include <string.h>
#include <time.h>
-#include <unistd.h>
-#include <sys/time.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <sys/fcntl.h>
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
diff --git a/dlls/dinput/joystick/linuxinput.c b/dlls/dinput/joystick/linuxinput.c
index f70cc9e..679709f 100644
--- a/dlls/dinput/joystick/linuxinput.c
+++ b/dlls/dinput/joystick/linuxinput.c
@@ -28,8 +28,12 @@
#include <stdio.h>
#include <string.h>
#include <time.h>
-#include <unistd.h>
-#include <sys/time.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <sys/fcntl.h>
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
diff --git a/dlls/dsound/buffer.c b/dlls/dsound/buffer.c
index cce69d6..5e2552c 100644
--- a/dlls/dsound/buffer.c
+++ b/dlls/dsound/buffer.c
@@ -24,7 +24,9 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/fcntl.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdlib.h>
#include <string.h>
#include <math.h> /* Insomnia - pow() function */
diff --git a/dlls/dsound/capture.c b/dlls/dsound/capture.c
index 533402b..e7fc835 100644
--- a/dlls/dsound/capture.c
+++ b/dlls/dsound/capture.c
@@ -28,7 +28,9 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/fcntl.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdlib.h>
#include <string.h>
diff --git a/dlls/dsound/dsound_main.c b/dlls/dsound/dsound_main.c
index 10d1a87..f6012b9 100644
--- a/dlls/dsound/dsound_main.c
+++ b/dlls/dsound/dsound_main.c
@@ -43,7 +43,9 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/fcntl.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdlib.h>
#include <string.h>
#include <math.h> /* Insomnia - pow() function */
diff --git a/dlls/dsound/mixer.c b/dlls/dsound/mixer.c
index cdc3034..c6e7013 100644
--- a/dlls/dsound/mixer.c
+++ b/dlls/dsound/mixer.c
@@ -24,7 +24,9 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/fcntl.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdlib.h>
#include <string.h>
#include <math.h> /* Insomnia - pow() function */
diff --git a/dlls/dsound/primary.c b/dlls/dsound/primary.c
index 61b294d..3b7a5cd 100644
--- a/dlls/dsound/primary.c
+++ b/dlls/dsound/primary.c
@@ -24,7 +24,9 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/fcntl.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdlib.h>
#include <string.h>
#include <math.h> /* Insomnia - pow() function */
diff --git a/dlls/dsound/propset.c b/dlls/dsound/propset.c
index 358a6cc..2cc6ac3 100644
--- a/dlls/dsound/propset.c
+++ b/dlls/dsound/propset.c
@@ -24,7 +24,9 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/fcntl.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdlib.h>
#include <string.h>
#include <math.h> /* Insomnia - pow() function */
diff --git a/dlls/dsound/sound3d.c b/dlls/dsound/sound3d.c
index a352888..a0b867c 100644
--- a/dlls/dsound/sound3d.c
+++ b/dlls/dsound/sound3d.c
@@ -41,7 +41,9 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/fcntl.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdlib.h>
#include <string.h>
#include <math.h> /* Insomnia - pow() function */
diff --git a/dlls/gdi/printdrv.c b/dlls/gdi/printdrv.c
index 0ae8f4c..15ac5a5 100644
--- a/dlls/gdi/printdrv.c
+++ b/dlls/gdi/printdrv.c
@@ -28,7 +28,9 @@
#include <string.h>
#include <ctype.h>
#include <errno.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <fcntl.h>
#include "winbase.h"
#include "winuser.h"
diff --git a/dlls/gdi/win16drv/prtdrv.c b/dlls/gdi/win16drv/prtdrv.c
index d401f85..28c7256 100644
--- a/dlls/gdi/win16drv/prtdrv.c
+++ b/dlls/gdi/win16drv/prtdrv.c
@@ -18,11 +18,15 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <errno.h>
#include "wine/winbase16.h"
#include "winuser.h"
diff --git a/dlls/icmp/icmp_main.c b/dlls/icmp/icmp_main.c
index 8fd1882..80f5615 100644
--- a/dlls/icmp/icmp_main.c
+++ b/dlls/icmp/icmp_main.c
@@ -49,10 +49,14 @@
# include <netinet/in.h>
#endif
-#include <sys/time.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <string.h>
#include <errno.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
diff --git a/dlls/kernel/comm.c b/dlls/kernel/comm.c
index 3bcb441..ae3b2f1 100644
--- a/dlls/kernel/comm.c
+++ b/dlls/kernel/comm.c
@@ -71,7 +71,9 @@
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <sys/poll.h>
#ifdef HAVE_SYS_MODEM_H
# include <sys/modem.h>
diff --git a/dlls/kernel/console.c b/dlls/kernel/console.c
index 2238012..0788ffe 100644
--- a/dlls/kernel/console.c
+++ b/dlls/kernel/console.c
@@ -33,7 +33,9 @@
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <assert.h>
#include "winbase.h"
diff --git a/dlls/kernel/sync.c b/dlls/kernel/sync.c
index 0048edf..62b80cc 100644
--- a/dlls/kernel/sync.c
+++ b/dlls/kernel/sync.c
@@ -21,7 +21,9 @@
#include "config.h"
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <errno.h>
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
diff --git a/dlls/kernel/thunk.c b/dlls/kernel/thunk.c
index 676f7b9..3a2fb0d 100644
--- a/dlls/kernel/thunk.c
+++ b/dlls/kernel/thunk.c
@@ -20,9 +20,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <string.h>
#include <sys/types.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "windef.h"
#include "winbase.h"
diff --git a/dlls/kernel/time.c b/dlls/kernel/time.c
index 2f604bb..01e0c075 100644
--- a/dlls/kernel/time.c
+++ b/dlls/kernel/time.c
@@ -21,9 +21,13 @@
#include "config.h"
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdlib.h>
-#include <sys/time.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <sys/times.h>
#include "file.h"
#include "ntddk.h"
diff --git a/dlls/kernel/toolhelp.c b/dlls/kernel/toolhelp.c
index f128d65..0602cd9 100644
--- a/dlls/kernel/toolhelp.c
+++ b/dlls/kernel/toolhelp.c
@@ -18,9 +18,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <ctype.h>
#include <assert.h>
#include "winbase.h"
diff --git a/dlls/lzexpand/lzexpand_main.c b/dlls/lzexpand/lzexpand_main.c
index a9a2a89..4a872f4 100644
--- a/dlls/lzexpand/lzexpand_main.c
+++ b/dlls/lzexpand/lzexpand_main.c
@@ -26,7 +26,9 @@
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "winbase.h"
#include "lzexpand.h"
diff --git a/dlls/mpr/wnet.c b/dlls/mpr/wnet.c
index 8de75c6..f09b52a 100644
--- a/dlls/mpr/wnet.c
+++ b/dlls/mpr/wnet.c
@@ -18,10 +18,14 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <ctype.h>
#include <string.h>
#include <sys/types.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "winbase.h"
#include "winnls.h"
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index c830f10..07e1b65 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -26,7 +26,9 @@
#include <time.h>
#include <stdio.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "ntddk.h"
#include "msvcrt.h"
diff --git a/dlls/netapi32/netapi32.c b/dlls/netapi32/netapi32.c
index 3b91f73..c369d23 100644
--- a/dlls/netapi32/netapi32.c
+++ b/dlls/netapi32/netapi32.c
@@ -21,7 +21,9 @@
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "winbase.h"
#include "winreg.h"
diff --git a/dlls/ntdll/cdrom.c b/dlls/ntdll/cdrom.c
index c5ff3ee..ba59d58 100644
--- a/dlls/ntdll/cdrom.c
+++ b/dlls/ntdll/cdrom.c
@@ -25,7 +25,9 @@
#include <errno.h>
#include <string.h>
#include <stdio.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
diff --git a/dlls/ntdll/debugtools.c b/dlls/ntdll/debugtools.c
index c10cf53..9cf808d 100644
--- a/dlls/ntdll/debugtools.c
+++ b/dlls/ntdll/debugtools.c
@@ -25,7 +25,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <ctype.h>
#include "wine/debug.h"
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index d79968e..1439715 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -23,7 +23,9 @@
#include <string.h>
#include <stdio.h>
#include <errno.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#ifdef HAVE_SYS_ERRNO_H
#include <sys/errno.h>
#endif
diff --git a/dlls/ntdll/om.c b/dlls/ntdll/om.c
index 56f6523..be876c8 100644
--- a/dlls/ntdll/om.c
+++ b/dlls/ntdll/om.c
@@ -18,9 +18,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "wine/debug.h"
#include "ntddk.h"
diff --git a/dlls/ntdll/sec.c b/dlls/ntdll/sec.c
index cef57ae..f97dd38 100644
--- a/dlls/ntdll/sec.c
+++ b/dlls/ntdll/sec.c
@@ -28,7 +28,9 @@
#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "windef.h"
#include "winbase.h"
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index 4200d58..f21bb01 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -27,7 +27,9 @@
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
diff --git a/dlls/ntdll/signal_sparc.c b/dlls/ntdll/signal_sparc.c
index 66f49cf..250f617 100644
--- a/dlls/ntdll/signal_sparc.c
+++ b/dlls/ntdll/signal_sparc.c
@@ -24,7 +24,9 @@
#include <signal.h>
#include <stdlib.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdio.h>
#include <sys/ucontext.h>
diff --git a/dlls/ntdll/time.c b/dlls/ntdll/time.c
index c07cabe..218c033 100644
--- a/dlls/ntdll/time.c
+++ b/dlls/ntdll/time.c
@@ -22,10 +22,16 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <string.h>
#include <time.h>
-#include <sys/time.h>
-#include <unistd.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "ntddk.h"
#include "wine/debug.h"
diff --git a/dlls/ole32/storage.c b/dlls/ole32/storage.c
index 2cfc5ae..2a22166 100644
--- a/dlls/ole32/storage.c
+++ b/dlls/ole32/storage.c
@@ -21,11 +21,15 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <assert.h>
#include <time.h>
#include <string.h>
#include <sys/types.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "windef.h"
#include "ntddk.h"
#include "winerror.h"
diff --git a/dlls/oleaut32/olepicture.c b/dlls/oleaut32/olepicture.c
index d3bd40f..117f160 100644
--- a/dlls/oleaut32/olepicture.c
+++ b/dlls/oleaut32/olepicture.c
@@ -37,7 +37,9 @@
#include "config.h"
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdio.h>
#include <string.h>
#include "winerror.h"
diff --git a/dlls/rpcrt4/rpcrt4_main.c b/dlls/rpcrt4/rpcrt4_main.c
index 735134f..27b60bd 100644
--- a/dlls/rpcrt4/rpcrt4_main.c
+++ b/dlls/rpcrt4/rpcrt4_main.c
@@ -24,8 +24,12 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include <sys/time.h>
-#include <unistd.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "windef.h"
#include "wine/windef16.h"
diff --git a/dlls/shell32/iconcache.c b/dlls/shell32/iconcache.c
index bd7b9d6..7bafddd 100644
--- a/dlls/shell32/iconcache.c
+++ b/dlls/shell32/iconcache.c
@@ -18,9 +18,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <string.h>
#include <sys/types.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "winbase.h"
#include "windef.h"
#include "wingdi.h"
diff --git a/dlls/shell32/shell.c b/dlls/shell32/shell.c
index 5cb71e8..a380482 100644
--- a/dlls/shell32/shell.c
+++ b/dlls/shell32/shell.c
@@ -23,7 +23,9 @@
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <ctype.h>
#include "windef.h"
diff --git a/dlls/shell32/shelllink.c b/dlls/shell32/shelllink.c
index e6c3043..55d4b04 100644
--- a/dlls/shell32/shelllink.c
+++ b/dlls/shell32/shelllink.c
@@ -22,7 +22,9 @@
#include <string.h>
#include <stdio.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <errno.h>
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c
index 0014a56..5301078 100644
--- a/dlls/shell32/shlexec.c
+++ b/dlls/shell32/shlexec.c
@@ -24,7 +24,9 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <ctype.h>
#include <assert.h>
diff --git a/dlls/shell32/systray.c b/dlls/shell32/systray.c
index 84ea925..6bd0ae5 100644
--- a/dlls/shell32/systray.c
+++ b/dlls/shell32/systray.c
@@ -24,7 +24,9 @@
#include "config.h"
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdlib.h>
#include <string.h>
diff --git a/dlls/twain/ds_ctrl.c b/dlls/twain/ds_ctrl.c
index 4dd3515..bc6841a 100644
--- a/dlls/twain/ds_ctrl.c
+++ b/dlls/twain/ds_ctrl.c
@@ -16,7 +16,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <unistd.h>
+#include "config.h"
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdlib.h>
#include "twain.h"
#include "twain_i.h"
diff --git a/dlls/user/exticon.c b/dlls/user/exticon.c
index bcc7063..4444bc7 100644
--- a/dlls/user/exticon.c
+++ b/dlls/user/exticon.c
@@ -27,7 +27,9 @@
#include <string.h>
#include <stdlib.h> /* abs() */
#include <sys/types.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "winbase.h"
#include "windef.h"
diff --git a/dlls/user/network.c b/dlls/user/network.c
index adf55a6..9185418 100644
--- a/dlls/user/network.c
+++ b/dlls/user/network.c
@@ -18,10 +18,14 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <ctype.h>
#include <string.h>
#include <sys/types.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "winbase.h"
#include "wine/winnet16.h"
diff --git a/dlls/version/resource.c b/dlls/version/resource.c
index af332da..b2dcc6d 100644
--- a/dlls/version/resource.c
+++ b/dlls/version/resource.c
@@ -25,7 +25,9 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "winbase.h"
#include "lzexpand.h"
diff --git a/dlls/win32s/w32sys.c b/dlls/win32s/w32sys.c
index a57de9c..6b49c54 100644
--- a/dlls/win32s/w32sys.c
+++ b/dlls/win32s/w32sys.c
@@ -19,7 +19,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <unistd.h>
+#include "config.h"
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "windef.h"
#include "wine/windef16.h"
diff --git a/dlls/winaspi/aspi.c b/dlls/winaspi/aspi.c
index 5889d2c..f85d5c7 100644
--- a/dlls/winaspi/aspi.c
+++ b/dlls/winaspi/aspi.c
@@ -46,7 +46,9 @@
#endif
#include <fcntl.h>
#include <dirent.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <errno.h>
#include <string.h>
diff --git a/dlls/winaspi/winaspi16.c b/dlls/winaspi/winaspi16.c
index 740f69a..1e9c2dd 100644
--- a/dlls/winaspi/winaspi16.c
+++ b/dlls/winaspi/winaspi16.c
@@ -24,7 +24,9 @@
#include <errno.h>
#include <fcntl.h>
#include <memory.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <string.h>
#include <stdio.h>
diff --git a/dlls/winaspi/winaspi32.c b/dlls/winaspi/winaspi32.c
index 7d3a33d..386f54d 100644
--- a/dlls/winaspi/winaspi32.c
+++ b/dlls/winaspi/winaspi32.c
@@ -26,7 +26,9 @@
#include <errno.h>
#include <fcntl.h>
#include <memory.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "winbase.h"
#include "aspi.h"
diff --git a/dlls/winedos/dosvm.c b/dlls/winedos/dosvm.c
index 2ffe542..23a3b7d 100644
--- a/dlls/winedos/dosvm.c
+++ b/dlls/winedos/dosvm.c
@@ -28,8 +28,12 @@
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
-#include <unistd.h>
-#include <sys/time.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <sys/types.h>
#include "wine/winbase16.h"
diff --git a/dlls/winedos/int16.c b/dlls/winedos/int16.c
index 2cd41ab..bbd1616 100644
--- a/dlls/winedos/int16.c
+++ b/dlls/winedos/int16.c
@@ -23,7 +23,9 @@
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "module.h"
#include "dosexe.h"
diff --git a/dlls/winedos/module.c b/dlls/winedos/module.c
index b55d50b..aafde81 100644
--- a/dlls/winedos/module.c
+++ b/dlls/winedos/module.c
@@ -29,10 +29,14 @@
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/time.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include "windef.h"
#include "wine/winbase16.h"
#include "wingdi.h"
diff --git a/dlls/winedos/xms.c b/dlls/winedos/xms.c
index fc03cb6..0b99736 100644
--- a/dlls/winedos/xms.c
+++ b/dlls/winedos/xms.c
@@ -20,7 +20,11 @@
* Note: This XMS emulation is hooked through the DPMI interrupt.
*/
-#include <unistd.h>
+#include "config.h"
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <string.h>
#include "winbase.h"
#include "wine/winbase16.h"
diff --git a/dlls/wineps/init.c b/dlls/wineps/init.c
index 210d1d7..9888e5b 100644
--- a/dlls/wineps/init.c
+++ b/dlls/wineps/init.c
@@ -22,7 +22,9 @@
#include "config.h"
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "gdi.h"
#include "psdrv.h"
diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c
index 623a901..18cdf62 100644
--- a/dlls/wininet/ftp.c
+++ b/dlls/wininet/ftp.c
@@ -34,7 +34,9 @@
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <time.h>
#include "winbase.h"
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 9f77002..ee20218 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -30,7 +30,9 @@
#endif
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <errno.h>
#include <string.h>
#include <time.h>
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index 50b2f23..e12b4e5 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -32,10 +32,14 @@
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
-#include <sys/time.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <stdlib.h>
#include <ctype.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "windef.h"
#include "winbase.h"
diff --git a/dlls/winmm/joystick.c b/dlls/winmm/joystick.c
index e7e4ba6..43b6b9d 100644
--- a/dlls/winmm/joystick.c
+++ b/dlls/winmm/joystick.c
@@ -23,7 +23,9 @@
#include "config.h"
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/dlls/winmm/joystick/joystick.c b/dlls/winmm/joystick/joystick.c
index fef5b78..5c5bbdf 100644
--- a/dlls/winmm/joystick/joystick.c
+++ b/dlls/winmm/joystick/joystick.c
@@ -39,7 +39,9 @@
#include "config.h"
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/dlls/winmm/time.c b/dlls/winmm/time.c
index 192140e..efe2665 100644
--- a/dlls/winmm/time.c
+++ b/dlls/winmm/time.c
@@ -24,8 +24,12 @@
#include "wine/port.h"
#include <time.h>
-#include <sys/time.h>
-#include <unistd.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "mmsystem.h"
#include "windef.h"
diff --git a/dlls/winmm/winealsa/audio.c b/dlls/winmm/winealsa/audio.c
index f6d9e1e..743fad4 100644
--- a/dlls/winmm/winealsa/audio.c
+++ b/dlls/winmm/winealsa/audio.c
@@ -27,7 +27,9 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <errno.h>
#include <limits.h>
#include <fcntl.h>
diff --git a/dlls/winmm/winealsa/audio_05.c b/dlls/winmm/winealsa/audio_05.c
index deb2e21..a5507eb 100644
--- a/dlls/winmm/winealsa/audio_05.c
+++ b/dlls/winmm/winealsa/audio_05.c
@@ -26,7 +26,9 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <errno.h>
#include <fcntl.h>
#ifdef HAVE_SYS_IOCTL_H
diff --git a/dlls/winmm/winearts/audio.c b/dlls/winmm/winearts/audio.c
index ce3c31f..ca822fc 100644
--- a/dlls/winmm/winearts/audio.c
+++ b/dlls/winmm/winearts/audio.c
@@ -43,7 +43,9 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <errno.h>
#include <fcntl.h>
#include "windef.h"
diff --git a/dlls/winmm/wineaudioio/audio.c b/dlls/winmm/wineaudioio/audio.c
index 5afa9f4..4238f90 100644
--- a/dlls/winmm/wineaudioio/audio.c
+++ b/dlls/winmm/wineaudioio/audio.c
@@ -42,7 +42,9 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <errno.h>
#include <fcntl.h>
#ifdef HAVE_SYS_IOCTL_H
diff --git a/dlls/winmm/winenas/audio.c b/dlls/winmm/winenas/audio.c
index c6f51e3f..8d90a09 100644
--- a/dlls/winmm/winenas/audio.c
+++ b/dlls/winmm/winenas/audio.c
@@ -39,8 +39,12 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
-#include <sys/time.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <errno.h>
#include <fcntl.h>
diff --git a/dlls/winmm/wineoss/audio.c b/dlls/winmm/wineoss/audio.c
index 1c7ece5..7335755 100644
--- a/dlls/winmm/wineoss/audio.c
+++ b/dlls/winmm/wineoss/audio.c
@@ -34,7 +34,9 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <errno.h>
#include <fcntl.h>
#ifdef HAVE_SYS_IOCTL_H
diff --git a/dlls/winmm/wineoss/midi.c b/dlls/winmm/wineoss/midi.c
index 0c3dc9d..b837a1c 100644
--- a/dlls/winmm/wineoss/midi.c
+++ b/dlls/winmm/wineoss/midi.c
@@ -29,7 +29,9 @@
#include "config.h"
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <fcntl.h>
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
diff --git a/dlls/winmm/wineoss/mixer.c b/dlls/winmm/wineoss/mixer.c
index 6ef828d..1e3f32e 100644
--- a/dlls/winmm/wineoss/mixer.c
+++ b/dlls/winmm/wineoss/mixer.c
@@ -26,7 +26,9 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <fcntl.h>
#include <errno.h>
#include <assert.h>
diff --git a/dlls/winmm/wineoss/mmaux.c b/dlls/winmm/wineoss/mmaux.c
index d2b987b..4d2f9f2 100644
--- a/dlls/winmm/wineoss/mmaux.c
+++ b/dlls/winmm/wineoss/mmaux.c
@@ -25,7 +25,9 @@
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <fcntl.h>
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
diff --git a/dlls/winsock/async.c b/dlls/winsock/async.c
index 29629e7..15239ca 100644
--- a/dlls/winsock/async.c
+++ b/dlls/winsock/async.c
@@ -86,7 +86,9 @@
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdlib.h>
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
diff --git a/dlls/winsock/socket.c b/dlls/winsock/socket.c
index bdb6c6e..2e0cefd 100644
--- a/dlls/winsock/socket.c
+++ b/dlls/winsock/socket.c
@@ -78,7 +78,9 @@
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdlib.h>
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
diff --git a/dlls/wsock32/socket.c b/dlls/wsock32/socket.c
index 53efd45..611151d 100644
--- a/dlls/wsock32/socket.c
+++ b/dlls/wsock32/socket.c
@@ -48,7 +48,9 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
diff --git a/dlls/x11drv/clipboard.c b/dlls/x11drv/clipboard.c
index dd0b954..e7793ff 100644
--- a/dlls/x11drv/clipboard.c
+++ b/dlls/x11drv/clipboard.c
@@ -64,7 +64,9 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <fcntl.h>
#include "ts_xlib.h"
diff --git a/dlls/x11drv/x11drv_main.c b/dlls/x11drv/x11drv_main.c
index 6ed3163..10a62df 100644
--- a/dlls/x11drv/x11drv_main.c
+++ b/dlls/x11drv/x11drv_main.c
@@ -25,8 +25,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/time.h>
-#include <unistd.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <X11/cursorfont.h>
#include "ts_xlib.h"
#include "ts_xutil.h"
diff --git a/files/change.c b/files/change.c
index 55477cd..18c619f 100644
--- a/files/change.c
+++ b/files/change.c
@@ -23,9 +23,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <assert.h>
#include <stdlib.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <string.h>
#include <time.h>
#include "winbase.h"
diff --git a/files/directory.c b/files/directory.c
index 9cd2147..9e3f3cd 100644
--- a/files/directory.c
+++ b/files/directory.c
@@ -26,7 +26,9 @@
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <errno.h>
#ifdef HAVE_SYS_ERRNO_H
#include <sys/errno.h>
diff --git a/files/dos_fs.c b/files/dos_fs.c
index da71ae2..3b0abea2 100644
--- a/files/dos_fs.c
+++ b/files/dos_fs.c
@@ -36,7 +36,9 @@
#include <sys/ioctl.h>
#endif
#include <time.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "windef.h"
#include "winerror.h"
diff --git a/files/drive.c b/files/drive.c
index 37da65e..94e151e 100644
--- a/files/drive.c
+++ b/files/drive.c
@@ -35,7 +35,9 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
diff --git a/files/file.c b/files/file.c
index 99bbb49..64b78b3 100644
--- a/files/file.c
+++ b/files/file.c
@@ -41,10 +41,14 @@
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
-#include <sys/time.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <sys/poll.h>
#include <time.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <utime.h>
#include "winerror.h"
diff --git a/files/profile.c b/files/profile.c
index 3b60843..8f342a2 100644
--- a/files/profile.c
+++ b/files/profile.c
@@ -32,7 +32,9 @@
#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "windef.h"
#include "winbase.h"
diff --git a/files/smb.c b/files/smb.c
index 16825c1..b84096d 100644
--- a/files/smb.c
+++ b/files/smb.c
@@ -71,10 +71,14 @@
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
-#include <sys/time.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <sys/poll.h>
#include <time.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <utime.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
diff --git a/graphics/x11drv/xfont.c b/graphics/x11drv/xfont.c
index 2c53a25..6d404a2 100644
--- a/graphics/x11drv/xfont.c
+++ b/graphics/x11drv/xfont.c
@@ -32,7 +32,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <sys/types.h>
#include <fcntl.h>
#include <math.h>
diff --git a/loader/main.c b/loader/main.c
index b54271f..88b2171 100644
--- a/loader/main.c
+++ b/loader/main.c
@@ -18,12 +18,16 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <locale.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdio.h>
#include <string.h>
#ifdef MALLOC_DEBUGGING
diff --git a/loader/module.c b/loader/module.c
index 637c693..e291b0d 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -18,13 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <assert.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "wine/winbase16.h"
#include "winerror.h"
#include "heap.h"
diff --git a/loader/ne/module.c b/loader/ne/module.c
index 4f8b37a..8947e26 100644
--- a/loader/ne/module.c
+++ b/loader/ne/module.c
@@ -25,7 +25,9 @@
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <ctype.h>
#include "winbase.h"
diff --git a/loader/ne/resource.c b/loader/ne/resource.c
index 57118d7..b12409c 100644
--- a/loader/ne/resource.c
+++ b/loader/ne/resource.c
@@ -28,7 +28,9 @@
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "windef.h"
#include "wine/winbase16.h"
diff --git a/loader/ne/segment.c b/loader/ne/segment.c
index 198576f..365e286 100644
--- a/loader/ne/segment.c
+++ b/loader/ne/segment.c
@@ -19,12 +19,16 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <fcntl.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <ctype.h>
#include <string.h>
diff --git a/loader/resource.c b/loader/resource.c
index 5d77879..a4a5e61 100644
--- a/loader/resource.c
+++ b/loader/resource.c
@@ -19,13 +19,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "windef.h"
#include "winbase.h"
#include "wine/winbase16.h"
diff --git a/loader/task.c b/loader/task.c
index 6e5b247..6a1dfee 100644
--- a/loader/task.c
+++ b/loader/task.c
@@ -24,7 +24,9 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "winbase.h"
#include "wingdi.h"
diff --git a/memory/global.c b/memory/global.c
index 9cfe90a..7f143cf 100644
--- a/memory/global.c
+++ b/memory/global.c
@@ -26,7 +26,9 @@
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <string.h>
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
diff --git a/memory/registry.c b/memory/registry.c
index 33e49aa..ed1b5f0 100644
--- a/memory/registry.c
+++ b/memory/registry.c
@@ -26,9 +26,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <stdlib.h>
#include <stdio.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "winbase.h"
#include "winreg.h"
diff --git a/memory/virtual.c b/memory/virtual.c
index d3583c4..239f6c1 100644
--- a/memory/virtual.c
+++ b/memory/virtual.c
@@ -27,7 +27,9 @@
#include <sys/errno.h>
#endif
#include <fcntl.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
diff --git a/misc/main.c b/misc/main.c
index 018869c..548eb6b 100644
--- a/misc/main.c
+++ b/misc/main.c
@@ -26,8 +26,12 @@
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
-#include <sys/time.h>
-#include <unistd.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "windef.h"
#include "winbase.h"
diff --git a/misc/registry.c b/misc/registry.c
index b838419..093d636 100644
--- a/misc/registry.c
+++ b/misc/registry.c
@@ -39,7 +39,9 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
diff --git a/msdos/dosconf.c b/msdos/dosconf.c
index 9612711..f297894 100644
--- a/msdos/dosconf.c
+++ b/msdos/dosconf.c
@@ -21,7 +21,9 @@
#include "config.h"
#include <stdio.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
diff --git a/msdos/dpmi.c b/msdos/dpmi.c
index 6ea5340..db19b52 100644
--- a/msdos/dpmi.c
+++ b/msdos/dpmi.c
@@ -21,7 +21,9 @@
#include "config.h"
#include "wine/port.h"
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <string.h>
#include "windef.h"
diff --git a/msdos/int13.c b/msdos/int13.c
index 76c6f06..dba23a3 100644
--- a/msdos/int13.c
+++ b/msdos/int13.c
@@ -18,9 +18,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <stdlib.h>
#include <sys/types.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "winbase.h"
#include "winioctl.h"
diff --git a/msdos/int1a.c b/msdos/int1a.c
index 3c4a10d..262cba8 100644
--- a/msdos/int1a.c
+++ b/msdos/int1a.c
@@ -18,8 +18,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <time.h>
-#include <sys/time.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <stdlib.h>
#include "miscemu.h"
#include "wine/debug.h"
diff --git a/msdos/int21.c b/msdos/int21.c
index 9e4b37c..c351287 100644
--- a/msdos/int21.c
+++ b/msdos/int21.c
@@ -33,9 +33,13 @@
# include <sys/file.h>
#endif
#include <string.h>
-#include <sys/time.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <sys/types.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <utime.h>
#include <ctype.h>
#include "windef.h"
diff --git a/msdos/int25.c b/msdos/int25.c
index 82c54c1..74372ce 100644
--- a/msdos/int25.c
+++ b/msdos/int25.c
@@ -18,10 +18,14 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "msdos.h"
#include "miscemu.h"
#include "drive.h"
diff --git a/msdos/int26.c b/msdos/int26.c
index 3a473c4..8e09e33 100644
--- a/msdos/int26.c
+++ b/msdos/int26.c
@@ -18,9 +18,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <stdlib.h>
#include <fcntl.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "msdos.h"
#include "miscemu.h"
#include "drive.h"
diff --git a/msdos/ioports.c b/msdos/ioports.c
index bb6b798..3a36ce3 100644
--- a/msdos/ioports.c
+++ b/msdos/ioports.c
@@ -32,7 +32,9 @@
#include <stdio.h>
#include <string.h>
#include <time.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "windef.h"
#include "callback.h"
#include "file.h"
diff --git a/msdos/vxd.c b/msdos/vxd.c
index 5b6dc13..67db926 100644
--- a/msdos/vxd.c
+++ b/msdos/vxd.c
@@ -18,10 +18,14 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <fcntl.h>
#include <memory.h>
#include <sys/types.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "winbase.h"
#include "windef.h"
#include "ntddk.h"
diff --git a/scheduler/client.c b/scheduler/client.c
index c5379aa..7ceb8ca 100644
--- a/scheduler/client.c
+++ b/scheduler/client.c
@@ -44,7 +44,9 @@
#endif
#include <sys/stat.h>
#include <sys/uio.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdarg.h>
#include "thread.h"
diff --git a/scheduler/handle.c b/scheduler/handle.c
index 683e574..e24f0e2 100644
--- a/scheduler/handle.c
+++ b/scheduler/handle.c
@@ -18,9 +18,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <assert.h>
#include <stdio.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "winbase.h"
#include "wine/server.h"
#include "winerror.h"
diff --git a/scheduler/process.c b/scheduler/process.c
index 2aacce8..b3efdff 100644
--- a/scheduler/process.c
+++ b/scheduler/process.c
@@ -29,7 +29,9 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "wine/exception.h"
diff --git a/scheduler/pthread.c b/scheduler/pthread.c
index ffa6947..e29b7b3 100644
--- a/scheduler/pthread.c
+++ b/scheduler/pthread.c
@@ -29,7 +29,9 @@
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <string.h>
#include "winbase.h"
diff --git a/scheduler/synchro.c b/scheduler/synchro.c
index 41788dc..f8b60fe 100644
--- a/scheduler/synchro.c
+++ b/scheduler/synchro.c
@@ -18,12 +18,18 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <assert.h>
#include <errno.h>
#include <signal.h>
-#include <sys/time.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <sys/poll.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <string.h>
#include "file.h" /* for DOSFS_UnixTimeToFileTime */
diff --git a/scheduler/sysdeps.c b/scheduler/sysdeps.c
index 06170db..f00b4fd 100644
--- a/scheduler/sysdeps.c
+++ b/scheduler/sysdeps.c
@@ -23,8 +23,12 @@
#include <signal.h>
#include <stdio.h>
-#include <unistd.h>
-#include <sys/time.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#ifdef HAVE_SYS_SYSCALL_H
# include <sys/syscall.h>
#endif
diff --git a/scheduler/syslevel.c b/scheduler/syslevel.c
index feb3a9b..974650d 100644
--- a/scheduler/syslevel.c
+++ b/scheduler/syslevel.c
@@ -18,7 +18,11 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <unistd.h>
+#include "config.h"
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <sys/types.h>
#include "ntddk.h"
#include "syslevel.h"
diff --git a/scheduler/thread.c b/scheduler/thread.c
index 0a71d05..574324c 100644
--- a/scheduler/thread.c
+++ b/scheduler/thread.c
@@ -27,7 +27,9 @@
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "wine/winbase16.h"
#include "thread.h"
#include "task.h"
diff --git a/win32/device.c b/win32/device.c
index 662f3ab4..8da2d72 100644
--- a/win32/device.c
+++ b/win32/device.c
@@ -24,7 +24,9 @@
#include "wine/port.h"
#include <stdlib.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <sys/types.h>
#include <string.h>
#include <stdarg.h>
diff --git a/win32/init.c b/win32/init.c
index f7c05bd..e870a2e 100644
--- a/win32/init.c
+++ b/win32/init.c
@@ -19,8 +19,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <stdlib.h>
#include <errno.h>
diff --git a/win32/kernel32.c b/win32/kernel32.c
index 6c3d695..c126659 100644
--- a/win32/kernel32.c
+++ b/win32/kernel32.c
@@ -19,9 +19,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <string.h>
#include <sys/types.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "windef.h"
#include "winbase.h"
diff --git a/win32/newfns.c b/win32/newfns.c
index 41d07ad..3fceb08 100644
--- a/win32/newfns.c
+++ b/win32/newfns.c
@@ -21,10 +21,16 @@
/* Misc. new functions - they should be moved into appropriate files
at a later date. */
+#include "config.h"
+
#include <stdio.h>
#include <string.h>
-#include <sys/time.h>
-#include <unistd.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
diff --git a/win32/time.c b/win32/time.c
index ed2840c..cd700bb 100644
--- a/win32/time.c
+++ b/win32/time.c
@@ -18,10 +18,16 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <string.h>
#include <time.h>
-#include <sys/time.h>
-#include <unistd.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "file.h"
#include "winerror.h"
#include "wine/debug.h"
diff --git a/windows/clipboard.c b/windows/clipboard.c
index 9927eda..5c2c20d 100644
--- a/windows/clipboard.c
+++ b/windows/clipboard.c
@@ -28,10 +28,14 @@
* TTY clipboard driver are available)
*/
+#include "config.h"
+
#include <stdlib.h>
#include <sys/types.h>
#include <fcntl.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include <string.h>
#include "windef.h"
diff --git a/windows/message.c b/windows/message.c
index f668a37..25d1ecd 100644
--- a/windows/message.c
+++ b/windows/message.c
@@ -18,10 +18,14 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
-#include <sys/time.h>
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
#include <sys/types.h>
#include "winbase.h"
diff --git a/windows/winhelp.c b/windows/winhelp.c
index e6123dd..0c46dfb 100644
--- a/windows/winhelp.c
+++ b/windows/winhelp.c
@@ -18,10 +18,14 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <unistd.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
#include "wine/debug.h"
#include "windef.h"
#include "wingdi.h"