Changeset 7942 in vbox for trunk/src/VBox
- Timestamp:
- Apr 11, 2008 8:32:20 PM (17 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/VBox/log-vbox.cpp
r7602 r7942 182 182 */ 183 183 static volatile uint32_t fInitializing = 0; 184 PRTLOGGER pLogger; 185 184 186 if (g_pLogger || !ASMAtomicCmpXchgU32(&fInitializing, 1, 0)) 185 187 return g_pLogger; … … 282 284 * Create the default logging instance. 283 285 */ 284 PRTLOGGER pLogger;285 286 #ifdef IN_RING3 286 287 # ifndef IN_GUEST_R3 -
trunk/src/VBox/Runtime/common/log/log.cpp
r7713 r7942 182 182 RTUINT fDestFlags, char *pszErrorMsg, size_t cchErrorMsg, const char *pszFilenameFmt, va_list args) 183 183 { 184 int rc; 185 size_t cb; 186 PRTLOGGER pLogger; 187 184 188 /* 185 189 * Validate input. … … 200 204 * Allocate a logger instance. 201 205 */ 202 int rc; 203 size_t cb = RT_OFFSETOF(RTLOGGER, afGroups[cGroups + 1]) + RTPATH_MAX; 204 PRTLOGGER pLogger = (PRTLOGGER)RTMemAllocZ(cb); 206 cb = RT_OFFSETOF(RTLOGGER, afGroups[cGroups + 1]) + RTPATH_MAX; 207 pLogger = (PRTLOGGER)RTMemAllocZ(cb); 205 208 if (pLogger) 206 209 { 210 uint8_t *pu8Code; 211 207 212 pLogger->u32Magic = RTLOGGER_MAGIC; 208 213 pLogger->papszGroups = papszGroups; … … 220 225 * Emit wrapper code. 221 226 */ 222 uint8_t *pu8Code = (uint8_t *)RTMemExecAlloc(64);227 pu8Code = (uint8_t *)RTMemExecAlloc(64); 223 228 if (pu8Code) 224 229 { … … 511 516 RTDECL(int) RTLogDestroy(PRTLOGGER pLogger) 512 517 { 518 int rc; 519 RTUINT iGroup; 520 RTSEMFASTMUTEX MutexSem; 521 513 522 /* 514 523 * Validate input. … … 520 529 * Acquire logger instance sem and disable all logging. (paranoia) 521 530 */ 522 intrc = rtlogLock(pLogger);531 rc = rtlogLock(pLogger); 523 532 if (RT_FAILURE(rc)) 524 533 return rc; 525 534 526 535 pLogger->fFlags |= RTLOGFLAGS_DISABLED; 527 RTUINTiGroup = pLogger->cGroups;536 iGroup = pLogger->cGroups; 528 537 while (iGroup-- > 0) 529 538 pLogger->afGroups[iGroup] = 0; … … 551 560 * Free the mutex and the instance memory. 552 561 */ 553 RTSEMFASTMUTEXMutexSem = pLogger->MutexSem;562 MutexSem = pLogger->MutexSem; 554 563 pLogger->MutexSem = NIL_RTSEMFASTMUTEX; 555 564 if (MutexSem != NIL_RTSEMFASTMUTEX) … … 760 769 RTDECL(int) RTLogCopyGroupsAndFlags(PRTLOGGER pDstLogger, PCRTLOGGER pSrcLogger, unsigned fFlagsOr, unsigned fFlagsAnd) 761 770 { 771 int rc; 772 unsigned cGroups; 773 762 774 /* 763 775 * Validate input. … … 786 798 pDstLogger->fFlags = (pSrcLogger->fFlags & fFlagsAnd) | fFlagsOr; 787 799 788 intrc = VINF_SUCCESS;789 unsignedcGroups = pSrcLogger->cGroups;800 rc = VINF_SUCCESS; 801 cGroups = pSrcLogger->cGroups; 790 802 if (cGroups < pDstLogger->cMaxGroups) 791 803 { … … 883 895 static bool rtlogIsGroupMatching(const char *pszGrp, const char **ppachMask, unsigned cchMask) 884 896 { 897 const char *pachMask; 898 885 899 if (!pszGrp || !*pszGrp) 886 900 return false; 887 const char *pachMask = *ppachMask;901 pachMask = *ppachMask; 888 902 for (;;) 889 903 { 890 904 if (RT_C_TO_LOWER(*pszGrp) != RT_C_TO_LOWER(*pachMask)) 891 905 { 906 const char *pszTmp; 907 892 908 /* 893 909 * Check for wildcard and do a minimal match if found. … … 907 923 908 924 /* do extremely minimal matching (fixme) */ 909 const char *pszTmp = strchr(pszGrp, RT_C_TO_LOWER(*pachMask));925 pszTmp = strchr(pszGrp, RT_C_TO_LOWER(*pachMask)); 910 926 if (!pszTmp) 911 927 pszTmp = strchr(pszGrp, RT_C_TO_UPPER(*pachMask)); … … 974 990 bool fEnabled = true; 975 991 char ch; 992 const char *pszStart; 993 unsigned i; 994 size_t cch; 995 976 996 while ((ch = *pszVar) == '+' || ch == '-' || ch == ' ' || ch == '\t' || ch == '\n' || ch == ';') 977 997 { … … 986 1006 * Find end. 987 1007 */ 988 const char *pszStart = pszVar;1008 pszStart = pszVar; 989 1009 while ((ch = *pszVar) != '\0' && ch != '+' && ch != '-' && ch != ' ' && ch != '\t') 990 1010 pszVar++; … … 994 1014 * Special group 'all'. 995 1015 */ 996 unsigned i; 997 size_t cch = pszVar - pszStart; 1016 cch = pszVar - pszStart; 998 1017 if ( cch >= 3 999 1018 && (pszStart[0] == 'a' || pszStart[0] == 'A') … … 1100 1119 { "noname", RTLOGGRPFLAGS_NONAME } 1101 1120 }; 1102 psz++;1103 1121 unsigned i; 1104 1122 bool fFound = false; 1123 psz++; 1105 1124 for (i = 0; i < ELEMENTS(aFlags) && !fFound; i++) 1106 1125 { … … 1172 1191 while (*pszVar) 1173 1192 { 1174 /* skip blanks. */1175 while (RT_C_IS_SPACE(*pszVar))1176 pszVar++;1177 if (!*pszVar)1178 return rc;1179 1180 1193 /* parse instruction. */ 1181 1194 static struct … … 1215 1228 bool fNo = false; 1216 1229 char ch; 1230 unsigned i; 1231 1232 /* skip blanks. */ 1233 while (RT_C_IS_SPACE(*pszVar)) 1234 pszVar++; 1235 if (!*pszVar) 1236 return rc; 1237 1217 1238 while ((ch = *pszVar) != '\0') 1218 1239 { … … 1237 1258 1238 1259 /* instruction. */ 1239 unsigned i;1240 1260 for (i = 0; i < ELEMENTS(aDest); i++) 1241 1261 { … … 1371 1391 if (pLogger) 1372 1392 { 1393 int32_t i; 1394 unsigned j; 1395 1373 1396 AssertReturn(pLogger->u32Magic == RTLOGGER_MAGIC, VERR_INVALID_MAGIC); 1374 1397 … … 1376 1399 * Iterate the table to see if there is already an entry for this thread. 1377 1400 */ 1378 i nt32_t i= ELEMENTS(g_aPerThreadLoggers);1401 i = ELEMENTS(g_aPerThreadLoggers); 1379 1402 while (i-- > 0) 1380 1403 if (g_aPerThreadLoggers[i].NativeThread == Self) … … 1395 1418 } 1396 1419 1397 unsigned j;1398 1420 for (j = 0; j < 10; j++) 1399 1421 { … … 1624 1646 static void rtlogLogger(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, va_list args) 1625 1647 { 1648 int rc; 1649 1626 1650 /* 1627 1651 * Validate and correct iGroup. … … 1646 1670 * Acquire logger instance sem. 1647 1671 */ 1648 intrc = rtlogLock(pLogger);1672 rc = rtlogLock(pLogger); 1649 1673 if (RT_FAILURE(rc)) 1650 1674 return; … … 1853 1877 { 1854 1878 size_t cb = sizeof(pLogger->achScratch) - pLogger->offScratch - 1; 1879 char *psz; 1880 const char *pszNewLine; 1855 1881 1856 1882 /* … … 1885 1911 * psz is pointing to the current position. 1886 1912 */ 1887 char *psz = &pLogger->achScratch[pLogger->offScratch];1913 psz = &pLogger->achScratch[pLogger->offScratch]; 1888 1914 if (pLogger->fFlags & RTLOGFLAGS_PREFIX_TS) 1889 1915 { … … 2157 2183 2158 2184 /* have newline? */ 2159 const char *pszNewLine = (const char *)memchr(pachChars, '\n', cb);2185 pszNewLine = (const char *)memchr(pachChars, '\n', cb); 2160 2186 if (pszNewLine) 2161 2187 { -
trunk/src/VBox/Runtime/common/log/logcom.cpp
r6525 r7942 111 111 for (pu8 = (const uint8_t *)pach; cb-- > 0; pu8++) 112 112 { 113 register unsigned cMaxWait; 114 register uint8_t u8; 115 113 116 /* expand \n -> \r\n */ 114 117 if (*pu8 == '\n') … … 116 119 117 120 /* Check if port is ready. */ 118 register unsigned cMaxWait = ~0; 119 register uint8_t u8; 121 cMaxWait = ~0; 120 122 do 121 123 { -
trunk/src/VBox/Runtime/common/string/strprintf.cpp
r5999 r7942 81 81 RTDECL(size_t) RTStrPrintfExV(PFNSTRFORMAT pfnFormat, void *pvArg, char *pszBuffer, size_t cchBuffer, const char *pszFormat, va_list args) 82 82 { 83 STRBUFARG Arg; 84 83 85 if (!cchBuffer) 84 86 { … … 87 89 } 88 90 89 STRBUFARG Arg;90 91 Arg.psz = pszBuffer; 91 92 Arg.cch = cchBuffer - 1; … … 102 103 { 103 104 va_list args; 105 size_t cbRet; 104 106 va_start(args, pszFormat); 105 size_tcbRet = RTStrPrintfExV(pfnFormat, pvArg, pszBuffer, cchBuffer, pszFormat, args);107 cbRet = RTStrPrintfExV(pfnFormat, pvArg, pszBuffer, cchBuffer, pszFormat, args); 106 108 va_end(args); 107 109 return cbRet; … … 111 113 { 112 114 va_list args; 115 size_t cbRet; 113 116 va_start(args, pszFormat); 114 size_tcbRet = RTStrPrintfV(pszBuffer, cchBuffer, pszFormat, args);117 cbRet = RTStrPrintfV(pszBuffer, cchBuffer, pszFormat, args); 115 118 va_end(args); 116 119 return cbRet; -
trunk/src/VBox/Runtime/common/string/strtonum.cpp
r7169 r7942 106 106 RTDECL(int) RTStrToUInt64Ex(const char *pszValue, char **ppszNext, unsigned uBase, uint64_t *pu64) 107 107 { 108 const char *psz = pszValue; 108 const char *psz = pszValue; 109 int iShift; 110 int rc; 111 uint64_t u64; 112 unsigned char uch; 109 113 110 114 /* … … 153 157 * Note: We only support ascii digits at this time... :-) 154 158 */ 155 i nt iShift = g_auchShift[uBase];159 iShift = g_auchShift[uBase]; 156 160 pszValue = psz; /* (Prefix and sign doesn't count in the digit counting.) */ 157 int rc = VINF_SUCCESS; 158 uint64_t u64 = 0; 159 unsigned char uch; 161 rc = VINF_SUCCESS; 162 u64 = 0; 160 163 while ((uch = (unsigned char)*psz) != 0) 161 164 { 162 165 unsigned char chDigit = g_auchDigits[uch]; 166 uint64_t u64Prev; 167 163 168 if (chDigit >= uBase) 164 169 break; 165 170 166 u int64_t u64Prev = u64;171 u64Prev = u64; 167 172 u64 *= uBase; 168 173 u64 += chDigit; … … 534 539 RTDECL(int) RTStrToInt64Ex(const char *pszValue, char **ppszNext, unsigned uBase, int64_t *pi64) 535 540 { 536 const char *psz = pszValue; 541 const char *psz = pszValue; 542 int iShift; 543 int rc; 544 int64_t i64; 545 unsigned char uch; 537 546 538 547 /* … … 581 590 * Note: We only support ascii digits at this time... :-) 582 591 */ 583 i nt iShift = g_auchShift[uBase]; /** @todo test this, it's probably not 100% right yet. */592 iShift = g_auchShift[uBase]; /** @todo test this, it's probably not 100% right yet. */ 584 593 pszValue = psz; /* (Prefix and sign doesn't count in the digit counting.) */ 585 int rc = VINF_SUCCESS; 586 int64_t i64 = 0; 587 unsigned char uch; 594 rc = VINF_SUCCESS; 595 i64 = 0; 588 596 while ((uch = (unsigned char)*psz) != 0) 589 597 { 590 598 unsigned char chDigit = g_auchDigits[uch]; 599 int64_t i64Prev; 600 591 601 if (chDigit >= uBase) 592 602 break; 593 603 594 i nt64_t i64Prev = i64;604 i64Prev = i64; 595 605 i64 *= uBase; 596 606 i64 += chDigit;
Note:
See TracChangeset
for help on using the changeset viewer.