0.9.10.16:
[sbcl.git] / src / runtime / darwin-os.c
diff --git a/src/runtime/darwin-os.c b/src/runtime/darwin-os.c
new file mode 100644 (file)
index 0000000..2923a7a
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * This is the Darwin incarnation of OS-dependent routines. See also
+ * "bsd-os.c".
+ */
+
+/*
+ * This software is part of the SBCL system. See the README file for
+ * more information.
+ *
+ * This software is derived from the CMU CL system, which was
+ * written at Carnegie Mellon University and released into the
+ * public domain. The software is in the public domain and is
+ * provided with absolutely no warranty. See the COPYING and CREDITS
+ * files for more information.
+ */
+
+#include "sbcl.h"
+#include "globals.h"
+#include "runtime.h"
+#include <signal.h>
+#include <ucontext.h>
+#include <limits.h>
+#include <mach-o/dyld.h>
+#include "bsd-os.h"
+
+char *
+os_get_runtime_executable_path()
+{
+    char path[PATH_MAX + 1];
+    uint32_t size = sizeof(path);
+
+    if (_NSGetExecutablePath(path, &size) == -1)
+        return NULL;
+    else
+        path[size] = '\0';
+
+    return copied_string(path);
+}