#include <inttypes.h>
#include <pthread.h>
#include "apple_glx_log.h"
+#include "util/debug.h"
static bool diagnostic = false;
static aslclient aslc;
void apple_glx_log_init(void) {
- if (getenv("LIBGL_DIAGNOSTIC")) {
+ if (env_var_as_boolean("LIBGL_DIAGNOSTIC", false)) {
diagnostic = true;
}
uint64_t thread = 0;
if (pthread_is_threaded_np()) {
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060
+ thread = (uint64_t)(uintptr_t)pthread_self();
+#elif MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+ if (&pthread_threadid_np) {
+ pthread_threadid_np(NULL, &thread);
+ } else {
+ thread = (uint64_t)(uintptr_t)pthread_self();
+ }
+#else
pthread_threadid_np(NULL, &thread);
+#endif
}
if (diagnostic) {
fprintf(stderr, "%-9s %24s:%-4d %s(%"PRIu64"): ",
_asl_level_string(level), file, line, function, thread);
vfprintf(stderr, fmt, args2);
+ va_end(args2);
}
msg = asl_new(ASL_TYPE_MSG);