apple/glx/log: added missing va_end() after va_copy()
[mesa.git] / src / glx / apple / apple_glx_log.c
index 9ebf666c9b4c0f6865ff31a38b005da91f43179b..ea39d30954e604aa085c4a7438f1b73a24cfda2f 100644 (file)
 #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;
     }
 
@@ -76,7 +77,17 @@ void _apple_glx_vlog(int level, const char *file, const char *function,
     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) {
@@ -86,6 +97,7 @@ void _apple_glx_vlog(int level, const char *file, const char *function,
         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);