From fe4ce08b25268ab7a007bb9eb2dd578ca5a9d5e8 Mon Sep 17 00:00:00 2001 From: Apple Date: Wed, 19 Sep 2012 20:02:25 +0000 Subject: [PATCH] libdispatch-228.23.tar.gz --- INSTALL | 23 ++++++++++++---- Makefile.am | 1 + config/config.h | 6 ++--- configure.ac | 66 ++++++++++++++++++++++++++++++++++----------- man/Makefile.am | 4 --- os/Makefile.am | 11 ++++++++ os/object.h | 2 +- private/Makefile.am | 2 ++ src/Makefile.am | 22 +++++++++++---- src/init.c | 2 ++ src/semaphore.c | 14 +++++----- src/transform.c | 7 ++++- 12 files changed, 120 insertions(+), 40 deletions(-) create mode 100644 os/Makefile.am diff --git a/INSTALL b/INSTALL index bac7e27..faf66d2 100644 --- a/INSTALL +++ b/INSTALL @@ -45,6 +45,16 @@ The following configure options may be of general interest: 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: +--with-apple-objc4-source + + Specify the path to Apple's objc4 package, so that appropriate headers can + be found and used. + +--with-apple-libauto-source + + Specify the path to Apple's libauto package, so that appropriate headers + can be found and used. + --disable-libdispatch-init-constructor Do not tag libdispatch's init routine as __constructor, in which case it @@ -61,16 +71,19 @@ Mac OS X as a replacement for /usr/lib/system/libdispatch.dylib: Typical configuration commands The following command lines create the configuration required to build -libdispatch for /usr/lib/system on Mac OS X Lion: +libdispatch for /usr/lib/system on OS X MountainLion: sh autogen.sh - ./configure CFLAGS='-arch x86_64 -arch i386 -g -Os' \ + 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 \ --enable-apple-tsd-optimizations \ - --with-apple-libc-source=/path/to/10.7.0/Libc-763.11 \ - --with-apple-libclosure-source=/path/to/10.7.0/libclosure-53 \ - --with-apple-xnu-source=/path/to/10.7.0/xnu-1699.22.73 + --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 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 4e3167c..72f4322 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,6 +7,7 @@ ACLOCAL_AMFLAGS = -I m4 SUBDIRS= \ dispatch \ man \ + os \ private \ src diff --git a/config/config.h b/config/config.h index 7fe2d63..0818e1e 100644 --- a/config/config.h +++ b/config/config.h @@ -143,13 +143,13 @@ #define PACKAGE_NAME "libdispatch" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "libdispatch 1.1" +#define PACKAGE_STRING "libdispatch 1.2" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "libdispatch" /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.1" +#define PACKAGE_VERSION "1.2" /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 @@ -170,7 +170,7 @@ /* #undef USE_POSIX_SEM */ /* Version number of package */ -#define VERSION "1.1" +#define VERSION "1.2" /* Define to 1 if on AIX 3. System headers sometimes define this. diff --git a/configure.ac b/configure.ac index 9e751e7..d1fe9c4 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ # AC_PREREQ(2.59) -AC_INIT([libdispatch], [1.1], [libdispatch@macosforge.org], [libdispatch]) +AC_INIT([libdispatch], [1.2], [libdispatch@macosforge.org], [libdispatch]) AC_REVISION([$$]) AC_CONFIG_AUX_DIR(config) AC_CONFIG_HEADER([config/config.h]) @@ -37,8 +37,22 @@ AC_ARG_WITH([apple-xnu-source], [AS_HELP_STRING([--with-apple-xnu-source], [Specify path to Apple XNU source])], [ apple_xnu_source_libkern_path=${withval}/libkern + apple_xnu_source_bsd_path=${withval}/bsd apple_xnu_source_osfmk_path=${withval}/osfmk - CPPFLAGS="$CPPFLAGS -I$apple_xnu_source_libkern_path" + CPPFLAGS="$CPPFLAGS -idirafter $apple_xnu_source_libkern_path -isystem $apple_xnu_source_bsd_path" +]) + +AC_ARG_WITH([apple-objc4-source], + [AS_HELP_STRING([--with-apple-objc4-source], + [Specify path to Apple objc4 source])], [ + apple_objc4_source_runtime_path=${withval}/runtime +]) + +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" ]) AC_CACHE_CHECK([for System.framework/PrivateHeaders], dispatch_cv_system_privateheaders, @@ -78,17 +92,16 @@ AS_IF([test "x$enable_apple_tsd_optimizations" = "xyes"], ) AC_USE_SYSTEM_EXTENSIONS +AM_INIT_AUTOMAKE([foreign no-dependencies]) +LT_INIT([disable-static]) + AC_PROG_INSTALL -AC_PROG_LIBTOOL AC_PATH_PROGS(MIG, mig) - AC_PATH_PROG(LEAKS, leaks) AS_IF([test "x$LEAKS" != "x"], [AC_DEFINE(HAVE_LEAKS, 1, [Define if Apple leaks program is present])] ) -AM_INIT_AUTOMAKE([foreign]) - DISPATCH_C_ATOMIC_BUILTINS case $dispatch_cv_atomic in @@ -131,20 +144,43 @@ AS_IF([test -n "$apple_xnu_source_osfmk_path"], [ [ln -fsh "$apple_xnu_source_osfmk_path" src/System], [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"], [ + CPPFLAGS="$CPPFLAGS -DPRIVATE=1" +]) # -# Parts of the testsuite use CoreFoundation and Foundation +# Check for CoreFoundation, Foundation and objc # AC_CHECK_HEADER([CoreFoundation/CoreFoundation.h], [have_corefoundation=true], [have_corefoundation=false] ) AM_CONDITIONAL(HAVE_COREFOUNDATION, $have_corefoundation) + AC_LANG_PUSH([Objective C]) -AC_CHECK_HEADER([Foundation/Foundation.h], [ - AC_DEFINE(USE_OBJC, 1, [Define to use Objective-C runtime]) - have_foundation=true], [have_foundation=false] +AC_CHECK_HEADER([Foundation/Foundation.h], + [have_foundation=true], [have_foundation=false] ) AM_CONDITIONAL(HAVE_FOUNDATION, $have_foundation) +# hack for objc4/runtime/objc-internal.h +AS_IF([test -n "$apple_objc4_source_runtime_path"], [ + saveCPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -I." + ln -fsh "$apple_objc4_source_runtime_path" objc +]) +AC_CHECK_HEADER([objc/objc-internal.h], [ + AC_DEFINE(USE_OBJC, 1, [Define to use Objective-C runtime]) + have_objc=true], [have_objc=false], + [#include ] +) +AS_IF([test -n "$apple_objc4_source_runtime_path"], [ + rm -f objc + CPPFLAGS="$saveCPPFLAGS" + AC_CONFIG_COMMANDS([src/objc], + [ln -fsh "$apple_objc4_source_runtime_path" src/objc], + [apple_objc4_source_runtime_path="$apple_objc4_source_runtime_path"]) +]) +AM_CONDITIONAL(USE_OBJC, $have_objc) AC_LANG_POP([Objective C]) # @@ -152,9 +188,9 @@ AC_LANG_POP([Objective C]) # of Machisms, including using Mach ports as event sources, etc. # AC_CHECK_HEADER([mach/mach.h], [ - AC_DEFINE(HAVE_MACH, 1, [Define if mach is present]) - AC_DEFINE(__DARWIN_NON_CANCELABLE, 1, [Define if using Darwin $NOCANCEL]) - have_mach=true], [have_mach=false] + AC_DEFINE(HAVE_MACH, 1, [Define if mach is present]) + AC_DEFINE(__DARWIN_NON_CANCELABLE, 1, [Define if using Darwin $NOCANCEL]) + have_mach=true], [have_mach=false] ) AM_CONDITIONAL(USE_MIG, $have_mach) @@ -239,7 +275,7 @@ AC_SUBST([OMIT_LEAF_FP_FLAGS]) AC_CACHE_CHECK([for darwin linker], [dispatch_cv_ld_darwin], [ saveLDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -dynamiclib -compatibility_version 1.2.3 -current_version 4.5.6" + LDFLAGS="$LDFLAGS -dynamiclib -compatibility_version 1.2.3 -current_version 4.5.6 -dead_strip" AC_LINK_IFELSE([AC_LANG_PROGRAM([ extern int foo; int foo;], [foo = 0;])], [dispatch_cv_ld_darwin="yes"], [dispatch_cv_ld_darwin="no"]) @@ -259,5 +295,5 @@ AC_COMPILE_IFELSE( # # Generate Makefiles. # -AC_CONFIG_FILES([Makefile dispatch/Makefile man/Makefile private/Makefile src/Makefile]) +AC_CONFIG_FILES([Makefile dispatch/Makefile man/Makefile os/Makefile private/Makefile src/Makefile]) AC_OUTPUT diff --git a/man/Makefile.am b/man/Makefile.am index 7ad94e2..0d58d14 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -77,10 +77,8 @@ install-data-hook: $(LN) -f dispatch_data_create.3 dispatch_data_create_subrange.3 && \ $(LN) -f dispatch_data_create.3 dispatch_data_create_map.3 && \ $(LN) -f dispatch_data_create.3 dispatch_data_apply.3 && \ - $(LN) -f dispatch_data_create.3 dispatch_data_copy_subrange.3 && \ $(LN) -f dispatch_data_create.3 dispatch_data_copy_region.3 && \ $(LN) -f dispatch_data_create.3 dispatch_data_get_size.3 && \ - $(LN) -f dispatch_data_create.3 dispatch_data_copy_subrange.3 && \ $(LN) -f dispatch_data_create.3 dispatch_data_empty.3 && \ $(LN) -f dispatch_io_create.3 dispatch_io_create_with_path.3 && \ $(LN) -f dispatch_io_create.3 dispatch_io_set_high_water.3 && \ @@ -139,10 +137,8 @@ uninstall-hook: dispatch_data_create_subrange.3 \ dispatch_data_create_map.3 \ dispatch_data_apply.3 \ - dispatch_data_copy_subrange.3 \ dispatch_data_copy_region.3 \ dispatch_data_get_size.3 \ - dispatch_data_copy_subrange.3 \ dispatch_data_empty.3 \ dispatch_io_create_with_path.3 \ dispatch_io_set_high_water.3 \ diff --git a/os/Makefile.am b/os/Makefile.am new file mode 100644 index 0000000..2189f16 --- /dev/null +++ b/os/Makefile.am @@ -0,0 +1,11 @@ +# +# +# + +osdir=$(includedir)/os + +os_HEADERS= \ + object.h + +noinst_HEADERS= \ + object_private.h diff --git a/os/object.h b/os/object.h index 7d1e5ce..4ddfa89 100644 --- a/os/object.h +++ b/os/object.h @@ -49,7 +49,7 @@ */ #ifndef OS_OBJECT_HAVE_OBJC_SUPPORT -#if defined(__OBJC2__) && !defined(__OBJC_GC__) && ( \ +#if defined(__OBJC__) && defined(__OBJC2__) && !defined(__OBJC_GC__) && ( \ __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_8 || \ __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_6_0) #define OS_OBJECT_HAVE_OBJC_SUPPORT 1 diff --git a/private/Makefile.am b/private/Makefile.am index 488ef52..f8d0ec7 100644 --- a/private/Makefile.am +++ b/private/Makefile.am @@ -4,6 +4,8 @@ noinst_HEADERS= \ benchmark.h \ + data_private.h \ + dispatch.h \ private.h \ queue_private.h \ source_private.h diff --git a/src/Makefile.am b/src/Makefile.am index 1af748c..f6b95e3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,6 +16,7 @@ libdispatch_la_SOURCES= \ semaphore.c \ source.c \ time.c \ + transform.c \ protocol.defs \ provider.d \ data_internal.h \ @@ -35,19 +36,30 @@ libdispatch_la_SOURCES= \ shims/time.h \ shims/tsd.h -INCLUDES=-I$(top_builddir) -I$(top_srcdir) -I$(top_srcdir)/private +AM_CPPFLAGS=-I$(top_builddir) -I$(top_srcdir) \ + -I$(top_srcdir)/private -I$(top_srcdir)/os -libdispatch_la_CFLAGS=-Wall $(VISIBILITY_FLAGS) $(OMIT_LEAF_FP_FLAGS) -libdispatch_la_CFLAGS+=$(MARCH_FLAGS) $(CBLOCKS_FLAGS) $(KQUEUE_CFLAGS) +AM_CFLAGS=-Wall $(VISIBILITY_FLAGS) $(OMIT_LEAF_FP_FLAGS) \ + $(MARCH_FLAGS) $(CBLOCKS_FLAGS) $(KQUEUE_CFLAGS) libdispatch_la_LDFLAGS=-avoid-version if HAVE_DARWIN_LD -libdispatch_la_LDFLAGS+=-Wl,-compatibility_version,1 -Wl,-current_version,$(VERSION) +libdispatch_la_LDFLAGS+=-Wl,-compatibility_version,1 \ + -Wl,-current_version,$(VERSION) -Wl,-dead_strip +endif + +if USE_OBJC +libdispatch_la_SOURCES+=object.m +libdispatch_la_OBJCFLAGS=$(AM_CFLAGS) -fobjc-gc +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,-unexported_symbols_list,$(top_srcdir)/xcodeconfig/libdispatch.unexport endif CLEANFILES= -DISTCLEANFILES=System +DISTCLEANFILES=System objc if USE_MIG BUILT_SOURCES= \ diff --git a/src/init.c b/src/init.c index 8f1456e..0cdaeb0 100644 --- a/src/init.c +++ b/src/init.c @@ -780,6 +780,7 @@ const struct dispatch_source_type_s _dispatch_source_type_mach_recv = { }; const struct dispatch_source_type_s _dispatch_source_type_sock = { +#ifdef EVFILT_SOCK .ke = { .filter = EVFILT_SOCK, .flags = EV_CLEAR, @@ -787,6 +788,7 @@ const struct dispatch_source_type_s _dispatch_source_type_sock = { .mask = NOTE_CONNRESET | NOTE_READCLOSED | NOTE_WRITECLOSED | NOTE_TIMEOUT | NOTE_NOSRCADDR | NOTE_IFDENIED | NOTE_SUSPEND | NOTE_RESUME | NOTE_KEEPALIVE, +#endif }; #pragma mark - diff --git a/src/semaphore.c b/src/semaphore.c index d3fd431..c3692c6 100644 --- a/src/semaphore.c +++ b/src/semaphore.c @@ -188,8 +188,7 @@ dispatch_semaphore_signal(dispatch_semaphore_t dsema) return 0; } if (slowpath(value == LONG_MIN)) { - DISPATCH_CLIENT_CRASH("Unbalanced call to dispatch_group_leave() or " - "dispatch_semaphore_signal()"); + DISPATCH_CLIENT_CRASH("Unbalanced call to dispatch_semaphore_signal()"); } return _dispatch_semaphore_signal_slow(dsema); } @@ -377,9 +376,12 @@ void dispatch_group_leave(dispatch_group_t dg) { dispatch_semaphore_t dsema = (dispatch_semaphore_t)dg; - - dispatch_semaphore_signal(dsema); - if (dsema->dsema_value == dsema->dsema_orig) { + dispatch_atomic_release_barrier(); + long value = dispatch_atomic_inc2o(dsema, dsema_value); + if (slowpath(value == LONG_MIN)) { + DISPATCH_CLIENT_CRASH("Unbalanced call to dispatch_group_leave()"); + } + if (slowpath(value == dsema->dsema_orig)) { (void)_dispatch_group_wake(dsema); } } @@ -534,7 +536,7 @@ dispatch_group_notify_f(dispatch_group_t dg, dispatch_queue_t dq, void *ctxt, prev->dsn_next = dsn; } else { _dispatch_retain(dg); - dsema->dsema_notify_head = dsn; + (void)dispatch_atomic_xchg2o(dsema, dsema_notify_head, dsn); if (dsema->dsema_value == dsema->dsema_orig) { _dispatch_group_wake(dsema); } diff --git a/src/transform.c b/src/transform.c index 775ce41..3bb1e3e 100644 --- a/src/transform.c +++ b/src/transform.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Apple Inc. All rights reserved. + * Copyright (c) 2011-2012 Apple Inc. All rights reserved. * * @APPLE_APACHE_LICENSE_HEADER_START@ * @@ -352,6 +352,7 @@ _dispatch_transform_to_utf16(dispatch_data_t data, int32_t byteOrder) }); if (!success) { + (void)_dispatch_transform_buffer_new(&buffer, 0, 0); dispatch_release(buffer.data); return NULL; } @@ -491,6 +492,7 @@ _dispatch_transform_from_utf16(dispatch_data_t data, int32_t byteOrder) }); if (!success) { + (void)_dispatch_transform_buffer_new(&buffer, 0, 0); dispatch_release(buffer.data); return NULL; } @@ -910,6 +912,9 @@ dispatch_data_create_with_transform(dispatch_data_t data, { if (input->type == _DISPATCH_DATA_FORMAT_UTF_ANY) { input = _dispatch_transform_detect_utf(data); + if (input == NULL) { + return NULL; + } } if ((input->type & ~output->input_mask) != 0) { -- 2.45.2