gint ves_icall_System_IO_FSW_SupportsFSW (void) { #if HAVE_KQUEUE return 3; #else MonoDl *fam_module; int lib_used = 4; /* gamin */ int inotify_instance; char *err; inotify_instance = ves_icall_System_IO_InotifyWatcher_GetInotifyInstance (); if (inotify_instance != -1) { close (inotify_instance); return 5; /* inotify */ } fam_module = mono_dl_open ("libgamin-1.so", MONO_DL_LAZY, NULL); if (fam_module == NULL) { lib_used = 2; /* FAM */ fam_module = mono_dl_open ("libfam.so", MONO_DL_LAZY, NULL); } if (fam_module == NULL) return 0; err = mono_dl_symbol (fam_module, "FAMNextEvent", (gpointer *) &FAMNextEvent); g_free (err); if (FAMNextEvent == NULL) return 0; return lib_used; #endif }
/** * mono_profiler_load: * @desc: arguments to configure the profiler * * Invoke this method to initialize the profiler. This will drive the * loading of the internal ("default") or any external profilers. * * This routine is invoked by Mono's driver, but must be called manually * if you embed Mono into your application. */ void mono_profiler_load (const char *desc) { mono_gc_base_init (); #ifndef DISABLE_PROFILER if (!desc || (strcmp ("default", desc) == 0) || (strncmp (desc, "default:", 8) == 0)) { mono_profiler_install_simple (desc); return; } #else if (!desc) { desc = "default"; } #endif { MonoDl *pmodule = NULL; const char* col = strchr (desc, ':'); char* libname; char* path; char *mname; char *err; void *iter; if (col != NULL) { mname = g_memdup (desc, col - desc + 1); mname [col - desc] = 0; } else { mname = g_strdup (desc); } libname = g_strdup_printf ("mono-profiler-%s", mname); iter = NULL; err = NULL; while ((path = mono_dl_build_path (NULL, libname, &iter))) { g_free (err); pmodule = mono_dl_open (path, MONO_DL_LAZY, &err); if (pmodule) { ProfilerInitializer func; if ((err = mono_dl_symbol (pmodule, INITIALIZER_NAME, (gpointer *)&func))) { g_warning ("Cannot find initializer function %s in profiler module: %s (%s)", INITIALIZER_NAME, libname, err); g_free (err); err = NULL; } else { func (desc); } break; } g_free (path); } if (!pmodule) { g_warning ("Error loading profiler module '%s': %s", libname, err); g_free (err); } g_free (libname); g_free (mname); g_free (path); } }
int mono_llvm_load (const char* bpath) { char *err = NULL; MonoDl *llvm_lib = mono_dl_open_runtime_lib ("mono-llvm", MONO_DL_LAZY, &err); if (!llvm_lib) { g_warning ("llvm load failed: %s\n", err); g_free (err); return FALSE; } err = mono_dl_symbol (llvm_lib, "mono_llvm_init", (void**)&mono_llvm_init_fptr); if (err) goto symbol_error; err = mono_dl_symbol (llvm_lib, "mono_llvm_cleanup", (void**)&mono_llvm_cleanup_fptr); if (err) goto symbol_error; err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_method", (void**)&mono_llvm_emit_method_fptr); if (err) goto symbol_error; err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_call", (void**)&mono_llvm_emit_call_fptr); if (err) goto symbol_error; err = mono_dl_symbol (llvm_lib, "mono_llvm_create_aot_module", (void**)&mono_llvm_create_aot_module_fptr); if (err) goto symbol_error; err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_aot_module", (void**)&mono_llvm_emit_aot_module_fptr); if (err) goto symbol_error; err = mono_dl_symbol (llvm_lib, "mono_llvm_check_method_supported", (void**)&mono_llvm_check_method_supported_fptr); if (err) goto symbol_error; err = mono_dl_symbol (llvm_lib, "mono_llvm_free_domain_info", (void**)&mono_llvm_free_domain_info_fptr); if (err) goto symbol_error; err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_aot_file_info", (void**)&mono_llvm_emit_aot_file_info_fptr); if (err) goto symbol_error; err = mono_dl_symbol (llvm_lib, "mono_llvm_emit_aot_data", (void**)&mono_llvm_emit_aot_data_fptr); if (err) goto symbol_error; return TRUE; symbol_error: g_warning ("llvm symbol load failed: %s\n", err); g_free (err); return FALSE; }
static gboolean load_profiler (MonoDl *pmodule, const char *desc, const char *symbol) { char *err; ProfilerInitializer func; if (!pmodule) return FALSE; if ((err = mono_dl_symbol (pmodule, symbol, (gpointer *) &func))) { g_free (err); return FALSE; } else { func (desc); } return TRUE; }