]> git.saurik.com Git - apple/launchd.git/blobdiff - liblaunch/launch_internal.h
launchd-842.92.1.tar.gz
[apple/launchd.git] / liblaunch / launch_internal.h
index aa6576f8e2772a9866e92d1d3f30d80304b38b0f..a78d4bd4277b62a6163bb4ce19dc598ae6725e0e 100644 (file)
@@ -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@
  * 
 #ifndef __LAUNCH_INTERNAL_H__
 #define __LAUNCH_INTERNAL_H__
 
+#include "vproc_priv.h"
+
 #include <paths.h>
+#include <dispatch/dispatch.h>
+#include <pthread.h>
+
+#if __has_include(<os/alloc_once_private.h>)
+#include <os/alloc_once_private.h>
+#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);