]> git.saurik.com Git - apple/libsystem.git/commitdiff
Libsystem-1213.tar.gz os-x-1010 os-x-10101 os-x-10102 os-x-10103 os-x-10104 os-x-10105 v1213
authorApple <opensource@apple.com>
Fri, 24 Oct 2014 17:53:10 +0000 (17:53 +0000)
committerApple <opensource@apple.com>
Fri, 24 Oct 2014 17:53:10 +0000 (17:53 +0000)
Libsystem.xcconfig
Libsystem.xcodeproj/project.pbxproj
alloc_once_private.h
init.c
optionallibs
requiredlibs
xcodescripts/create_dylib_symlinks.sh
xcodescripts/create_system_framework.sh
xcodescripts/linker_arguments.sh

index 87b46fe56ba7322b2dae4a78e05d4decb0395282..a1ddf293405866c51b83542c51fba5a11c7ccd87 100644 (file)
@@ -1,13 +1,20 @@
 #include "<DEVELOPER_DIR>/Makefiles/CoreOS/Xcode/BSD.xcconfig"
+#include "<DEVELOPER_DIR>/AppleInternal/XcodeConfig/SimulatorSupport.xcconfig"
+
+// Set INSTALL_PATH[sdk=macosx*] when SimulatorSupport.xcconfig is unavailable
+INSTALL_PATH[sdk=macosx*] = $(INSTALL_PATH_ACTUAL)
+
 BUILD_VARIANTS = normal debug
-INSTALL_PATH = /usr/lib
+SUPPORTED_PLATFORMS = macosx iphoneos iphonesimulator iphoneosnano iphonesimulatornano
+INSTALL_PATH_ACTUAL = /usr/lib
 DYLIB_CURRENT_VERSION = $(CURRENT_VERSION_STRING_$(RC_XBS))
 ORDER_FILE = $(SDKROOT)/$(APPLE_INTERNAL_DIR)/OrderFiles/libSystem.order
 ORDER_FILE[sdk=iphonesimulator*] =
+OTHER_CFLAGS = -include $(BUILT_PRODUCTS_DIR)/config.$(CURRENT_ARCH).$(CURRENT_VARIANT).h
 OTHER_LDFLAGS = -Wl,-search_paths_first -nodefaultlibs @$(BUILT_PRODUCTS_DIR)/linker_arguments.$(CURRENT_ARCH).$(CURRENT_VARIANT).txt
 LD_GENERATE_MAP_FILE = YES
 EXECUTABLE_PREFIX = lib
-PRIVATE_HEADERS_FOLDER_PATH = /usr/local/include/os
+PRIVATE_HEADERS_FOLDER_PATH = $(INSTALL_PATH_PREFIX)/usr/local/include/os
 LIBRARY_SEARCH_PATHS = $(SDKROOT)/usr/lib/system $(SDKROOT)/usr/local/lib/system
 GCC_NO_COMMON_BLOCKS = YES
 GCC_WARN_64_TO_32_BIT_CONVERSION = YES
index f9bd58f60d4bfbfbc6a60d519b955b252edafa69..c3ba59d0c105e980f599cc049a5268ce84109d8b 100644 (file)
@@ -62,7 +62,7 @@
                BA2BD8FF136D27FE00FF78C0 /* CopyFiles */ = {
                        isa = PBXCopyFilesBuildPhase;
                        buildActionMask = 8;
-                       dstPath = /System/Library/Frameworks/System.framework/Versions/B/Resources;
+                       dstPath = "$(INSTALL_PATH_PREFIX)/System/Library/Frameworks/System.framework/Versions/B/Resources";
                        dstSubfolderSpec = 0;
                        files = (
                                BA2BD900136D282200FF78C0 /* Info.plist in CopyFiles */,
                BA5511B3136C9D780012B9B5 /* APPLE_LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = APPLE_LICENSE; sourceTree = "<group>"; };
                BA5511B4136C9D780012B9B5 /* CompatibilityHacks.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = CompatibilityHacks.c; sourceTree = "<group>"; };
                BA5511B6136C9D780012B9B5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
-               BA5511B7136C9D780012B9B5 /* init.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = init.c; sourceTree = "<group>"; };
+               BA5511B7136C9D780012B9B5 /* init.c */ = {isa = PBXFileReference; indentWidth = 8; lastKnownFileType = sourcecode.c.c; path = init.c; sourceTree = "<group>"; tabWidth = 8; usesTabs = 1; };
                BA5511B9136C9D780012B9B5 /* optionallibs */ = {isa = PBXFileReference; lastKnownFileType = text; path = optionallibs; sourceTree = "<group>"; };
                BA5511BA136C9D780012B9B5 /* requiredlibs */ = {isa = PBXFileReference; lastKnownFileType = text; path = requiredlibs; sourceTree = "<group>"; };
                BA5511C4136C9E2E0012B9B5 /* libSystem.B.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libSystem.B.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
                C64EE1D7136F644700676C52 /* create_dylib_symlinks.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_dylib_symlinks.sh; sourceTree = "<group>"; };
                C64EE1D8136F644700676C52 /* create_system_framework.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_system_framework.sh; sourceTree = "<group>"; };
                C64EE1D9136F644700676C52 /* linker_arguments.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = linker_arguments.sh; sourceTree = "<group>"; };
-               C9A43CAB15374DB200388D0C /* alloc_once_private.h */ = {isa = PBXFileReference; fileEncoding = 4; path = alloc_once_private.h; sourceTree = "<group>"; };
+               C9A43CAB15374DB200388D0C /* alloc_once_private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = alloc_once_private.h; sourceTree = "<group>"; };
                C9B56C55153751A600C153A8 /* Libsystem.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Libsystem.xcconfig; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
                        baseConfigurationReference = C9B56C55153751A600C153A8 /* Libsystem.xcconfig */;
                        buildSettings = {
                                PRODUCT_NAME = "$(TARGET_NAME).B";
+                               "PRODUCT_NAME[sdk=iphonesimulator*]" = "$(TARGET_NAME)";
                        };
                        name = Release;
                };
index 6f65f84a9771f52044ec0a74903d41df8f712ed1..da5a5eaa909273b63b8f295792ede7030067e015 100644 (file)
@@ -56,6 +56,8 @@
 #define OS_ALLOC_ONCE_KEY_LIBSYSTEM_PLATFORM   15
 #define OS_ALLOC_ONCE_KEY_LIBSYSTEM_PTHREAD    16
 #define OS_ALLOC_ONCE_KEY_LIBSYSTEM_STATS      17
+#define OS_ALLOC_ONCE_KEY_LIBSECINIT   18
+#define OS_ALLOC_ONCE_KEY_LIBSYSTEM_CORESERVICES 19
 
 /* Keys OS_ALLOC_ONCE_KEY_MAX - 10 upwards are reserved for the system. */
 #define OS_ALLOC_ONCE_KEY_RESERVED_0   (OS_ALLOC_ONCE_KEY_MAX - 10)
diff --git a/init.c b/init.c
index 9df51a18f3856a94d2b6f3bbc607c526fee4f736..e09c5237cfb861111af72195b03ff52d4a6514e5 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2008, 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (c) 2007, 2008, 2011-2013 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
 
 #include <TargetConditionals.h>        // for TARGET_OS_EMBEDDED
 
+#include <stddef.h>
+#include <stdlib.h>
+#include <libc_private.h>
 #include <pthread.h>
 #include <pthread/private.h>
-#include <_libkernel_init.h>
-#include <stdlib.h>
 #include <dlfcn.h>
 #include <errno.h>
-#include <TargetConditionals.h>
-
-struct ProgramVars; /* forward reference */
+#include <_libkernel_init.h> // Must be after voucher_private.h
 
 // system library initialisers
-extern void bootstrap_init(void);              // from liblaunch.dylib
 extern void mach_init(void);                   // from libsystem_kernel.dylib
 extern void __libplatform_init(void *future_use, const char *envp[], const char *apple[], const struct ProgramVars *vars);
 extern void __pthread_init(const struct _libpthread_functions *libpthread_funcs, const char *envp[], const char *apple[], const struct ProgramVars *vars);     // from libsystem_pthread.dylib
-extern void __libc_init(const struct ProgramVars *vars, void (*atfork_prepare)(void), void (*atfork_parent)(void), void (*atfork_child)(void), const char *apple[]);   // from libsystem_c.dylib
 extern void __malloc_init(const char *apple[]); // from libsystem_malloc.dylib
 extern void __keymgr_initializer(void);                // from libkeymgr.dylib
 extern void _dyld_initializer(void);           // from libdyld.dylib
 extern void libdispatch_init(void);            // from libdispatch.dylib
 extern void _libxpc_initializer(void);         // from libxpc.dylib
+extern void _libsecinit_initializer(void);        // from libsecinit.dylib
+
 
 // signal malloc stack logging that initialisation has finished
 extern void __stack_logging_early_finished(void); // form libsystem_c.dylib
 
+// clear qos tsd (from pthread)
+extern void _pthread_clear_qos_tsd(mach_port_t) __attribute__((weak_import));
+
 // system library atfork handlers
 extern void _pthread_fork_prepare(void);
 extern void _pthread_fork_parent(void);
 extern void _pthread_fork_child(void);
 extern void _pthread_fork_child_postinit(void);
+extern void _pthread_exit_if_canceled(int);
 
 extern void dispatch_atfork_prepare(void);
 extern void dispatch_atfork_parent(void);
@@ -68,7 +71,6 @@ extern void _malloc_fork_parent(void);
 extern void _malloc_fork_child(void);
 
 extern void _mach_fork_child(void);
-extern void _libc_fork_child(void);
 extern void _notify_fork_child(void);
 extern void _dyld_fork_child(void);
 extern void xpc_atfork_prepare(void);
@@ -79,50 +81,87 @@ extern void _libSC_info_fork_parent(void);
 extern void _libSC_info_fork_child(void);
 extern void _asl_fork_child(void);
 
+#if defined(HAVE_SYSTEM_CORESERVICES)
+// libsystem_coreservices.dylib
+extern void _libcoreservices_fork_child(void);
+extern char *_dirhelper(int, char *, size_t);
+#endif
+
+#if TARGET_IPHONE_SIMULATOR
+// no-op _pthread_clear_qos_tsd in the simulator, as its an upcall from libsyscall
+#define _pthread_clear_qos_tsd NULL
+#endif
+
 // advance decls for below;
 void libSystem_atfork_prepare(void);
 void libSystem_atfork_parent(void);
 void libSystem_atfork_child(void);
 
-void _pthread_exit_if_canceled(int);
-
-/*
- * libsyscall_initializer() initializes all of libSystem.dylib <rdar://problem/4892197>
- */
-static __attribute__((constructor))
-void libSystem_initializer(int argc, const char* argv[], const char* envp[], const char* apple[], const struct ProgramVars* vars)
+// libsyscall_initializer() initializes all of libSystem.dylib
+// <rdar://problem/4892197>
+__attribute__((constructor))
+static void
+libSystem_initializer(int argc,
+                     const char* argv[],
+                     const char* envp[],
+                     const char* apple[],
+                     const struct ProgramVars* vars)
 {
        static const struct _libkernel_functions libkernel_funcs = {
-               .version = 1,
+               .version = 3,
+               // V1 functions
                .dlsym = dlsym,
                .malloc = malloc,
                .free = free,
                .realloc = realloc,
                ._pthread_exit_if_canceled = _pthread_exit_if_canceled,
+               // V2 functions (removed)
+               // V3 functions
+               .pthread_clear_qos_tsd = _pthread_clear_qos_tsd,
        };
 
        static const struct _libpthread_functions libpthread_funcs = {
-               .version = 1,
+               .version = 2,
                .exit = exit,
+               .malloc = malloc,
+               .free = free,
+       };
+       
+       static const struct _libc_functions libc_funcs = {
+               .version = 1,
+               .atfork_prepare = libSystem_atfork_prepare,
+               .atfork_parent = libSystem_atfork_parent,
+               .atfork_child = libSystem_atfork_child,
+#if defined(HAVE_SYSTEM_CORESERVICES)
+               .dirhelper = _dirhelper,
+#endif
        };
 
        __libkernel_init(&libkernel_funcs, envp, apple, vars);
 
-       bootstrap_init();
        __libplatform_init(NULL, envp, apple, vars);
-
        __pthread_init(&libpthread_funcs, envp, apple, vars);
-       __libc_init(vars, libSystem_atfork_prepare, libSystem_atfork_parent, libSystem_atfork_child, apple);
+       _libc_initializer(&libc_funcs, envp, apple, vars);
 
        // TODO: Move __malloc_init before __libc_init after breaking malloc's upward link to Libc
        __malloc_init(apple);
 
+#if !TARGET_IPHONE_SIMULATOR
+       /* <rdar://problem/9664631> */
+       __keymgr_initializer();
+#endif
+
        _dyld_initializer();
        libdispatch_init();
        _libxpc_initializer();
 
+#if !(TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR)
+       _libsecinit_initializer();
+#endif
+
        __stack_logging_early_finished();
 
+
        /* <rdar://problem/11588042>
         * C99 standard has the following in section 7.5(3):
         * "The value of errno is zero at program startup, but is never set
@@ -132,10 +171,11 @@ void libSystem_initializer(int argc, const char* argv[], const char* envp[], con
 }
 
 /*
- * libSystem_atfork_{prepare,parent,child}() are called by libc when we fork, then we deal with running fork handlers
- * for everyone else.
+ * libSystem_atfork_{prepare,parent,child}() are called by libc during fork(2).
+ * They call the corresponding atfork handlers for other libsystem components.
  */
-void libSystem_atfork_prepare(void)
+void
+libSystem_atfork_prepare(void)
 {
        _libSC_info_fork_prepare();
        xpc_atfork_prepare();
@@ -144,7 +184,8 @@ void libSystem_atfork_prepare(void)
        _malloc_fork_prepare();
 }
 
-void libSystem_atfork_parent(void)
+void
+libSystem_atfork_parent(void)
 {
        _malloc_fork_parent();
        _pthread_fork_parent();
@@ -153,16 +194,21 @@ void libSystem_atfork_parent(void)
        _libSC_info_fork_parent();
 }
 
-void libSystem_atfork_child(void)
+void
+libSystem_atfork_child(void)
 {
        _dyld_fork_child();
        _pthread_fork_child();
        _malloc_fork_child();
        dispatch_atfork_child();
        
-       bootstrap_init();
        _mach_fork_child();
        _libc_fork_child();
+
+#if defined(HAVE_SYSTEM_CORESERVICES)
+       _libcoreservices_fork_child();
+#endif
+
        _asl_fork_child();
        _notify_fork_child();
        xpc_atfork_child();
index 2d0cde254c0ceff882076fb7957ab79134250deb..f7425cdc5510b1bf159d94869a88ecedf9c55ae1 100644 (file)
@@ -1,4 +1,10 @@
 keymgr
 quarantine
+system_coreservices system_sim_coreservices
+system_coretls
+system_network
+system_secinit
 system_stats
+system_trace system_sim_trace
+system_networkextension
 unc
index 763e333290b0a270924f515f6be2787a89b89730..9fa7c33668b784ecfe4dab70b5a2c121bf1f12f3 100644 (file)
@@ -1,26 +1,25 @@
-cache
+cache cache_sim
 commonCrypto
 compiler_rt
-copyfile
+copyfile copyfile_sim
 corecrypto
 dispatch
 dyld
-launch
-macho
-removefile
-system_asl
-system_blocks
-system_c
-system_configuration
-system_dnssd
-system_info
-system_kernel
-system_m
+launch launch_sim
+macho macho_sim
+removefile removefile_sim
+system_asl system_sim_asl
+system_blocks system_sim_blocks
+system_c system_sim_c
+system_configuration system_sim_configuration
+system_dnssd system_sim_dnssd
+system_info system_sim_info
+system_kernel system_sim_kernel
+system_m system_sim_m
 system_malloc
-system_network
-system_notify
-system_platform
-system_pthread
-system_sandbox
-unwind
+system_notify notify_sim
+system_platform system_sim_platform
+system_pthread system_sim_pthread
+system_sandbox system_sim_sandbox
+unwind unwind_sim
 xpc
index 6bcbc3a0b806aa223747c08aab55008214edcce2..cb0ef81761a6af0f352ca4dd3e70b7f6aa7a4220 100755 (executable)
@@ -1,11 +1,11 @@
-#!/bin/sh -x
+#!/bin/bash -x
 
 if [ $# -ne 3 ]; then
     echo "Usage: $0 <dstroot> <action> <variants>" 1>&2
     exit 1
 fi
 
-DSTROOT="$1"
+DSTROOT="$1${INSTALL_PATH_PREFIX}"
 ACTION="$2"
 VARIANTS="$3"
 
@@ -20,7 +20,12 @@ if [ "${ACTION}" != "installhdrs" ]; then
            suffix="_${variant}"
        fi
 
-        ln -sf "libSystem.B${suffix}.dylib" "${DSTROOT}/usr/lib/libSystem${suffix}.dylib" || exit 1
+        if [[ "${PLATFORM_NAME}" =~ simulator ]] ; then
+            ln -sf "libSystem${suffix}.dylib" "${DSTROOT}/usr/lib/libSystem.B${suffix}.dylib" || exit 1
+        else
+            ln -sf "libSystem.B${suffix}.dylib" "${DSTROOT}/usr/lib/libSystem${suffix}.dylib" || exit 1
+        fi
+
        for i in ${BSD_LIBS}; do
            ln -sf "libSystem.dylib" "${DSTROOT}/usr/lib/lib${i}.dylib" || exit 1
        done
index 08498952476a39413e86254c67a947abf9693256..968dc58d31de1001dbe158edb1615d2b3343c675 100755 (executable)
@@ -1,11 +1,11 @@
-#!/bin/sh -x
+#!/bin/bash -x
 
 if [ $# -ne 5 ]; then
     echo "Usage: $0 <dstroot> <srcroot> <action> <archs> <variants>" 1>&2
     exit 1
 fi
 
-DSTROOT="$1"
+DSTROOT="$1${INSTALL_PATH_PREFIX}"
 SRCROOT="$2"
 ACTION="$3"
 ARCHS="$4"
@@ -27,6 +27,10 @@ for variant in ${VARIANTS}; do
        suffix="_${variant}"
     fi
     ln -sf "Versions/Current/System${suffix}" "${DSTROOT}/${FPATH}/System${suffix}" || exit 1
-       ln -sf "../../../../../../usr/lib/libSystem.B${suffix}.dylib" "${DSTROOT}/${FPATH}/Versions/B/System${suffix}" || exit 1
 
+    if [[ "${PLATFORM_NAME}" =~ simulator ]] ; then
+       ln -sf "../../../../../../usr/lib/libSystem${suffix}.dylib" "${DSTROOT}/${FPATH}/Versions/B/System${suffix}" || exit 1
+    else
+       ln -sf "../../../../../../usr/lib/libSystem.B${suffix}.dylib" "${DSTROOT}/${FPATH}/Versions/B/System${suffix}" || exit 1
+    fi
 done
index f6eb7713af689d336bf4cddd56d72a22afb4897f..ea75f9fef30e60a83e85e24ecc2b6c7cdebbe361 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh -x
+#!/bin/bash -x
 
 if [ $# -ne 5 ]; then
     echo "Usage: $0 <archs> <variants> <outputdir> <sdkroot> <srcroot>" 1>&2
@@ -19,6 +19,7 @@ mkdir -p "${OUTPUTDIR}"
 for arch in ${ARCHS}; do
     for variant in ${VARIANTS}; do
        OUTPUTFILE="${OUTPUTDIR}/linker_arguments.${arch}.${variant}.txt"
+       OUTPUTCONFIG="${OUTPUTDIR}/config.${arch}.${variant}.h"
        TEMPDIR="${OUTPUTDIR}/linker_arguments_tmp"
 
        mkdir -p "${TEMPDIR}"
@@ -58,11 +59,29 @@ for arch in ${ARCHS}; do
                echo "${l}"
            fi
        done | sed -E -e 's/^lib//' -e 's/\..*$$//' | sort -u > ${INUSRLOCALLIBSYSTEM}
-       comm -12 ${ALLLIBS} ${INUSRLIBSYSTEM} > ${FROMUSRLIBSYSTEM}
-       comm -12 ${ALLLIBS} ${INUSRLOCALLIBSYSTEM} > ${POSSIBLEUSRLOCALLIBSYSTEM}
+
+       while read line ; do
+           for lib in ${line} ; do
+               egrep "^${lib}$" ${INUSRLIBSYSTEM} && break
+           done
+       done < ${ALLLIBS} > ${FROMUSRLIBSYSTEM}
+
+       while read line ; do
+           for lib in ${line} ; do
+               egrep "^${lib}$" ${INUSRLOCALLIBSYSTEM} && break
+           done
+       done < ${ALLLIBS} > ${POSSIBLEUSRLOCALLIBSYSTEM}
+
        comm -13 ${FROMUSRLIBSYSTEM} ${POSSIBLEUSRLOCALLIBSYSTEM} > ${FROMUSRLOCALLIBSYSTEM}
        cat ${FROMUSRLIBSYSTEM} ${FROMUSRLOCALLIBSYSTEM} | sort > ${ACTUALLIBS}
-       comm -23 ${REQUIREDLIBS} ${ACTUALLIBS} > ${MISSINGLIBS}
+
+       while read line ; do
+           found=0
+           for lib in ${line} ; do
+               egrep -q "^${lib}$" ${ACTUALLIBS} && found=1
+           done
+           [[ $found == 0 ]] && echo ${line}
+       done < ${REQUIREDLIBS} > ${MISSINGLIBS}
 
        if [ -s ${MISSINGLIBS} ]; then
            echo '*** missing required libs ***'
@@ -70,6 +89,10 @@ for arch in ${ARCHS}; do
            exit 1
        fi
 
+       cat ${FROMUSRLIBSYSTEM} | while read lib; do
+               echo "#define HAVE_"$(echo "${lib/_sim/}" | tr 'a-z' 'A-Z')" 1"
+       done >> "${OUTPUTCONFIG}"
+
        cat ${FROMUSRLIBSYSTEM} | while read lib; do
            echo "-Wl,-reexport-l${lib}"
        done >> "${OUTPUTFILE}"