45738dfa0c1c2160bfc4c92ba00a3fbcf9bef7fb
[sbcl.git] / src / runtime / darwin-os.c
1 /*
2  * This is the Darwin incarnation of OS-dependent routines. See also
3  * "bsd-os.c".
4  */
5
6 /*
7  * This software is part of the SBCL system. See the README file for
8  * more information.
9  *
10  * This software is derived from the CMU CL system, which was
11  * written at Carnegie Mellon University and released into the
12  * public domain. The software is in the public domain and is
13  * provided with absolutely no warranty. See the COPYING and CREDITS
14  * files for more information.
15  */
16
17 #include "sbcl.h"
18 #include "globals.h"
19 #include "runtime.h"
20 #include <signal.h>
21 #include <ucontext.h>
22 #include <limits.h>
23 #include <mach-o/dyld.h>
24 #include "bsd-os.h"
25 #include <errno.h>
26
27 char *
28 os_get_runtime_executable_path()
29 {
30     char path[PATH_MAX + 1];
31     uint32_t size = sizeof(path);
32
33     if (_NSGetExecutablePath(path, &size) == -1)
34         return NULL;
35     else
36         path[size] = '\0';
37
38     return copied_string(path);
39 }
40