Changeset 4496 for trunk/src/kernel32/misc.cpp
- Timestamp:
- Oct 18, 2000, 7:09:34 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/misc.cpp
r4431 r4496 1 /* $Id: misc.cpp,v 1.2 6 2000-10-05 13:48:09sandervl Exp $ */1 /* $Id: misc.cpp,v 1.27 2000-10-18 17:09:33 sandervl Exp $ */ 2 2 3 3 /* … … 29 29 #include "initterm.h" 30 30 #include "logging.h" 31 #include "exceptutil.h" 31 32 #include <wprocess.h> 32 33 #include <versionos2.h> … … 251 252 #if defined(DEBUG) && defined(CHECK_ODINHEAP) 252 253 int checkOdinHeap = 1; 253 #define ODIN_HEAPCHECK() if(checkOdinHeap)_heap_check();254 #define ODIN_HEAPCHECK() if(checkOdinHeap) _heap_check(); 254 255 #else 255 256 #define ODIN_HEAPCHECK() … … 272 273 if(!getenv("NOWIN32LOG")) { 273 274 #endif 274 275 276 277 278 279 280 281 275 char logname[CCHMAXPATH]; 276 277 sprintf(logname, "odin32_%d.log", loadNr); 278 flog = fopen(logname, "w"); 279 if(flog == NULL) {//probably running exe on readonly device 280 sprintf(logname, "%sodin32_%d.log", kernel32Path, loadNr); 281 flog = fopen(logname, "w"); 282 } 282 283 oldcrtmsghandle = _set_crt_msg_handle(fileno(flog)); 283 284 } … … 291 292 292 293 va_start(argptr, tekst); 293 if(thdb) { 294 294 if(thdb) { 295 thdb->logfile = (DWORD)flog; 295 296 if(sel == 0x150b && !fIsOS2Image) { 296 297 298 elsefprintf(flog, "t%d: ", thdb->threadId);297 fprintf(flog, "t%d: (FS=150B) ", thdb->threadId); 298 } 299 else fprintf(flog, "t%d: ", thdb->threadId); 299 300 } 300 301 vfprintf(flog, tekst, argptr); … … 326 327 if(!getenv("NOWIN32LOG")) { 327 328 #endif 328 329 330 331 332 333 334 335 329 char logname[CCHMAXPATH]; 330 331 sprintf(logname, "odin32_%d.log", loadNr); 332 flog = fopen(logname, "w"); 333 if(flog == NULL) {//probably running exe on readonly device 334 sprintf(logname, "%sodin32_%d.log", kernel32Path, loadNr); 335 flog = fopen(logname, "w"); 336 } 336 337 } 337 338 else … … 344 345 345 346 va_start(argptr, tekst); 346 if(thdb) { 347 347 if(thdb) { 348 thdb->logfile = (DWORD)flog; 348 349 } 349 350 vfprintf(flog, tekst, argptr); … … 378 379 379 380 va_start(argptr, tekst); 381 if(thdb) { 382 thdb->logfile = (DWORD)flog; 383 } 380 384 vfprintf((FILE *)logfile, tekst, argptr); 381 385 if(thdb) thdb->logfile = 0; … … 390 394 } 391 395 //****************************************************************************** 392 // Check if the exception occurred inside a fprintf (logging THDB member set)393 // If true, decrease the lock count for that file stream394 // NOTE: HACK: DEPENDS ON COMPILER VERSION!!!!395 //****************************************************************************** 396 void CheckLogException()396 //WriteLog has to take special care to handle dprintfs inside our os/2 exception 397 //handler; if an exception occurs inside a dprintf, using dprintf in the exception 398 //handler will hang the process 399 //****************************************************************************** 400 void LogException(int state) 397 401 { 398 402 THDB *thdb = GetThreadTHDB(); … … 402 406 403 407 if(thdb->logfile) { 404 //oops, exception in vfprintf; let's clear the lock count 408 if(state == ENTER_EXCEPTION) { 405 409 #if (__IBMCPP__ == 300) || (__IBMC__ == 300) 406 410 lock = (USHORT *)(thdb->logfile+0x1C); 407 411 #else 408 412 #error Check the offset of the lock count word in the file stream structure for this compiler revision!!!!! 409 413 #endif 410 (*lock)--; 414 (*lock)--; 415 } 416 else { //LEAVE_EXCEPTION 417 #if (__IBMCPP__ == 300) || (__IBMC__ == 300) 418 lock = (USHORT *)(thdb->logfile+0x1C); 419 #else 420 #error Check the offset of the lock count word in the file stream structure for this compiler revision!!!!! 421 #endif 422 (*lock)++; 423 } 424 } 425 } 426 //****************************************************************************** 427 //Check if the exception occurred inside a fprintf (logging THDB member set) 428 //If true, decrease the lock count for that file stream 429 //NOTE: HACK: DEPENDS ON COMPILER VERSION!!!! 430 //****************************************************************************** 431 void CheckLogException() 432 { 433 THDB *thdb = GetThreadTHDB(); 434 USHORT *lock; 435 436 if(!thdb) return; 437 438 if(thdb->logfile) { 439 //oops, exception in vfprintf; let's clear the lock count 440 #if (__IBMCPP__ == 300) || (__IBMC__ == 300) 441 lock = (USHORT *)(thdb->logfile+0x1C); 442 #else 443 #error Check the offset of the lock count word in the file stream structure for this compiler revision!!!!! 444 #endif 445 (*lock)--; 411 446 } 412 447 } … … 418 453 { 419 454 if(oldcrtmsghandle) 420 455 _set_crt_msg_handle(oldcrtmsghandle); 421 456 422 457 fclose(flog); … … 433 468 if(!getenv("NOWIN32LOG")) { 434 469 #endif 435 470 OpenPrivateLogFilePE(); 436 471 } 437 472 } … … 446 481 if(!getenv("NOWIN32LOG")) { 447 482 #endif 448 483 ClosePrivateLogFilePE(); 449 484 } 450 485 }
Note:
See TracChangeset
for help on using the changeset viewer.