Skip to content

Commit 17b7382

Browse files
dgrove-ossdas
authored andcommitted
avoid requiring __DISPATCH_BUILDING_SWIFT_MODULE__ macro on Linux
Instead of using a special macro, check for __has_feature(modules) to activate including stdio.h in dispatch.h on Linux. Also, fix one place where OS_OBJECT_SWIFT_3 was used outside of an OS_OBJECT_USE_OBJC block (to prepare for SWIFT_SDK_OVERLAY_DISPATCH_EPOCH being defined by the clang importer on non-Darwin platforms). Signed-off-by: Daniel A. Steffen <[email protected]>
1 parent c40d554 commit 17b7382

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

dispatch/dispatch.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
#include <fcntl.h>
4949

5050
#ifdef __linux__
51-
#ifdef __DISPATCH_BUILDING_SWIFT_MODULE__
52-
#include <stdio.h> // for off_t
51+
#if __has_feature(modules)
52+
#include <stdio.h> // for off_t (to match Glibc.modulemap)
5353
#endif
5454
#endif
5555

dispatch/object.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ typedef union {
108108
#define DISPATCH_RETURNS_RETAINED
109109
#endif
110110

111-
#if OS_OBJECT_SWIFT3
111+
#if OS_OBJECT_SWIFT3 && OS_OBJECT_USE_OBJC
112112
#define DISPATCH_SOURCE_TYPE_DECL(name) \
113113
DISPATCH_EXPORT struct dispatch_source_type_s \
114114
_dispatch_source_type_##name; \

src/Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ SWIFT_GEN_FILES= \
149149
$(SWIFT_OBJ_FILES:%=%.~partial.swiftdoc) \
150150
$(SWIFT_OBJ_FILES:%=%.~partial.swiftdeps)
151151

152-
SWIFTC_FLAGS = -Xcc -D__DISPATCH_BUILDING_SWIFT_MODULE__=1 -Xcc -fmodule-map-file=$(abs_top_srcdir)/dispatch/module.modulemap -I$(abs_top_srcdir) -Xcc -fblocks
152+
SWIFTC_FLAGS = -Xcc -fmodule-map-file=$(abs_top_srcdir)/dispatch/module.modulemap -I$(abs_top_srcdir) -Xcc -fblocks
153153

154154
$(abs_builddir)/swift/%.o: $(abs_srcdir)/swift/%.swift
155155
$(SWIFTC) -frontend -c $(SWIFT_ABS_SRC_FILES) -primary-file $< \

0 commit comments

Comments
 (0)