radv,vulkan: add a new x11 wsi drirc workaround for DOOM Eternal
[mesa.git] / src / util / u_process.c
index 0454760f471cc828ecf901f59ec76dfef0c7b8f0..74c4d10192ef34eb7a388ff9b7e583ef66d1038e 100644 (file)
 #include <unistd.h>
 #endif
 
+#if DETECT_OS_APPLE
+#include <mach-o/dyld.h>
+#endif
+
 #if defined(__linux__) && defined(HAVE_PROGRAM_INVOCATION_NAME)
 
 static char *path = NULL;
@@ -166,6 +170,11 @@ util_get_process_exec_path(char* process_path, size_t len)
 {
 #if DETECT_OS_WINDOWS
    return GetModuleFileNameA(NULL, process_path, len);
+#elif DETECT_OS_APPLE
+   uint32_t bufSize = len;
+   int result = _NSGetExecutablePath(process_path, &bufSize);
+
+   return (result == 0) ? strlen(process_path) : 0;
 #elif DETECT_OS_UNIX
    ssize_t r;