From: Vinson Lee Date: Tue, 24 Mar 2020 22:20:36 +0000 (-0700) Subject: util/u_process: Add util_get_process_exec_path for macOS. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=603f38f1715b5dd88c8ef8bbd1192a5e3ce8a7c5;p=mesa.git 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 Reviewed-by: Pierre-Eric Pelloux-Prayer Tested-by: Marge Bot Part-of: --- 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 #endif +#if DETECT_OS_APPLE +#include +#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;