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
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
SUBDIRS= \
dispatch \
man \
+ os \
private \
src
#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.
#
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])
[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,
)
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
[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])
#
# 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)
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"])
#
# 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
$(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 && \
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 \
--- /dev/null
+#
+#
+#
+
+osdir=$(includedir)/os
+
+os_HEADERS= \
+ object.h
+
+noinst_HEADERS= \
+ object_private.h
*/
#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
noinst_HEADERS= \
benchmark.h \
+ data_private.h \
+ dispatch.h \
private.h \
queue_private.h \
source_private.h
semaphore.c \
source.c \
time.c \
+ transform.c \
protocol.defs \
provider.d \
data_internal.h \
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= \
};
const struct dispatch_source_type_s _dispatch_source_type_sock = {
+#ifdef EVFILT_SOCK
.ke = {
.filter = EVFILT_SOCK,
.flags = EV_CLEAR,
.mask = NOTE_CONNRESET | NOTE_READCLOSED | NOTE_WRITECLOSED |
NOTE_TIMEOUT | NOTE_NOSRCADDR | NOTE_IFDENIED | NOTE_SUSPEND |
NOTE_RESUME | NOTE_KEEPALIVE,
+#endif
};
#pragma mark -
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);
}
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);
}
}
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);
}
/*
- * Copyright (c) 2011 Apple Inc. All rights reserved.
+ * Copyright (c) 2011-2012 Apple Inc. All rights reserved.
*
* @APPLE_APACHE_LICENSE_HEADER_START@
*
});
if (!success) {
+ (void)_dispatch_transform_buffer_new(&buffer, 0, 0);
dispatch_release(buffer.data);
return NULL;
}
});
if (!success) {
+ (void)_dispatch_transform_buffer_new(&buffer, 0, 0);
dispatch_release(buffer.data);
return NULL;
}
{
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) {