]> git.saurik.com Git - apple/libdispatch.git/commitdiff
libdispatch-228.23.tar.gz mac-os-x-1082 mac-os-x-1083 mac-os-x-1084 mac-os-x-1085 v228.23
authorApple <opensource@apple.com>
Wed, 19 Sep 2012 20:02:25 +0000 (20:02 +0000)
committerApple <opensource@apple.com>
Wed, 19 Sep 2012 20:02:25 +0000 (20:02 +0000)
12 files changed:
INSTALL
Makefile.am
config/config.h
configure.ac
man/Makefile.am
os/Makefile.am [new file with mode: 0644]
os/object.h
private/Makefile.am
src/Makefile.am
src/init.c
src/semaphore.c
src/transform.c

diff --git a/INSTALL b/INSTALL
index bac7e27e82990c2d163cd4d2d5e98324f6e4a88b..faf66d2317616c383f2f529b5455330d8dc13304 100644 (file)
--- 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
index 4e3167c2aaa5d12076308b0e0f013ef2b6703d44..72f432242c0378ca0e5e905d978178eddca8b110 100644 (file)
@@ -7,6 +7,7 @@ ACLOCAL_AMFLAGS = -I m4
 SUBDIRS=                                       \
        dispatch                                \
        man                                             \
+       os                                              \
        private                                 \
        src
 
index 7fe2d6348e6fdc528ba72d4834a5a373eca6aa1d..0818e1ea0c45e55ae448501b5c35fd5ae3a3acf7 100644 (file)
 #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
 /* #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.
index 9e751e7ed0140ff2ba3bc259db294b47fcc015f2..d1fe9c40bbbf8d159a14bb9b4e359375f24c8a2a 100644 (file)
@@ -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 <objc/runtime.h>]
+)
+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
index 7ad94e21b8d0e63e09ef9001b82f8296a217cd68..0d58d141f0f315dd1afb098c732c6b99b1e102fc 100644 (file)
@@ -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 (file)
index 0000000..2189f16
--- /dev/null
@@ -0,0 +1,11 @@
+#
+#
+#
+
+osdir=$(includedir)/os
+
+os_HEADERS=    \
+       object.h
+
+noinst_HEADERS=        \
+       object_private.h
index 7d1e5ce85d99e8d8f1042c2559fdc33772f46338..4ddfa89c4307d7be3816be2e14310456a62d7741 100644 (file)
@@ -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
index 488ef520e72d3dcd8112d79cf4132038c226e1f4..f8d0ec7677e6067b95ca0dec7e5ba2cfb6d95828 100644 (file)
@@ -4,6 +4,8 @@
 
 noinst_HEADERS=                        \
        benchmark.h                     \
+       data_private.h          \
+       dispatch.h                      \
        private.h                       \
        queue_private.h         \
        source_private.h
index 1af748c5281155161051705501fc1efe5fa1a15c..f6b95e36642e65207e370464de24e8db57916199 100644 (file)
@@ -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=                         \
index 8f1456eddab3565de51aefb4e809c4d501416f1a..0cdaeb0fed9c4550ebbfcfc1ad5b4493241a192a 100644 (file)
@@ -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 -
index d3fd431174cf6d385ac6831cfaea9da846bde467..c3692c6ec8f8dbb201ad6971401fb3e961a68998 100644 (file)
@@ -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);
                }
index 775ce41279163f89021567fa4801870598db3e3c..3bb1e3eed45ddcaebbd68c39e6af3d6e4e670891 100644 (file)
@@ -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) {