void * dbgsysLoadLibrary(const char *name, char *err_buf, int err_buflen) { void * result; #ifdef NATIVE result = dlopen(name, RTLD_LAZY); #else sysMonitorEnter(greenThreadSelf(), &_dl_lock); result = dlopen(name, RTLD_NOW); sysMonitorExit(greenThreadSelf(), &_dl_lock); /* * This is a bit of bulletproofing to catch the commonly occurring * problem of people loading a library which depends on libthread into * the VM. thr_main() should always return -1 which means that libthread * isn't loaded. */ if (thr_main() != -1) { VM_CALL(panic)("libthread loaded into green threads"); } #endif if (result == NULL) { (void)strncpy(err_buf, dlerror(), err_buflen-2); err_buf[err_buflen-1] = '\0'; } return result; }
void dbgsysUnloadLibrary(void *handle) { #ifndef NATIVE sysMonitorEnter(greenThreadSelf(), &_dl_lock); #endif (void)dlclose(handle); #ifndef NATIVE sysMonitorExit(greenThreadSelf(), &_dl_lock); #endif }
void sysUnloadLibrary(void *handle) { #ifdef NEED_DL_LOCK sysMonitorEnter(sysThreadSelf(), &_dl_lock); dlclose(handle); sysMonitorExit(sysThreadSelf(), &_dl_lock); #else dlclose(handle); #endif }
void * dbgsysFindLibraryEntry(void *handle, const char *name) { void * sym; #ifndef NATIVE sysMonitorEnter(greenThreadSelf(), &_dl_lock); #endif sym = dlsym(handle, name); #ifndef NATIVE sysMonitorExit(greenThreadSelf(), &_dl_lock); #endif return sym; }
void * sysFindLibraryEntry(void *handle, const char *name) { void *sym; #ifdef NEED_DL_LOCK sysMonitorEnter(sysThreadSelf(), &_dl_lock); sym = dlsym(handle, name); sysMonitorExit(sysThreadSelf(), &_dl_lock); #else sym = dlsym(handle, name); #endif return sym; }
static void _UnlockBlkMgr(sys_thread_t* thrd ) { sysMonitorExit( thrd, blkvar.blkMgrMon ); }