From a8f6861eec01727dea5315450cd9c152ddc27f59 Mon Sep 17 00:00:00 2001
From: Apple <opensource@apple.com>
Date: Thu, 22 Sep 2016 17:40:04 +0000
Subject: [PATCH] Libsystem-1238.tar.gz

---
 Libsystem.xcconfig                  | 10 +++++++
 Libsystem.xcodeproj/project.pbxproj |  3 ++-
 alloc_once_private.h                | 42 +++++++++++++++--------------
 init.c                              |  5 ++--
 optionallibs                        |  7 +----
 requiredlibs                        |  4 +++
 6 files changed, 42 insertions(+), 29 deletions(-)

diff --git a/Libsystem.xcconfig b/Libsystem.xcconfig
index e9f5bd2..2baddb0 100644
--- a/Libsystem.xcconfig
+++ b/Libsystem.xcconfig
@@ -24,3 +24,13 @@ INFOPLIST_INSTALL_PATH = Versions/B/Resources
 INFOPLIST_INSTALL_PATH[sdk=iphoneos*] =
 INFOPLIST_INSTALL_PATH[sdk=*simulator*] =
 INFOPLIST_INSTALL_PATH[sdk=watchos*] =
+INFOPLIST_OUTPUT_FORMAT = binary
+INFOPLIST_OUTPUT_FORMAT[sdk=macosx*] = xml
+APPLY_RULES_IN_COPY_FILES = YES
+PLIST_FILE_OUTPUT_FORMAT = binary
+PLIST_FILE_OUTPUT_FORMAT[sdk=macosx*] = xml
+
+// override presence of $(EXECUTABLE_VARIANT_SUFFIX) in the default EXECUTABLE_NAME rdar://26234727
+DYLIB_INSTALL_NAME_EXECUTABLE_NAME = $(EXECUTABLE_PREFIX)$(PRODUCT_NAME)$(EXECUTABLE_SUFFIX)
+DYLIB_INSTALL_NAME_EXECUTABLE_PATH = $(DYLIB_INSTALL_NAME_EXECUTABLE_NAME)
+LD_DYLIB_INSTALL_NAME = $(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(DYLIB_INSTALL_NAME_EXECUTABLE_PATH)
diff --git a/Libsystem.xcodeproj/project.pbxproj b/Libsystem.xcodeproj/project.pbxproj
index ab049ea..7339ac6 100644
--- a/Libsystem.xcodeproj/project.pbxproj
+++ b/Libsystem.xcodeproj/project.pbxproj
@@ -180,7 +180,7 @@
 		BA5511A9136C9D400012B9B5 /* Project object */ = {
 			isa = PBXProject;
 			attributes = {
-				LastUpgradeCheck = 0420;
+				LastUpgradeCheck = 0700;
 			};
 			buildConfigurationList = BA5511AC136C9D400012B9B5 /* Build configuration list for PBXProject "Libsystem" */;
 			compatibilityVersion = "Xcode 3.2";
@@ -287,6 +287,7 @@
 			buildSettings = {
 				PRODUCT_NAME = "$(TARGET_NAME).B";
 				"PRODUCT_NAME[sdk=iphonesimulator*]" = "$(TARGET_NAME)";
+				SDKROOT = macosx.internal;
 			};
 			name = Release;
 		};
diff --git a/alloc_once_private.h b/alloc_once_private.h
index da5a5ea..a565d45 100644
--- a/alloc_once_private.h
+++ b/alloc_once_private.h
@@ -38,26 +38,28 @@
 /* Keys for use with os_once_alloc. */
 
 /* Keys for Libsystem. */
-#define OS_ALLOC_ONCE_KEY_LIBSYSTEM_NOTIFY	0
-#define OS_ALLOC_ONCE_KEY_LIBXPC	1
-#define OS_ALLOC_ONCE_KEY_LIBSYSTEM_C	2
-#define OS_ALLOC_ONCE_KEY_LIBSYSTEM_INFO	3
-#define OS_ALLOC_ONCE_KEY_LIBSYSTEM_NETWORK	4
-#define OS_ALLOC_ONCE_KEY_LIBCACHE	5
-#define OS_ALLOC_ONCE_KEY_LIBCOMMONCRYPTO	6
-#define OS_ALLOC_ONCE_KEY_LIBDISPATCH	7
-#define OS_ALLOC_ONCE_KEY_LIBDYLD	8
-#define OS_ALLOC_ONCE_KEY_LIBKEYMGR	9
-#define OS_ALLOC_ONCE_KEY_LIBLAUNCH	10
-#define OS_ALLOC_ONCE_KEY_LIBMACHO	11
-#define OS_ALLOC_ONCE_KEY_OS_TRACE	12
-#define OS_ALLOC_ONCE_KEY_LIBSYSTEM_BLOCKS	13
-#define OS_ALLOC_ONCE_KEY_LIBSYSTEM_MALLOC	14
-#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
+#define OS_ALLOC_ONCE_KEY_LIBSYSTEM_NOTIFY			0
+#define OS_ALLOC_ONCE_KEY_LIBXPC					1
+#define OS_ALLOC_ONCE_KEY_LIBSYSTEM_C				2
+#define OS_ALLOC_ONCE_KEY_LIBSYSTEM_INFO			3
+#define OS_ALLOC_ONCE_KEY_LIBSYSTEM_NETWORK			4
+#define OS_ALLOC_ONCE_KEY_LIBCACHE					5
+#define OS_ALLOC_ONCE_KEY_LIBCOMMONCRYPTO			6
+#define OS_ALLOC_ONCE_KEY_LIBDISPATCH				7
+#define OS_ALLOC_ONCE_KEY_LIBDYLD					8
+#define OS_ALLOC_ONCE_KEY_LIBKEYMGR					9
+#define OS_ALLOC_ONCE_KEY_LIBLAUNCH					10
+#define OS_ALLOC_ONCE_KEY_LIBMACHO					11
+#define OS_ALLOC_ONCE_KEY_OS_TRACE					12
+#define OS_ALLOC_ONCE_KEY_LIBSYSTEM_BLOCKS			13
+#define OS_ALLOC_ONCE_KEY_LIBSYSTEM_MALLOC			14
+#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
+#define OS_ALLOC_ONCE_KEY_LIBSYSTEM_SYMPTOMS		20
+#define OS_ALLOC_ONCE_KEY_LIBSYSTEM_PLATFORM_ASL	21
 
 /* 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 254815e..e684473 100644
--- a/init.c
+++ b/init.c
@@ -144,20 +144,21 @@ libSystem_initializer(int argc,
 	__libkernel_init(&libkernel_funcs, envp, apple, vars);
 
 	__libplatform_init(NULL, envp, apple, vars);
+
 	__pthread_init(&libpthread_funcs, envp, apple, vars);
+
 	_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_OS_SIMULATOR
+#if !TARGET_OS_SIMULATOR && !TARGET_OS_TV && !TARGET_OS_WATCH
 	/* <rdar://problem/9664631> */
 	__keymgr_initializer();
 #endif
 
 	_dyld_initializer();
 
-
 	libdispatch_init();
 	_libxpc_initializer();
 
diff --git a/optionallibs b/optionallibs
index 2885215..6308f5b 100644
--- a/optionallibs
+++ b/optionallibs
@@ -1,12 +1,7 @@
 keymgr
 quarantine
 system_containermanager
-system_coreservices
-system_coretls
-system_network
 system_networkextension
 system_secinit
-system_sim_trace
-system_trace
-unc
+system_symptoms
 vminterpose
diff --git a/requiredlibs b/requiredlibs
index 55c06a9..5343f7c 100644
--- a/requiredlibs
+++ b/requiredlibs
@@ -12,14 +12,18 @@ system_asl
 system_blocks
 system_c
 system_configuration
+system_coreservices
+system_coretls
 system_dnssd
 system_info
 system_kernel system_sim_kernel
 system_m
 system_malloc
+system_network
 system_notify
 system_platform system_sim_platform
 system_pthread system_sim_pthread
 system_sandbox
+system_trace
 unwind unwind_sim
 xpc
-- 
2.47.2