Changeset 28361 in vbox
- Timestamp:
- Apr 15, 2010 1:46:02 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/runtime-loader.h
r28357 r28361 64 64 * probably be preferable. */ 65 65 66 #include <iprt/asm.h>67 #include <iprt/assert.h>68 #include <iprt/cdefs.h>69 #include <iprt/err.h>70 66 #include <iprt/ldr.h> 71 67 #include <iprt/log.h> 72 #include <iprt/thread.h> 73 #include <iprt/types.h> 68 #include <iprt/once.h> 74 69 75 70 #ifdef RT_RUNTIME_LOADER_GENERATE_BODY_STUBS … … 99 94 # undef RT_PROXY_STUB 100 95 101 enum RT_RTLDR_LOAD_STATE 96 /* The function which does the actual work for RT_RUNTIME_LOADER_FUNCTION, 97 * serialised for thread safety. */ 98 static int rtldrLoadOnce(void *, void *) 102 99 { 103 UNLOADED = 0, 104 LOADING, 105 DONE 106 }; 100 RTLDRMOD hLib; 107 101 108 static uint32_t rtldrState = UNLOADED; 109 static uint32_t rtldrRC = VERR_WRONG_ORDER; 102 LogFlowFunc(("\n")); 103 int rc = RTLdrLoad(RT_RUNTIME_LOADER_LIB_NAME, &hLib); 104 for (unsigned i = 0; RT_SUCCESS(rc) && SharedFuncs[i].name != NULL; ++i) 105 rc = RTLdrGetSymbol(hLib, SharedFuncs[i].name, (void**)SharedFuncs[i].fn); 106 LogFlowFunc(("rc = %Rrc\n", rc)); 107 return rc; 108 } 110 109 111 110 /** Load the shared library RT_RUNTIME_LOADER_LIB_NAME and resolve the symbols … … 115 114 RTR3DECL(int) RT_RUNTIME_LOADER_FUNCTION(void) 116 115 { 117 int rc;116 static RTONCE sOnce = RTONCE_INITIALIZER; 118 117 119 118 LogFlowFunc(("\n")); 120 if (ASMAtomicCmpXchgU32(&rtldrState, LOADING, UNLOADED)) 121 { 122 RTLDRMOD hLib; 123 124 rc = RTLdrLoad(RT_RUNTIME_LOADER_LIB_NAME, &hLib); 125 for (unsigned i = 0; RT_SUCCESS(rc) && SharedFuncs[i].name != NULL; ++i) 126 rc = RTLdrGetSymbol(hLib, SharedFuncs[i].name, (void**)SharedFuncs[i].fn); 127 rtldrRC = rc; 128 rtldrState = DONE; 129 } 130 else 131 { 132 while(rtldrState == LOADING) 133 RTThreadYield(); 134 rc = rtldrRC; 135 } 136 Assert(rtldrState == DONE); 119 int rc = RTOnce (&sOnce, rtldrLoadOnce, NULL, NULL); 137 120 LogFlowFunc(("rc = %Rrc\n", rc)); 138 121 return rc; 139 122 } 123 140 124 #elif defined(RT_RUNTIME_LOADER_GENERATE_HEADER) 141 125 # ifdef RT_RUNTIME_LOADER_GENERATE_DECLS
Note:
See TracChangeset
for help on using the changeset viewer.