Changeset 39485 in vbox for trunk/src/VBox
- Timestamp:
- Dec 1, 2011 9:51:39 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/crOpenGL/load.c
r38864 r39485 56 56 57 57 static int stub_initialized = 0; 58 #ifdef WINDOWS 59 static CRmutex stub_init_mutex; 60 #define STUB_INIT_LOCK() do { crLockMutex(&stub_init_mutex); } while (0) 61 #define STUB_INIT_UNLOCK() do { crUnlockMutex(&stub_init_mutex); } while (0) 62 #else 63 #define STUB_INIT_LOCK() do { } while (0) 64 #define STUB_INIT_UNLOCK() do { } while (0) 65 #endif 58 66 59 67 /* NOTE: 'SPUDispatchTable glim' is declared in NULLfuncs.py now */ … … 311 319 * We call all the SPU's cleanup functions. 312 320 */ 313 static void stubSPUTearDown(void) 314 { 315 crDebug("stubSPUTearDown"); 316 if (!stub_initialized) return; 317 318 stub_initialized = 0; 321 static void stubSPUTearDownLocked(void) 322 { 323 crDebug("stubSPUTearDownLocked"); 319 324 320 325 #ifdef WINDOWS … … 359 364 360 365 crMemset(&stub, 0, sizeof(stub)); 366 367 } 368 369 /** 370 * This is called when we exit. 371 * We call all the SPU's cleanup functions. 372 */ 373 static void stubSPUTearDown(void) 374 { 375 STUB_INIT_LOCK(); 376 if (stub_initialized) 377 { 378 stubSPUTearDownLocked(); 379 stub_initialized = 0; 380 } 381 STUB_INIT_UNLOCK(); 361 382 } 362 383 … … 1101 1122 * Returns TRUE on success, FALSE otherwise. 1102 1123 */ 1103 bool1104 stubInit (void)1124 static bool 1125 stubInitLocked(void) 1105 1126 { 1106 1127 /* Here is where we contact the mothership to find out what we're supposed … … 1121 1142 int disable_sync = 0; 1122 1143 1123 if (stub_initialized)1124 return true;1125 1126 1144 stubInitVars(); 1127 1145 … … 1256 1274 #endif 1257 1275 1258 stub_initialized = 1;1259 1276 return true; 1277 } 1278 1279 /** 1280 * Do one-time initializations for the faker. 1281 * Returns TRUE on success, FALSE otherwise. 1282 */ 1283 bool 1284 stubInit(void) 1285 { 1286 bool bRc = true; 1287 /* we need to serialize the initialization, otherwise racing is possible 1288 * for XPDM-based d3d when a d3d switcher is testing the gl lib in two or more threads 1289 * NOTE: the STUB_INIT_LOCK/UNLOCK is a NOP for non-win currently */ 1290 STUB_INIT_LOCK(); 1291 if (!stub_initialized) 1292 bRc = stub_initialized = stubInitLocked(); 1293 STUB_INIT_UNLOCK(); 1294 return bRc; 1260 1295 } 1261 1296 … … 1272 1307 #include <windows.h> 1273 1308 1309 #ifdef DEBUG_misha 1310 /* debugging: this is to be able to catch first-chance notifications 1311 * for exceptions other than EXCEPTION_BREAKPOINT in kernel debugger */ 1312 # define VDBG_VEHANDLER 1313 #endif 1314 1315 #ifdef VDBG_VEHANDLER 1316 static PVOID g_VBoxWDbgVEHandler = NULL; 1317 LONG WINAPI vboxVDbgVectoredHandler(struct _EXCEPTION_POINTERS *pExceptionInfo) 1318 { 1319 PEXCEPTION_RECORD pExceptionRecord = pExceptionInfo->ExceptionRecord; 1320 PCONTEXT pContextRecord = pExceptionInfo->ContextRecord; 1321 switch (pExceptionRecord->ExceptionCode) 1322 { 1323 case EXCEPTION_BREAKPOINT: 1324 case EXCEPTION_ACCESS_VIOLATION: 1325 case EXCEPTION_STACK_OVERFLOW: 1326 case EXCEPTION_ARRAY_BOUNDS_EXCEEDED: 1327 case EXCEPTION_FLT_DIVIDE_BY_ZERO: 1328 case EXCEPTION_FLT_INVALID_OPERATION: 1329 case EXCEPTION_INT_DIVIDE_BY_ZERO: 1330 case EXCEPTION_ILLEGAL_INSTRUCTION: 1331 CRASSERT(0); 1332 break; 1333 default: 1334 break; 1335 } 1336 return EXCEPTION_CONTINUE_SEARCH; 1337 } 1338 1339 void vboxVDbgVEHandlerRegister() 1340 { 1341 CRASSERT(!g_VBoxWDbgVEHandler); 1342 g_VBoxWDbgVEHandler = AddVectoredExceptionHandler(1,vboxVDbgVectoredHandler); 1343 CRASSERT(g_VBoxWDbgVEHandler); 1344 } 1345 1346 void vboxVDbgVEHandlerUnregister() 1347 { 1348 ULONG uResult; 1349 if (g_VBoxWDbgVEHandler) 1350 { 1351 uResult = RemoveVectoredExceptionHandler(g_VBoxWDbgVEHandler); 1352 CRASSERT(uResult); 1353 g_VBoxWDbgVEHandler = NULL; 1354 } 1355 } 1356 #endif 1357 1274 1358 /* Windows crap */ 1275 1359 BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved) … … 1282 1366 { 1283 1367 CRNetServer ns; 1368 1369 crInitMutex(&stub_init_mutex); 1370 1371 #ifdef VDBG_VEHANDLER 1372 vboxVDbgVEHandlerRegister(); 1373 #endif 1284 1374 1285 1375 crNetInit(NULL, NULL); … … 1290 1380 { 1291 1381 crDebug("Failed to connect to host (is guest 3d acceleration enabled?), aborting ICD load."); 1382 #ifdef VDBG_VEHANDLER 1383 vboxVDbgVEHandlerUnregister(); 1384 #endif 1292 1385 return FALSE; 1293 1386 } … … 1301 1394 { 1302 1395 stubSPUSafeTearDown(); 1396 1397 #ifdef VDBG_VEHANDLER 1398 vboxVDbgVEHandlerUnregister(); 1399 #endif 1400 1303 1401 break; 1304 1402 }
Note:
See TracChangeset
for help on using the changeset viewer.