[launchd-changes] [23479] trunk/launchd/src
source_changes at macosforge.org
source_changes at macosforge.org
Wed Jan 9 14:18:12 PST 2008
Revision: 23479
http://trac.macosforge.org/projects/launchd/changeset/23479
Author: zarzycki at apple.com
Date: 2008-01-09 14:18:09 -0800 (Wed, 09 Jan 2008)
Log Message:
-----------
We should use a better internal ABI when we can.
Modified Paths:
--------------
trunk/launchd/src/Makefile.am
trunk/launchd/src/Makefile.in
trunk/launchd/src/launchd.c
trunk/launchd/src/launchd.h
trunk/launchd/src/launchd_core_logic.c
trunk/launchd/src/launchd_core_logic.h
trunk/launchd/src/launchd_runtime.c
trunk/launchd/src/launchd_runtime.h
trunk/launchd/src/launchd_unix_ipc.c
Modified: trunk/launchd/src/Makefile.am
===================================================================
--- trunk/launchd/src/Makefile.am 2008-01-09 17:35:12 UTC (rev 23478)
+++ trunk/launchd/src/Makefile.am 2008-01-09 22:18:09 UTC (rev 23479)
@@ -1,4 +1,4 @@
-AM_CFLAGS = -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wfloat-equal -Wshadow -Wpacked -Wpadded -Wstrict-overflow=4 -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -freorder-blocks -Dmig_external=__private_extern__
+AM_CFLAGS = -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wfloat-equal -Wshadow -Wpacked -Wpadded -Wstrict-overflow=4 -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -Dmig_external=__private_extern__
CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \
launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c \
@@ -46,7 +46,7 @@
SystemStarter_LDFLAGS = -framework CoreFoundation -framework IOKit
SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c
-launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing
+launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -freorder-blocks # -fomit-frame-pointer # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing
launchd_LDFLAGS = -lbsm
launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c job_forwardUser.c mach_excServer.c
Modified: trunk/launchd/src/Makefile.in
===================================================================
--- trunk/launchd/src/Makefile.in 2008-01-09 17:35:12 UTC (rev 23478)
+++ trunk/launchd/src/Makefile.in 2008-01-09 22:18:09 UTC (rev 23479)
@@ -238,7 +238,7 @@
target_alias = @target_alias@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-AM_CFLAGS = -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wfloat-equal -Wshadow -Wpacked -Wpadded -Wstrict-overflow=4 -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -freorder-blocks -Dmig_external=__private_extern__
+AM_CFLAGS = -F/System/Library/PrivateFrameworks -Wall -Wextra -Waggregate-return -Wfloat-equal -Wshadow -Wpacked -Wpadded -Wstrict-overflow=4 -Wmissing-prototypes -Wmissing-declarations -Werror -D__MigTypeCheck=1 -fvisibility=hidden -Dmig_external=__private_extern__
CLEANFILES = protocol_vproc.h protocol_vprocServer.c protocol_vprocUser.c protocol_vprocServer.h \
launchd_internal.h launchd_internalServer.h launchd_internalServer.c launchd_internalUser.c \
notifyServer.c notifyServer.h job_replyUser.c job_reply.h __version.c mach_excServer.c mach_excServer.h
@@ -254,7 +254,7 @@
@LIBS_ONLY_FALSE at SystemStarter_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS)
@LIBS_ONLY_FALSE at SystemStarter_LDFLAGS = -framework CoreFoundation -framework IOKit
@LIBS_ONLY_FALSE at SystemStarter_SOURCES = StartupItems.c IPC.c SystemStarter.c
- at LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing
+ at LIBS_ONLY_FALSE@launchd_CFLAGS = -mdynamic-no-pic $(AM_CFLAGS) -freorder-blocks # -fomit-frame-pointer # -Wconversion # -Wstrict-aliasing=2 -fstrict-aliasing
@LIBS_ONLY_FALSE at launchd_LDFLAGS = -lbsm
@LIBS_ONLY_FALSE at launchd_SOURCES = launchd.c launchd_core_logic.c launchd_unix_ipc.c protocol_vprocServer.c notifyServer.c launchd_internalUser.c launchd_internalServer.c job_replyUser.c launchd_runtime.c launchd_runtime_kill.c job_forwardUser.c mach_excServer.c
@LIBS_ONLY_FALSE at launchproxy_LDFLAGS = -weak_framework Security
Modified: trunk/launchd/src/launchd.c
===================================================================
--- trunk/launchd/src/launchd.c 2008-01-09 17:35:12 UTC (rev 23478)
+++ trunk/launchd/src/launchd.c 2008-01-09 22:18:09 UTC (rev 23479)
@@ -227,7 +227,7 @@
}
-int
+INTERNAL_ABI int
_fd(int fd)
{
if (fd >= 0) {
@@ -242,7 +242,7 @@
launchd_assumes(mkdir(SHUTDOWN_LOG_DIR, S_IRWXU) != -1 || errno == EEXIST);
}
-void
+INTERNAL_ABI void
launchd_shutdown(void)
{
int64_t now;
@@ -271,7 +271,7 @@
launchd_assert(jobmgr_shutdown(root_jobmgr) != NULL);
}
-void
+INTERNAL_ABI void
launchd_single_user(void)
{
runtime_syslog(LOG_NOTICE, "Going to single-user mode");
@@ -285,7 +285,7 @@
runtime_kill(-1, SIGKILL);
}
-void
+INTERNAL_ABI void
launchd_SessionCreate(void)
{
OSStatus (*sescr)(SessionCreationFlags flags, SessionAttributeBits attributes);
@@ -392,7 +392,7 @@
}
}
-void
+INTERNAL_ABI bool
_log_launchd_bug(const char *rcs_rev, const char *path, unsigned int line, const char *test)
{
int saved_errno = errno;
@@ -417,4 +417,6 @@
}
runtime_syslog(LOG_NOTICE, "Bug: %s:%u (%s):%u: %s", file, line, buf, saved_errno, test);
+
+ return false;
}
Modified: trunk/launchd/src/launchd.h
===================================================================
--- trunk/launchd/src/launchd.h 2008-01-09 17:35:12 UTC (rev 23478)
+++ trunk/launchd/src/launchd.h 2008-01-09 22:18:09 UTC (rev 23479)
@@ -35,16 +35,16 @@
extern bool fake_shutdown_in_progress;
extern bool network_up;
-bool init_check_pid(pid_t);
+INTERNAL_ABI bool init_check_pid(pid_t);
-launch_data_t launchd_setstdio(int d, launch_data_t o);
-void launchd_SessionCreate(void);
-void launchd_shutdown(void);
-void launchd_single_user(void);
+INTERNAL_ABI launch_data_t launchd_setstdio(int d, launch_data_t o);
+INTERNAL_ABI void launchd_SessionCreate(void);
+INTERNAL_ABI void launchd_shutdown(void);
+INTERNAL_ABI void launchd_single_user(void);
boolean_t launchd_mach_ipc_demux(mach_msg_header_t *Request, mach_msg_header_t *Reply);
-void mach_start_shutdown(void);
+INTERNAL_ABI void mach_start_shutdown(void);
-int _fd(int fd);
+INTERNAL_ABI int _fd(int fd);
#endif
Modified: trunk/launchd/src/launchd_core_logic.c
===================================================================
--- trunk/launchd/src/launchd_core_logic.c 2008-01-09 17:35:12 UTC (rev 23478)
+++ trunk/launchd/src/launchd_core_logic.c 2008-01-09 22:18:09 UTC (rev 23479)
@@ -275,7 +275,7 @@
};
#define jobmgr_assumes(jm, e) \
- (likely(e) ? true : jobmgr_log_bug(jm, __LINE__), false)
+ (likely(e) ? true : jobmgr_log_bug(jm, __LINE__))
static jobmgr_t jobmgr_new(jobmgr_t jm, mach_port_t requestorport, mach_port_t transfer_port, bool sflag, const char *name);
static job_t jobmgr_import2(jobmgr_t jm, launch_data_t pload);
@@ -296,7 +296,7 @@
static void jobmgr_logv(jobmgr_t jm, int pri, int err, const char *msg, va_list ap) __attribute__((format(printf, 4, 0)));
static void jobmgr_log(jobmgr_t jm, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4)));
/* static void jobmgr_log_error(jobmgr_t jm, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4))); */
-static void jobmgr_log_bug(jobmgr_t jm, unsigned int line);
+static bool jobmgr_log_bug(jobmgr_t jm, unsigned int line);
#define DO_RUSAGE_SUMMATION 0
@@ -375,7 +375,7 @@
#define job_assumes(j, e) \
- (likely(e) ? true : job_log_bug(j, __LINE__), false)
+ (likely(e) ? true : job_log_bug(j, __LINE__))
static void job_import_keys(launch_data_t obj, const char *key, void *context);
static void job_import_bool(job_t j, const char *key, bool value);
@@ -417,7 +417,7 @@
static void job_log_stdouterr(job_t j);
static void job_logv(job_t j, int pri, int err, const char *msg, va_list ap) __attribute__((format(printf, 4, 0)));
static void job_log_error(job_t j, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4)));
-static void job_log_bug(job_t j, unsigned int line);
+static bool job_log_bug(job_t j, unsigned int line);
static void job_log_stdouterr2(job_t j, const char *msg, ...);
static void job_set_exeception_port(job_t j, mach_port_t port);
static kern_return_t job_handle_mpm_wait(job_t j, mach_port_t srp, int *waitstatus);
@@ -530,7 +530,7 @@
}
}
-void
+INTERNAL_ABI void
job_stop(job_t j)
{
if (!j->p || j->anonymous) {
@@ -548,7 +548,7 @@
job_log(j, LOG_DEBUG, "Sent SIGTERM signal");
}
-launch_data_t
+INTERNAL_ABI launch_data_t
job_export(job_t j)
{
launch_data_t tmp, tmp2, tmp3, r = launch_data_alloc(LAUNCH_DATA_DICTIONARY);
@@ -690,7 +690,7 @@
runtime_closelog(); /* hack to flush logs */
}
-jobmgr_t
+INTERNAL_ABI jobmgr_t
jobmgr_shutdown(jobmgr_t jm)
{
jobmgr_t jmi, jmn;
@@ -773,7 +773,7 @@
free(jm);
}
-void
+INTERNAL_ABI void
job_remove(job_t j)
{
struct waiting_for_removal *w4r;
@@ -1273,7 +1273,7 @@
return NULL;
}
-job_t
+INTERNAL_ABI job_t
job_import(launch_data_t pload)
{
job_t j = jobmgr_import2(root_jobmgr, pload);
@@ -1285,7 +1285,7 @@
return job_dispatch(j, false);
}
-launch_data_t
+INTERNAL_ABI launch_data_t
job_import_bulk(launch_data_t pload)
{
launch_data_t resp = launch_data_alloc(LAUNCH_DATA_ARRAY);
@@ -1895,7 +1895,7 @@
return j;
}
-job_t
+INTERNAL_ABI job_t
job_find(const char *label)
{
job_t ji;
@@ -1964,7 +1964,7 @@
return NULL;
}
-job_t
+INTERNAL_ABI job_t
job_mig_intran(mach_port_t p)
{
struct ldcred ldc;
@@ -1990,7 +1990,7 @@
return jr;
}
-job_t
+INTERNAL_ABI job_t
job_find_by_service_port(mach_port_t p)
{
struct machservice *ms;
@@ -2004,7 +2004,7 @@
return NULL;
}
-void
+INTERNAL_ABI void
job_mig_destructor(job_t j)
{
/*
@@ -2042,7 +2042,7 @@
}
}
-launch_data_t
+INTERNAL_ABI launch_data_t
job_export_all(void)
{
launch_data_t resp = launch_data_alloc(LAUNCH_DATA_DICTIONARY);
@@ -2255,7 +2255,7 @@
}
}
-job_t
+INTERNAL_ABI job_t
job_dispatch(job_t j, bool kickstart)
{
/*
@@ -3239,7 +3239,7 @@
}
}
-void
+bool
jobmgr_log_bug(jobmgr_t jm, unsigned int line)
{
static const char *file;
@@ -3263,9 +3263,11 @@
} else {
runtime_syslog(LOG_NOTICE, "Bug: %s:%u (%s):%u", file, line, buf, saved_errno);
}
+
+ return false;
}
-void
+bool
job_log_bug(job_t j, unsigned int line)
{
static const char *file;
@@ -3289,6 +3291,8 @@
} else {
runtime_syslog(LOG_NOTICE, "Bug: %s:%u (%s):%u", file, line, buf, saved_errno);
}
+
+ return false;
}
void
@@ -3338,7 +3342,7 @@
va_end(ap);
}
-void
+INTERNAL_ABI void
job_log(job_t j, int pri, const char *msg, ...)
{
va_list ap;
@@ -4587,7 +4591,7 @@
return bootstrapper;
}
-jobmgr_t
+INTERNAL_ABI jobmgr_t
jobmgr_delete_anything_with_port(jobmgr_t jm, mach_port_t port)
{
struct machservice *ms, *next_ms;
@@ -4787,13 +4791,13 @@
return argv_ret;
}
-void
+INTERNAL_ABI void
job_checkin(job_t j)
{
j->checkedin = true;
}
-bool
+INTERNAL_ABI bool
job_ack_port_destruction(mach_port_t p)
{
struct machservice *ms;
@@ -4822,7 +4826,7 @@
return true;
}
-void
+INTERNAL_ABI void
job_ack_no_senders(job_t j)
{
j->priv_port_has_senders = false;
@@ -4845,7 +4849,7 @@
return NULL;
}
-bool
+INTERNAL_ABI bool
job_is_anonymous(job_t j)
{
return j->anonymous;
@@ -5064,7 +5068,7 @@
}
}
-void
+INTERNAL_ABI void
jobmgr_dispatch_all_semaphores(jobmgr_t jm)
{
jobmgr_t jmi, jmn;
@@ -6666,7 +6670,7 @@
return BOOTSTRAP_SUCCESS;
}
-void
+INTERNAL_ABI void
jobmgr_init(bool sflag)
{
const char *root_session_type = getpid() == 1 ? VPROCMGR_SESSION_SYSTEM : VPROCMGR_SESSION_BACKGROUND;
Modified: trunk/launchd/src/launchd_core_logic.h
===================================================================
--- trunk/launchd/src/launchd_core_logic.h 2008-01-09 17:35:12 UTC (rev 23478)
+++ trunk/launchd/src/launchd_core_logic.h 2008-01-09 22:18:09 UTC (rev 23479)
@@ -20,6 +20,7 @@
* @APPLE_APACHE_LICENSE_HEADER_END@
*/
+#include <launchd_runtime.h>
#include "libbootstrap_public.h"
#include "liblaunch_public.h"
@@ -29,27 +30,27 @@
extern jobmgr_t root_jobmgr;
extern mach_port_t inherited_bootstrap_port;
-void jobmgr_init(bool);
-jobmgr_t jobmgr_shutdown(jobmgr_t jm);
-void jobmgr_dispatch_all_semaphores(jobmgr_t jm);
-jobmgr_t jobmgr_delete_anything_with_port(jobmgr_t jm, mach_port_t port);
+INTERNAL_ABI void jobmgr_init(bool);
+INTERNAL_ABI jobmgr_t jobmgr_shutdown(jobmgr_t jm);
+INTERNAL_ABI void jobmgr_dispatch_all_semaphores(jobmgr_t jm);
+INTERNAL_ABI jobmgr_t jobmgr_delete_anything_with_port(jobmgr_t jm, mach_port_t port);
-launch_data_t job_export_all(void);
+INTERNAL_ABI launch_data_t job_export_all(void);
-job_t job_dispatch(job_t j, bool kickstart); /* returns j on success, NULL on job removal */
-job_t job_find(const char *label);
-job_t job_find_by_service_port(mach_port_t p);
-bool job_ack_port_destruction(mach_port_t p);
-bool job_is_anonymous(job_t j);
-launch_data_t job_export(job_t j);
-void job_stop(job_t j);
-void job_checkin(job_t j);
-void job_remove(job_t j);
-job_t job_import(launch_data_t pload);
-launch_data_t job_import_bulk(launch_data_t pload);
-job_t job_mig_intran(mach_port_t mp);
-void job_mig_destructor(job_t j);
-void job_ack_no_senders(job_t j);
-void job_log(job_t j, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4)));
+INTERNAL_ABI job_t job_dispatch(job_t j, bool kickstart); /* returns j on success, NULL on job removal */
+INTERNAL_ABI job_t job_find(const char *label);
+INTERNAL_ABI job_t job_find_by_service_port(mach_port_t p);
+INTERNAL_ABI bool job_ack_port_destruction(mach_port_t p);
+INTERNAL_ABI bool job_is_anonymous(job_t j);
+INTERNAL_ABI launch_data_t job_export(job_t j);
+INTERNAL_ABI void job_stop(job_t j);
+INTERNAL_ABI void job_checkin(job_t j);
+INTERNAL_ABI void job_remove(job_t j);
+INTERNAL_ABI job_t job_import(launch_data_t pload);
+INTERNAL_ABI launch_data_t job_import_bulk(launch_data_t pload);
+INTERNAL_ABI job_t job_mig_intran(mach_port_t mp);
+INTERNAL_ABI void job_mig_destructor(job_t j);
+INTERNAL_ABI void job_ack_no_senders(job_t j);
+INTERNAL_ABI void job_log(job_t j, int pri, const char *msg, ...) __attribute__((format(printf, 3, 4)));
#endif
Modified: trunk/launchd/src/launchd_runtime.c
===================================================================
--- trunk/launchd/src/launchd_runtime.c 2008-01-09 17:35:12 UTC (rev 23478)
+++ trunk/launchd/src/launchd_runtime.c 2008-01-09 22:18:09 UTC (rev 23479)
@@ -122,7 +122,7 @@
static FILE *ourlogfile;
-mach_port_t
+INTERNAL_ABI mach_port_t
runtime_get_kernel_port(void)
{
return launchd_internal_port;
@@ -132,7 +132,7 @@
//static int internal_mask_pri = LOG_UPTO(LOG_DEBUG);
-void
+INTERNAL_ABI void
launchd_runtime_init(void)
{
mach_msg_size_t mxmsgsz;
@@ -167,7 +167,7 @@
pthread_attr_destroy(&attr);
}
-void
+INTERNAL_ABI void
launchd_runtime_init2(void)
{
size_t i;
@@ -197,7 +197,7 @@
return NULL;
}
-const char *
+INTERNAL_ABI const char *
proc_flags_to_C_names(unsigned int flags)
{
#define MAX_PFLAG_STR "P_ADVLOCK|P_CONTROLT|P_LP64|P_NOCLDSTOP|P_PPWAIT|P_PROFIL|P_SELECT|P_CONTINUED|P_SUGID|P_SYSTEM|P_TIMEOUT|P_TRACED|P_RESV3|P_WEXIT|P_EXEC|P_OWEUPC|P_AFFINITY|P_TRANSLATED|P_RESV5|P_CHECKOPENEVT|P_DEPENDENCY_CAPABLE|P_REBOOT|P_TBE|P_RESV7|P_THCWD|P_RESV9|P_RESV10|P_RESV11|P_NOSHLIB|P_FORCEQUOTA|P_NOCLDWAIT|P_NOREMOTEHANG|0xdeadbeeffeedface"
@@ -261,7 +261,7 @@
return flags_buf;
}
-const char *
+INTERNAL_ABI const char *
reboot_flags_to_C_names(unsigned int flags)
{
#define MAX_RB_STR "RB_ASKNAME|RB_SINGLE|RB_NOSYNC|RB_HALT|RB_INITNAME|RB_DFLTROOT|RB_ALTBOOT|RB_UNIPROC|RB_SAFEBOOT|RB_UPSDELAY|0xdeadbeeffeedface"
@@ -300,7 +300,7 @@
return flags_buf;
}
-const char *
+INTERNAL_ABI const char *
signal_to_C_name(unsigned int sig)
{
static char unknown[25];
@@ -621,7 +621,7 @@
-void
+INTERNAL_ABI void
launchd_runtime(void)
{
mig_reply_error_t *req = NULL, *resp = NULL;
@@ -653,19 +653,19 @@
}
}
-kern_return_t
+INTERNAL_ABI kern_return_t
launchd_set_bport(mach_port_t name)
{
return errno = task_set_bootstrap_port(mach_task_self(), name);
}
-kern_return_t
+INTERNAL_ABI kern_return_t
launchd_get_bport(mach_port_t *name)
{
return errno = task_get_bootstrap_port(mach_task_self(), name);
}
-kern_return_t
+INTERNAL_ABI kern_return_t
launchd_mport_notify_req(mach_port_t name, mach_msg_id_t which)
{
mach_port_mscount_t msgc = (which == MACH_NOTIFY_PORT_DESTROYED) ? 0 : 1;
@@ -689,7 +689,7 @@
return errno;
}
-pid_t
+INTERNAL_ABI pid_t
runtime_fork(mach_port_t bsport)
{
sigset_t emptyset, oset;
@@ -727,7 +727,7 @@
}
-void
+INTERNAL_ABI void
runtime_set_timeout(timeout_callback to_cb, unsigned int sec)
{
if (sec == 0 || to_cb == NULL) {
@@ -739,7 +739,7 @@
runtime_idle_timeout = sec * 1000;
}
-kern_return_t
+INTERNAL_ABI kern_return_t
runtime_add_mport(mach_port_t name, mig_callback demux, mach_msg_size_t msg_size)
{
size_t needed_table_sz = (MACH_PORT_INDEX(name) + 1) * sizeof(mig_callback);
@@ -773,7 +773,7 @@
return errno = mach_port_move_member(mach_task_self(), name, target_set);
}
-kern_return_t
+INTERNAL_ABI kern_return_t
runtime_remove_mport(mach_port_t name)
{
mig_cb_table[MACH_PORT_INDEX(name)] = NULL;
@@ -781,31 +781,31 @@
return errno = mach_port_move_member(mach_task_self(), name, MACH_PORT_NULL);
}
-kern_return_t
+INTERNAL_ABI kern_return_t
launchd_mport_make_send(mach_port_t name)
{
return errno = mach_port_insert_right(mach_task_self(), name, name, MACH_MSG_TYPE_MAKE_SEND);
}
-kern_return_t
+INTERNAL_ABI kern_return_t
launchd_mport_close_recv(mach_port_t name)
{
return errno = mach_port_mod_refs(mach_task_self(), name, MACH_PORT_RIGHT_RECEIVE, -1);
}
-kern_return_t
+INTERNAL_ABI kern_return_t
launchd_mport_create_recv(mach_port_t *name)
{
return errno = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, name);
}
-kern_return_t
+INTERNAL_ABI kern_return_t
launchd_mport_deallocate(mach_port_t name)
{
return errno = mach_port_deallocate(mach_task_self(), name);
}
-int
+INTERNAL_ABI int
kevent_bulk_mod(struct kevent *kev, size_t kev_cnt)
{
size_t i;
@@ -817,7 +817,7 @@
return kevent(mainkq, kev, kev_cnt, kev, kev_cnt, NULL);
}
-int
+INTERNAL_ABI int
kevent_mod(uintptr_t ident, short filter, u_short flags, u_int fflags, intptr_t data, void *udata)
{
struct kevent kev;
@@ -966,7 +966,7 @@
au_tok = &tp->msgh_audit;
}
-bool
+INTERNAL_ABI bool
runtime_get_caller_creds(struct ldcred *ldc)
{
if (unlikely(!au_tok)) {
@@ -1098,7 +1098,7 @@
}
}
-int
+INTERNAL_ABI int
runtime_close(int fd)
{
int i;
@@ -1108,7 +1108,7 @@
case EVFILT_VNODE:
case EVFILT_WRITE:
case EVFILT_READ:
- if ((int)bulk_kev[i].ident == fd) {
+ if (unlikely((int)bulk_kev[i].ident == fd)) {
runtime_syslog(LOG_DEBUG, "Skipping kevent index: %d", i);
bulk_kev[i].filter = 0;
}
@@ -1120,7 +1120,7 @@
return close(fd);
}
-void
+INTERNAL_ABI void
runtime_closelog(void)
{
runtime_log_push();
@@ -1131,7 +1131,7 @@
}
}
-int
+INTERNAL_ABI int
runtime_fsync(int fd)
{
#if 0
@@ -1145,7 +1145,7 @@
#endif
}
-int
+INTERNAL_ABI int
runtime_setlogmask(int maskpri)
{
internal_mask_pri = maskpri;
@@ -1153,7 +1153,7 @@
return internal_mask_pri;
}
-void
+INTERNAL_ABI void
runtime_syslog(int pri, const char *message, ...)
{
struct runtime_syslog_attr attr = {
@@ -1170,7 +1170,7 @@
va_end(ap);
}
-void
+INTERNAL_ABI void
runtime_vsyslog(struct runtime_syslog_attr *attr, const char *message, va_list args)
{
int saved_errno = errno;
@@ -1314,7 +1314,7 @@
}
#endif
-void
+INTERNAL_ABI void
runtime_log_push(void)
{
static pthread_mutex_t ourlock = PTHREAD_MUTEX_INITIALIZER;
@@ -1368,7 +1368,7 @@
}
}
-kern_return_t
+INTERNAL_ABI kern_return_t
runtime_log_forward(uid_t forward_uid, gid_t forward_gid, vm_offset_t inval, mach_msg_type_number_t invalCnt)
{
struct logmsg_s *lm, *lm_walk;
@@ -1404,7 +1404,7 @@
return 0;
}
-kern_return_t
+INTERNAL_ABI kern_return_t
runtime_log_drain(mach_port_t srp, vm_offset_t *outval, mach_msg_type_number_t *outvalCnt)
{
launchd_assumes(drain_reply_port == 0);
@@ -1428,13 +1428,13 @@
* In the long run, reference counting should completely automate when a
* process can and should exit.
*/
-void
+INTERNAL_ABI void
runtime_add_ref(void)
{
runtime_busy_cnt++;
}
-void
+INTERNAL_ABI void
runtime_del_ref(void)
{
runtime_busy_cnt--;
@@ -1494,7 +1494,7 @@
return 0;
}
-void
+INTERNAL_ABI void
launchd_log_vm_stats(void)
{
static struct vm_statistics orig_stats;
@@ -1542,7 +1542,7 @@
launchd_mport_deallocate(mhs);
}
-bool
+INTERNAL_ABI bool
do_apple_internal_logging(void)
{
static int apple_internal_logging = 1;
@@ -1555,7 +1555,7 @@
return (apple_internal_logging == 0);
}
-int64_t
+INTERNAL_ABI int64_t
runtime_get_wall_time(void)
{
struct timeval tv;
@@ -1570,13 +1570,13 @@
return r;
}
-uint64_t
+INTERNAL_ABI uint64_t
runtime_get_opaque_time(void)
{
return mach_absolute_time();
}
-uint64_t
+INTERNAL_ABI uint64_t
runtime_opaque_time_to_nano(uint64_t o)
{
#if defined(__i386__)
Modified: trunk/launchd/src/launchd_runtime.h
===================================================================
--- trunk/launchd/src/launchd_runtime.h 2008-01-09 17:35:12 UTC (rev 23478)
+++ trunk/launchd/src/launchd_runtime.h 2008-01-09 22:18:09 UTC (rev 23479)
@@ -70,6 +70,12 @@
#endif
+#ifdef __i386__
+#define INTERNAL_ABI __attribute__((regparm(3)))
+#else
+#define INTERNAL_ABI
+#endif
+
#define likely(x) __builtin_expect((bool)(x), true)
#define unlikely(x) __builtin_expect((bool)(x), false)
@@ -87,53 +93,50 @@
* Use launchd_assert() for core initialization routines.
*/
#define launchd_assumes(e) \
- (__builtin_expect(!(e), 0) ? _log_launchd_bug(__rcs_file_version__, __FILE__, __LINE__, #e), false : true)
+ (likely(e) ? true : _log_launchd_bug(__rcs_file_version__, __FILE__, __LINE__, #e))
-#define launchd_blame(e, b) \
- (__builtin_expect(!(e), 0) ? syslog(LOG_DEBUG, "Encountered bug: %d", b), false : true)
-
#define launchd_assert(e) if (__builtin_constant_p(e)) { char __compile_time_assert__[e ? 1 : -1] __attribute__((unused)); } else if (!launchd_assumes(e)) { abort(); }
-void _log_launchd_bug(const char *rcs_rev, const char *path, unsigned int line, const char *test);
+INTERNAL_ABI bool _log_launchd_bug(const char *rcs_rev, const char *path, unsigned int line, const char *test);
typedef void (*kq_callback)(void *, struct kevent *);
typedef boolean_t (*mig_callback)(mach_msg_header_t *, mach_msg_header_t *);
typedef void (*timeout_callback)(void);
-mach_port_t runtime_get_kernel_port(void);
+INTERNAL_ABI mach_port_t runtime_get_kernel_port(void);
-void runtime_add_ref(void);
-void runtime_del_ref(void);
+INTERNAL_ABI void runtime_add_ref(void);
+INTERNAL_ABI void runtime_del_ref(void);
-void launchd_runtime_init(void);
-void launchd_runtime_init2(void);
-void launchd_runtime(void) __attribute__((noreturn));
+INTERNAL_ABI void launchd_runtime_init(void);
+INTERNAL_ABI void launchd_runtime_init2(void);
+INTERNAL_ABI void launchd_runtime(void) __attribute__((noreturn));
-void launchd_log_vm_stats(void);
+INTERNAL_ABI void launchd_log_vm_stats(void);
-int runtime_close(int fd);
-int runtime_fsync(int fd);
+INTERNAL_ABI int runtime_close(int fd);
+INTERNAL_ABI int runtime_fsync(int fd);
#define RUNTIME_ADVISABLE_IDLE_TIMEOUT 30
-void runtime_set_timeout(timeout_callback to_cb, unsigned int sec);
-kern_return_t runtime_add_mport(mach_port_t name, mig_callback demux, mach_msg_size_t msg_size);
-kern_return_t runtime_remove_mport(mach_port_t name);
-bool runtime_get_caller_creds(struct ldcred *ldc);
+INTERNAL_ABI void runtime_set_timeout(timeout_callback to_cb, unsigned int sec);
+INTERNAL_ABI kern_return_t runtime_add_mport(mach_port_t name, mig_callback demux, mach_msg_size_t msg_size);
+INTERNAL_ABI kern_return_t runtime_remove_mport(mach_port_t name);
+INTERNAL_ABI bool runtime_get_caller_creds(struct ldcred *ldc);
-const char *signal_to_C_name(unsigned int sig);
-const char *reboot_flags_to_C_names(unsigned int flags);
-const char *proc_flags_to_C_names(unsigned int flags);
+INTERNAL_ABI const char *signal_to_C_name(unsigned int sig);
+INTERNAL_ABI const char *reboot_flags_to_C_names(unsigned int flags);
+INTERNAL_ABI const char *proc_flags_to_C_names(unsigned int flags);
-bool do_apple_internal_logging(void);
+INTERNAL_ABI bool do_apple_internal_logging(void);
-int kevent_bulk_mod(struct kevent *kev, size_t kev_cnt);
-int kevent_mod(uintptr_t ident, short filter, u_short flags, u_int fflags, intptr_t data, void *udata);
+INTERNAL_ABI int kevent_bulk_mod(struct kevent *kev, size_t kev_cnt);
+INTERNAL_ABI int kevent_mod(uintptr_t ident, short filter, u_short flags, u_int fflags, intptr_t data, void *udata);
-pid_t runtime_fork(mach_port_t bsport);
+INTERNAL_ABI pid_t runtime_fork(mach_port_t bsport);
-kern_return_t runtime_log_forward(uid_t forward_uid, gid_t forward_gid, vm_offset_t inval, mach_msg_type_number_t invalCnt);
-kern_return_t runtime_log_drain(mach_port_t srp, vm_offset_t *outval, mach_msg_type_number_t *outvalCnt);
+INTERNAL_ABI kern_return_t runtime_log_forward(uid_t forward_uid, gid_t forward_gid, vm_offset_t inval, mach_msg_type_number_t invalCnt);
+INTERNAL_ABI kern_return_t runtime_log_drain(mach_port_t srp, vm_offset_t *outval, mach_msg_type_number_t *outvalCnt);
#define LOG_APPLEONLY 0x4141504c /* AAPL in hex */
@@ -147,24 +150,23 @@
pid_t about_pid;
};
-int runtime_setlogmask(int maskpri);
-void runtime_closelog(void);
-void runtime_syslog(int pri, const char *message, ...) __attribute__((format(printf, 2, 3)));
-void runtime_vsyslog(struct runtime_syslog_attr *attr, const char *message, va_list args) __attribute__((format(printf, 2, 0)));
-void runtime_log_push(void);
+INTERNAL_ABI int runtime_setlogmask(int maskpri);
+INTERNAL_ABI void runtime_closelog(void);
+INTERNAL_ABI void runtime_syslog(int pri, const char *message, ...) __attribute__((format(printf, 2, 3)));
+INTERNAL_ABI void runtime_vsyslog(struct runtime_syslog_attr *attr, const char *message, va_list args) __attribute__((format(printf, 2, 0)));
+INTERNAL_ABI void runtime_log_push(void);
-int64_t runtime_get_wall_time(void);
-uint64_t runtime_get_opaque_time(void);
-uint64_t runtime_opaque_time_to_nano(uint64_t o);
+INTERNAL_ABI int64_t runtime_get_wall_time(void);
+INTERNAL_ABI uint64_t runtime_get_opaque_time(void);
+INTERNAL_ABI uint64_t runtime_opaque_time_to_nano(uint64_t o);
+INTERNAL_ABI kern_return_t launchd_set_bport(mach_port_t name);
+INTERNAL_ABI kern_return_t launchd_get_bport(mach_port_t *name);
+INTERNAL_ABI kern_return_t launchd_mport_notify_req(mach_port_t name, mach_msg_id_t which);
+INTERNAL_ABI kern_return_t launchd_mport_notify_cancel(mach_port_t name, mach_msg_id_t which);
+INTERNAL_ABI kern_return_t launchd_mport_create_recv(mach_port_t *name);
+INTERNAL_ABI kern_return_t launchd_mport_deallocate(mach_port_t name);
+INTERNAL_ABI kern_return_t launchd_mport_make_send(mach_port_t name);
+INTERNAL_ABI kern_return_t launchd_mport_close_recv(mach_port_t name);
-kern_return_t launchd_set_bport(mach_port_t name);
-kern_return_t launchd_get_bport(mach_port_t *name);
-kern_return_t launchd_mport_notify_req(mach_port_t name, mach_msg_id_t which);
-kern_return_t launchd_mport_notify_cancel(mach_port_t name, mach_msg_id_t which);
-kern_return_t launchd_mport_create_recv(mach_port_t *name);
-kern_return_t launchd_mport_deallocate(mach_port_t name);
-kern_return_t launchd_mport_make_send(mach_port_t name);
-kern_return_t launchd_mport_close_recv(mach_port_t name);
-
#endif
Modified: trunk/launchd/src/launchd_unix_ipc.c
===================================================================
--- trunk/launchd/src/launchd_unix_ipc.c 2008-01-09 17:35:12 UTC (rev 23478)
+++ trunk/launchd/src/launchd_unix_ipc.c 2008-01-09 22:18:09 UTC (rev 23479)
@@ -418,11 +418,17 @@
rmc->resp = resp;
}
+static int
+close_abi_fixup(int fd)
+{
+ return runtime_close(fd);
+}
+
void
ipc_close(struct conncb *c)
{
LIST_REMOVE(c, sle);
- launchd_close(c->conn, runtime_close);
+ launchd_close(c->conn, close_abi_fixup);
free(c);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/launchd-changes/attachments/20080109/6de5b36c/attachment-0001.html
More information about the launchd-changes
mailing list