Commit 158dde05 authored by Dan Winship's avatar Dan Winship

Replace #ifdef HAVE_UNISTD_H checks with #ifdef G_OS_UNIX

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
parent 3981cddb
...@@ -630,13 +630,6 @@ ...@@ -630,13 +630,6 @@
/* Define to 1 if you have the `timegm' function. */ /* Define to 1 if you have the `timegm' function. */
/* #undef HAVE_TIMEGM */ /* #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 /* Define if your printf function family supports positional parameters as
specified by Unix98. */ specified by Unix98. */
/* #undef HAVE_UNIX98_PRINTF */ /* #undef HAVE_UNIX98_PRINTF */
......
...@@ -779,7 +779,7 @@ AC_CHECK_HEADERS([mntent.h sys/mnttab.h sys/vfstab.h sys/mntctl.h fstab.h]) ...@@ -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]) AC_CHECK_HEADERS([linux/magic.h sys/prctl.h])
# Some versions of MSC lack these # 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 # We don't care about this, but we need to keep including it in
# glibconfig.h for backward compatibility # glibconfig.h for backward compatibility
...@@ -799,7 +799,9 @@ AC_CHECK_HEADERS([xlocale.h]) ...@@ -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_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> 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> #include <sys/stat.h>
#ifdef G_OS_UNIX
#include <unistd.h> #include <unistd.h>
#endif
#ifdef HAVE_SYS_STATFS_H #ifdef HAVE_SYS_STATFS_H
#include <sys/statfs.h> #include <sys/statfs.h>
#endif #endif
...@@ -922,9 +924,6 @@ AS_IF([test $ac_cv_sizeof_ssize_t = $ac_cv_sizeof_int && ...@@ -922,9 +924,6 @@ AS_IF([test $ac_cv_sizeof_ssize_t = $ac_cv_sizeof_int &&
#ifdef HAVE_STDINT_H #ifdef HAVE_STDINT_H
# include <stdint.h> # include <stdint.h>
#endif #endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <sys/types.h> #include <sys/types.h>
int main () int main ()
{ {
...@@ -944,9 +943,6 @@ int main () ...@@ -944,9 +943,6 @@ int main ()
#ifdef HAVE_STDINT_H #ifdef HAVE_STDINT_H
# include <stdint.h> # include <stdint.h>
#endif #endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <sys/types.h> #include <sys/types.h>
int main () int main ()
{ {
......
...@@ -23,10 +23,6 @@ ...@@ -23,10 +23,6 @@
#include "config.h" #include "config.h"
#include <string.h> #include <string.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "gdbusauthmechanismexternal.h" #include "gdbusauthmechanismexternal.h"
#include "gcredentials.h" #include "gcredentials.h"
......
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_UNISTD_H #ifdef G_OS_UNIX
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef _WIN32 #ifdef G_OS_WIN32
#include <io.h> #include <io.h>
#endif #endif
......
...@@ -105,10 +105,6 @@ ...@@ -105,10 +105,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "gdbusauth.h" #include "gdbusauth.h"
#include "gdbusutils.h" #include "gdbusutils.h"
......
...@@ -29,9 +29,6 @@ ...@@ -29,9 +29,6 @@
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#if MAJOR_IN_MKDEV #if MAJOR_IN_MKDEV
#include <sys/mkdev.h> #include <sys/mkdev.h>
......
...@@ -24,9 +24,6 @@ ...@@ -24,9 +24,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "giotypes.h" #include "giotypes.h"
#include "gsocket.h" #include "gsocket.h"
......
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#ifdef HAVE_UNISTD_H #ifdef G_OS_UNIX
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef _WIN32 #ifdef G_OS_WIN32
#include <io.h> #include <io.h>
#endif #endif
......
...@@ -27,9 +27,6 @@ ...@@ -27,9 +27,6 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdlib.h> #include <stdlib.h>
#include "gdummyfile.h" #include "gdummyfile.h"
......
...@@ -30,6 +30,9 @@ ...@@ -30,6 +30,9 @@
#include <stdio.h> #include <stdio.h>
#include <locale.h> #include <locale.h>
#include <errno.h> #include <errno.h>
#ifdef G_OS_UNIX
#include <unistd.h>
#endif
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
#include <io.h> #include <io.h>
#endif #endif
...@@ -38,10 +41,6 @@ ...@@ -38,10 +41,6 @@
#include <gio/gzlibcompressor.h> #include <gio/gzlibcompressor.h>
#include <gio/gconverteroutputstream.h> #include <gio/gconverteroutputstream.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <glib.h> #include <glib.h>
#include "gvdb/gvdb-builder.h" #include "gvdb/gvdb-builder.h"
......
...@@ -29,10 +29,6 @@ ...@@ -29,10 +29,6 @@
#include <stdio.h> #include <stdio.h>
#include <locale.h> #include <locale.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "gvdb/gvdb-builder.h" #include "gvdb/gvdb-builder.h"
#include "strinfo.c" #include "strinfo.c"
......
...@@ -29,8 +29,6 @@ ...@@ -29,8 +29,6 @@
#include <fcntl.h> #include <fcntl.h>
#if G_OS_UNIX #if G_OS_UNIX
#include <dirent.h> #include <dirent.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
......
...@@ -32,9 +32,6 @@ ...@@ -32,9 +32,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <string.h> #include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
...@@ -62,11 +59,11 @@ ...@@ -62,11 +59,11 @@
#include <gfileinfo-priv.h> #include <gfileinfo-priv.h>
#include <gvfs.h> #include <gvfs.h>
#ifndef G_OS_WIN32 #ifdef G_OS_UNIX
#include <unistd.h>
#include "glib-unix.h" #include "glib-unix.h"
#include "glib-private.h" #include "glib-private.h"
#endif #endif
#include "glibintl.h"
#include "thumbnail-verify.h" #include "thumbnail-verify.h"
...@@ -97,6 +94,7 @@ ...@@ -97,6 +94,7 @@
#include "gioerror.h" #include "gioerror.h"
#include "gthemedicon.h" #include "gthemedicon.h"
#include "gcontenttypeprivate.h" #include "gcontenttypeprivate.h"
#include "glibintl.h"
struct ThumbMD5Context { struct ThumbMD5Context {
......
...@@ -25,9 +25,6 @@ ...@@ -25,9 +25,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <errno.h> #include <errno.h>
#include <glib.h> #include <glib.h>
...@@ -39,6 +36,7 @@ ...@@ -39,6 +36,7 @@
#include "glibintl.h" #include "glibintl.h"
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
#include <unistd.h>
#include "glib-unix.h" #include "glib-unix.h"
#include "gfiledescriptorbased.h" #include "gfiledescriptorbased.h"
#endif #endif
......
...@@ -25,9 +25,6 @@ ...@@ -25,9 +25,6 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
...@@ -41,6 +38,7 @@ ...@@ -41,6 +38,7 @@
#include "glocalfileinfo.h" #include "glocalfileinfo.h"
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
#include <unistd.h>
#include "gfiledescriptorbased.h" #include "gfiledescriptorbased.h"
#endif #endif
......
...@@ -22,14 +22,7 @@ ...@@ -22,14 +22,7 @@
#include "config.h" #include "config.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h> #include <string.h>
#include <errno.h>
#include <fcntl.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "gsimpleasyncresult.h" #include "gsimpleasyncresult.h"
#include "gasyncresult.h" #include "gasyncresult.h"
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <gstdio.h> #include <gstdio.h>
#ifdef HAVE_UNISTD_H #ifdef G_OS_UNIX
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
......
...@@ -29,11 +29,6 @@ ...@@ -29,11 +29,6 @@
#include <locale.h> #include <locale.h>
#include <time.h> #include <time.h>
#include <stdarg.h> #include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "gconvert.h" #include "gconvert.h"
#include "gdataset.h" #include "gdataset.h"
......
...@@ -50,10 +50,6 @@ ...@@ -50,10 +50,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_LANGINFO_TIME #ifdef HAVE_LANGINFO_TIME
#include <langinfo.h> #include <langinfo.h>
#endif #endif
......
...@@ -30,9 +30,6 @@ ...@@ -30,9 +30,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_CRT_EXTERNS_H #ifdef HAVE_CRT_EXTERNS_H
#include <crt_externs.h> /* for _NSGetEnviron */ #include <crt_externs.h> /* for _NSGetEnviron */
#endif #endif
......
...@@ -22,9 +22,6 @@ ...@@ -22,9 +22,6 @@
#include "glibconfig.h" #include "glibconfig.h"
#include <sys/stat.h> #include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
...@@ -35,6 +32,9 @@ ...@@ -35,6 +32,9 @@
#include <fcntl.h> #include <fcntl.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef G_OS_UNIX
#include <unistd.h>
#endif
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
#include <windows.h> #include <windows.h>
#include <io.h> #include <io.h>
......
...@@ -36,10 +36,6 @@ ...@@ -36,10 +36,6 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "giochannel.h" #include "giochannel.h"
#include "gstrfuncs.h" #include "gstrfuncs.h"
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef HAVE_UNISTD_H #ifdef G_OS_UNIX
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
......
...@@ -62,9 +62,9 @@ ...@@ -62,9 +62,9 @@
#ifdef HAVE_SYS_TIME_H #ifdef HAVE_SYS_TIME_H
#include <sys/time.h> #include <sys/time.h>
#endif /* HAVE_SYS_TIME_H */ #endif /* HAVE_SYS_TIME_H */
#ifdef HAVE_UNISTD_H #ifdef G_OS_UNIX
#include <unistd.h> #include <unistd.h>
#endif /* HAVE_UNISTD_H */ #endif /* G_OS_UNIX */
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
......
...@@ -25,15 +25,16 @@ ...@@ -25,15 +25,16 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_MMAP #ifdef HAVE_MMAP
#include <sys/mman.h> #include <sys/mman.h>
#endif #endif
#include "glibconfig.h" #include "glibconfig.h"
#ifdef G_OS_UNIX
#include <unistd.h>
#endif
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
#include <windows.h> #include <windows.h>
#include <io.h> #include <io.h>
......
...@@ -52,9 +52,6 @@ ...@@ -52,9 +52,6 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <signal.h> #include <signal.h>
#include <locale.h> #include <locale.h>
#include <errno.h> #include <errno.h>
...@@ -74,6 +71,10 @@ ...@@ -74,6 +71,10 @@
#include "gstring.h" #include "gstring.h"
#include "gpattern.h" #include "gpattern.h"
#ifdef G_OS_UNIX
#include <unistd.h>
#endif
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
#include <process.h> /* For getpid() */ #include <process.h> /* For getpid() */
#include <io.h> #include <io.h>
......
...@@ -66,9 +66,9 @@ ...@@ -66,9 +66,9 @@
#endif #endif
#endif /* GLIB_HAVE_SYS_POLL_H */ #endif /* GLIB_HAVE_SYS_POLL_H */
#ifdef HAVE_UNISTD_H #ifdef G_OS_UNIX
#include <unistd.h> #include <unistd.h>
#endif /* HAVE_UNISTD_H */ #endif /* G_OS_UNIX */
#include <errno.h> #include <errno.h>
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
......
...@@ -44,10 +44,6 @@ ...@@ -44,10 +44,6 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "grand.h" #include "grand.h"
#include "genviron.h" #include "genviron.h"
...@@ -56,6 +52,10 @@ ...@@ -56,6 +52,10 @@
#include "gtestutils.h" #include "gtestutils.h"
#include "gthread.h" #include "gthread.h"
#ifdef G_OS_UNIX
#include <unistd.h>
#endif
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
#include <stdlib.h> #include <stdlib.h>
#endif #endif
......
...@@ -38,9 +38,6 @@ ...@@ -38,9 +38,6 @@
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "gscanner.h" #include "gscanner.h"
...@@ -49,8 +46,11 @@ ...@@ -49,8 +46,11 @@
#include "gstring.h" #include "gstring.h"
#include "gtestutils.h" #include "gtestutils.h"
#ifdef G_OS_UNIX
#include <unistd.h>
#endif
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
#include <io.h> /* For _read() */ #include <io.h>
#endif #endif
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#ifdef HAVE_UNISTD_H #ifdef G_OS_UNIX
#include <unistd.h> /* sysconf() */ #include <unistd.h> /* sysconf() */
#endif #endif
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef HAVE_UNISTD_H #ifdef G_OS_UNIX
#include <unistd.h> #include <unistd.h>
#endif #endif
......
...@@ -30,9 +30,6 @@ ...@@ -30,9 +30,6 @@
#include "config.h" #include "config.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
......
...@@ -29,14 +29,12 @@ ...@@ -29,14 +29,12 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/time.h> #include <sys/time.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
#endif #endif
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_RESOURCE_H #ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h> #include <sys/resource.h>
#endif #endif
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
#include <string.h> #include <string.h>
#ifdef HAVE_UNISTD_H #ifdef G_OS_UNIX
#include <unistd.h> #include <unistd.h>
#endif #endif
...@@ -1039,7 +1039,7 @@ g_get_num_processors (void) ...@@ -1039,7 +1039,7 @@ g_get_num_processors (void)
if (count > 0) if (count > 0)
return count; return count;
} }
#elif defined(HAVE_UNISTD_H) && defined(_SC_NPROCESSORS_ONLN) #elif defined(_SC_NPROCESSORS_ONLN)
{ {
int count; int count;
......
...@@ -33,9 +33,9 @@ ...@@ -33,9 +33,9 @@
#include <stdlib.h> #include <stdlib.h>
#ifdef HAVE_UNISTD_H #ifdef G_OS_UNIX
#include <unistd.h> #include <unistd.h>
#endif /* HAVE_UNISTD_H */ #endif /* G_OS_UNIX */
#ifdef HAVE_SYS_TIME_H #ifdef HAVE_SYS_TIME_H