this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Preparations for building launchd

+258 -41
+101 -33
kernel-include/sys/spawn_internal.h
··· 54 54 PSPA_SPECIAL = 0, 55 55 PSPA_EXCEPTION = 1, 56 56 PSPA_AU_SESSION = 2, 57 + PSPA_IMP_WATCHPORTS = 3, 57 58 } pspa_t; 58 59 59 60 /* ··· 88 89 #define NBINPREFS 4 89 90 90 91 /* 92 + * Mapping of opaque data pointer to a MAC policy (specified by name). 93 + */ 94 + typedef struct _ps_mac_policy_extension { 95 + char policyname[128]; 96 + union { 97 + uint64_t data; 98 + void *datap; /* pointer in kernel memory */ 99 + }; 100 + uint64_t datalen; 101 + } _ps_mac_policy_extension_t; 102 + 103 + /* 104 + * A collection of extra data passed to MAC policies for the newly spawned process. 105 + */ 106 + typedef struct _posix_spawn_mac_policy_extensions { 107 + int psmx_alloc; 108 + int psmx_count; 109 + _ps_mac_policy_extension_t psmx_extensions[]; 110 + } *_posix_spawn_mac_policy_extensions_t; 111 + 112 + /* 113 + * Returns size in bytes of a _posix_spawn_mac_policy_extensions holding x elements. 114 + */ 115 + #define PS_MAC_EXTENSIONS_SIZE(x) \ 116 + __offsetof(struct _posix_spawn_mac_policy_extensions, psmx_extensions[(x)]) 117 + 118 + #define PS_MAC_EXTENSIONS_INIT_COUNT 2 119 + 120 + 121 + /* 91 122 * A posix_spawnattr structure contains all of the attribute elements that 92 123 * can be set, as well as any metadata whose validity is signalled by the 93 124 * presence of a bit in the flags field. All fields are initialized to the ··· 95 126 */ 96 127 typedef struct _posix_spawnattr { 97 128 short psa_flags; /* spawn attribute flags */ 129 + short flags_padding; /* get the flags to be int aligned */ 98 130 sigset_t psa_sigdefault; /* signal set to default */ 99 131 sigset_t psa_sigmask; /* signal set to mask */ 100 132 pid_t psa_pgroup; /* pgroup to spawn into */ ··· 103 135 int psa_apptype; /* app type and process spec behav */ 104 136 uint64_t psa_cpumonitor_percent; /* CPU usage monitor percentage */ 105 137 uint64_t psa_cpumonitor_interval; /* CPU usage monitor interval, in seconds */ 106 - _posix_spawn_port_actions_t psa_ports; /* special/exception ports */ 107 - /* XXX - k64/u32 unaligned below here */ 108 - #if CONFIG_MEMORYSTATUS || CONFIG_EMBEDDED || TARGET_OS_EMBEDDED 109 - /* Jetsam related */ 110 - short psa_jetsam_flags; /* flags */ 111 - int psa_priority; /* relative importance */ 112 - int psa_high_water_mark; /* resident page count limit */ 113 - #endif 138 + /* 139 + * TODO: cleanup - see <rdar://problem/12858307>. psa_ports is a pointer, 140 + * meaning that the fields following differ in alignment between 32 and 141 + * 64-bit architectures. All pointers (existing and new) should therefore 142 + * be placed at the end; changing this now, however, would currently break 143 + * some legacy dependencies. The radar will be used to track resolution when 144 + * appropriate. 145 + */ 146 + 147 + short psa_jetsam_flags; /* jetsam flags */ 148 + short short_padding; /* Padding for alignment issues */ 149 + int psa_priority; /* jetsam relative importance */ 150 + int psa_high_water_mark; /* jetsam resident page count limit */ 151 + int int_padding; /* Padding for alignment issues */ 152 + /* MAC policy-specific extensions. */ 153 + _posix_spawn_port_actions_t psa_ports; /* special/exception ports */ 154 + _posix_spawn_mac_policy_extensions_t psa_mac_extensions; 114 155 } *_posix_spawnattr_t; 115 156 116 157 /* 117 158 * Jetsam flags 118 159 */ 119 - #if CONFIG_MEMORYSTATUS || CONFIG_EMBEDDED || TARGET_OS_EMBEDDED 120 - #define POSIX_SPAWN_JETSAM_USE_EFFECTIVE_PRIORITY 0x1 121 - #endif 160 + #define POSIX_SPAWN_JETSAM_SET 0x8000 161 + 162 + #define POSIX_SPAWN_JETSAM_USE_EFFECTIVE_PRIORITY 0x1 163 + #define POSIX_SPAWN_JETSAM_HIWATER_BACKGROUND 0x2 122 164 123 165 /* 124 - * DEPRECATED: maintained for transition purposes only 125 - * posix_spawn apptype settings. 166 + * Deprecated posix_spawn psa_flags values 167 + * 168 + * POSIX_SPAWN_OSX_TALAPP_START 0x0400 169 + * POSIX_SPAWN_IOS_RESV1_APP_START 0x0400 170 + * POSIX_SPAWN_IOS_APPLE_DAEMON_START 0x0800 171 + * POSIX_SPAWN_IOS_APP_START 0x1000 172 + * POSIX_SPAWN_OSX_WIDGET_START 0x0800 173 + * POSIX_SPAWN_OSX_DBCLIENT_START 0x0800 174 + * POSIX_SPAWN_OSX_RESVAPP_START 0x1000 126 175 */ 127 - #if TARGET_OS_EMBEDDED || CONFIG_EMBEDDED 128 - /* for compat sake */ 129 - #define POSIX_SPAWN_OSX_TALAPP_START 0x0400 130 - #define POSIX_SPAWN_IOS_RESV1_APP_START 0x0400 131 - #define POSIX_SPAWN_IOS_APPLE_DAEMON_START 0x0800 /* not a bug, same as widget just rename */ 132 - #define POSIX_SPAWN_IOS_APP_START 0x1000 133 - #else /* TARGET_OS_EMBEDDED */ 134 - #define POSIX_SPAWN_OSX_TALAPP_START 0x0400 135 - #define POSIX_SPAWN_OSX_WIDGET_START 0x0800 136 - #define POSIX_SPAWN_OSX_DBCLIENT_START 0x0800 /* not a bug, same as widget just rename */ 137 - #define POSIX_SPAWN_OSX_RESVAPP_START 0x1000 /* reserved for app start usages */ 138 - #endif /* TARGET_OS_EMBEDDED */ 139 176 177 + /* 178 + * Deprecated posix_spawn psa_apptype values 179 + * 180 + * POSIX_SPAWN_PROCESS_TYPE_APPLEDAEMON 0x00000001 181 + * POSIX_SPAWN_PROCESS_TYPE_UIAPP 0x00000002 182 + * POSIX_SPAWN_PROCESS_TYPE_ADAPTIVE 0x00000004 183 + * POSIX_SPAWN_PROCESS_TYPE_TAL 0x00000001 184 + * POSIX_SPAWN_PROCESS_TYPE_WIDGET 0x00000002 185 + * POSIX_SPAWN_PROCESS_TYPE_DELAYIDLESLEEP 0x10000000 186 + * 187 + * POSIX_SPAWN_PROCESS_FLAG_IMPORTANCE_DONOR 0x00000010 188 + * POSIX_SPAWN_PROCESS_FLAG_ADAPTIVE 0x00000020 189 + * POSIX_SPAWN_PROCESS_FLAG_START_BACKGROUND 0x00000040 190 + * POSIX_SPAWN_PROCESS_FLAG_START_LIGHT_THROTTLE 0x00000080 191 + */ 140 192 141 193 /* 142 - * posix_spawn apptype and process attribute settings. 194 + * posix_spawn psa_apptype process type settings. 195 + * when POSIX_SPAWN_PROC_TYPE is set, old psa_apptype bits are ignored 143 196 */ 144 - #if TARGET_OS_EMBEDDED || CONFIG_EMBEDDED 145 - #define POSIX_SPAWN_APPTYPE_IOS_APPLEDAEMON 0x0001 /* it is an iOS apple daemon */ 146 - #else /* TARGET_OS_EMBEDDED */ 147 - #define POSIX_SPAWN_APPTYPE_OSX_TAL 0x0001 /* it is a TAL app */ 148 - #define POSIX_SPAWN_APPTYPE_OSX_WIDGET 0x0002 /* it is a widget */ 149 - #define POSIX_SPAWN_APPTYPE_DELAYIDLESLEEP 0x10000000 /* Process is marked to delay idle sleep on disk IO */ 150 - #endif /* TARGET_OS_EMBEDDED */ 197 + 198 + #define POSIX_SPAWN_PROCESS_TYPE_NORMAL 0x00000000 199 + #define POSIX_SPAWN_PROCESS_TYPE_DEFAULT POSIX_SPAWN_PROCESS_TYPE_NORMAL 200 + 201 + #define POSIX_SPAWN_PROC_TYPE_MASK 0x00000F00 202 + 203 + #define POSIX_SPAWN_PROC_TYPE_APP_DEFAULT 0x00000100 204 + #define POSIX_SPAWN_PROC_TYPE_APP_TAL 0x00000200 205 + 206 + #define POSIX_SPAWN_PROC_TYPE_DAEMON_STANDARD 0x00000300 207 + #define POSIX_SPAWN_PROC_TYPE_DAEMON_INTERACTIVE 0x00000400 208 + #define POSIX_SPAWN_PROC_TYPE_DAEMON_BACKGROUND 0x00000500 209 + #define POSIX_SPAWN_PROC_TYPE_DAEMON_ADAPTIVE 0x00000600 151 210 152 211 /* 153 212 * Allowable posix_spawn() file actions ··· 238 297 __darwin_size_t port_actions_size; /* size of port actions block */ 239 298 _posix_spawn_port_actions_t 240 299 port_actions; /* pointer to port block */ 300 + __darwin_size_t mac_extensions_size; 301 + _posix_spawn_mac_policy_extensions_t 302 + mac_extensions; /* pointer to policy-specific 303 + * attributes */ 304 + 241 305 }; 242 306 243 307 #ifdef KERNEL ··· 255 319 uint32_t file_actions; /* pointer to block */ 256 320 uint32_t port_actions_size; /* size of port actions block */ 257 321 uint32_t port_actions; /* pointer to block */ 322 + uint32_t mac_extensions_size; 323 + uint32_t mac_extensions; 258 324 }; 259 325 260 326 struct user__posix_spawn_args_desc { ··· 264 330 user_addr_t file_actions; /* pointer to block */ 265 331 user_size_t port_actions_size; /* size of port actions block */ 266 332 user_addr_t port_actions; /* pointer to block */ 333 + user_size_t mac_extensions_size; /* size of MAC-specific attrs. */ 334 + user_addr_t mac_extensions; /* pointer to block */ 267 335 }; 268 336 269 337
+12
platform-include/os/assumes.h
··· 1 + #ifndef _OS_ASSUMES_H 2 + #define _OS_ASSUMES_H 3 + 4 + #define posix_assumes_zero_ctx(a, b, c) (c) 5 + #define os_assumes_zero_ctx(a, b, c) (c) 6 + #define os_assumes_zero(a) (a); 7 + #define os_assumes_ctx(a, b, c) (c) 8 + #define posix_assumes_zero(a) (a) 9 + #define __OS_COMPILETIME_ASSERT__(a) 10 + 11 + #endif 12 +
+10
platform-include/sys/spawn.h
··· 58 58 */ 59 59 #define POSIX_SPAWN_SETEXEC 0x0040 60 60 #define POSIX_SPAWN_START_SUSPENDED 0x0080 61 + #ifdef PRIVATE 62 + #define _POSIX_SPAWN_DISABLE_ASLR 0x0100 63 + /* unused 0x0200 */ 64 + /* for compat sake */ 65 + #define POSIX_SPAWN_OSX_TALAPP_START 0x0400 66 + #define POSIX_SPAWN_OSX_WIDGET_START 0x0800 67 + #define POSIX_SPAWN_OSX_DBCLIENT_START 0x0800 /* not a bug, same as widget just rename */ 68 + #define POSIX_SPAWN_OSX_RESVAPP_START 0x1000 /* reserved for app start usages */ 69 + #define _POSIX_SPAWN_ALLOW_DATA_EXEC 0x2000 70 + #endif /* PRIVATE */ 61 71 #define POSIX_SPAWN_CLOEXEC_DEFAULT 0x4000 62 72 63 73 /*
+53
platform-include/xpc/launchd.h
··· 1 + #ifndef XPC_LAUNCHD_H 2 + #define XPC_LAUNCHD_H 3 + 4 + typedef int xpc_service_type_t; 5 + typedef int xpc_jetsam_band_t; 6 + typedef char event_name_t[100]; 7 + 8 + enum { 9 + XPC_JETSAM_BAND_SUSPENDED, 10 + XPC_JETSAM_BAND_BACKGROUND_OPPORTUNISTIC, 11 + XPC_JETSAM_BAND_BACKGROUND, 12 + XPC_JETSAM_BAND_MAIL, 13 + XPC_JETSAM_BAND_PHONE, 14 + XPC_JETSAM_BAND_UI_SUPPORT, 15 + XPC_JETSAM_BAND_FOREGROUND_SUPPORT, 16 + XPC_JETSAM_BAND_FOREGROUND, 17 + XPC_JETSAM_BAND_AUDIO, 18 + XPC_JETSAM_BAND_ACCESSORY, 19 + XPC_JETSAM_BAND_CRITICAL, 20 + XPC_JETSAM_BAND_TELEPHONY, 21 + }; 22 + 23 + enum { 24 + JETSAM_PRIORITY_IDLE, 25 + JETSAM_PRIORITY_BACKGROUND_OPPORTUNISTIC, 26 + JETSAM_PRIORITY_BACKGROUND, 27 + JETSAM_PRIORITY_MAIL, 28 + JETSAM_PRIORITY_PHONE, 29 + JETSAM_PRIORITY_UI_SUPPORT, 30 + JETSAM_PRIORITY_FOREGROUND_SUPPORT, 31 + JETSAM_PRIORITY_FOREGROUND, 32 + JETSAM_PRIORITY_AUDIO_AND_ACCESSORY, 33 + JETSAM_PRIORITY_CRITICAL, 34 + JETSAM_PRIORITY_TELEPHONY, 35 + }; 36 + 37 + #define XPC_SERVICE_ENV_ATTACHED "XPC_SERVICE_ENV_ATTACHED" 38 + #define XPC_SERVICE_RENDEZVOUS_TOKEN "XPC_SERVICE_RENDEZVOUS_TOKEN" 39 + 40 + #define XPC_EVENT_ROUTINE_KEY_STREAM "STREAM" 41 + #define XPC_EVENT_ROUTINE_KEY_TOKEN "TOKEN" 42 + #define XPC_EVENT_ROUTINE_KEY_NAME "NAME" 43 + #define XPC_EVENT_ROUTINE_KEY_ENTITLEMENTS "ENTITLEMENTS" 44 + #define XPC_EVENT_ROUTINE_KEY_EVENT "EVENT" 45 + #define XPC_EVENT_ROUTINE_KEY_FLAGS "FLAGS" 46 + 47 + #define XPC_EVENT_FLAG_ENTITLEMENTS 1 48 + 49 + #define EXNOMEM 12 50 + #define EXINVAL 22 51 + 52 + #endif 53 +
+1
src/CMakeLists.txt
··· 98 98 add_subdirectory(DiskArbitration) 99 99 add_subdirectory(xar) 100 100 add_subdirectory(libedit) 101 + #add_subdirectory(launchd/src) 101 102 102 103 ###################### 103 104 # libc++ & libc++abi #
+3
src/darling-config.h.in
··· 13 13 #cmakedefine FRAMEWORK_COREAUDIO 14 14 #cmakedefine FRAMEWORK_APPKIT 15 15 16 + #ifndef __APPLE__ 17 + 16 18 /* 17 19 * Credit: 18 20 * ··· 34 36 #define __uint64_t uint64_t 35 37 /* #define __darwin_natural_t long */ 36 38 39 + #endif 37 40 38 41 #endif
+59
src/launchd/src/CMakeLists.txt
··· 1 + project(launchd) 2 + 3 + cmake_minimum_required(VERSION 2.4.0) 4 + 5 + if(COMMAND cmake_policy) 6 + cmake_policy(SET CMP0003 NEW) 7 + endif(COMMAND cmake_policy) 8 + 9 + 10 + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../external/libdispatch/) 11 + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../external/libdispatch/private) 12 + include_directories(${DARLING_TOP_DIRECTORY}/platform-include) 13 + include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 14 + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../liblaunch/) 15 + include_directories(${DARLING_TOP_DIRECTORY}/src/libc/darwin) 16 + include_directories(${DARLING_TOP_DIRECTORY}/src/libc/gen) 17 + include_directories(${DARLING_TOP_DIRECTORY}/src/libinfo/lookup.subproj) 18 + include_directories(${CMAKE_CURRENT_BINARY_DIR}) 19 + 20 + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fblocks -nostdinc -include ${DARLING_TOP_DIRECTORY}/kernel-include/sys/fileport.h -ggdb") 21 + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib") 22 + 23 + mig(job.defs) 24 + mig(helper.defs) 25 + mig(internal.defs) 26 + mig(job_forward.defs) 27 + mig(job_reply.defs) 28 + mig(mach_exc.defs) 29 + #mig(job_types.defs) 30 + #mig(protocol_jobmgr.defs) 31 + 32 + add_definitions(-DPRIVATE) 33 + 34 + set(launchd_sources 35 + core.c 36 + ipc.c 37 + kill2.c 38 + ktrace.c 39 + launchd.c 40 + log.c 41 + runtime.c 42 + ${CMAKE_CURRENT_BINARY_DIR}/jobServer.c 43 + ${CMAKE_CURRENT_BINARY_DIR}/helperUser.c 44 + ${CMAKE_CURRENT_BINARY_DIR}/internalUser.c 45 + ${CMAKE_CURRENT_BINARY_DIR}/job_forwardUser.c 46 + ${CMAKE_CURRENT_BINARY_DIR}/job_replyUser.c 47 + ${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c 48 + #${CMAKE_CURRENT_BINARY_DIR}/job_typesUser.c 49 + ) 50 + 51 + SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib${SUFFIX}/darling") 52 + SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) 53 + SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) 54 + 55 + add_executable(launchd ${launchd_sources}) 56 + target_link_libraries(launchd system) 57 + 58 + install(TARGETS launchd DESTINATION bin) 59 +
+2 -2
src/launchd/src/core.c
··· 54 54 #include <sys/socket.h> 55 55 #include <sys/syscall.h> 56 56 #include <sys/kern_memorystatus.h> 57 + #include <sys/spawn_internal.h> 58 + #include <sys/proc_info.h> 57 59 #include <net/if.h> 58 60 #include <netinet/in.h> 59 61 #include <netinet/in_var.h> ··· 76 78 #include <string.h> 77 79 #include <ctype.h> 78 80 #include <glob.h> 79 - #include <System/sys/spawn.h> 80 - #include <System/sys/spawn_internal.h> 81 81 #include <spawn.h> 82 82 #include <spawn_private.h> 83 83 #include <time.h>
+1
src/launchd/src/mach_exc.defs
··· 1 + ../../kernel/mach/mach_exc.defs
+16 -6
src/libc/include/spawn_private.h
··· 32 32 int posix_spawnattr_getpcontrol_np(const posix_spawnattr_t * __restrict, int * __restrict) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); 33 33 int posix_spawnattr_setpcontrol_np(posix_spawnattr_t *, const int) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_2); 34 34 35 - int posix_spawnattr_getapptype_np(const posix_spawnattr_t * __restrict, int * __restrict) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0); 36 - int posix_spawnattr_setapptype_np(posix_spawnattr_t *, const int) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0); 35 + int posix_spawnattr_getprocesstype_np(const posix_spawnattr_t * __restrict, int * __restrict) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0); 36 + int posix_spawnattr_setprocesstype_np(posix_spawnattr_t *, const int) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0); 37 37 38 38 int posix_spawnattr_setcpumonitor(posix_spawnattr_t * __restrict, uint64_t, uint64_t) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0); 39 39 int posix_spawnattr_getcpumonitor(posix_spawnattr_t * __restrict, uint64_t *, uint64_t *) __OSX_AVAILABLE_STARTING(__MAC_10_8, __IPHONE_6_0); 40 + int posix_spawnattr_setcpumonitor_default(posix_spawnattr_t * __restrict) __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_6_0); 41 + 40 42 41 - #if TARGET_OS_EMBEDDED 42 - int posix_spawnattr_setjetsam(posix_spawnattr_t * __restrict attr, 43 - short flags, int priority, int high_water_mark) __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_5_0); 44 - #endif 43 + #define POSIX_SPAWN_IMPORTANCE_PORT_COUNT 32 44 + int posix_spawnattr_set_importancewatch_port_np(posix_spawnattr_t * __restrict attr, 45 + int count, mach_port_t portarray[]) __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_6_0); 46 + 47 + #define POSIX_SPAWN_MACPOLICYINFO_WITHSIZE 1 48 + int posix_spawnattr_getmacpolicyinfo_np(const posix_spawnattr_t * __restrict, const char *, void **, size_t *) __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0); 49 + int posix_spawnattr_setmacpolicyinfo_np(posix_spawnattr_t * __restrict, const char *, void *, size_t) __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0); 50 + 51 + int posix_spawnattr_setcoalition_np(const posix_spawnattr_t * __restrict, uint64_t) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); 52 + 53 + int posix_spawnattr_set_qos_clamp_np(const posix_spawnattr_t * __restrict, uint64_t) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); 54 + int posix_spawnattr_get_qos_clamp_np(const posix_spawnattr_t * __restrict, uint64_t * __restrict) __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0); 45 55 46 56 #endif /* !defined _SPAWN_PRIVATE_H_*/