[1031] branches/PR-11056762/darwintrace/darwintrace.c
Revision: 1031 http://trac.macosforge.org/projects/darwinbuild/changeset/1031 Author: kvv@apple.com Date: 2012-03-22 13:26:07 -0700 (Thu, 22 Mar 2012) Log Message: ----------- <rdar://problem/11056762> crash in darwintrace.dylib when building clang Modified Paths: -------------- branches/PR-11056762/darwintrace/darwintrace.c Modified: branches/PR-11056762/darwintrace/darwintrace.c =================================================================== --- branches/PR-11056762/darwintrace/darwintrace.c 2012-03-22 20:25:46 UTC (rev 1030) +++ branches/PR-11056762/darwintrace/darwintrace.c 2012-03-22 20:26:07 UTC (rev 1031) @@ -32,6 +32,7 @@ #include <crt_externs.h> #include <fcntl.h> +#include <pthread.h> #include <spawn.h> #include <stdarg.h> #include <stdio.h> @@ -141,9 +142,7 @@ if (path != test) free(path); } -static inline void darwintrace_setup() { - if (darwintrace_fd != -2) return; - +static void _darwintrace_setup(void) { char* path = getenv("DARWINTRACE_LOG"); if (path != NULL) { int olderrno = errno; @@ -222,6 +221,11 @@ } } +static inline void darwintrace_setup(void) { + static pthread_once_t once = PTHREAD_ONCE_INIT; + pthread_once(&once, &_darwintrace_setup); +} + /* darwintrace_setup must have been called already */ static inline void darwintrace_logpath(int fd, const char *procname, char *tag, const char *path) { if (darwintrace_ignores) {
participants (1)
-
source_changes@macosforge.org