radv/gfx10: implement a bug workaround for NGG -> legacy transitions
[mesa.git] / src / util / u_process.c
index a1667e78074d3c8b1da670a746d79486b7cf14ba..cbccf48ed016ce6bed794240126d3fcb4142471a 100644 (file)
 
 #undef GET_PROGRAM_NAME
 
-#if (defined(__GNU_LIBRARY__) || defined(__GLIBC__)) && !defined(__UCLIBC__)
-#    if !defined(__GLIBC__) || (__GLIBC__ < 2)
-/* These aren't declared in any libc5 header */
-extern char *program_invocation_name, *program_invocation_short_name;
-#    endif
+#if defined(__linux__) && defined(HAVE_PROGRAM_INVOCATION_NAME)
 static const char *
 __getProgramName()
 {
@@ -52,6 +48,10 @@ __getProgramName()
       static char *path;
 
       if (!path)
+         /* Note: realpath() allocates memory that we will keep around for
+          * the lifetime of the app, and then leak as the app closes.
+          * FIXME: we should find a way to clean this properly
+          */
          path = realpath("/proc/self/exe", NULL);
 
       if (path && strncmp(path, program_invocation_name, strlen(path)) == 0) {
@@ -75,7 +75,7 @@ __getProgramName()
    return program_invocation_name;
 }
 #    define GET_PROGRAM_NAME() __getProgramName()
-#elif defined(__CYGWIN__)
+#elif defined(HAVE_PROGRAM_INVOCATION_NAME)
 #    define GET_PROGRAM_NAME() program_invocation_short_name
 #elif defined(__FreeBSD__) && (__FreeBSD__ >= 2)
 #    include <osreldate.h>