X-Git-Url: https://git.saurik.com/apple/launchd.git/blobdiff_plain/eabd170121c913d6b497fa2503e49f09f5412ddc..refs/heads/master:/liblaunch/launch_internal.h diff --git a/liblaunch/launch_internal.h b/liblaunch/launch_internal.h index aa6576f..a78d4bd 100644 --- a/liblaunch/launch_internal.h +++ b/liblaunch/launch_internal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2007-2012 Apple Inc. All rights reserved. * * @APPLE_APACHE_LICENSE_HEADER_START@ * @@ -21,14 +21,69 @@ #ifndef __LAUNCH_INTERNAL_H__ #define __LAUNCH_INTERNAL_H__ +#include "vproc_priv.h" + #include +#include +#include + +#if __has_include() +#include +#if defined(OS_ALLOC_ONCE_KEY_LIBLAUNCH) +#define _LIBLAUNCH_HAS_ALLOC_ONCE 1 +#endif +#endif + +typedef struct _launch *launch_t; + +struct launch_globals_s { + // liblaunch.c + pthread_once_t lc_once; + pthread_mutex_t lc_mtx; + launch_t l; + launch_data_t async_resp; + + launch_t in_flight_msg_recv_client; + + int64_t s_am_embedded_god; + + // libvproc.c + dispatch_queue_t _vproc_gone2zero_queue; + _vproc_transaction_callout _vproc_gone2zero_callout; + void *_vproc_gone2zero_ctx; + + dispatch_once_t _vproc_transaction_once; + uint64_t _vproc_transaction_enabled; + dispatch_queue_t _vproc_transaction_queue; + int64_t _vproc_transaction_cnt; +}; +typedef struct launch_globals_s *launch_globals_t; + +void _launch_init_globals(launch_globals_t globals); + +#if !_LIBLAUNCH_HAS_ALLOC_ONCE +launch_globals_t _launch_globals_impl(void); +#endif + +__attribute__((__pure__)) +static inline launch_globals_t +_launch_globals(void) { +#if _LIBLAUNCH_HAS_ALLOC_ONCE + return (launch_globals_t)os_alloc_once(OS_ALLOC_ONCE_KEY_LIBLAUNCH, + sizeof(struct launch_globals_s), + (void*)&_launch_init_globals); +#else + return _launch_globals_impl(); +#endif +} #pragma GCC visibility push(default) #define LAUNCHD_DB_PREFIX "/private/var/db/launchd.db" #define LAUNCHD_LOG_PREFIX "/private/var/log" -typedef struct _launch *launch_t; +#define LAUNCHD_JOB_DEFAULTS "Defaults" +#define LAUNCHD_JOB_DEFAULTS_CACHED "CachedDefaults" launch_t launchd_fdopen(int, int); int launchd_getfd(launch_t);