Replace #ifdef HAVE_UNISTD_H checks with #ifdef G_OS_UNIX
authorDan Winship <danw@gnome.org>
Sat, 19 Oct 2013 17:04:00 +0000 (13:04 -0400)
committerDan Winship <danw@gnome.org>
Wed, 20 Nov 2013 14:25:39 +0000 (09:25 -0500)
In Windows development environments that have it, <unistd.h> is mostly
just a wrapper around several other native headers (in particular,
<io.h>, which contains read(), close(), etc, and <process.h>, which
contains getpid()). But given that some Windows dev environments don't
have <unistd.h>, everything that uses those functions on Windows
already needed to include the correct Windows header as well, and so
there is never any point to including <unistd.h> on Windows.

Also, remove some <unistd.h> includes (and a few others) that were
unnecessary even on unix.

https://bugzilla.gnome.org/show_bug.cgi?id=710519

48 files changed:
config.h.win32.in
configure.ac
gio/gdbusauthmechanismexternal.c
gio/gdbusauthmechanismsha1.c
gio/gdbusconnection.c
gio/gdbusmessage.c
gio/gdbusprivate.c
gio/gdbusserver.c
gio/gdummyfile.c
gio/glib-compile-resources.c
gio/glib-compile-schemas.c
gio/glocalfile.c
gio/glocalfileinfo.c
gio/glocalfileinputstream.c
gio/glocalfileoutputstream.c
gio/gsimpleasyncresult.c
gio/gtestdbus.c
glib/gbookmarkfile.c
glib/gdatetime.c
glib/genviron.c
glib/gfileutils.c
glib/giochannel.c
glib/gkeyfile.c
glib/gmain.c
glib/gmappedfile.c
glib/gmessages.c
glib/gpoll.c
glib/grand.c
glib/gscanner.c
glib/gslice.c
glib/gstdio.c
glib/gstring.c
glib/gtestutils.c
glib/gthread.c
glib/gtimer.c
glib/gutils.c
glib/tests/base64.c
glib/tests/checksum.c
glib/tests/hmac.c
glib/tests/mappedfile.c
glib/tests/node.c
glib/tests/thread.c
gmodule/gmodule.c
gobject/glib-genmarshal.c
gobject/gobject-query.c
tests/env-test.c
tests/file-test.c
tests/gio-test.c

index c20231e..62e3085 100644 (file)
 /* Define to 1 if you have the `timegm' function. */
 /* #undef HAVE_TIMEGM */
 
-/* Define to 1 if you have the <unistd.h> header file. */
-#ifndef _MSC_VER
-#define HAVE_UNISTD_H 1
-#else /* _MSC_VER */
-/* #undef HAVE_UNISTD_H */
-#endif /* _MSC_VER */
-
 /* Define if your printf function family supports positional parameters as
    specified by Unix98. */
 /* #undef HAVE_UNIX98_PRINTF */
index 1f3e7b7..6654e79 100644 (file)
@@ -779,7 +779,7 @@ AC_CHECK_HEADERS([mntent.h sys/mnttab.h sys/vfstab.h sys/mntctl.h fstab.h])
 AC_CHECK_HEADERS([linux/magic.h sys/prctl.h])
 
 # Some versions of MSC lack these
-AC_CHECK_HEADERS([dirent.h sys/time.h unistd.h])
+AC_CHECK_HEADERS([dirent.h sys/time.h])
 
 # We don't care about this, but we need to keep including it in
 # glibconfig.h for backward compatibility
@@ -799,7 +799,9 @@ AC_CHECK_HEADERS([xlocale.h])
 AC_CHECK_MEMBERS([struct stat.st_mtimensec, struct stat.st_mtim.tv_nsec, struct stat.st_atimensec, struct stat.st_atim.tv_nsec, struct stat.st_ctimensec, struct stat.st_ctim.tv_nsec])
 AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_blocks, struct statfs.f_fstypename, struct statfs.f_bavail],,, [#include <sys/types.h>
 #include <sys/stat.h>
+#ifdef G_OS_UNIX
 #include <unistd.h>
+#endif
 #ifdef HAVE_SYS_STATFS_H
 #include <sys/statfs.h>
 #endif
@@ -922,9 +924,6 @@ AS_IF([test $ac_cv_sizeof_ssize_t = $ac_cv_sizeof_int &&
 #ifdef HAVE_STDINT_H
 # include <stdint.h>
 #endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
 #include <sys/types.h>
 int main ()
 {
@@ -944,9 +943,6 @@ int main ()
 #ifdef HAVE_STDINT_H
 # include <stdint.h>
 #endif
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
 #include <sys/types.h>
 int main ()
 {
index 40ff3f3..38a2f65 100644 (file)
 #include "config.h"
 
 #include <string.h>
-#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 
 #include "gdbusauthmechanismexternal.h"
 #include "gcredentials.h"
index e4f75eb..dae509e 100644 (file)
 #include <fcntl.h>
 #include <errno.h>
 #include <sys/types.h>
-#ifdef HAVE_UNISTD_H
+#ifdef G_OS_UNIX
 #include <unistd.h>
 #endif
-#ifdef _WIN32
+#ifdef G_OS_WIN32
 #include <io.h>
 #endif
 
index 8a0748d..57fa193 100644 (file)
 
 #include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 
 #include "gdbusauth.h"
 #include "gdbusutils.h"
index d52143c..341f4e7 100644 (file)
@@ -29,9 +29,6 @@
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 
 #if MAJOR_IN_MKDEV
 #include <sys/mkdev.h>
index 785a0c0..b7d9336 100644 (file)
@@ -24,9 +24,6 @@
 
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 
 #include "giotypes.h"
 #include "gsocket.h"
index 43cc9ba..7f3d8e6 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
-#ifdef HAVE_UNISTD_H
+#ifdef G_OS_UNIX
 #include <unistd.h>
 #endif
-#ifdef _WIN32
+#ifdef G_OS_WIN32
 #include <io.h>
 #endif
 
index 4546e3c..8f22715 100644 (file)
@@ -27,9 +27,6 @@
 #include <string.h>
 #include <errno.h>
 #include <fcntl.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #include <stdlib.h>
 
 #include "gdummyfile.h"
index d7dd580..822262b 100644 (file)
@@ -30,6 +30,9 @@
 #include <stdio.h>
 #include <locale.h>
 #include <errno.h>
+#ifdef G_OS_UNIX
+#include <unistd.h>
+#endif
 #ifdef G_OS_WIN32
 #include <io.h>
 #endif
 #include <gio/gzlibcompressor.h>
 #include <gio/gconverteroutputstream.h>
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #include <glib.h>
 #include "gvdb/gvdb-builder.h"
 
index 9b93581..d2ae81a 100644 (file)
 #include <stdio.h>
 #include <locale.h>
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #include "gvdb/gvdb-builder.h"
 #include "strinfo.c"
 
index 862d2fb..be516c1 100644 (file)
@@ -29,8 +29,6 @@
 #include <fcntl.h>
 #if G_OS_UNIX
 #include <dirent.h>
-#endif
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
 
index 5e60bf8..4f6d5a2 100644 (file)
@@ -32,9 +32,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #include <fcntl.h>
 #include <errno.h>
 #ifdef G_OS_UNIX
 #include <gfileinfo-priv.h>
 #include <gvfs.h>
 
-#ifndef G_OS_WIN32
+#ifdef G_OS_UNIX
+#include <unistd.h>
 #include "glib-unix.h"
 #include "glib-private.h"
 #endif
-#include "glibintl.h"
 
 #include "thumbnail-verify.h"
 
@@ -97,6 +94,7 @@
 #include "gioerror.h"
 #include "gthemedicon.h"
 #include "gcontenttypeprivate.h"
+#include "glibintl.h"
 
 
 struct ThumbMD5Context {
index 2c32353..ea2cfd1 100644 (file)
@@ -25,9 +25,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #include <errno.h>
 
 #include <glib.h>
@@ -39,6 +36,7 @@
 #include "glibintl.h"
 
 #ifdef G_OS_UNIX
+#include <unistd.h>
 #include "glib-unix.h"
 #include "gfiledescriptorbased.h"
 #endif
index b50dada..a1cdc86 100644 (file)
@@ -25,9 +25,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #include <errno.h>
 #include <string.h>
 
@@ -41,6 +38,7 @@
 #include "glocalfileinfo.h"
 
 #ifdef G_OS_UNIX
+#include <unistd.h>
 #include "gfiledescriptorbased.h"
 #endif
 
index c5d8103..2c7f2da 100644 (file)
 
 #include "config.h"
 
-#include <sys/types.h>
-#include <sys/stat.h>
 #include <string.h>
-#include <errno.h>
-#include <fcntl.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 
 #include "gsimpleasyncresult.h"
 #include "gasyncresult.h"
index 151173f..0b4ef6b 100644 (file)
@@ -27,7 +27,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <gstdio.h>
-#ifdef HAVE_UNISTD_H
+#ifdef G_OS_UNIX
 #include <unistd.h>
 #endif
 #ifdef G_OS_WIN32
index 569d438..a2eaab3 100644 (file)
 #include <locale.h>
 #include <time.h>
 #include <stdarg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 
 #include "gconvert.h"
 #include "gdataset.h"
index f7f4ba2..6069e90 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #ifdef HAVE_LANGINFO_TIME
 #include <langinfo.h>
 #endif
index 9f0ae24..01e8b82 100644 (file)
@@ -30,9 +30,6 @@
 
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #ifdef HAVE_CRT_EXTERNS_H
 #include <crt_externs.h> /* for _NSGetEnviron */
 #endif
index 233d299..fb47fc8 100644 (file)
@@ -22,9 +22,6 @@
 #include "glibconfig.h"
 
 #include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
@@ -35,6 +32,9 @@
 #include <fcntl.h>
 #include <stdlib.h>
 
+#ifdef G_OS_UNIX
+#include <unistd.h>
+#endif
 #ifdef G_OS_WIN32
 #include <windows.h>
 #include <io.h>
index 84e9d76..b9c45df 100644 (file)
 #include <string.h>
 #include <errno.h>
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #include "giochannel.h"
 
 #include "gstrfuncs.h"
index b3fcb67..ff5c5eb 100644 (file)
@@ -36,7 +36,7 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
+#ifdef G_OS_UNIX
 #include <unistd.h>
 #endif
 #ifdef G_OS_WIN32
index ad25707..c3b1f16 100644 (file)
@@ -62,9 +62,9 @@
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
 #endif /* HAVE_SYS_TIME_H */
-#ifdef HAVE_UNISTD_H
+#ifdef G_OS_UNIX
 #include <unistd.h>
-#endif /* HAVE_UNISTD_H */
+#endif /* G_OS_UNIX */
 #include <errno.h>
 #include <string.h>
 
index 7d241e7..1c019e1 100644 (file)
 #include <sys/types.h> 
 #include <sys/stat.h> 
 #include <fcntl.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #ifdef HAVE_MMAP
 #include <sys/mman.h>
 #endif
 
 #include "glibconfig.h"
 
+#ifdef G_OS_UNIX
+#include <unistd.h>
+#endif
+
 #ifdef G_OS_WIN32
 #include <windows.h>
 #include <io.h>
index 2965d28..f21fc7e 100644 (file)
@@ -52,9 +52,6 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #include <signal.h>
 #include <locale.h>
 #include <errno.h>
 #include "gstring.h"
 #include "gpattern.h"
 
+#ifdef G_OS_UNIX
+#include <unistd.h>
+#endif
+
 #ifdef G_OS_WIN32
 #include <process.h>           /* For getpid() */
 #include <io.h>
index 354c08f..66c5f0e 100644 (file)
@@ -66,9 +66,9 @@
 #endif
 
 #endif /* GLIB_HAVE_SYS_POLL_H */
-#ifdef HAVE_UNISTD_H
+#ifdef G_OS_UNIX
 #include <unistd.h>
-#endif /* HAVE_UNISTD_H */
+#endif /* G_OS_UNIX */
 #include <errno.h>
 
 #ifdef G_OS_WIN32
index 3f043ad..fb2a8ec 100644 (file)
 #include <stdio.h>
 #include <string.h>
 #include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
 #include "grand.h"
 
 #include "genviron.h"
 #include "gtestutils.h"
 #include "gthread.h"
 
+#ifdef G_OS_UNIX
+#include <unistd.h>
+#endif
+
 #ifdef G_OS_WIN32
 #include <stdlib.h>
 #endif
index 9fc5e7c..9d73749 100644 (file)
@@ -38,9 +38,6 @@
 #include <stdarg.h>
 #include <string.h>
 #include <stdio.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 
 #include "gscanner.h"
 
 #include "gstring.h"
 #include "gtestutils.h"
 
+#ifdef G_OS_UNIX
+#include <unistd.h>
+#endif
 #ifdef G_OS_WIN32
-#include <io.h> /* For _read() */
+#include <io.h>
 #endif
 
 
index 24ce62f..5f545fc 100644 (file)
@@ -32,7 +32,7 @@
 #include <string.h>
 #include <errno.h>
 
-#ifdef HAVE_UNISTD_H
+#ifdef G_OS_UNIX
 #include <unistd.h>             /* sysconf() */
 #endif
 #ifdef G_OS_WIN32
index a78558f..dfb3feb 100644 (file)
@@ -27,7 +27,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
-#ifdef HAVE_UNISTD_H
+#ifdef G_OS_UNIX
 #include <unistd.h>
 #endif
 
index ef77133..782fd4a 100644 (file)
@@ -30,9 +30,6 @@
 
 #include "config.h"
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #include <stdarg.h>
 #include <stdlib.h>
 #include <stdio.h>
index 353a2db..fa820db 100644 (file)
 #include <sys/wait.h>
 #include <sys/time.h>
 #include <fcntl.h>
+#include <unistd.h>
 #include <glib/gstdio.h>
 #endif
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #endif
index c4114aa..2df13c4 100644 (file)
@@ -45,7 +45,7 @@
 
 #include <string.h>
 
-#ifdef HAVE_UNISTD_H
+#ifdef G_OS_UNIX
 #include <unistd.h>
 #endif
 
@@ -1039,7 +1039,7 @@ g_get_num_processors (void)
       if (count > 0)
         return count;
     }
-#elif defined(HAVE_UNISTD_H) && defined(_SC_NPROCESSORS_ONLN)
+#elif defined(_SC_NPROCESSORS_ONLN)
   {
     int count;
 
index a45c3cf..f1bef07 100644 (file)
@@ -33,9 +33,9 @@
 
 #include <stdlib.h>
 
-#ifdef HAVE_UNISTD_H
+#ifdef G_OS_UNIX
 #include <unistd.h>
-#endif /* HAVE_UNISTD_H */
+#endif /* G_OS_UNIX */
 
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
index 1395757..6ed1a65 100644 (file)
@@ -31,9 +31,6 @@
 #include "config.h"
 #include "glibconfig.h"
 
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #include <stdarg.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -45,6 +42,7 @@
 #include <sys/stat.h>
 #ifdef G_OS_UNIX
 #include <pwd.h>
+#include <unistd.h>
 #endif
 #include <sys/types.h>
 #ifdef HAVE_SYS_PARAM_H
index e5ac5b9..e1420e1 100644 (file)
@@ -1,8 +1,5 @@
 #include <glib.h>
 #include <string.h>
-#ifdef G_OS_UNIX
-#include <unistd.h>
-#endif
 #include <stdlib.h>
 
 #define DATA_SIZE 1024
index a5d2ea0..b6ae3ef 100644 (file)
@@ -1,8 +1,5 @@
 #include <glib.h>
 #include <string.h>
-#ifdef G_OS_UNIX
-#include <unistd.h>
-#endif
 #include <stdlib.h>
 
 /* Test GChecksum by computing the checksums of every initial
index c8215db..f6ee643 100644 (file)
@@ -1,8 +1,5 @@
 #include <glib.h>
 #include <string.h>
-#ifdef G_OS_UNIX
-#include <unistd.h>
-#endif
 #include <stdlib.h>
 
 /* HMAC-MD5 test vectors as per RFC 2202 */
index 6b22105..99c26c9 100644 (file)
@@ -2,14 +2,18 @@
 
 #include <glib.h>
 #include <string.h>
-#ifdef G_OS_UNIX
-#include <unistd.h>
-#endif
 #include <glib/gstdio.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <fcntl.h>
 
+#ifdef G_OS_UNIX
+#include <unistd.h>
+#endif
+#ifdef G_OS_WIN32
+#include <io.h>
+#endif
+
 static void
 test_basic (void)
 {
index b1994eb..1f5e5eb 100644 (file)
 
 #include "glib.h"
 
-#ifdef G_OS_UNIX
-#include <unistd.h>
-#endif
-
 #define C2P(c)          ((gpointer) ((long) (c)))
 #define P2C(p)          ((gchar) ((long) (p)))
 
index a4f3976..11d847b 100644 (file)
@@ -32,7 +32,7 @@
 
 #include <glib.h>
 
-#ifndef G_OS_WIN32
+#ifdef G_OS_UNIX
 #include <unistd.h>
 #include <sys/resource.h>
 #endif
index e441bbc..25d22a5 100644 (file)
@@ -38,7 +38,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#ifdef HAVE_UNISTD_H
+#ifdef G_OS_UNIX
 #include <unistd.h>
 #endif
 #ifdef G_OS_WIN32
index 6ef6ea7..c8612e4 100644 (file)
@@ -23,9 +23,6 @@
 #include <fcntl.h>
 #include <string.h>
 #include <errno.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #include <sys/types.h>
 #include <sys/stat.h>
 
@@ -36,6 +33,9 @@
 #include <glib.h>
 #include <glib/gprintf.h>
 
+#ifdef G_OS_UNIX
+#include <unistd.h>
+#endif
 #ifdef G_OS_WIN32
 #include <io.h>
 #endif
index 179acb6..5c6f0af 100644 (file)
@@ -21,9 +21,6 @@
 
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
 #include <sys/stat.h>
 #include <fcntl.h>
 
index b75eb42..1b2e219 100644 (file)
 
 #include <glib.h>
 
-#ifdef G_OS_UNIX
-#include <unistd.h>
-#endif
-
 int 
 main (int argc, char *argv[])
 {
index 6c8d207..ce958d5 100644 (file)
 
 #include <gstdio.h>
 
+#include <fcntl.h>             /* For open() */
+
 #ifdef G_OS_UNIX
 #include <unistd.h>
 #endif
-
-#include <fcntl.h>             /* For open() */
-
 #ifdef G_OS_WIN32
 #include <io.h>                        /* For read(), write() etc */
 #endif
index 06c385c..fd4ffe0 100644 (file)
   #define STRICT
   #include <windows.h>
   #define pipe(fds) _pipe(fds, 4096, _O_BINARY)
-#else
-  #ifdef HAVE_UNISTD_H
-    #include <unistd.h>
-  #endif
+#endif
+
+#ifdef G_OS_UNIX
+  #include <unistd.h>
 #endif
 
 static int nrunning;