From 40bf583a68dd600771332317ae33b015dfd6890c Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 16 Feb 2018 11:45:42 -0800 Subject: [PATCH] protect unistd.h inclusion with a check for Unix This ensures that all the inclusions of unistd.h inclusion are protected with the check that the header exists. This header is only available on unix like environments to define the standard of compliance. This protection is needed for other environments like Windows. --- CMakeLists.txt | 1 - cmake/config.h.in | 3 --- dispatch/dispatch.h | 2 +- private/private.h | 2 +- src/internal.h | 2 +- src/queue.c | 2 ++ tests/Foundation/bench.mm | 2 ++ tests/bsdtestharness.c | 2 ++ tests/bsdtests.c | 2 ++ tests/bsdtests.h | 2 ++ tests/cffd.c | 2 ++ tests/dispatch_after.c | 2 ++ tests/dispatch_apply.c | 2 ++ tests/dispatch_cascade.c | 2 ++ tests/dispatch_concur.c | 2 ++ tests/dispatch_context_for_key.c | 2 ++ tests/dispatch_deadname.c | 2 ++ tests/dispatch_drift.c | 2 ++ tests/dispatch_group.c | 2 ++ tests/dispatch_io.c | 2 ++ tests/dispatch_io_net.c | 2 ++ tests/dispatch_overcommit.c | 2 ++ tests/dispatch_priority.c | 2 ++ tests/dispatch_proc.c | 2 ++ tests/dispatch_queue_finalizer.c | 2 ++ tests/dispatch_read.c | 2 ++ tests/dispatch_read2.c | 2 ++ tests/dispatch_readsync.c | 2 ++ tests/dispatch_select.c | 2 ++ tests/dispatch_sema.c | 2 ++ tests/dispatch_sync_on_main.c | 2 ++ tests/dispatch_test.c | 2 ++ tests/dispatch_vm.c | 2 ++ tests/dispatch_vnode.c | 2 ++ 34 files changed, 61 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97d306dca..ead4696a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -221,7 +221,6 @@ check_include_files("strings.h" HAVE_STRINGS_H) check_include_files("sys/guarded.h" HAVE_SYS_GUARDED_H) check_include_files("sys/stat.h" HAVE_SYS_STAT_H) check_include_files("sys/types.h" HAVE_SYS_TYPES_H) -check_include_files("unistd.h" HAVE_UNISTD_H) check_include_files("objc/objc-internal.h" HAVE_OBJC) if(HAVE_MACH) diff --git a/cmake/config.h.in b/cmake/config.h.in index 12a253056..380d41ec5 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in @@ -192,9 +192,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_TARGETCONDITIONALS_H -/* Define to 1 if you have the header file. */ -#cmakedefine01 HAVE_UNISTD_H - /* Define to 1 if you have the `_pthread_workqueue_init' function. */ #cmakedefine HAVE__PTHREAD_WORKQUEUE_INIT diff --git a/dispatch/dispatch.h b/dispatch/dispatch.h index a4b54593c..d36259c75 100644 --- a/dispatch/dispatch.h +++ b/dispatch/dispatch.h @@ -35,7 +35,7 @@ #include #include #include -#if !defined(HAVE_UNISTD_H) || HAVE_UNISTD_H +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include #endif #include diff --git a/private/private.h b/private/private.h index cb4f6769a..ee2b26e43 100644 --- a/private/private.h +++ b/private/private.h @@ -41,7 +41,7 @@ #include #include #endif -#if HAVE_UNISTD_H +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include #endif #include diff --git a/src/internal.h b/src/internal.h index 98e13a316..84505e527 100644 --- a/src/internal.h +++ b/src/internal.h @@ -285,7 +285,7 @@ DISPATCH_EXPORT DISPATCH_NOTHROW void dispatch_atfork_child(void); #include #include #include -#if HAVE_UNISTD_H +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include #endif diff --git a/src/queue.c b/src/queue.c index 3d0f10c8b..d747a5941 100644 --- a/src/queue.c +++ b/src/queue.c @@ -903,7 +903,9 @@ libdispatch_init(void) } #if DISPATCH_USE_THREAD_LOCAL_STORAGE +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #ifndef __ANDROID__ diff --git a/tests/Foundation/bench.mm b/tests/Foundation/bench.mm index 635679ffc..20d11c210 100644 --- a/tests/Foundation/bench.mm +++ b/tests/Foundation/bench.mm @@ -31,7 +31,9 @@ #include #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include #include diff --git a/tests/bsdtestharness.c b/tests/bsdtestharness.c index 7aad1c07b..08f3f7d29 100644 --- a/tests/bsdtestharness.c +++ b/tests/bsdtestharness.c @@ -23,7 +23,9 @@ #include #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #ifdef __APPLE__ #include diff --git a/tests/bsdtests.c b/tests/bsdtests.c index 2c07a5d0b..09700fae5 100644 --- a/tests/bsdtests.c +++ b/tests/bsdtests.c @@ -25,7 +25,9 @@ #include #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include #include diff --git a/tests/bsdtests.h b/tests/bsdtests.h index f2961945b..48e73a2d8 100644 --- a/tests/bsdtests.h +++ b/tests/bsdtests.h @@ -41,7 +41,9 @@ #include #endif +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include diff --git a/tests/cffd.c b/tests/cffd.c index 7ba91eead..3655c01c2 100644 --- a/tests/cffd.c +++ b/tests/cffd.c @@ -22,7 +22,9 @@ #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include #include diff --git a/tests/dispatch_after.c b/tests/dispatch_after.c index 6c95a3b43..2b46dc903 100644 --- a/tests/dispatch_after.c +++ b/tests/dispatch_after.c @@ -20,7 +20,9 @@ #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include #ifdef __APPLE__ diff --git a/tests/dispatch_apply.c b/tests/dispatch_apply.c index 380fd355a..d77d8bb18 100644 --- a/tests/dispatch_apply.c +++ b/tests/dispatch_apply.c @@ -20,7 +20,9 @@ #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include #ifdef __APPLE__ diff --git a/tests/dispatch_cascade.c b/tests/dispatch_cascade.c index 1f3cd40b5..fce2790cb 100644 --- a/tests/dispatch_cascade.c +++ b/tests/dispatch_cascade.c @@ -20,7 +20,9 @@ #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include diff --git a/tests/dispatch_concur.c b/tests/dispatch_concur.c index e7f02260c..960f565a8 100644 --- a/tests/dispatch_concur.c +++ b/tests/dispatch_concur.c @@ -20,7 +20,9 @@ #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include #include diff --git a/tests/dispatch_context_for_key.c b/tests/dispatch_context_for_key.c index c10a8694e..bcf1ab8ed 100644 --- a/tests/dispatch_context_for_key.c +++ b/tests/dispatch_context_for_key.c @@ -21,7 +21,9 @@ #include #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include diff --git a/tests/dispatch_deadname.c b/tests/dispatch_deadname.c index 805944ea7..3c752800e 100644 --- a/tests/dispatch_deadname.c +++ b/tests/dispatch_deadname.c @@ -24,7 +24,9 @@ #include #endif #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include diff --git a/tests/dispatch_drift.c b/tests/dispatch_drift.c index a6631a8d0..e483f3666 100644 --- a/tests/dispatch_drift.c +++ b/tests/dispatch_drift.c @@ -23,7 +23,9 @@ #endif #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include #ifdef __APPLE__ diff --git a/tests/dispatch_group.c b/tests/dispatch_group.c index a9a8e8bef..af5974225 100644 --- a/tests/dispatch_group.c +++ b/tests/dispatch_group.c @@ -19,7 +19,9 @@ */ #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include #include diff --git a/tests/dispatch_io.c b/tests/dispatch_io.c index a29cb5628..12870ced2 100644 --- a/tests/dispatch_io.c +++ b/tests/dispatch_io.c @@ -25,7 +25,9 @@ #include #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include #ifdef __APPLE__ diff --git a/tests/dispatch_io_net.c b/tests/dispatch_io_net.c index fd680aef1..eaa84b824 100644 --- a/tests/dispatch_io_net.c +++ b/tests/dispatch_io_net.c @@ -20,7 +20,9 @@ #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include #include diff --git a/tests/dispatch_overcommit.c b/tests/dispatch_overcommit.c index c103c68c1..4c187411d 100644 --- a/tests/dispatch_overcommit.c +++ b/tests/dispatch_overcommit.c @@ -25,7 +25,9 @@ #include #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include #ifdef __APPLE__ diff --git a/tests/dispatch_priority.c b/tests/dispatch_priority.c index a2eb954e9..c500e8771 100644 --- a/tests/dispatch_priority.c +++ b/tests/dispatch_priority.c @@ -21,7 +21,9 @@ #include #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include #ifdef __APPLE__ diff --git a/tests/dispatch_proc.c b/tests/dispatch_proc.c index 6c3b70167..0c0a18d0c 100644 --- a/tests/dispatch_proc.c +++ b/tests/dispatch_proc.c @@ -20,7 +20,9 @@ #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include #include diff --git a/tests/dispatch_queue_finalizer.c b/tests/dispatch_queue_finalizer.c index e70df4368..acd2275ff 100644 --- a/tests/dispatch_queue_finalizer.c +++ b/tests/dispatch_queue_finalizer.c @@ -19,7 +19,9 @@ */ #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include #include diff --git a/tests/dispatch_read.c b/tests/dispatch_read.c index 9c09a06bb..3e938fd7e 100644 --- a/tests/dispatch_read.c +++ b/tests/dispatch_read.c @@ -24,7 +24,9 @@ #include #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include diff --git a/tests/dispatch_read2.c b/tests/dispatch_read2.c index 398aa2cd8..13021e91c 100644 --- a/tests/dispatch_read2.c +++ b/tests/dispatch_read2.c @@ -25,7 +25,9 @@ #include #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include #ifdef __APPLE__ diff --git a/tests/dispatch_readsync.c b/tests/dispatch_readsync.c index f01d982eb..293387a8b 100644 --- a/tests/dispatch_readsync.c +++ b/tests/dispatch_readsync.c @@ -21,7 +21,9 @@ #include #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #ifdef __ANDROID__ #include #else diff --git a/tests/dispatch_select.c b/tests/dispatch_select.c index 2ec1c891a..d66372213 100644 --- a/tests/dispatch_select.c +++ b/tests/dispatch_select.c @@ -21,7 +21,9 @@ #include #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include diff --git a/tests/dispatch_sema.c b/tests/dispatch_sema.c index f42847209..7195ef77b 100644 --- a/tests/dispatch_sema.c +++ b/tests/dispatch_sema.c @@ -19,7 +19,9 @@ */ #include +#if !USE_WIN32_SEM #include +#endif #include #include diff --git a/tests/dispatch_sync_on_main.c b/tests/dispatch_sync_on_main.c index 227120c72..10761471f 100644 --- a/tests/dispatch_sync_on_main.c +++ b/tests/dispatch_sync_on_main.c @@ -22,7 +22,9 @@ #include #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include #include diff --git a/tests/dispatch_test.c b/tests/dispatch_test.c index ea581945b..8beda903c 100644 --- a/tests/dispatch_test.c +++ b/tests/dispatch_test.c @@ -27,7 +27,9 @@ #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #if __has_include() #define HAS_SYS_EVENT_H 1 #include diff --git a/tests/dispatch_vm.c b/tests/dispatch_vm.c index 68774111d..e4617ba7f 100644 --- a/tests/dispatch_vm.c +++ b/tests/dispatch_vm.c @@ -21,7 +21,9 @@ #include #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #ifdef __APPLE__ #include #endif diff --git a/tests/dispatch_vnode.c b/tests/dispatch_vnode.c index 45cae7240..b97ab75d3 100644 --- a/tests/dispatch_vnode.c +++ b/tests/dispatch_vnode.c @@ -21,7 +21,9 @@ #include #include #include +#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include +#endif #include