Skip to content

Commit c1107b0

Browse files
libdispatch-1008.200.78
Imported from libdispatch-1008.200.78.tar.gz
1 parent 96dcfca commit c1107b0

File tree

109 files changed

+16743
-11747
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+16743
-11747
lines changed

CMakeLists.txt

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,40 @@ include(GNUInstallDirs)
2525
set(WITH_BLOCKS_RUNTIME "" CACHE PATH "Path to blocks runtime")
2626

2727
include(DispatchAppleOptions)
28+
include(DispatchSanitization)
29+
30+
include(DispatchCompilerWarnings)
31+
dispatch_common_warnings()
2832

2933
option(ENABLE_DISPATCH_INIT_CONSTRUCTOR "enable libdispatch_init as a constructor" ON)
3034
set(USE_LIBDISPATCH_INIT_CONSTRUCTOR ${ENABLE_DISPATCH_INIT_CONSTRUCTOR})
3135

32-
# TODO(compnerd) swift options
36+
option(ENABLE_SWIFT "enable libdispatch swift overlay" OFF)
37+
if(ENABLE_SWIFT)
38+
if(NOT CMAKE_SWIFT_COMPILER)
39+
message(FATAL_ERROR "CMAKE_SWIFT_COMPILER must be defined to enable swift")
40+
endif()
41+
42+
get_filename_component(SWIFT_TOOLCHAIN ${CMAKE_SWIFT_COMPILER} DIRECTORY)
43+
get_filename_component(SWIFT_TOOLCHAIN ${SWIFT_TOOLCHAIN} DIRECTORY)
44+
45+
string(TOLOWER ${CMAKE_SYSTEM_NAME} SWIFT_OS)
46+
set(SWIFT_RUNTIME_LIBDIR ${SWIFT_TOOLCHAIN}/lib/swift/${SWIFT_OS}/${CMAKE_SYSTEM_PROCESSOR})
47+
48+
add_library(swiftCore
49+
SHARED IMPORTED GLOBAL)
50+
set_target_properties(swiftCore
51+
PROPERTIES
52+
IMPORTED_LOCATION
53+
${SWIFT_RUNTIME_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}swiftCore${CMAKE_SHARED_LIBRARY_SUFFIX})
54+
55+
add_library(swiftSwiftOnoneSupport
56+
SHARED IMPORTED GLOBAL)
57+
set_target_properties(swiftSwiftOnoneSupport
58+
PROPERTIES
59+
IMPORTED_LOCATION
60+
${SWIFT_RUNTIME_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}swiftSwiftOnoneSupport${CMAKE_SHARED_LIBRARY_SUFFIX})
61+
endif()
3362

3463
option(BUILD_SHARED_LIBS "build shared libraries" ON)
3564

@@ -59,8 +88,7 @@ if(ENABLE_INTERNAL_PTHREAD_WORKQUEUES)
5988
set(HAVE_PTHREAD_WORKQUEUES 0)
6089
else()
6190
check_include_files(pthread/workqueue_private.h HAVE_PTHREAD_WORKQUEUE_PRIVATE_H)
62-
check_include_files(pthread_workqueue.h HAVE_PTHREAD_WORKQUEUE_H)
63-
if(HAVE_PTHREAD_WORKQUEUE_PRIVATE_H AND HAVE_PTHREAD_WORKQUEUE_H)
91+
if(HAVE_PTHREAD_WORKQUEUE_PRIVATE_H)
6492
set(HAVE_PTHREAD_WORKQUEUES 1)
6593
set(DISPATCH_USE_INTERNAL_WORKQUEUE 0)
6694
else()
@@ -111,7 +139,6 @@ check_function_exists(mach_port_construct HAVE_MACH_PORT_CONSTRUCT)
111139
check_function_exists(malloc_create_zone HAVE_MALLOC_CREATE_ZONE)
112140
check_function_exists(pthread_key_init_np HAVE_PTHREAD_KEY_INIT_NP)
113141
check_function_exists(pthread_main_np HAVE_PTHREAD_MAIN_NP)
114-
check_function_exists(pthread_workqueue_setdispatch_np HAVE_PTHREAD_WORKQUEUE_SETDISPATCH_NP)
115142
check_function_exists(strlcpy HAVE_STRLCPY)
116143
check_function_exists(sysconf HAVE_SYSCONF)
117144

@@ -152,7 +179,6 @@ check_include_files("stdint.h" HAVE_STDINT_H)
152179
check_include_files("stdlib.h" HAVE_STDLIB_H)
153180
check_include_files("string.h" HAVE_STRING_H)
154181
check_include_files("strings.h" HAVE_STRINGS_H)
155-
check_include_files("sys/cdefs.h" HAVE_SYS_CDEFS_H)
156182
check_include_files("sys/guarded.h" HAVE_SYS_GUARDED_H)
157183
check_include_files("sys/stat.h" HAVE_SYS_STAT_H)
158184
check_include_files("sys/types.h" HAVE_SYS_TYPES_H)
@@ -198,21 +224,19 @@ if(leaks_EXECUTABLE)
198224
endif()
199225

200226
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
201-
add_custom_command(OUTPUT
202-
"${CMAKE_SOURCE_DIR}/dispatch/module.modulemap"
203-
"${CMAKE_SOURCE_DIR}/private/module.modulemap"
204-
COMMAND
205-
${CMAKE_COMMAND} -E create_symlink "${CMAKE_SOURCE_DIR}/darwin/module.modulemap" "${CMAKE_SOURCE_DIR}/dispatch/module.modulemap"
206-
COMMAND
207-
${CMAKE_COMMAND} -E create_symlink "${CMAKE_SOURCE_DIR}/darwin/module.modulemap" "${CMAKE_SOURCE_DIR}/private/module.modulemap")
227+
add_custom_target(module-map-symlinks
228+
ALL
229+
COMMAND
230+
${CMAKE_COMMAND} -E create_symlink "${CMAKE_SOURCE_DIR}/dispatch/darwin/module.modulemap" "${CMAKE_SOURCE_DIR}/dispatch/module.modulemap"
231+
COMMAND
232+
${CMAKE_COMMAND} -E create_symlink "${CMAKE_SOURCE_DIR}/private/darwin/module.modulemap" "${CMAKE_SOURCE_DIR}/private/module.modulemap")
208233
else()
209-
add_custom_command(OUTPUT
210-
"${CMAKE_SOURCE_DIR}/dispatch/module.modulemap"
211-
"${CMAKE_SOURCE_DIR}/private/module.modulemap"
212-
COMMAND
213-
${CMAKE_COMMAND} -E create_symlink "${CMAKE_SOURCE_DIR}/generic/module.modulemap" "${CMAKE_SOURCE_DIR}/dispatch/module.modulemap"
214-
COMMAND
215-
${CMAKE_COMMAND} -E create_symlink "${CMAKE_SOURCE_DIR}/generic/module.modulemap" "${CMAKE_SOURCE_DIR}/private/module.modulemap")
234+
add_custom_target(module-map-symlinks
235+
ALL
236+
COMMAND
237+
${CMAKE_COMMAND} -E create_symlink "${CMAKE_SOURCE_DIR}/dispatch/generic/module.modulemap" "${CMAKE_SOURCE_DIR}/dispatch/module.modulemap"
238+
COMMAND
239+
${CMAKE_COMMAND} -E create_symlink "${CMAKE_SOURCE_DIR}/private/generic/module.modulemap" "${CMAKE_SOURCE_DIR}/private/module.modulemap")
216240
endif()
217241
configure_file("${CMAKE_SOURCE_DIR}/cmake/config.h.in"
218242
"${CMAKE_BINARY_DIR}/config/config_ac.h")

INSTALL.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,21 @@ libdispatch for /usr/lib/system on OS X El Capitan:
129129
Typical configuration line for FreeBSD 8.x and 9.x to build libdispatch with
130130
clang and blocks support:
131131
132-
sh autogen.sh
133-
./configure CC=clang --with-blocks-runtime=/usr/local/lib
134-
make check
132+
```
133+
cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DWITH_BLOCKS_RUNTIME=/usr/local/lib <path-to-source>
134+
ninja
135+
ninja test
136+
```
137+
138+
### Building for android
139+
140+
Note that this assumes that you are building on Linux. It requires that you
141+
have the android NDK available. It has been tested against API Level 21.
142+
143+
```
144+
cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=21 -DCMAKE_ANDROID_NDK=<path to android NDK> <path-to-source>
145+
ninja
146+
```
135147
136148
### Building and installing for Linux
137149
@@ -140,19 +152,19 @@ on Ubuntu; currently supported versions are 14.04, 15.10 and 16.04.
140152
141153
1. The first thing to do is install required packages:
142154
143-
`sudo apt-get install autoconf libtool pkg-config clang systemtap-sdt-dev libbsd-dev linux-libc-dev`
155+
`sudo apt-get install cmake ninja-build clang systemtap-sdt-dev libbsd-dev linux-libc-dev`
144156
145157
Note: compiling libdispatch requires clang 3.8 or better and
146158
the gold linker. If the default clang on your Ubuntu version is
147159
too old, see http://apt.llvm.org/ to install a newer version.
148160
On older Ubuntu releases, you may need to install binutils-gold
149161
to get the gold linker.
150162
151-
2. Build (as in the general instructions above)
163+
2. Build
152164
153165
```
154-
sh autogen.sh
155-
./configure
156-
make
157-
make install
166+
cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ <path-to-source>
167+
ninja
168+
ninja install
158169
```
170+

PATCHES

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,3 +353,24 @@ github commits starting with 29bdc2f from
353353
[8947dcf] APPLIED rdar://33531111
354354
[5ad9208] APPLIED rdar://33531111
355355
[698d085] APPLIED rdar://33531111
356+
[ce1ce45] APPLIED rdar://35017478
357+
[291f34d] APPLIED rdar://35017478
358+
[666df60] APPLIED rdar://35017478
359+
[80dd736] APPLIED rdar://35017478
360+
[0fd5a69] APPLIED rdar://35017478
361+
[0e35ed9] APPLIED rdar://35017478
362+
[70ce56b] APPLIED rdar://35017478
363+
[40fc1f3] APPLIED rdar://35017478
364+
[9ec74ed] APPLIED rdar://35017478
365+
[7f330ed] APPLIED rdar://35017478
366+
[947b51c] APPLIED rdar://35017478
367+
[295f676] APPLIED rdar://35017478
368+
[48196a2] APPLIED rdar://35017478
369+
[a28fc2b] APPLIED rdar://35017478
370+
[791ce5d] APPLIED rdar://35017478
371+
[0d0a998] APPLIED rdar://35017478
372+
[29329b5] APPLIED rdar://35017478
373+
[141403a] APPLIED rdar://35017478
374+
[b7f1beb] APPLIED rdar://35017478
375+
[7ef9cde] APPLIED rdar://35017478
376+
[12c9ca8] APPLIED rdar://35017478

cmake/config.h.in

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,6 @@
152152
/* Define to 1 if you have the <pthread/workqueue_private.h> header file. */
153153
#cmakedefine HAVE_PTHREAD_WORKQUEUE_PRIVATE_H
154154

155-
/* Define to 1 if you have the `pthread_workqueue_setdispatch_np' function. */
156-
#cmakedefine HAVE_PTHREAD_WORKQUEUE_SETDISPATCH_NP
157-
158155
/* Define to 1 if you have the <stdint.h> header file. */
159156
#cmakedefine01 HAVE_STDINT_H
160157

@@ -176,9 +173,6 @@
176173
/* Define to 1 if you have the `sysconf' function. */
177174
#cmakedefine01 HAVE_SYSCONF
178175

179-
/* Define to 1 if you have the <sys/cdefs.h> header file. */
180-
#cmakedefine01 HAVE_SYS_CDEFS_H
181-
182176
/* Define to 1 if you have the <sys/guarded.h> header file. */
183177
#cmakedefine HAVE_SYS_GUARDED_H
184178

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
2+
if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
3+
# TODO: someone needs to provide the msvc equivalent warning flags
4+
macro(dispatch_common_warnings)
5+
endmacro()
6+
else()
7+
macro(dispatch_common_warnings)
8+
add_compile_options(-Werror)
9+
add_compile_options(-Wall)
10+
add_compile_options(-Wextra)
11+
add_compile_options(-Wmissing-prototypes)
12+
add_compile_options(-Wdocumentation)
13+
add_compile_options(-Wunreachable-code)
14+
add_compile_options(-Wshadow)
15+
add_compile_options(-Wconversion)
16+
add_compile_options(-Wconstant-conversion)
17+
add_compile_options(-Wint-conversion)
18+
add_compile_options(-Wbool-conversion)
19+
add_compile_options(-Wenum-conversion)
20+
add_compile_options(-Wassign-enum)
21+
add_compile_options(-Wshorten-64-to-32)
22+
add_compile_options(-Wnewline-eof)
23+
add_compile_options(-Wdeprecated-declarations)
24+
add_compile_options(-Wsign-conversion)
25+
add_compile_options(-Winfinite-recursion)
26+
add_compile_options(-Warray-bounds-pointer-arithmetic)
27+
add_compile_options(-Watomic-properties)
28+
add_compile_options(-Wcomma)
29+
add_compile_options(-Wconditional-uninitialized)
30+
add_compile_options(-Wcovered-switch-default)
31+
add_compile_options(-Wdate-time)
32+
add_compile_options(-Wdeprecated)
33+
add_compile_options(-Wdouble-promotion)
34+
add_compile_options(-Wduplicate-enum)
35+
add_compile_options(-Wexpansion-to-defined)
36+
add_compile_options(-Wfloat-equal)
37+
add_compile_options(-Widiomatic-parentheses)
38+
add_compile_options(-Wnullable-to-nonnull-conversion)
39+
add_compile_options(-Wobjc-interface-ivars)
40+
add_compile_options(-Wover-aligned)
41+
add_compile_options(-Wpacked)
42+
add_compile_options(-Wpointer-arith)
43+
add_compile_options(-Wselector)
44+
add_compile_options(-Wstatic-in-inline)
45+
add_compile_options(-Wsuper-class-method-mismatch)
46+
add_compile_options(-Wswitch-enum)
47+
add_compile_options(-Wunguarded-availability)
48+
add_compile_options(-Wunused)
49+
50+
add_compile_options(-Wno-unknown-warning-option)
51+
add_compile_options(-Wno-trigraphs)
52+
add_compile_options(-Wno-four-char-constants)
53+
add_compile_options(-Wno-disabled-macro-expansion)
54+
add_compile_options(-Wno-pedantic)
55+
add_compile_options(-Wno-bad-function-cast)
56+
add_compile_options(-Wno-c++-compat)
57+
add_compile_options(-Wno-c++98-compat)
58+
add_compile_options(-Wno-c++98-compat-pedantic)
59+
add_compile_options(-Wno-cast-align)
60+
add_compile_options(-Wno-cast-qual)
61+
add_compile_options(-Wno-documentation-unknown-command)
62+
add_compile_options(-Wno-format-nonliteral)
63+
add_compile_options(-Wno-missing-variable-declarations)
64+
add_compile_options(-Wno-old-style-cast)
65+
add_compile_options(-Wno-padded)
66+
add_compile_options(-Wno-reserved-id-macro)
67+
add_compile_options(-Wno-shift-sign-overflow)
68+
add_compile_options(-Wno-undef)
69+
add_compile_options(-Wno-unreachable-code-aggressive)
70+
add_compile_options(-Wno-unused-macros)
71+
add_compile_options(-Wno-used-but-marked-unused)
72+
add_compile_options(-Wno-vla)
73+
endmacro()
74+
endif()
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
set(DISPATCH_USE_SANITIZER "" CACHE STRING
3+
"Define the sanitizer used to build binaries and tests.")
4+
5+
if(CMAKE_SYSTEM_NAME STREQUAL Darwin AND DISPATCH_USE_SANITIZER)
6+
message(FATAL_ERROR "building libdispatch with sanitization is not supported on Darwin")
7+
endif()
8+
9+
if(DISPATCH_USE_SANITIZER)
10+
# TODO(compnerd) ensure that the compiler supports these options before adding
11+
# them. At the moment, assume that this will just be used with a GNU
12+
# compatible driver and that the options are spelt correctly in light of that.
13+
add_compile_options("-fno-omit-frame-pointer")
14+
if(CMAKE_BUILD_TYPE MATCHES "Debug")
15+
add_compile_options("-O1")
16+
elseif(NOT CMAKE_BUILD_TYPE MATCHES "Debug" AND
17+
NOT CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
18+
add_compile_options("-gline-tables-only")
19+
endif()
20+
21+
if(LLVM_USE_SANITIZER STREQUAL "Address")
22+
add_compile_options("-fsanitize=address")
23+
elseif(DISPATCH_USE_SANITIZER MATCHES "Memory(WithOrigins)?")
24+
add_compile_options("-fsanitize=memory")
25+
if(DISPATCH_USE_SANITIZER STREQUAL "MemoryWithOrigins")
26+
add_compile_options("-fsanitize-memory-track-origins")
27+
endif()
28+
elseif(DISPATCH_USE_SANITIZER STREQUAL "Undefined")
29+
add_compile_options("-fsanitize=undefined")
30+
add_compile_options("-fno-sanitize=vptr,function")
31+
add_compile_options("-fno-sanitize-recover=all")
32+
elseif(DISPATCH_USE_SANITIZER STREQUAL "Thread")
33+
add_compile_options("-fsanitize=thread")
34+
elseif(DISPATCH_USE_SANITIZER STREQUAL "Address;Undefined" OR
35+
DISPATCH_USE_SANITIZER STREQUAL "Undefined;Address")
36+
add_compile_options("-fsanitize=address,undefined")
37+
add_compile_options("-fno-sanitize=vptr,function")
38+
add_compile_options("-fno-sanitize-recover=all")
39+
elseif(DISPATCH_USE_SANITIZER STREQUAL "Leaks")
40+
add_compile_options("-fsanitize=leak")
41+
else()
42+
message(FATAL_ERROR "unsupported value of DISPATCH_USE_SANITIZER: ${DISPATCH_USE_SANITIZER}")
43+
endif()
44+
endif()

cmake/modules/SwiftSupport.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ function(add_swift_library library)
5757
${module_directory}/${ASL_MODULE_NAME}.swiftdoc
5858
DEPENDS
5959
${ASL_SOURCES}
60+
${CMAKE_SWIFT_COMPILER}
6061
COMMAND
6162
${CMAKE_COMMAND} -E make_directory ${module_directory}
6263
COMMAND

config/config.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@
106106
/* Define to 1 if you have the `mach_approximate_time' function. */
107107
#define HAVE_MACH_APPROXIMATE_TIME 1
108108

109-
/* Define to 1 if you have the `mach_port_construct' function. */
110-
#define HAVE_MACH_PORT_CONSTRUCT 1
111-
112109
/* Define to 1 if you have the `malloc_create_zone' function. */
113110
#define HAVE_MALLOC_CREATE_ZONE 1
114111

@@ -148,9 +145,6 @@
148145
/* Define to 1 if you have the <pthread/workqueue_private.h> header file. */
149146
#define HAVE_PTHREAD_WORKQUEUE_PRIVATE_H 1
150147

151-
/* Define to 1 if you have the `pthread_workqueue_setdispatch_np' function. */
152-
#define HAVE_PTHREAD_WORKQUEUE_SETDISPATCH_NP 1
153-
154148
/* Define to 1 if you have the <stdint.h> header file. */
155149
#define HAVE_STDINT_H 1
156150

configure.ac

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ AC_ARG_WITH([swift-toolchain],
190190
armv7l*)
191191
target_cpu="armv7"
192192
;;
193+
armv6l*)
194+
target_cpu="armv6"
195+
;;
193196
*)
194197
esac
195198
;;

dispatch/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ install(FILES
1414
source.h
1515
time.h
1616
DESTINATION
17-
${CMAKE_INSTALL_FULL_INCLUDEDIR}/dispatch/)
17+
${CMAKE_INSTALL_FULL_INCLUDEDIR}/dispatch)
1818
if(ENABLE_SWIFT)
19+
get_filename_component(MODULE_MAP module.modulemap REALPATH)
1920
install(FILES
20-
module.modulemap
21+
${MODULE_MAP}
2122
DESTINATION
22-
${CMAKE_INSTALL_FULL_INCLUEDIR}/dispatch/)
23+
${CMAKE_INSTALL_FULL_INCLUDEDIR}/dispatch)
2324
endif()
2425

dispatch/base.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,20 @@
120120
#endif
121121
#endif
122122

123-
#if TARGET_OS_WIN32 && defined(__DISPATCH_BUILDING_DISPATCH__) && \
124-
defined(__cplusplus)
123+
#if TARGET_OS_WIN32
124+
#ifdef __cplusplus
125+
#ifdef __DISPATCH_BUILDING_DISPATCH__
125126
#define DISPATCH_EXPORT extern "C" extern __declspec(dllexport)
126-
#elif TARGET_OS_WIN32 && defined(__DISPATCH_BUILDING_DISPATCH__)
127+
#else
127128
#define DISPATCH_EXPORT extern __declspec(dllexport)
128-
#elif TARGET_OS_WIN32 && defined(__cplusplus)
129+
#endif // __DISPATCH_BUILDING_DISPATCH__
130+
#else // __cplusplus
131+
#ifdef __DISPATCH_BUILDING_DISPATCH__
129132
#define DISPATCH_EXPORT extern "C" extern __declspec(dllimport)
130-
#elif TARGET_OS_WIN32
133+
#else
131134
#define DISPATCH_EXPORT extern __declspec(dllimport)
135+
#endif // __DISPATCH_BUILDING_DISPATCH__
136+
#endif // __cplusplus
132137
#elif __GNUC__
133138
#define DISPATCH_EXPORT extern __attribute__((visibility("default")))
134139
#else

0 commit comments

Comments
 (0)