void _os_debug_logv(int level, const char *msg, va_list ap) { if (os_slowpath(os_debug_log_globals()->errors_only) && level > LOG_ERR) { // more important = lower integer return; } char *buf, *freebuf; size_t len; len = vasprintf(&buf, msg, ap); if (!buf) { return; } freebuf = buf; // The os_debug_log macros prepend many spaces to the format string. // Overwrite them with a timestamp, *or* skip them. const size_t pfxlen = strlen(_OS_DEBUG_LOG_PREFIX); const size_t timelen = 16; __OS_COMPILETIME_ASSERT__(pfxlen >= timelen); if (os_fastpath(len > pfxlen)) { if (os_slowpath(os_debug_log_globals()->prepend_timestamp)) { char tmp = buf[timelen]; snprintf(buf, timelen + 1, "%16llu", _os_debug_log_ticks_since_start()); buf[timelen] = tmp; // snprintf's null } else { buf += pfxlen; } } _os_debug_log_write(level, buf); free(freebuf); }
void launchd_runtime_init2(void) { size_t i; __OS_COMPILETIME_ASSERT__(SIG_ERR == (typeof(SIG_ERR))-1); for (i = 0; i < (sizeof(sigigns) / sizeof(int)); i++) { sigaddset(&sigign_set, sigigns[i]); (void)posix_assumes_zero(signal(sigigns[i], SIG_IGN)); } }