Initial set of Ward sgen annotations (#5705)
[mono.git] / mono / utils / mono-dl-darwin.c
1 /**
2  * \file
3  * Interface to the dynamic linker
4  *
5  * Author:
6  *    Mono Team (http://www.mono-project.com)
7  *
8  * Copyright 2001-2004 Ximian, Inc.
9  * Copyright 2004-2009 Novell, Inc.
10  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
11  */
12 #include <config.h>
13
14 #if defined (TARGET_MACH)
15
16 #include "mono/utils/mono-dl.h"
17 #include "mono/utils/mono-embed.h"
18 #include "mono/utils/mono-path.h"
19
20 #include <stdlib.h>
21 #include <stdio.h>
22 #include <ctype.h>
23 #include <string.h>
24 #include <glib.h>
25 #include <dlfcn.h>
26 #include <unistd.h>
27 #include <mach-o/dyld.h>
28
29 const char *
30 mono_dl_get_so_prefix (void)
31 {
32         return "lib";
33 }
34 const char **
35 mono_dl_get_so_suffixes (void)
36 {
37         static const char *suffixes[] = {
38                 ".dylib",
39                 ".so",
40                 ".bundle",
41                 "",
42         };
43         return suffixes;
44 }
45
46 int
47 mono_dl_get_executable_path (char *buf, int buflen)
48 {
49         uint32_t bsize = buflen;
50         if (_NSGetExecutablePath (buf, &bsize) == 0)
51                 return strlen (buf);
52         return -1;
53 }
54
55 const char*
56 mono_dl_get_system_dir (void)
57 {
58 #ifdef TARGET_IOS
59         /* IOS9 can't load system libraries using relative paths, i.e. 'libc' doesn't work, but '/usr/lib/libc' does. */
60         return "/usr/lib";
61 #else
62         return NULL;
63 #endif
64 }
65
66 #endif