Mesa (master): util/u_process: Add util_get_process_exec_path for macOS.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Mar 25 22:01:26 UTC 2020


Module: Mesa
Branch: master
Commit: 603f38f1715b5dd88c8ef8bbd1192a5e3ce8a7c5
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=603f38f1715b5dd88c8ef8bbd1192a5e3ce8a7c5

Author: Vinson Lee <vlee at freedesktop.org>
Date:   Tue Mar 24 15:20:36 2020 -0700

util/u_process: Add util_get_process_exec_path for macOS.

Fixes: f8f1413070ae ("util/u_process: add util_get_process_exec_path")
Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2682
Signed-off-by: Vinson Lee <vlee at freedesktop.org>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4313>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4313>

---

 src/util/u_process.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/util/u_process.c b/src/util/u_process.c
index 0454760f471..74c4d10192e 100644
--- a/src/util/u_process.c
+++ b/src/util/u_process.c
@@ -40,6 +40,10 @@
 #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;
 



More information about the mesa-commit mailing list