Skip to content

Commit f9e3e91

Browse files
compnerdktopley-apple
authored andcommitted
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. Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
1 parent 7a36b92 commit f9e3e91

File tree

6 files changed

+5
-7
lines changed

6 files changed

+5
-7
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ check_include_files("strings.h" HAVE_STRINGS_H)
221221
check_include_files("sys/guarded.h" HAVE_SYS_GUARDED_H)
222222
check_include_files("sys/stat.h" HAVE_SYS_STAT_H)
223223
check_include_files("sys/types.h" HAVE_SYS_TYPES_H)
224-
check_include_files("unistd.h" HAVE_UNISTD_H)
225224
check_include_files("objc/objc-internal.h" HAVE_OBJC)
226225

227226
if(HAVE_MACH)

cmake/config.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,6 @@
192192
/* Define to 1 if you have the <TargetConditionals.h> header file. */
193193
#cmakedefine HAVE_TARGETCONDITIONALS_H
194194

195-
/* Define to 1 if you have the <unistd.h> header file. */
196-
#cmakedefine01 HAVE_UNISTD_H
197-
198195
/* Define to 1 if you have the `_pthread_workqueue_init' function. */
199196
#cmakedefine HAVE__PTHREAD_WORKQUEUE_INIT
200197

dispatch/dispatch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include <stdint.h>
3636
#include <stdbool.h>
3737
#include <stdarg.h>
38-
#if !defined(HAVE_UNISTD_H) || HAVE_UNISTD_H
38+
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
3939
#include <unistd.h>
4040
#endif
4141
#include <fcntl.h>

private/private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#include <mach/mach.h>
4242
#include <mach/message.h>
4343
#endif
44-
#if HAVE_UNISTD_H
44+
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
4545
#include <unistd.h>
4646
#endif
4747
#include <pthread.h>

src/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ DISPATCH_EXPORT DISPATCH_NOTHROW void dispatch_atfork_child(void);
285285
#include <stdio.h>
286286
#include <stdlib.h>
287287
#include <string.h>
288-
#if HAVE_UNISTD_H
288+
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
289289
#include <unistd.h>
290290
#endif
291291

src/queue.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,9 @@ libdispatch_init(void)
903903
}
904904

905905
#if DISPATCH_USE_THREAD_LOCAL_STORAGE
906+
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
906907
#include <unistd.h>
908+
#endif
907909
#include <sys/syscall.h>
908910

909911
#ifndef __ANDROID__

0 commit comments

Comments
 (0)