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