From 50e10035d3221f220feb4674319665e28d2fe915 Mon Sep 17 00:00:00 2001 From: "Daniel A. Steffen" Date: Tue, 1 Dec 2015 07:55:03 -0800 Subject: [PATCH 1/2] Update autotools buildsystem for libdispatch-500.1.5 and testsuite --- INSTALL | 41 ++++++++++++--------- Makefile.am | 4 ++- README.md | 2 +- config/config.h | 65 +++++++++++++++++++--------------- configure.ac | 84 ++++++++++++++++++++++++++++++-------------- dispatch/Makefile.am | 1 + private/Makefile.am | 5 ++- src/Makefile.am | 50 ++++++++++++++++++-------- tests/Makefile.am | 26 +++++++------- 9 files changed, 175 insertions(+), 103 deletions(-) diff --git a/INSTALL b/INSTALL index faf66d231..86ebc6abb 100644 --- a/INSTALL +++ b/INSTALL @@ -20,10 +20,15 @@ An uncustomized install requires: The following configure options may be of general interest: ---with-apple-libc-source +--with-apple-libpthread-source - Specify the path to Apple's Libc package, so that appropriate headers can - be found and used. + Specify the path to Apple's libpthread package, so that appropriate headers + can be found and used. + +--with-apple-libplatform-source + + Specify the path to Apple's libplatform package, so that appropriate headers + can be found and used. --with-apple-libclosure-source @@ -38,12 +43,12 @@ The following configure options may be of general interest: --with-blocks-runtime On systems where -fblocks is supported, specify an additional library path - in which libBlocksRuntime can be found. This is not required on Mac OS X, + in which libBlocksRuntime can be found. This is not required on OS X, where the Blocks runtime is included in libSystem, but is required on FreeBSD. The following options are likely to only be useful when building libdispatch on -Mac OS X as a replacement for /usr/lib/system/libdispatch.dylib: +OS X as a replacement for /usr/lib/system/libdispatch.dylib: --with-apple-objc4-source @@ -59,31 +64,33 @@ Mac OS X as a replacement for /usr/lib/system/libdispatch.dylib: Do not tag libdispatch's init routine as __constructor, in which case it must be run manually before libdispatch routines can be called. This is the - default when building on Mac OS X. For /usr/lib/system/libdispatch.dylib + default when building on OS X. For /usr/lib/system/libdispatch.dylib the init routine is called automatically during process start. --enable-apple-tsd-optimizations Use a non-portable allocation scheme for pthread per-thread data (TSD) keys - when building libdispatch for /usr/lib/system on Mac OS X. This should not - be used on other OS's, or on Mac OS X when building a stand-alone library. + when building libdispatch for /usr/lib/system on OS X. This should not + be used on other OS's, or on OS X when building a stand-alone library. Typical configuration commands The following command lines create the configuration required to build -libdispatch for /usr/lib/system on OS X MountainLion: +libdispatch for /usr/lib/system on OS X El Capitan: - sh autogen.sh + clangpath=$(dirname `xcrun --find clang`) + sudo mkdir -p "$clangpath/../local/lib/clang/enable_objc_gc" + LIBTOOLIZE=glibtoolize sh autogen.sh cflags='-arch x86_64 -arch i386 -g -Os' ./configure CFLAGS="$cflags" OBJCFLAGS="$cflags" CXXFLAGS="$cflags" \ - --prefix=/usr --libdir=/usr/lib/system \ - --disable-dependency-tracking --disable-static \ + --prefix=/usr --libdir=/usr/lib/system --disable-static \ --enable-apple-tsd-optimizations \ - --with-apple-libc-source=/path/to/10.8.0/Libc-825.24 \ - --with-apple-libclosure-source=/path/to/10.8.0/libclosure-59 \ - --with-apple-xnu-source=/path/to/10.8.0/xnu-2050.7.9 \ - --with-apple-objc4-source=/path/to/10.8.0/objc4-532 \ - --with-apple-libauto-source=/path/to/10.8.0/libauto-185.1 + --with-apple-libpthread-source=/path/to/10.11.0/libpthread-137.1.1 \ + --with-apple-libplatform-source=/path/to/10.11.0/libplatform-73.1.1 \ + --with-apple-libclosure-source=/path/to/10.11.0/libclosure-65 \ + --with-apple-xnu-source=/path/to/10.11.0/xnu-3247.1.106 \ + --with-apple-objc4-source=/path/to/10.11.0/objc4-680 \ + --with-apple-libauto-source=/path/to/10.11.0/libauto-186 make check Typical configuration line for FreeBSD 8.x and 9.x to build libdispatch with diff --git a/Makefile.am b/Makefile.am index 72f432242..944387474 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,9 +9,11 @@ SUBDIRS= \ man \ os \ private \ - src + src \ + tests EXTRA_DIST= \ + README.md \ LICENSE \ PATCHES \ autogen.sh \ diff --git a/README.md b/README.md index 1cbae0348..d65a13cbd 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ libdispatch on Darwin is a combination of logic in the `xnu` kernel alongside th Our first tasks for this project are: -0. Develop a makefile or other build script for the project on Linux. The current build system is focused on Darwin. +0. Adapt the current autotools build system to work on Linux, or develop a new makefile or other build script for the project on Linux. The current version of the build system has only been tested on Darwin, though previous versions have been made to work on FreeBSD and Linux (see INSTALL). 0. Omit as much of the extra functionality of the library as possible, to get a core version of the project building. Much of the OS X-specific functionality can be elided completely on Linux. 0. Adopt libdispatch in other Core Libraries projects, especially Foundation. This will validate our work and get immediate coverage on basic functionality. 0. Incrementally add functionality back in. diff --git a/config/config.h b/config/config.h index 894428199..f96d70a67 100644 --- a/config/config.h +++ b/config/config.h @@ -102,17 +102,20 @@ /* Define to 1 if you have the header file. */ /* #undef HAVE_PTHREAD_NP_H */ +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_QOS_H 1 + /* Define if pthread work queues are present */ #define HAVE_PTHREAD_WORKQUEUES 1 -/* Define to 1 if you have the `pthread_workqueue_setdispatch_np' function. */ -#define HAVE_PTHREAD_WORKQUEUE_SETDISPATCH_NP 1 +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_WORKQUEUE_H 1 -/* Define to 1 if you have the `_pthread_workqueue_init' function. */ -#define HAVE__PTHREAD_WORKQUEUE_INIT 1 +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_WORKQUEUE_PRIVATE_H 1 -/* Define to 1 if you have the header file. */ -#define HAVE_PTHREAD_QOS_H 1 +/* Define to 1 if you have the `pthread_workqueue_setdispatch_np' function. */ +#define HAVE_PTHREAD_WORKQUEUE_SETDISPATCH_NP 1 /* Define to 1 if you have the header file. */ #define HAVE_STDINT_H 1 @@ -147,8 +150,10 @@ /* Define to 1 if you have the header file. */ #define HAVE_UNISTD_H 1 -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ +/* Define to 1 if you have the `_pthread_workqueue_init' function. */ +#define HAVE__PTHREAD_WORKQUEUE_INIT 1 + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ #define LT_OBJDIR ".libs/" /* Name of package */ @@ -161,13 +166,16 @@ #define PACKAGE_NAME "libdispatch" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "libdispatch 1.2" +#define PACKAGE_STRING "libdispatch 1.3" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "libdispatch" +/* Define to the home page for this package. */ +#define PACKAGE_URL "http://libdispatch.macosforge.org" + /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.2" +#define PACKAGE_VERSION "1.3" /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 @@ -184,20 +192,30 @@ /* Define to use POSIX semaphores */ /* #undef USE_POSIX_SEM */ -/* Version number of package */ -#define VERSION "1.2" - -/* Define to 1 if on AIX 3. - System headers sometimes define this. - We just want to avoid a redefinition error message. */ +/* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE -/* # undef _ALL_SOURCE */ +# define _ALL_SOURCE 1 #endif - /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 #endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Version number of package */ +#define VERSION "1.3" /* Define to 1 if on MINIX. */ /* #undef _MINIX */ @@ -211,14 +229,3 @@ /* Define if using Darwin $NOCANCEL */ #define __DARWIN_NON_CANCELABLE 1 - -/* Enable extensions on Solaris. */ -#ifndef __EXTENSIONS__ -# define __EXTENSIONS__ 1 -#endif -#ifndef _POSIX_PTHREAD_SEMANTICS -# define _POSIX_PTHREAD_SEMANTICS 1 -#endif -#ifndef _TANDEM_SOURCE -# define _TANDEM_SOURCE 1 -#endif diff --git a/configure.ac b/configure.ac index 223084c61..fc0664d33 100644 --- a/configure.ac +++ b/configure.ac @@ -2,8 +2,8 @@ # When this file changes, rerun autogen.sh. # -AC_PREREQ(2.59) -AC_INIT([libdispatch], [1.2], [libdispatch@macosforge.org], [libdispatch]) +AC_PREREQ(2.69) +AC_INIT([libdispatch], [1.3], [libdispatch@macosforge.org], [libdispatch], [http://libdispatch.macosforge.org]) AC_REVISION([$$]) AC_CONFIG_AUX_DIR(config) AC_CONFIG_HEADER([config/config.h]) @@ -14,32 +14,42 @@ AM_MAINTAINER_MODE AC_PROG_CC([clang gcc cc]) AC_PROG_CXX([clang++ g++ c++]) AC_PROG_OBJC([clang gcc cc]) +AC_PROG_OBJCXX([clang++ g++ c++]) # # On Mac OS X, some required header files come from other source packages; # allow specifying where those are. # -AC_ARG_WITH([apple-libc-source], - [AS_HELP_STRING([--with-apple-libc-source], - [Specify path to Apple Libc source])], [ - apple_libc_source_pthreads_path=${withval}/pthreads - CPPFLAGS="$CPPFLAGS -I$apple_libc_source_pthreads_path" +AC_ARG_WITH([apple-libpthread-source], + [AS_HELP_STRING([--with-apple-libpthread-source], + [Specify path to Apple libpthread source])], [ + apple_libpthread_source_path=${withval} + CPPFLAGS="$CPPFLAGS -isystem $apple_libpthread_source_path" +]) + +AC_ARG_WITH([apple-libplatform-source], + [AS_HELP_STRING([--with-apple-libplatform-source], + [Specify path to Apple libplatform source])], [ + apple_libplatform_source_include_path=${withval}/include + CPPFLAGS="$CPPFLAGS -isystem $apple_libplatform_source_include_path" ]) AC_ARG_WITH([apple-libclosure-source], [AS_HELP_STRING([--with-apple-libclosure-source], [Specify path to Apple libclosure source])], [ apple_libclosure_source_path=${withval} - CPPFLAGS="$CPPFLAGS -I$apple_libclosure_source_path" + CPPFLAGS="$CPPFLAGS -isystem $apple_libclosure_source_path" ]) AC_ARG_WITH([apple-xnu-source], [AS_HELP_STRING([--with-apple-xnu-source], [Specify path to Apple XNU source])], [ + apple_xnu_source_libsyscall_path=${withval}/libsyscall + apple_xnu_source_libproc_path=${withval}/libsyscall/wrappers/libproc apple_xnu_source_libkern_path=${withval}/libkern apple_xnu_source_bsd_path=${withval}/bsd apple_xnu_source_osfmk_path=${withval}/osfmk - CPPFLAGS="$CPPFLAGS -idirafter $apple_xnu_source_libkern_path -isystem $apple_xnu_source_bsd_path" + CPPFLAGS="$CPPFLAGS -idirafter $apple_xnu_source_libkern_path -isystem $apple_xnu_source_bsd_path -isystem $apple_xnu_source_libsyscall_path -isystem $apple_xnu_source_libproc_path " ]) AC_ARG_WITH([apple-objc4-source], @@ -52,7 +62,7 @@ AC_ARG_WITH([apple-libauto-source], [AS_HELP_STRING([--with-apple-libauto-source], [Specify path to Apple libauto source])], [ apple_libauto_source_path=${withval} - CPPFLAGS="$CPPFLAGS -I$apple_libauto_source_path" + CPPFLAGS="$CPPFLAGS -isystem $apple_libauto_source_path" ]) AC_CACHE_CHECK([for System.framework/PrivateHeaders], dispatch_cv_system_privateheaders, @@ -60,7 +70,7 @@ AC_CACHE_CHECK([for System.framework/PrivateHeaders], dispatch_cv_system_private [dispatch_cv_system_privateheaders=yes], [dispatch_cv_system_privateheaders=no])] ) AS_IF([test "x$dispatch_cv_system_privateheaders" != "xno"], - [CPPFLAGS="$CPPFLAGS -I/System/Library/Frameworks/System.framework/PrivateHeaders"] + [CPPFLAGS="$CPPFLAGS -isystem /System/Library/Frameworks/System.framework/PrivateHeaders"] ) # @@ -97,6 +107,12 @@ LT_INIT([disable-static]) AC_PROG_INSTALL AC_PATH_PROGS(MIG, mig) +AC_PATH_PROG(DTRACE, dtrace) +AS_IF([test "x$DTRACE" != "x"], [use_dtrace=true],[ + use_dtrace=false + CPPFLAGS="$CPPFLAGS -DDISPATCH_USE_DTRACE=0" +]) +AM_CONDITIONAL(USE_DTRACE, $use_dtrace) AC_PATH_PROG(LEAKS, leaks) AS_IF([test "x$LEAKS" != "x"], [AC_DEFINE(HAVE_LEAKS, 1, [Define if Apple leaks program is present])] @@ -128,21 +144,38 @@ AC_CHECK_HEADER(sys/event.h, [], # Checks for header files. # AC_HEADER_STDC -AC_CHECK_HEADERS([TargetConditionals.h pthread_np.h malloc/malloc.h libkern/OSCrossEndian.h libkern/OSAtomic.h sys/guarded.h libproc_internal.h]) +AC_CHECK_HEADERS([TargetConditionals.h pthread_np.h malloc/malloc.h libkern/OSCrossEndian.h libkern/OSAtomic.h sys/guarded.h fcntl.h]) -# hack for pthread_machdep.h's #include -AS_IF([test -n "$apple_xnu_source_osfmk_path"], [ +# hack for pthread/private headers +AS_IF([test -n "$apple_libpthread_source_path" -a -n "$apple_xnu_source_osfmk_path"], [ saveCPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS -I." + ln -fsh "$apple_libpthread_source_path"/private/tsd_private.h pthread_machdep.h + ln -fsh "$apple_libpthread_source_path"/private pthread ln -fsh "$apple_xnu_source_osfmk_path" System + mkdir -p mach && ln -fsh "$apple_xnu_source_osfmk_path"/mach/coalition.h mach ]) -AC_CHECK_HEADERS([pthread_machdep.h]) -AS_IF([test -n "$apple_xnu_source_osfmk_path"], [ - rm -f System +AC_CHECK_HEADERS([pthread_machdep.h pthread/qos.h]) +AC_CHECK_HEADERS([pthread/workqueue_private.h pthread_workqueue.h], + [AC_DEFINE(HAVE_PTHREAD_WORKQUEUES, 1, [Define if pthread work queues are present])] +) +AC_CHECK_HEADERS([libproc_internal.h], [], [], [#include ]) +AC_CHECK_FUNCS([pthread_workqueue_setdispatch_np _pthread_workqueue_init]) +AS_IF([test -n "$apple_libpthread_source_path" -a -n "$apple_xnu_source_osfmk_path"], [ + rm -f pthread_machdep.h pthread System mach/coalition.h CPPFLAGS="$saveCPPFLAGS" + AC_CONFIG_COMMANDS([src/pthread_machdep.h], + [ln -fsh "$apple_libpthread_source_path"/private/tsd_private.h src/pthread_machdep.h], + [apple_libpthread_source_path="$apple_libpthread_source_path"]) + AC_CONFIG_COMMANDS([src/pthread], + [ln -fsh "$apple_libpthread_source_path"/private src/pthread], + [apple_libpthread_source_path="$apple_libpthread_source_path"]) AC_CONFIG_COMMANDS([src/System], [ln -fsh "$apple_xnu_source_osfmk_path" src/System], [apple_xnu_source_osfmk_path="$apple_xnu_source_osfmk_path"]) + AC_CONFIG_COMMANDS([src/mach/coalition.h], + [ln -fsh "$apple_xnu_source_osfmk_path"/mach/coalition.h src/mach], + [apple_xnu_source_osfmk_path="$apple_xnu_source_osfmk_path"]) ]) # hack for xnu/bsd/sys/event.h EVFILT_SOCK declaration AS_IF([test -n "$apple_xnu_source_bsd_path"], [ @@ -194,15 +227,6 @@ AC_CHECK_HEADER([mach/mach.h], [ ) AM_CONDITIONAL(USE_MIG, $have_mach) -# -# We use the availability of pthread_workqueue.h to decide whether to compile -# in support for pthread work queues. -# -AC_CHECK_HEADER([pthread_workqueue.h], - [AC_DEFINE(HAVE_PTHREAD_WORKQUEUES, 1, [Define if pthread work queues are present])] -) -AC_CHECK_FUNCS([pthread_workqueue_setdispatch_np]) - # # Find functions and declarations we care about. # @@ -295,5 +319,11 @@ AC_COMPILE_IFELSE( # # Generate Makefiles. # -AC_CONFIG_FILES([Makefile dispatch/Makefile man/Makefile os/Makefile private/Makefile src/Makefile]) +AC_CONFIG_FILES([Makefile dispatch/Makefile man/Makefile os/Makefile private/Makefile src/Makefile tests/Makefile]) + +# +# Generate testsuite links +# +AC_CONFIG_LINKS([tests/dispatch:${x:+}private tests/leaks-wrapper:tests/leaks-wrapper.sh]) + AC_OUTPUT diff --git a/dispatch/Makefile.am b/dispatch/Makefile.am index 6dc850b21..6233f4c98 100644 --- a/dispatch/Makefile.am +++ b/dispatch/Makefile.am @@ -6,6 +6,7 @@ dispatchdir=$(includedir)/dispatch dispatch_HEADERS= \ base.h \ + block.h \ data.h \ dispatch.h \ group.h \ diff --git a/private/Makefile.am b/private/Makefile.am index de1239168..017bd0590 100644 --- a/private/Makefile.am +++ b/private/Makefile.am @@ -7,8 +7,11 @@ noinst_HEADERS= \ data_private.h \ introspection_private.h \ io_private.h \ + layout_private.h \ mach_private.h \ private.h \ queue_private.h \ - source_private.h + source_private.h \ + voucher_activity_private.h \ + voucher_private.h diff --git a/src/Makefile.am b/src/Makefile.am index 630a4806d..007279ed8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,9 +5,11 @@ lib_LTLIBRARIES=libdispatch.la libdispatch_la_SOURCES= \ + allocator.c \ apply.c \ benchmark.c \ data.c \ + introspection.c \ init.c \ io.c \ object.c \ @@ -17,10 +19,14 @@ libdispatch_la_SOURCES= \ source.c \ time.c \ transform.c \ + voucher.c \ protocol.defs \ provider.d \ + allocator_internal.h \ data_internal.h \ + inline_internal.h \ internal.h \ + introspection_internal.h \ io_internal.h \ object_internal.h \ queue_internal.h \ @@ -28,49 +34,65 @@ libdispatch_la_SOURCES= \ shims.h \ source_internal.h \ trace.h \ + voucher_internal.h \ shims/atomic.h \ + shims/atomic_sfb.h \ shims/getprogname.h \ shims/hw_config.h \ shims/perfmon.h \ shims/time.h \ - shims/tsd.h + shims/tsd.h \ + shims/yield.h AM_CPPFLAGS=-I$(top_builddir) -I$(top_srcdir) \ -I$(top_srcdir)/private -I$(top_srcdir)/os -AM_CFLAGS=-Wall $(VISIBILITY_FLAGS) $(OMIT_LEAF_FP_FLAGS) \ - $(MARCH_FLAGS) $(CBLOCKS_FLAGS) $(KQUEUE_CFLAGS) +DISPATCH_CFLAGS=-Wall $(VISIBILITY_FLAGS) $(OMIT_LEAF_FP_FLAGS) \ + $(MARCH_FLAGS) $(KQUEUE_CFLAGS) +AM_CFLAGS=$(DISPATCH_CFLAGS) $(CBLOCKS_FLAGS) +AM_OBJCFLAGS=$(DISPATCH_CFLAGS) $(CBLOCKS_FLAGS) +AM_CXXFLAGS=$(DISPATCH_CFLAGS) $(CXXBLOCKS_FLAGS) +AM_OBJCXXFLAGS=$(DISPATCH_CFLAGS) $(CXXBLOCKS_FLAGS) libdispatch_la_LDFLAGS=-avoid-version if HAVE_DARWIN_LD libdispatch_la_LDFLAGS+=-Wl,-compatibility_version,1 \ - -Wl,-current_version,$(VERSION) -Wl,-dead_strip + -Wl,-current_version,$(VERSION) -Wl,-dead_strip \ + -Wl,-alias_list,$(top_srcdir)/xcodeconfig/libdispatch.aliases endif if USE_OBJC -libdispatch_la_SOURCES+=object.m -libdispatch_la_OBJCFLAGS=$(AM_CFLAGS) -fobjc-gc +libdispatch_la_SOURCES+=block.cpp data.m object.m +libdispatch_la_OBJCFLAGS=$(AM_OBJCFLAGS) -Wno-switch -fobjc-gc +libdispatch_la_CXXFLAGS=$(AM_CXXFLAGS) -std=gnu++11 -fno-exceptions libdispatch_la_LDFLAGS+=-Wl,-upward-lobjc -Wl,-upward-lauto \ -Wl,-order_file,$(top_srcdir)/xcodeconfig/libdispatch.order \ - -Wl,-alias_list,$(top_srcdir)/xcodeconfig/libdispatch.aliases \ + -Wl,-alias_list,$(top_srcdir)/xcodeconfig/libdispatch_objc.aliases \ -Wl,-unexported_symbols_list,$(top_srcdir)/xcodeconfig/libdispatch.unexport endif -CLEANFILES= -DISTCLEANFILES=System objc - if USE_MIG -BUILT_SOURCES= \ +MIG_SOURCES= \ protocolUser.c \ protocol.h \ protocolServer.c \ protocolServer.h -nodist_libdispatch_la_SOURCES=$(BUILT_SOURCES) -CLEANFILES+=$(BUILT_SOURCES) - %User.c %.h %Server.c %Server.h: $(abs_srcdir)/%.defs $(MIG) -user $*User.c -header $*.h \ -server $*Server.c -sheader $*Server.h $< endif + +if USE_DTRACE +DTRACE_SOURCES=provider.h + +%.h: $(abs_srcdir)/%.d + $(DTRACE) -h -s $< -o $@ +endif + +BUILT_SOURCES=$(MIG_SOURCES) $(DTRACE_SOURCES) +nodist_libdispatch_la_SOURCES=$(BUILT_SOURCES) +CLEANFILES=$(BUILT_SOURCES) +DISTCLEANFILES=pthread_machdep.h pthread System mach objc + diff --git a/tests/Makefile.am b/tests/Makefile.am index 59125ddcc..e1b222fd1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -2,13 +2,15 @@ # # +AUTOMAKE_OPTIONS = serial-tests subdir-objects + noinst_LTLIBRARIES=libbsdtests.la libbsdtests_la_SOURCES= \ bsdtests.c \ bsdtests.h \ dispatch_test.c \ - dispatch_test.h \ + dispatch_test.h check_PROGRAMS= \ bsdtestharness \ @@ -62,15 +64,17 @@ dispatch_priority2_CPPFLAGS=$(AM_CPPFLAGS) -DUSE_SET_TARGET_QUEUE=1 AM_CPPFLAGS=-I$(top_builddir) -I$(top_srcdir) -AM_CFLAGS=-Wall $(MARCH_FLAGS) $(CBLOCKS_FLAGS) -AM_OBJCFLAGS=-Wall $(MARCH_FLAGS) $(CBLOCKS_FLAGS) -fobjc-gc -AM_CXXFLAGS=-Wall $(MARCH_FLAGS) $(CXXBLOCKS_FLAGS) +DISPATCH_TESTS_CFLAGS=-Wall -Wno-deprecated-declarations $(MARCH_FLAGS) +AM_CFLAGS=$(DISPATCH_TESTS_CFLAGS) $(CBLOCKS_FLAGS) +AM_OBJCFLAGS=$(DISPATCH_TESTS_CFLAGS) $(CBLOCKS_FLAGS) +AM_CXXFLAGS=$(DISPATCH_TESTS_CFLAGS) $(CXXBLOCKS_FLAGS) +AM_OBJCXXFLAGS=$(DISPATCH_TESTS_CFLAGS) $(CXXBLOCKS_FLAGS) LDADD=libbsdtests.la ../src/libdispatch.la libbsdtests_la_LDFLAGS=-avoid-version TESTS_ENVIRONMENT=./bsdtestharness -DISTCLEAN=bench.cc +DISTCLEAN=Foundation/bench.cc if HAVE_COREFOUNDATION TESTS+= \ @@ -92,16 +96,12 @@ TESTS+= \ nsoperation \ bench -dispatch_sync_gc_SOURCES=dispatch_sync_gc.m +dispatch_sync_gc_SOURCES=Foundation/dispatch_sync_gc.m dispatch_sync_gc_LDFLAGS=-framework Foundation -dispatch_apply_gc_SOURCES=dispatch_apply_gc.m +dispatch_apply_gc_SOURCES=Foundation/dispatch_apply_gc.m dispatch_apply_gc_LDFLAGS=-framework Foundation -nsoperation_SOURCES=nsoperation.m +nsoperation_SOURCES=Foundation/nsoperation.m nsoperation_LDFLAGS=-framework Foundation -nodist_bench_SOURCES=bench.cc -bench_SOURCES=func.c +bench_SOURCES=Foundation/bench.mm func.c bench_LDFLAGS=-framework Foundation -# Workaround missing objcxx support in older autotools -bench.o: bench.cc - $(CXXCOMPILE) -x objective-c++ -c -o $@ $< endif From 662b0ef92a25f66288441aebfdb11bdfa2ab79e3 Mon Sep 17 00:00:00 2001 From: "Daniel A. Steffen" Date: Tue, 1 Dec 2015 08:17:59 -0800 Subject: [PATCH 2/2] Missing pieces required for building as /usr/lib/system/libdispatch.dylib on OSX El Capitan --- src/queue.c | 27 ++++++++++++++++++++++++++- src/queue_internal.h | 25 +++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/queue.c b/src/queue.c index 5868e8799..cdf011d50 100644 --- a/src/queue.c +++ b/src/queue.c @@ -711,7 +711,6 @@ dispatch_assert_queue_not(dispatch_queue_t dq) #pragma mark dispatch_init #if HAVE_PTHREAD_WORKQUEUE_QOS -int _dispatch_set_qos_class_enabled; pthread_priority_t _dispatch_background_priority; pthread_priority_t _dispatch_user_initiated_priority; @@ -1651,6 +1650,21 @@ dispatch_pthread_root_queue_create(const char *label, unsigned long flags, NULL); } +#if DISPATCH_IOHID_SPI +dispatch_queue_t +_dispatch_pthread_root_queue_create_with_observer_hooks_4IOHID(const char *label, + unsigned long flags, const pthread_attr_t *attr, + dispatch_pthread_root_queue_observer_hooks_t observer_hooks, + dispatch_block_t configure) +{ + if (!observer_hooks->queue_will_execute || + !observer_hooks->queue_did_execute) { + DISPATCH_CLIENT_CRASH("Invalid pthread root queue observer hooks"); + } + return _dispatch_pthread_root_queue_create(label, flags, attr, configure, + observer_hooks); +} +#endif #endif // DISPATCH_ENABLE_PTHREAD_ROOT_QUEUES @@ -1842,6 +1856,17 @@ dispatch_get_specific(const void *key) return ctxt; } +#if DISPATCH_IOHID_SPI +bool +_dispatch_queue_is_exclusively_owned_by_current_thread_4IOHID( + dispatch_queue_t dq) // rdar://problem/18033810 +{ + if (dq->dq_width > 1) { + DISPATCH_CLIENT_CRASH("Invalid queue type"); + } + return (dq->dq_thread && dq->dq_thread == _dispatch_thread_port()); +} +#endif #pragma mark - #pragma mark dispatch_queue_debug diff --git a/src/queue_internal.h b/src/queue_internal.h index 143ab1e2a..858ee273d 100644 --- a/src/queue_internal.h +++ b/src/queue_internal.h @@ -379,4 +379,29 @@ void _dispatch_block_invoke(const struct dispatch_block_private_data_s *dbcpd); #endif /* __BLOCKS__ */ +typedef struct dispatch_pthread_root_queue_observer_hooks_s { + void (*queue_will_execute)(dispatch_queue_t queue); + void (*queue_did_execute)(dispatch_queue_t queue); +} dispatch_pthread_root_queue_observer_hooks_s; +typedef dispatch_pthread_root_queue_observer_hooks_s + *dispatch_pthread_root_queue_observer_hooks_t; + +#ifdef __APPLE__ +#define DISPATCH_IOHID_SPI 1 + +DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT +DISPATCH_NOTHROW DISPATCH_NONNULL4 +dispatch_queue_t +_dispatch_pthread_root_queue_create_with_observer_hooks_4IOHID( + const char *label, unsigned long flags, const pthread_attr_t *attr, + dispatch_pthread_root_queue_observer_hooks_t observer_hooks, + dispatch_block_t configure); + +DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NOTHROW +bool +_dispatch_queue_is_exclusively_owned_by_current_thread_4IOHID( + dispatch_queue_t queue); + +#endif // __APPLE__ + #endif