Changeset 20823 in vbox
- Timestamp:
- Jun 23, 2009 12:48:34 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/stream.cpp
r18808 r20823 42 42 #include <iprt/param.h> 43 43 #include <iprt/string.h> 44 45 #include "internal/alignmentchecks.h" 44 46 #include "internal/magics.h" 45 47 … … 402 404 if (pcbWritten) 403 405 { 406 IPRT_ALIGNMENT_CHECKS_DISABLE(); /* glibc / mempcpy again */ 404 407 *pcbWritten = fwrite(pvBuf, 1, cbWrite, pStream->pFile); 408 IPRT_ALIGNMENT_CHECKS_ENABLE(); 405 409 if ( *pcbWritten == cbWrite 406 410 || !ferror(pStream->pFile)) … … 411 415 { 412 416 /* 413 * Must readit all!417 * Must write it all! 414 418 */ 415 if (fwrite(pvBuf, cbWrite, 1, pStream->pFile) == 1) 419 IPRT_ALIGNMENT_CHECKS_DISABLE(); /* glibc / mempcpy again */ 420 size_t cbWritten = fwrite(pvBuf, cbWrite, 1, pStream->pFile); 421 IPRT_ALIGNMENT_CHECKS_ENABLE(); 422 if (cbWritten == 1) 416 423 return VINF_SUCCESS; 417 424 if (!ferror(pStream->pFile)) … … 500 507 { 501 508 cchString--; /* save space for the terminator. */ 502 509 #ifdef HAVE_FWRITE_UNLOCKED 503 510 flockfile(pStream->pFile); 504 511 #endif 505 512 for (;;) 506 513 { 507 514 #ifdef HAVE_FWRITE_UNLOCKED 508 515 int ch = fgetc_unlocked(pStream->pFile); 509 516 #else 510 517 int ch = fgetc(pStream->pFile); 511 518 #endif 512 519 if (ch == EOF) 513 520 { 514 521 #ifdef HAVE_FWRITE_UNLOCKED 515 522 if (feof_unlocked(pStream->pFile)) 516 523 #else 517 524 if (feof(pStream->pFile)) 518 525 #endif 519 526 { 520 527 rc = VERR_EOF; 521 528 break; 522 529 } 523 530 #ifdef HAVE_FWRITE_UNLOCKED 524 531 if (ferror_unlocked(pStream->pFile)) 525 532 #else 526 533 if (ferror(pStream->pFile)) 527 534 #endif 528 535 rc = VERR_READ_ERROR; 529 536 else … … 543 550 } 544 551 } 545 552 #ifdef HAVE_FWRITE_UNLOCKED 546 553 funlockfile(pStream->pFile); 547 554 #endif 548 555 549 556 *pszString = '\0'; … … 597 604 if (RT_SUCCESS(rc)) 598 605 { 599 #ifdef HAVE_FWRITE_UNLOCKED 606 IPRT_ALIGNMENT_CHECKS_DISABLE(); /* glibc / mempcpy again */ 607 #ifdef HAVE_FWRITE_UNLOCKED 600 608 if (fwrite_unlocked(pachChars, cchChars, 1, pStream->pFile) != 1) 601 609 #else 602 610 if (fwrite(pachChars, cchChars, 1, pStream->pFile) != 1) 603 611 #endif 604 612 ASMAtomicXchgS32(&pStream->i32Error, VERR_WRITE_ERROR); 613 IPRT_ALIGNMENT_CHECKS_ENABLE(); 605 614 } 606 615 } … … 627 636 { 628 637 /** @todo consider making this thread safe... */ 629 638 #ifdef HAVE_FWRITE_UNLOCKED 630 639 flockfile(pStream->pFile); 631 640 rc = (int)RTStrFormatV(rtstrmOutput, pStream, NULL, NULL, pszFormat, args); 632 641 funlockfile(pStream->pFile); 633 642 #else 634 643 rc = (int)RTStrFormatV(rtstrmOutput, pStream, NULL, NULL, pszFormat, args); 635 644 #endif 636 645 Assert(rc >= 0); 637 646 }
Note:
See TracChangeset
for help on using the changeset viewer.