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@freedesktop.org>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@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>
#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;
{
#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;