[MonoDataSqlite] Add test for Xamarin.iOS specific bug 27864
[mono-project.git] / mono / utils / mono-dl-posix.c
blobbe52a3e6e4cad1fbc7514daf02da7a9b17382c88
1 /*
2 * mono-dl.c: Interface to the dynamic linker
4 * Author:
5 * Mono Team (http://www.mono-project.com)
7 * Copyright 2001-2004 Ximian, Inc.
8 * Copyright 2004-2009 Novell, Inc.
9 */
10 #include <config.h>
12 #ifdef HAVE_UNISTD_H
13 #include <unistd.h>
14 #endif
16 #if defined(_POSIX_VERSION)
18 #include "mono/utils/mono-dl.h"
19 #include "mono/utils/mono-embed.h"
20 #include "mono/utils/mono-path.h"
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <ctype.h>
25 #include <string.h>
26 #include <glib.h>
27 #include <dlfcn.h>
29 #if !defined (TARGET_MACH)
30 const char *
31 mono_dl_get_so_prefix (void)
33 return "lib";
35 const char **
36 mono_dl_get_so_suffixes (void)
38 static const char *suffixes[] = {
39 ".so",
40 "",
42 return suffixes;
45 int
46 mono_dl_get_executable_path (char *buf, int buflen)
48 return readlink ("/proc/self/exe", buf, buflen - 1);
50 #endif
52 void *
53 mono_dl_open_file (const char *file, int flags)
55 #ifdef PLATFORM_ANDROID
56 /* Bionic doesn't support NULL filenames */
57 if (!file)
58 return NULL;
59 #endif
60 return dlopen (file, flags);
63 void
64 mono_dl_close_handle (MonoDl *module)
66 dlclose (module->handle);
69 void*
70 mono_dl_lookup_symbol (MonoDl *module, const char *name)
72 return dlsym (module->handle, name);
75 int
76 mono_dl_convert_flags (int flags)
78 int lflags = flags & MONO_DL_LOCAL? 0: RTLD_GLOBAL;
80 if (flags & MONO_DL_LAZY)
81 lflags |= RTLD_LAZY;
82 else
83 lflags |= RTLD_NOW;
84 return lflags;
87 char*
88 mono_dl_current_error_string (void)
90 return g_strdup (dlerror ());
93 #endif