- Timestamp:
- Jul 8, 2008 9:29:43 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/initterm-r0drv.cpp
r9602 r10390 34 34 *******************************************************************************/ 35 35 #include <iprt/initterm.h> 36 #include <iprt/asm.h> 36 37 #include <iprt/assert.h> 37 38 #include <iprt/err.h> … … 42 43 #include "internal/initterm.h" 43 44 #include "internal/thread.h" 45 46 47 /******************************************************************************* 48 * Global Variables * 49 *******************************************************************************/ 50 /** Count of current IPRT users. 51 * In ring-0 several drivers / kmods / kexts / wossnames may share the 52 * same runtime code. So, we need to keep count in order not to terminate 53 * it prematurely. */ 54 static int32_t volatile g_crtR0Users = 0; 44 55 45 56 … … 54 65 int rc; 55 66 Assert(fReserved == 0); 67 68 /* 69 * The first user initializes it. 70 * We rely on the module loader to ensure that there are no 71 * initialization races should two modules share the IPRT. 72 */ 73 if (ASMAtomicIncS32(&g_crtR0Users) != 1) 74 return VINF_SUCCESS; 75 56 76 rc = rtR0InitNative(); 57 77 if (RT_SUCCESS(rc)) … … 80 100 RTR0DECL(void) RTR0Term(void) 81 101 { 102 /* 103 * Last user does the cleanup. 104 */ 105 int32_t cNewUsers = ASMAtomicDecS32(&g_crtR0Users); 106 Assert(cNewUsers >= 0); 107 if (cNewUsers != 0) 108 return; 109 82 110 #if !defined(RT_OS_LINUX) && !defined(RT_OS_WINDOWS) 83 111 rtThreadTerm();
Note:
See TracChangeset
for help on using the changeset viewer.