From 158dde050702f83a058962d14156a02234fc9685 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Sat, 19 Oct 2013 13:04:00 -0400 Subject: [PATCH] Replace #ifdef HAVE_UNISTD_H checks with #ifdef G_OS_UNIX In Windows development environments that have it, is mostly just a wrapper around several other native headers (in particular, , which contains read(), close(), etc, and , which contains getpid()). But given that some Windows dev environments don't have , 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 on Windows. Also, remove some includes (and a few others) that were unnecessary even on unix. https://bugzilla.gnome.org/show_bug.cgi?id=710519 --- config.h.win32.in | 7 ------- configure.ac | 10 +++------- gio/gdbusauthmechanismexternal.c | 4 ---- gio/gdbusauthmechanismsha1.c | 4 ++-- gio/gdbusconnection.c | 4 ---- gio/gdbusmessage.c | 3 --- gio/gdbusprivate.c | 3 --- gio/gdbusserver.c | 4 ++-- gio/gdummyfile.c | 3 --- gio/glib-compile-resources.c | 7 +++---- gio/glib-compile-schemas.c | 4 ---- gio/glocalfile.c | 2 -- gio/glocalfileinfo.c | 8 +++----- gio/glocalfileinputstream.c | 4 +--- gio/glocalfileoutputstream.c | 4 +--- gio/gsimpleasyncresult.c | 7 ------- gio/gtestdbus.c | 2 +- glib/gbookmarkfile.c | 5 ----- glib/gdatetime.c | 4 ---- glib/genviron.c | 3 --- glib/gfileutils.c | 6 +++--- glib/giochannel.c | 4 ---- glib/gkeyfile.c | 2 +- glib/gmain.c | 4 ++-- glib/gmappedfile.c | 7 ++++--- glib/gmessages.c | 7 ++++--- glib/gpoll.c | 4 ++-- glib/grand.c | 8 ++++---- glib/gscanner.c | 8 ++++---- glib/gslice.c | 2 +- glib/gstdio.c | 2 +- glib/gstring.c | 3 --- glib/gtestutils.c | 4 +--- glib/gthread.c | 4 ++-- glib/gtimer.c | 4 ++-- glib/gutils.c | 4 +--- glib/tests/base64.c | 3 --- glib/tests/checksum.c | 3 --- glib/tests/hmac.c | 3 --- glib/tests/mappedfile.c | 10 +++++++--- glib/tests/node.c | 4 ---- glib/tests/thread.c | 2 +- gmodule/gmodule.c | 2 +- gobject/glib-genmarshal.c | 6 +++--- gobject/gobject-query.c | 3 --- tests/env-test.c | 4 ---- tests/file-test.c | 5 ++--- tests/gio-test.c | 8 ++++---- 48 files changed, 66 insertions(+), 152 deletions(-) diff --git a/config.h.win32.in b/config.h.win32.in index c20231e08..62e308586 100644 --- a/config.h.win32.in +++ b/config.h.win32.in @@ -630,13 +630,6 @@ /* Define to 1 if you have the `timegm' function. */ /* #undef HAVE_TIMEGM */ -/* Define to 1 if you have the 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 */ diff --git a/configure.ac b/configure.ac index 1f3e7b7e6..6654e7956 100644 --- a/configure.ac +++ b/configure.ac @@ -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 #include +#ifdef G_OS_UNIX #include +#endif #ifdef HAVE_SYS_STATFS_H #include #endif @@ -922,9 +924,6 @@ AS_IF([test $ac_cv_sizeof_ssize_t = $ac_cv_sizeof_int && #ifdef HAVE_STDINT_H # include #endif -#ifdef HAVE_UNISTD_H -# include -#endif #include int main () { @@ -944,9 +943,6 @@ int main () #ifdef HAVE_STDINT_H # include #endif -#ifdef HAVE_UNISTD_H -# include -#endif #include int main () { diff --git a/gio/gdbusauthmechanismexternal.c b/gio/gdbusauthmechanismexternal.c index 40ff3f3f0..38a2f6500 100644 --- a/gio/gdbusauthmechanismexternal.c +++ b/gio/gdbusauthmechanismexternal.c @@ -23,10 +23,6 @@ #include "config.h" #include -#include -#ifdef HAVE_UNISTD_H -#include -#endif #include "gdbusauthmechanismexternal.h" #include "gcredentials.h" diff --git a/gio/gdbusauthmechanismsha1.c b/gio/gdbusauthmechanismsha1.c index e4f75eb0e..dae509e8e 100644 --- a/gio/gdbusauthmechanismsha1.c +++ b/gio/gdbusauthmechanismsha1.c @@ -26,10 +26,10 @@ #include #include #include -#ifdef HAVE_UNISTD_H +#ifdef G_OS_UNIX #include #endif -#ifdef _WIN32 +#ifdef G_OS_WIN32 #include #endif diff --git a/gio/gdbusconnection.c b/gio/gdbusconnection.c index 8a0748d2c..57fa193ab 100644 --- a/gio/gdbusconnection.c +++ b/gio/gdbusconnection.c @@ -105,10 +105,6 @@ #include #include -#include -#ifdef HAVE_UNISTD_H -#include -#endif #include "gdbusauth.h" #include "gdbusutils.h" diff --git a/gio/gdbusmessage.c b/gio/gdbusmessage.c index d52143c15..341f4e7ce 100644 --- a/gio/gdbusmessage.c +++ b/gio/gdbusmessage.c @@ -29,9 +29,6 @@ #include #include #include -#ifdef HAVE_UNISTD_H -#include -#endif #if MAJOR_IN_MKDEV #include diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c index 785a0c090..b7d9336c5 100644 --- a/gio/gdbusprivate.c +++ b/gio/gdbusprivate.c @@ -24,9 +24,6 @@ #include #include -#ifdef HAVE_UNISTD_H -#include -#endif #include "giotypes.h" #include "gsocket.h" diff --git a/gio/gdbusserver.c b/gio/gdbusserver.c index 43cc9ba37..7f3d8e66d 100644 --- a/gio/gdbusserver.c +++ b/gio/gdbusserver.c @@ -25,10 +25,10 @@ #include #include #include -#ifdef HAVE_UNISTD_H +#ifdef G_OS_UNIX #include #endif -#ifdef _WIN32 +#ifdef G_OS_WIN32 #include #endif diff --git a/gio/gdummyfile.c b/gio/gdummyfile.c index 4546e3c13..8f2271538 100644 --- a/gio/gdummyfile.c +++ b/gio/gdummyfile.c @@ -27,9 +27,6 @@ #include #include #include -#ifdef HAVE_UNISTD_H -#include -#endif #include #include "gdummyfile.h" diff --git a/gio/glib-compile-resources.c b/gio/glib-compile-resources.c index d7dd58014..822262ba0 100644 --- a/gio/glib-compile-resources.c +++ b/gio/glib-compile-resources.c @@ -30,6 +30,9 @@ #include #include #include +#ifdef G_OS_UNIX +#include +#endif #ifdef G_OS_WIN32 #include #endif @@ -38,10 +41,6 @@ #include #include -#ifdef HAVE_UNISTD_H -#include -#endif - #include #include "gvdb/gvdb-builder.h" diff --git a/gio/glib-compile-schemas.c b/gio/glib-compile-schemas.c index 9b9358183..d2ae81aa7 100644 --- a/gio/glib-compile-schemas.c +++ b/gio/glib-compile-schemas.c @@ -29,10 +29,6 @@ #include #include -#ifdef HAVE_UNISTD_H -#include -#endif - #include "gvdb/gvdb-builder.h" #include "strinfo.c" diff --git a/gio/glocalfile.c b/gio/glocalfile.c index 862d2fbcd..be516c143 100644 --- a/gio/glocalfile.c +++ b/gio/glocalfile.c @@ -29,8 +29,6 @@ #include #if G_OS_UNIX #include -#endif -#ifdef HAVE_UNISTD_H #include #endif diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c index 5e60bf8ac..4f6d5a2cc 100644 --- a/gio/glocalfileinfo.c +++ b/gio/glocalfileinfo.c @@ -32,9 +32,6 @@ #include #include #include -#ifdef HAVE_UNISTD_H -#include -#endif #include #include #ifdef G_OS_UNIX @@ -62,11 +59,11 @@ #include #include -#ifndef G_OS_WIN32 +#ifdef G_OS_UNIX +#include #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 { diff --git a/gio/glocalfileinputstream.c b/gio/glocalfileinputstream.c index 2c32353e1..ea2cfd1f6 100644 --- a/gio/glocalfileinputstream.c +++ b/gio/glocalfileinputstream.c @@ -25,9 +25,6 @@ #include #include #include -#ifdef HAVE_UNISTD_H -#include -#endif #include #include @@ -39,6 +36,7 @@ #include "glibintl.h" #ifdef G_OS_UNIX +#include #include "glib-unix.h" #include "gfiledescriptorbased.h" #endif diff --git a/gio/glocalfileoutputstream.c b/gio/glocalfileoutputstream.c index b50dada89..a1cdc8670 100644 --- a/gio/glocalfileoutputstream.c +++ b/gio/glocalfileoutputstream.c @@ -25,9 +25,6 @@ #include #include #include -#ifdef HAVE_UNISTD_H -#include -#endif #include #include @@ -41,6 +38,7 @@ #include "glocalfileinfo.h" #ifdef G_OS_UNIX +#include #include "gfiledescriptorbased.h" #endif diff --git a/gio/gsimpleasyncresult.c b/gio/gsimpleasyncresult.c index c5d8103d5..2c7f2dafd 100644 --- a/gio/gsimpleasyncresult.c +++ b/gio/gsimpleasyncresult.c @@ -22,14 +22,7 @@ #include "config.h" -#include -#include #include -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif #include "gsimpleasyncresult.h" #include "gasyncresult.h" diff --git a/gio/gtestdbus.c b/gio/gtestdbus.c index 151173f79..0b4ef6b87 100644 --- a/gio/gtestdbus.c +++ b/gio/gtestdbus.c @@ -27,7 +27,7 @@ #include #include #include -#ifdef HAVE_UNISTD_H +#ifdef G_OS_UNIX #include #endif #ifdef G_OS_WIN32 diff --git a/glib/gbookmarkfile.c b/glib/gbookmarkfile.c index 569d438b7..a2eaab331 100644 --- a/glib/gbookmarkfile.c +++ b/glib/gbookmarkfile.c @@ -29,11 +29,6 @@ #include #include #include -#include -#include -#ifdef HAVE_UNISTD_H -#include -#endif #include "gconvert.h" #include "gdataset.h" diff --git a/glib/gdatetime.c b/glib/gdatetime.c index f7f4ba2a9..6069e9033 100644 --- a/glib/gdatetime.c +++ b/glib/gdatetime.c @@ -50,10 +50,6 @@ #include #include -#ifdef HAVE_UNISTD_H -#include -#endif - #ifdef HAVE_LANGINFO_TIME #include #endif diff --git a/glib/genviron.c b/glib/genviron.c index 9f0ae24ca..01e8b82ea 100644 --- a/glib/genviron.c +++ b/glib/genviron.c @@ -30,9 +30,6 @@ #include #include -#ifdef HAVE_UNISTD_H -#include -#endif #ifdef HAVE_CRT_EXTERNS_H #include /* for _NSGetEnviron */ #endif diff --git a/glib/gfileutils.c b/glib/gfileutils.c index 233d299f7..fb47fc8a4 100644 --- a/glib/gfileutils.c +++ b/glib/gfileutils.c @@ -22,9 +22,6 @@ #include "glibconfig.h" #include -#ifdef HAVE_UNISTD_H -#include -#endif #include #include #include @@ -35,6 +32,9 @@ #include #include +#ifdef G_OS_UNIX +#include +#endif #ifdef G_OS_WIN32 #include #include diff --git a/glib/giochannel.c b/glib/giochannel.c index 84e9d7691..b9c45dfdd 100644 --- a/glib/giochannel.c +++ b/glib/giochannel.c @@ -36,10 +36,6 @@ #include #include -#ifdef HAVE_UNISTD_H -#include -#endif - #include "giochannel.h" #include "gstrfuncs.h" diff --git a/glib/gkeyfile.c b/glib/gkeyfile.c index b3fcb679e..ff5c5eb64 100644 --- a/glib/gkeyfile.c +++ b/glib/gkeyfile.c @@ -36,7 +36,7 @@ #include #include #include -#ifdef HAVE_UNISTD_H +#ifdef G_OS_UNIX #include #endif #ifdef G_OS_WIN32 diff --git a/glib/gmain.c b/glib/gmain.c index ad2570705..c3b1f16ed 100644 --- a/glib/gmain.c +++ b/glib/gmain.c @@ -62,9 +62,9 @@ #ifdef HAVE_SYS_TIME_H #include #endif /* HAVE_SYS_TIME_H */ -#ifdef HAVE_UNISTD_H +#ifdef G_OS_UNIX #include -#endif /* HAVE_UNISTD_H */ +#endif /* G_OS_UNIX */ #include #include diff --git a/glib/gmappedfile.c b/glib/gmappedfile.c index 7d241e730..1c019e10a 100644 --- a/glib/gmappedfile.c +++ b/glib/gmappedfile.c @@ -25,15 +25,16 @@ #include #include #include -#ifdef HAVE_UNISTD_H -#include -#endif #ifdef HAVE_MMAP #include #endif #include "glibconfig.h" +#ifdef G_OS_UNIX +#include +#endif + #ifdef G_OS_WIN32 #include #include diff --git a/glib/gmessages.c b/glib/gmessages.c index 2965d28a2..f21fc7ef5 100644 --- a/glib/gmessages.c +++ b/glib/gmessages.c @@ -52,9 +52,6 @@ #include #include #include -#ifdef HAVE_UNISTD_H -#include -#endif #include #include #include @@ -74,6 +71,10 @@ #include "gstring.h" #include "gpattern.h" +#ifdef G_OS_UNIX +#include +#endif + #ifdef G_OS_WIN32 #include /* For getpid() */ #include diff --git a/glib/gpoll.c b/glib/gpoll.c index 354c08fdf..66c5f0ee7 100644 --- a/glib/gpoll.c +++ b/glib/gpoll.c @@ -66,9 +66,9 @@ #endif #endif /* GLIB_HAVE_SYS_POLL_H */ -#ifdef HAVE_UNISTD_H +#ifdef G_OS_UNIX #include -#endif /* HAVE_UNISTD_H */ +#endif /* G_OS_UNIX */ #include #ifdef G_OS_WIN32 diff --git a/glib/grand.c b/glib/grand.c index 3f043ad5e..fb2a8ec5b 100644 --- a/glib/grand.c +++ b/glib/grand.c @@ -44,10 +44,6 @@ #include #include #include -#ifdef HAVE_UNISTD_H -#include -#endif - #include "grand.h" #include "genviron.h" @@ -56,6 +52,10 @@ #include "gtestutils.h" #include "gthread.h" +#ifdef G_OS_UNIX +#include +#endif + #ifdef G_OS_WIN32 #include #endif diff --git a/glib/gscanner.c b/glib/gscanner.c index 9fc5e7c46..9d737495b 100644 --- a/glib/gscanner.c +++ b/glib/gscanner.c @@ -38,9 +38,6 @@ #include #include #include -#ifdef HAVE_UNISTD_H -#include -#endif #include "gscanner.h" @@ -49,8 +46,11 @@ #include "gstring.h" #include "gtestutils.h" +#ifdef G_OS_UNIX +#include +#endif #ifdef G_OS_WIN32 -#include /* For _read() */ +#include #endif diff --git a/glib/gslice.c b/glib/gslice.c index 24ce62f69..5f545fc36 100644 --- a/glib/gslice.c +++ b/glib/gslice.c @@ -32,7 +32,7 @@ #include #include -#ifdef HAVE_UNISTD_H +#ifdef G_OS_UNIX #include /* sysconf() */ #endif #ifdef G_OS_WIN32 diff --git a/glib/gstdio.c b/glib/gstdio.c index a78558fcc..dfb3feb1c 100644 --- a/glib/gstdio.c +++ b/glib/gstdio.c @@ -27,7 +27,7 @@ #include #include -#ifdef HAVE_UNISTD_H +#ifdef G_OS_UNIX #include #endif diff --git a/glib/gstring.c b/glib/gstring.c index ef77133c6..782fd4a00 100644 --- a/glib/gstring.c +++ b/glib/gstring.c @@ -30,9 +30,6 @@ #include "config.h" -#ifdef HAVE_UNISTD_H -#include -#endif #include #include #include diff --git a/glib/gtestutils.c b/glib/gtestutils.c index 353a2db2e..fa820db21 100644 --- a/glib/gtestutils.c +++ b/glib/gtestutils.c @@ -29,14 +29,12 @@ #include #include #include +#include #include #endif #include #include #include -#ifdef HAVE_UNISTD_H -#include -#endif #ifdef HAVE_SYS_RESOURCE_H #include #endif diff --git a/glib/gthread.c b/glib/gthread.c index c4114aa92..2df13c4c6 100644 --- a/glib/gthread.c +++ b/glib/gthread.c @@ -45,7 +45,7 @@ #include -#ifdef HAVE_UNISTD_H +#ifdef G_OS_UNIX #include #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; diff --git a/glib/gtimer.c b/glib/gtimer.c index a45c3cff0..f1bef0723 100644 --- a/glib/gtimer.c +++ b/glib/gtimer.c @@ -33,9 +33,9 @@ #include -#ifdef HAVE_UNISTD_H +#ifdef G_OS_UNIX #include -#endif /* HAVE_UNISTD_H */ +#endif /* G_OS_UNIX */ #ifdef HAVE_SYS_TIME_H #include diff --git a/glib/gutils.c b/glib/gutils.c index 1395757d1..6ed1a65fa 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -31,9 +31,6 @@ #include "config.h" #include "glibconfig.h" -#ifdef HAVE_UNISTD_H -#include -#endif #include #include #include @@ -45,6 +42,7 @@ #include #ifdef G_OS_UNIX #include +#include #endif #include #ifdef HAVE_SYS_PARAM_H diff --git a/glib/tests/base64.c b/glib/tests/base64.c index e5ac5b960..e1420e101 100644 --- a/glib/tests/base64.c +++ b/glib/tests/base64.c @@ -1,8 +1,5 @@ #include #include -#ifdef G_OS_UNIX -#include -#endif #include #define DATA_SIZE 1024 diff --git a/glib/tests/checksum.c b/glib/tests/checksum.c index a5d2ea0a3..b6ae3ef5b 100644 --- a/glib/tests/checksum.c +++ b/glib/tests/checksum.c @@ -1,8 +1,5 @@ #include #include -#ifdef G_OS_UNIX -#include -#endif #include /* Test GChecksum by computing the checksums of every initial diff --git a/glib/tests/hmac.c b/glib/tests/hmac.c index c8215dbe5..f6ee643b1 100644 --- a/glib/tests/hmac.c +++ b/glib/tests/hmac.c @@ -1,8 +1,5 @@ #include #include -#ifdef G_OS_UNIX -#include -#endif #include /* HMAC-MD5 test vectors as per RFC 2202 */ diff --git a/glib/tests/mappedfile.c b/glib/tests/mappedfile.c index 6b2210512..99c26c9e7 100644 --- a/glib/tests/mappedfile.c +++ b/glib/tests/mappedfile.c @@ -2,14 +2,18 @@ #include #include -#ifdef G_OS_UNIX -#include -#endif #include #include #include #include +#ifdef G_OS_UNIX +#include +#endif +#ifdef G_OS_WIN32 +#include +#endif + static void test_basic (void) { diff --git a/glib/tests/node.c b/glib/tests/node.c index b1994eb3c..1f5e5ebab 100644 --- a/glib/tests/node.c +++ b/glib/tests/node.c @@ -33,10 +33,6 @@ #include "glib.h" -#ifdef G_OS_UNIX -#include -#endif - #define C2P(c) ((gpointer) ((long) (c))) #define P2C(p) ((gchar) ((long) (p))) diff --git a/glib/tests/thread.c b/glib/tests/thread.c index a4f3976d4..11d847b78 100644 --- a/glib/tests/thread.c +++ b/glib/tests/thread.c @@ -32,7 +32,7 @@ #include -#ifndef G_OS_WIN32 +#ifdef G_OS_UNIX #include #include #endif diff --git a/gmodule/gmodule.c b/gmodule/gmodule.c index e441bbc9d..25d22a525 100644 --- a/gmodule/gmodule.c +++ b/gmodule/gmodule.c @@ -38,7 +38,7 @@ #include #include #include -#ifdef HAVE_UNISTD_H +#ifdef G_OS_UNIX #include #endif #ifdef G_OS_WIN32 diff --git a/gobject/glib-genmarshal.c b/gobject/glib-genmarshal.c index 6ef6ea725..c8612e4e5 100644 --- a/gobject/glib-genmarshal.c +++ b/gobject/glib-genmarshal.c @@ -23,9 +23,6 @@ #include #include #include -#ifdef HAVE_UNISTD_H -#include -#endif #include #include @@ -36,6 +33,9 @@ #include #include +#ifdef G_OS_UNIX +#include +#endif #ifdef G_OS_WIN32 #include #endif diff --git a/gobject/gobject-query.c b/gobject/gobject-query.c index 179acb69c..5c6f0afd0 100644 --- a/gobject/gobject-query.c +++ b/gobject/gobject-query.c @@ -21,9 +21,6 @@ #include #include -#ifdef HAVE_UNISTD_H -#include -#endif #include #include diff --git a/tests/env-test.c b/tests/env-test.c index b75eb4250..1b2e2193b 100644 --- a/tests/env-test.c +++ b/tests/env-test.c @@ -37,10 +37,6 @@ #include -#ifdef G_OS_UNIX -#include -#endif - int main (int argc, char *argv[]) { diff --git a/tests/file-test.c b/tests/file-test.c index 6c8d2076b..ce958d53f 100644 --- a/tests/file-test.c +++ b/tests/file-test.c @@ -37,12 +37,11 @@ #include +#include /* For open() */ + #ifdef G_OS_UNIX #include #endif - -#include /* For open() */ - #ifdef G_OS_WIN32 #include /* For read(), write() etc */ #endif diff --git a/tests/gio-test.c b/tests/gio-test.c index 06c385cc5..fd4ffe03d 100644 --- a/tests/gio-test.c +++ b/tests/gio-test.c @@ -40,10 +40,10 @@ #define STRICT #include #define pipe(fds) _pipe(fds, 4096, _O_BINARY) -#else - #ifdef HAVE_UNISTD_H - #include - #endif +#endif + +#ifdef G_OS_UNIX + #include #endif static int nrunning;