mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-10-31 08:22:16 +01:00 
			
		
		
		
	glib/tests: Clean up inclusion of unistd.h
Include unistd.h only when G_OS_UNIX is defined (or when G_OS_WIN32 is not defined). This will avoid including unistd.h unconditionally and/or unecessarily, which may cause problems in certain scenarios, such as when building the tests on Visual C++, which does not come with a unistd.h and MinGW, where unistd.h is essentially a wrapper for io.h and process.h. https://bugzilla.gnome.org/show_bug.cgi?id=711047
This commit is contained in:
		| @@ -1,8 +1,6 @@ | |||||||
| #include "config.h" |  | ||||||
|  |  | ||||||
| #include <glib.h> | #include <glib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #ifdef HAVE_UNISTD_H | #ifdef G_OS_UNIX | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| #endif | #endif | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
|   | |||||||
| @@ -1,8 +1,6 @@ | |||||||
| #include "config.h" |  | ||||||
|  |  | ||||||
| #include <glib.h> | #include <glib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #ifdef HAVE_UNISTD_H | #ifdef G_OS_UNIX | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| #endif | #endif | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
|   | |||||||
| @@ -1,6 +1,8 @@ | |||||||
| #include <unistd.h> |  | ||||||
| #include <glib.h> | #include <glib.h> | ||||||
| #include <glib/gwakeup.h> | #include <glib/gwakeup.h> | ||||||
|  | #ifdef G_OS_UNIX | ||||||
|  | #include <unistd.h> | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #ifdef _WIN32 | #ifdef _WIN32 | ||||||
| static void alarm (int sec) { } | static void alarm (int sec) { } | ||||||
|   | |||||||
| @@ -1,8 +1,6 @@ | |||||||
| #include "config.h" |  | ||||||
|  |  | ||||||
| #include <glib.h> | #include <glib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #ifdef HAVE_UNISTD_H | #ifdef G_OS_UNIX | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| #endif | #endif | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
|   | |||||||
| @@ -1,9 +1,8 @@ | |||||||
| #define GLIB_DISABLE_DEPRECATION_WARNINGS | #define GLIB_DISABLE_DEPRECATION_WARNINGS | ||||||
|  |  | ||||||
| #include <config.h> |  | ||||||
| #include <glib.h> | #include <glib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #ifdef HAVE_UNISTD_H | #ifdef G_OS_UNIX | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| #endif | #endif | ||||||
| #include <glib/gstdio.h> | #include <glib/gstdio.h> | ||||||
|   | |||||||
| @@ -27,20 +27,16 @@ | |||||||
| #undef G_DISABLE_ASSERT | #undef G_DISABLE_ASSERT | ||||||
| #undef G_LOG_DOMAIN | #undef G_LOG_DOMAIN | ||||||
|  |  | ||||||
| #ifdef HAVE_CONFIG_H |  | ||||||
| #include "config.h" |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
|  |  | ||||||
| #ifdef HAVE_UNISTD_H | #include "glib.h" | ||||||
|  |  | ||||||
|  | #ifdef G_OS_UNIX | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #include "glib.h" |  | ||||||
|  |  | ||||||
| #define C2P(c)          ((gpointer) ((long) (c))) | #define C2P(c)          ((gpointer) ((long) (c))) | ||||||
| #define P2C(p)          ((gchar) ((long) (p))) | #define P2C(p)          ((gchar) ((long) (p))) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -22,9 +22,10 @@ | |||||||
|  |  | ||||||
| #include <errno.h>  /* errno */ | #include <errno.h>  /* errno */ | ||||||
| #include <glib.h> | #include <glib.h> | ||||||
| #ifndef _WIN32 | #ifdef G_OS_UNIX | ||||||
| #include <unistd.h> /* pipe() */ | #include <unistd.h> /* pipe() */ | ||||||
| #else | #endif | ||||||
|  | #ifdef G_OS_WIN32 | ||||||
| #include <io.h> | #include <io.h> | ||||||
| #include <fcntl.h> | #include <fcntl.h> | ||||||
| #define pipe(fds) _pipe(fds, 4096, _O_BINARY) | #define pipe(fds) _pipe(fds, 4096, _O_BINARY) | ||||||
|   | |||||||
| @@ -26,17 +26,14 @@ | |||||||
| #include <sys/time.h> | #include <sys/time.h> | ||||||
| #endif | #endif | ||||||
| #include <sys/types.h> | #include <sys/types.h> | ||||||
| #ifdef HAVE_UNISTD_H |  | ||||||
| #include <unistd.h> |  | ||||||
| #endif |  | ||||||
| #ifdef HAVE_SYS_PRCTL_H | #ifdef HAVE_SYS_PRCTL_H | ||||||
| #include <sys/prctl.h> | #include <sys/prctl.h> | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
| #include <glib.h> | #include <glib.h> | ||||||
|  |  | ||||||
| #ifndef G_OS_WIN32 | #ifndef G_OS_WIN32 | ||||||
|  | #include <unistd.h> | ||||||
| #include <sys/resource.h> | #include <sys/resource.h> | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
| #include <glib.h> | #include <glib.h> | ||||||
|  | #ifdef G_OS_UNIX | ||||||
| #include <unistd.h> | #include <unistd.h> | ||||||
|  | #endif | ||||||
|  |  | ||||||
| static GMainLoop *loop; | static GMainLoop *loop; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user