儲存庫 kBuild 的更動 2771
- 時間撮記:
- 2015-2-1 下午08:48:36 (10 年 以前)
- 位置:
- trunk/src/kmk
- 檔案:
-
- 修改 9 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/kmk/expand.c
r2770 r2771 190 190 #else /* CONFIG_WITH_VALUE_LENGTH */ 191 191 if (!v->append) 192 value = allocated_variable_expand_2 (v->value, v->value_length, value_lenp); 192 { 193 if (!IS_VARIABLE_RECURSIVE_WITHOUT_DOLLAR (v)) 194 value = allocated_variable_expand_2 (v->value, v->value_length, value_lenp); 195 else 196 { 197 unsigned int len = v->value_length; 198 value = xmalloc (len + 2); 199 memcpy (value, v->value, len + 1); 200 value[len + 1] = '\0'; /* Extra terminator like allocated_variable_expand_2 returns. Why? */ 201 if (value_lenp) 202 *value_lenp = len; 203 } 204 } 193 205 else 194 206 { … … 312 324 #ifdef CONFIG_WITH_VALUE_LENGTH 313 325 assert (v->value_length == strlen (v->value)); 314 if (!v->recursive )326 if (!v->recursive || IS_VARIABLE_RECURSIVE_WITHOUT_DOLLAR (v)) 315 327 o = variable_buffer_output (o, v->value, v->value_length); 316 328 else … … 1010 1022 1011 1023 /* Either expand it or copy it, depending. */ 1012 if (! v->recursive )1024 if (! v->recursive || IS_VARIABLE_RECURSIVE_WITHOUT_DOLLAR (v)) 1013 1025 #ifdef CONFIG_WITH_VALUE_LENGTH 1014 1026 return variable_buffer_output (buf, v->value, v->value_length); -
trunk/src/kmk/function.c
r2770 r2771 2168 2168 /* Compile the variable for evalval, evalctx and expansion. */ 2169 2169 2170 if ( !v->evalprog)2171 kmk_cc_compile_variable_for_eval (v);2172 if (!v->expandprog)2173 kmk_cc_compile_variable_for_expand(v);2170 if ( v->recursive 2171 && !IS_VARIABLE_RECURSIVE_WITHOUT_DOLLAR (v)) 2172 kmk_cc_compile_variable_for_expand (v); 2173 kmk_cc_compile_variable_for_eval (v); 2174 2174 # endif 2175 2175 } … … 4122 4122 if (var1->value == var2->value) 4123 4123 return variable_buffer_output (o, "", 0); /* eq */ 4124 if (!var1->recursive && !var2->recursive) 4124 if ( (!var1->recursive || IS_VARIABLE_RECURSIVE_WITHOUT_DOLLAR (var1)) 4125 && (!var2->recursive || IS_VARIABLE_RECURSIVE_WITHOUT_DOLLAR (var2)) ) 4125 4126 { 4126 4127 if ( var1->value_length == var2->value_length … … 6005 6006 if (v && v->value_length) 6006 6007 { 6007 if (v->recursive )6008 if (v->recursive && !IS_VARIABLE_RECURSIVE_WITHOUT_DOLLAR (v)) 6008 6009 { 6009 6010 v->exp_count = EXP_COUNT_MAX; -
trunk/src/kmk/kbuild.c
r2770 r2771 1575 1575 { \ 1576 1576 paVars[iVar].pVar = pVar; \ 1577 if ( 1578 || !memchr(pVar->value, '$', pVar->value_length)) \1577 if ( !pVar->recursive \ 1578 || IS_VARIABLE_RECURSIVE_WITHOUT_DOLLAR(pVar)) \ 1579 1579 { \ 1580 1580 paVars[iVar].pszExp = pVar->value; \ -
trunk/src/kmk/kmk_cc_exec.c
r2770 r2771 42 42 #include <stdarg.h> 43 43 #include <assert.h> 44 45 /******************************************************************************* 46 * Defined Constants And Macros * 47 *******************************************************************************/ 48 /** @def KMK_CC_WITH_STATS 49 * Enables the collection of extra statistics. */ 50 #ifndef KMK_CC_WITH_STATS 51 # ifdef CONFIG_WITH_MAKE_STATS 52 # define KMK_CC_WITH_STATS 53 # endif 54 #endif 55 56 /** @def KMK_CC_STRICT 57 * Indicates whether assertions and other checks are enabled. */ 58 #ifndef KMK_CC_STRICT 59 # ifndef NDEBUG 60 # define KMK_CC_STRICT 61 # endif 62 #endif 63 64 #ifdef KMK_CC_STRICT 65 # ifdef _MSC_VER 66 # define KMK_CC_ASSERT(a_TrueExpr) do { if (!(a_TrueExpr)) __debugbreak(); } while (0) 67 # else 68 # define KMK_CC_ASSERT(a_TrueExpr) assert(a_TrueExpr) 69 # endif 70 #else 71 # define KMK_CC_ASSERT(a_TrueExpr) do {} while (0) 72 #endif 73 #define KMK_CC_ASSERT_ALIGNED(a_uValue, a_uAlignment) \ 74 KMK_CC_ASSERT( ((a_uValue) & ((a_uAlignment) - 1)) == 0 ) 44 75 45 76 … … 264 295 /** Calculates the size of an KMKCCEXPPLAINFUNC with a_cArgs. */ 265 296 #define KMKCCEXPDYNFUNC_SIZE(a_cArgs) ( sizeof(KMKCCEXPFUNCCORE) \ 266 297 + (a_cArgs) * sizeof(((PKMKCCEXPDYNFUNC)(uintptr_t)42)->aArgs[0]) ) 267 298 268 299 /** … … 289 320 /** Statistics. */ 290 321 KMKCCEXPSTATS Stats; 322 #ifdef KMK_CC_STRICT 323 /** The hash of the input string. Used to check that we get all the change 324 * notifications we require. */ 325 uint32_t uInputHash; 326 #endif 291 327 } KMKCCEXPPROG; 292 328 /** Pointer to a string expansion program. */ … … 295 331 296 332 /******************************************************************************* 297 * Defined Constants And Macros *298 *******************************************************************************/299 #ifndef NDEBUG300 # ifdef _MSC_VER301 # define KMK_CC_ASSERT(a_TrueExpr) do { if (!(a_TrueExpr)) __debugbreak(); } while (0)302 # else303 # define KMK_CC_ASSERT(a_TrueExpr) assert(a_TrueExpr)304 # endif305 #else306 # define KMK_CC_ASSERT(a_TrueExpr) do {} while (0)307 #endif308 #define KMK_CC_ASSERT_ALIGNED(a_uValue, a_uAlignment) \309 KMK_CC_ASSERT( ((a_uValue) & ((a_uAlignment) - 1)) == 0 )310 311 312 /*******************************************************************************313 333 * Global Variables * 314 334 *******************************************************************************/ 335 static uint32_t g_cVarForExpandCompilations = 0; 336 static uint32_t g_cVarForExpandExecs = 0; 337 #ifdef KMK_CC_WITH_STATS 338 static uint32_t g_cBlockAllocated = 0; 339 static uint32_t g_cbAllocated = 0; 340 static uint32_t g_cBlocksAllocatedExpProgs = 0; 341 static uint32_t g_cbAllocatedExpProgs = 0; 342 static uint32_t g_cSingleBlockExpProgs = 0; 343 static uint32_t g_cTwoBlockExpProgs = 0; 344 static uint32_t g_cMultiBlockExpProgs = 0; 345 static uint32_t g_cbUnusedMemExpProgs = 0; 346 #endif 315 347 316 348 … … 331 363 332 364 /** 365 * Prints stats (for kmk -p). 366 */ 367 void kmk_cc_print_stats(void) 368 { 369 puts(_("\n# The kmk 'compiler' and kmk 'program executor':\n")); 370 371 printf(_("# Variables compiled for string expansion: %6u\n"), g_cVarForExpandCompilations); 372 printf(_("# Variables string expansion runs: %6u\n"), g_cVarForExpandExecs); 373 printf(_("# String expansion runs per compile: %6u\n"), g_cVarForExpandExecs / g_cVarForExpandExecs); 374 #ifdef KMK_CC_WITH_STATS 375 printf(_("# Single alloc block exp progs: %6u (%u%%)\n" 376 "# Two alloc block exp progs: %6u (%u%%)\n" 377 "# Three or more alloc block exp progs: %6u (%u%%)\n" 378 ), 379 g_cSingleBlockExpProgs, (uint32_t)((uint64_t)g_cSingleBlockExpProgs * 100 / g_cVarForExpandCompilations), 380 g_cTwoBlockExpProgs, (uint32_t)((uint64_t)g_cTwoBlockExpProgs * 100 / g_cVarForExpandCompilations), 381 g_cMultiBlockExpProgs, (uint32_t)((uint64_t)g_cMultiBlockExpProgs * 100 / g_cVarForExpandCompilations)); 382 printf(_("# Total amount of memory for exp progs: %8u bytes\n" 383 "# in: %6u blocks\n" 384 "# avg block size: %6u bytes\n" 385 "# unused memory: %8u bytes (%u%%)\n" 386 "# avg unused memory per block: %6u bytes\n" 387 "\n"), 388 g_cbAllocatedExpProgs, g_cBlocksAllocatedExpProgs, g_cbAllocatedExpProgs / g_cBlocksAllocatedExpProgs, 389 g_cbUnusedMemExpProgs, (uint32_t)((uint64_t)g_cbUnusedMemExpProgs * 100 / g_cbAllocatedExpProgs), 390 g_cbUnusedMemExpProgs / g_cBlocksAllocatedExpProgs); 391 392 printf(_("# Total amount of block mem allocated: %8u bytes\n"), g_cbAllocated); 393 printf(_("# Total number of block allocated: %8u\n"), g_cBlockAllocated); 394 printf(_("# Average block size: %8u byte\n"), g_cbAllocated / g_cBlockAllocated); 395 #endif 396 397 puts(""); 398 } 399 400 401 /* 402 * 403 * Various utility functions. 404 * Various utility functions. 405 * Various utility functions. 406 * 407 */ 408 409 /** 410 * Counts the number of dollar chars in the string. 411 * 412 * @returns Number of dollar chars. 413 * @param pchStr The string to search (does not need to be zero 414 * terminated). 415 * @param cchStr The length of the string. 416 */ 417 static uint32_t kmk_cc_count_dollars(const char *pchStr, uint32_t cchStr) 418 { 419 uint32_t cDollars = 0; 420 const char *pch; 421 while ((pch = memchr(pchStr, '$', cchStr)) != NULL) 422 { 423 cDollars++; 424 cchStr -= pch - pchStr + 1; 425 pchStr = pch + 1; 426 } 427 return cDollars; 428 } 429 430 #ifdef KMK_CC_STRICT 431 /** 432 * Used to check that function arguments are left alone. 433 * @returns Updated hash. 434 * @param uHash The current hash value. 435 * @param psz The string to hash. 436 */ 437 static uint32_t kmk_cc_debug_string_hash(uint32_t uHash, const char *psz) 438 { 439 unsigned char ch; 440 while ((ch = *(unsigned char const *)psz++) != '\0') 441 uHash = (uHash << 6) + (uHash << 16) - uHash + (unsigned char)ch; 442 return uHash; 443 } 444 445 /** 446 * Used to check that function arguments are left alone. 447 * @returns Updated hash. 448 * @param uHash The current hash value. 449 * @param pch The string to hash, not terminated. 450 * @param cch The number of chars to hash. 451 */ 452 static uint32_t kmk_cc_debug_string_hash_n(uint32_t uHash, const char *pch, uint32_t cch) 453 { 454 while (cch-- > 0) 455 { 456 unsigned char ch = *(unsigned char const *)pch++; 457 uHash = (uHash << 6) + (uHash << 16) - uHash + (unsigned char)ch; 458 } 459 return uHash; 460 } 461 462 #endif 463 464 465 466 /* 467 * 468 * The allocator. 469 * The allocator. 470 * The allocator. 471 * 472 */ 473 474 475 /** 333 476 * For the first allocation using the block allocator. 334 477 * … … 349 492 */ 350 493 if (cbHint <= 512) 351 cbBlock = 512; 494 { 495 if (cbHint <= 256) 496 cbBlock = 128; 497 else 498 cbBlock = 256; 499 } 352 500 else if (cbHint < 2048) 353 501 cbBlock = 1024; … … 366 514 *ppBlockTail = pNewBlock; 367 515 516 #ifdef KMK_CC_WITH_STATS 517 g_cBlockAllocated++; 518 g_cbAllocated += cbBlock; 519 #endif 520 368 521 return pNewBlock + 1; 369 522 } … … 439 592 *ppBlockTail = pNewBlock; 440 593 594 #ifdef KMK_CC_WITH_STATS 595 g_cBlockAllocated++; 596 g_cbAllocated += cbBlock; 597 #endif 598 441 599 return pNewBlock + 1; 442 600 } … … 506 664 507 665 /* Figure the block size. */ 508 uint32_t cbBlock = pOldBlock->cbBlock;666 uint32_t cbBlock = !pOldBlock->pNext ? 128 : pOldBlock->cbBlock; 509 667 while (cbBlock - sizeof(KMKCCEXPJUMP) - sizeof(*pNewBlock) < cb) 510 668 cbBlock *= 2; … … 517 675 *ppBlockTail = pNewBlock; 518 676 677 #ifdef KMK_CC_WITH_STATS 678 g_cBlockAllocated++; 679 g_cbAllocated += cbBlock; 680 #endif 681 519 682 pRet = (PKMKCCEXPCORE)(pNewBlock + 1); 520 683 … … 571 734 572 735 573 /** 574 * Counts the number of dollar chars in the string. 575 * 576 * @returns Number of dollar chars. 577 * @param pchStr The string to search (does not need to be zero 578 * terminated). 579 * @param cchStr The length of the string. 580 */ 581 static uint32_t kmk_cc_count_dollars(const char *pchStr, uint32_t cchStr) 582 { 583 uint32_t cDollars = 0; 584 const char *pch; 585 while ((pch = memchr(pchStr, '$', cchStr)) != NULL) 586 { 587 cDollars++; 588 cchStr -= pch - pchStr + 1; 589 pchStr = pch + 1; 590 } 591 return cDollars; 592 } 736 /* 737 * 738 * The string expansion compiler. 739 * The string expansion compiler. 740 * The string expansion compiler. 741 * 742 */ 593 743 594 744 … … 622 772 default: 623 773 return 0; 774 775 case 'e': 776 if (!strcmp(pszFunction, "eval")) 777 return 1; 778 if (!strcmp(pszFunction, "evalctx")) 779 return 1; 780 return 0; 781 624 782 case 'f': 625 if (pszFunction[1] == 'i') 626 { 627 if (!strcmp(pszFunction, "filter")) 628 return 1; 629 if (!strcmp(pszFunction, "filter-out")) 630 return 1; 631 } 783 if (!strcmp(pszFunction, "filter")) 784 return 1; 785 if (!strcmp(pszFunction, "filter-out")) 786 return 1; 787 if (!strcmp(pszFunction, "for")) 788 return 1; 632 789 return 0; 790 633 791 case 's': 634 792 if (!strcmp(pszFunction, "sort")) … … 1295 1453 PKMKCCBLOCK pBlock; 1296 1454 pProg = kmk_cc_block_alloc_first(&pBlock, sizeof(*pProg), 1297 (kmk_cc_count_dollars(pchStr, cchStr) + 8) * 16);1455 (kmk_cc_count_dollars(pchStr, cchStr) + 4) * 8); 1298 1456 if (pProg) 1299 1457 { … … 1303 1461 pProg->pFirstInstr = (PKMKCCEXPCORE)kmk_cc_block_get_next_ptr(pBlock); 1304 1462 kmk_cc_exp_stats_init(&pProg->Stats); 1463 #ifdef KMK_CC_STRICT 1464 pProg->uInputHash = kmk_cc_debug_string_hash_n(0, pchStr, cchStr); 1465 #endif 1305 1466 1306 1467 /* … … 1308 1469 */ 1309 1470 if (kmk_cc_exp_compile_common(&pProg->pBlockTail, pchStr, cchStr) == 0) 1471 { 1472 #ifdef KMK_CC_WITH_STATS 1473 pBlock = pProg->pBlockTail; 1474 if (!pBlock->pNext) 1475 g_cSingleBlockExpProgs++; 1476 else if (!pBlock->pNext->pNext) 1477 g_cTwoBlockExpProgs++; 1478 else 1479 g_cMultiBlockExpProgs++; 1480 for (; pBlock; pBlock = pBlock->pNext) 1481 { 1482 g_cBlocksAllocatedExpProgs++; 1483 g_cbAllocatedExpProgs += pBlock->cbBlock; 1484 g_cbUnusedMemExpProgs += pBlock->cbBlock - pBlock->offNext; 1485 } 1486 #endif 1310 1487 return pProg; 1488 } 1311 1489 kmk_cc_block_free_list(pProg->pBlockTail); 1312 1490 } 1313 1491 return NULL; 1314 1492 } 1315 1316 1493 1317 1494 … … 1325 1502 { 1326 1503 return NULL; 1504 } 1505 1506 1507 /** 1508 * Updates the recursive_without_dollar member of a variable structure. 1509 * 1510 * This avoid compiling string expansion programs without only a CopyString 1511 * instruction. By setting recursive_without_dollar to 1, code calling 1512 * kmk_cc_compile_variable_for_expand and kmk_exec_expand_to_var_buf will 1513 * instead treat start treating it as a simple variable, which is faster. 1514 * 1515 * @returns The updated recursive_without_dollar value. 1516 * @param pVar Pointer to the variable. 1517 */ 1518 static int kmk_cc_update_variable_recursive_without_dollar(struct variable *pVar) 1519 { 1520 int fValue; 1521 KMK_CC_ASSERT(pVar->recursive_without_dollar == 0); 1522 1523 if (memchr(pVar->value, '$', pVar->value_length)) 1524 fValue = -1; 1525 else 1526 fValue = 1; 1527 pVar->recursive_without_dollar = fValue; 1528 1529 return fValue; 1327 1530 } 1328 1531 … … 1337 1540 struct kmk_cc_expandprog *kmk_cc_compile_variable_for_expand(struct variable *pVar) 1338 1541 { 1542 KMK_CC_ASSERT(strlen(pVar->value) == pVar->value_length); 1339 1543 KMK_CC_ASSERT(!pVar->expandprog); 1544 KMK_CC_ASSERT(pVar->recursive_without_dollar <= 0); 1545 1340 1546 if ( !pVar->expandprog 1341 && pVar->value_length > 01342 1547 && pVar->recursive) 1343 1548 { 1344 KMK_CC_ASSERT(strlen(pVar->value) == pVar->value_length); 1345 pVar->expandprog = kmk_cc_exp_compile(pVar->value, pVar->value_length); 1549 if ( pVar->recursive_without_dollar < 0 1550 || ( pVar->recursive_without_dollar == 0 1551 && kmk_cc_update_variable_recursive_without_dollar(pVar) < 0) ) 1552 { 1553 pVar->expandprog = kmk_cc_exp_compile(pVar->value, pVar->value_length); 1554 g_cVarForExpandCompilations++; 1555 } 1346 1556 } 1347 1557 return pVar->expandprog; 1348 1558 } 1349 1350 1351 #ifndef NDEBUG1352 /**1353 * Used to check that function arguments are left alone.1354 * @returns Updated hash.1355 * @param uHash The current hash value.1356 * @param psz The string to hash.1357 */1358 static uint32_t kmk_exec_debug_string_hash(uint32_t uHash, const char *psz)1359 {1360 unsigned char ch;1361 while ((ch = *(unsigned char const *)psz++) != '\0')1362 uHash = (uHash << 6) + (uHash << 16) - uHash + (unsigned char)ch;1363 return uHash;1364 }1365 #endif1366 1559 1367 1560 … … 1377 1570 if (pVar->value_length > 0) 1378 1571 { 1379 if (!pVar->recursive )1572 if (!pVar->recursive || IS_VARIABLE_RECURSIVE_WITHOUT_DOLLAR(pVar)) 1380 1573 pchDst = variable_buffer_output(pchDst, pVar->value, pVar->value_length); 1381 1574 else … … 1527 1720 if (!pInstr->Core.fDirty) 1528 1721 { 1529 #if ndef NDEBUG1722 #ifdef KMK_CC_STRICT 1530 1723 uint32_t uCrcBefore = 0; 1531 1724 uint32_t uCrcAfter = 0; 1532 1725 iArg = pInstr->Core.cArgs; 1533 1726 while (iArg-- > 0) 1534 uCrcBefore = kmk_ exec_debug_string_hash(uCrcBefore, pInstr->apszArgs[iArg]);1727 uCrcBefore = kmk_cc_debug_string_hash(uCrcBefore, pInstr->apszArgs[iArg]); 1535 1728 #endif 1536 1729 1537 1730 pchDst = pInstr->Core.pfnFunction(pchDst, (char **)&pInstr->apszArgs[0], pInstr->Core.pszFuncName); 1538 1731 1539 #if ndef NDEBUG1732 #ifdef KMK_CC_STRICT 1540 1733 iArg = pInstr->Core.cArgs; 1541 1734 while (iArg-- > 0) 1542 uCrcAfter = kmk_ exec_debug_string_hash(uCrcAfter, pInstr->apszArgs[iArg]);1735 uCrcAfter = kmk_cc_debug_string_hash(uCrcAfter, pInstr->apszArgs[iArg]); 1543 1736 KMK_CC_ASSERT(uCrcBefore == uCrcAfter); 1544 1737 #endif … … 1575 1768 if (!pInstr->Core.fDirty) 1576 1769 { 1577 #if ndef NDEBUG1770 #ifdef KMK_CC_STRICT 1578 1771 uint32_t uCrcBefore = 0; 1579 1772 uint32_t uCrcAfter = 0; … … 1590 1783 papszArgsShadow[iArg] = pszArg; 1591 1784 papszArgs[iArg] = pszArg; 1592 #if ndef NDEBUG1593 uCrcBefore = kmk_ exec_debug_string_hash(uCrcBefore, pszArg);1785 #ifdef KMK_CC_STRICT 1786 uCrcBefore = kmk_cc_debug_string_hash(uCrcBefore, pszArg); 1594 1787 #endif 1595 1788 } … … 1599 1792 while (iArg-- > 0) 1600 1793 { 1601 #if ndef NDEBUG1794 #ifdef KMK_CC_STRICT 1602 1795 KMK_CC_ASSERT(papszArgsShadow[iArg] == papszArgs[iArg]); 1603 uCrcAfter = kmk_ exec_debug_string_hash(uCrcAfter, papszArgsShadow[iArg]);1796 uCrcAfter = kmk_cc_debug_string_hash(uCrcAfter, papszArgsShadow[iArg]); 1604 1797 #endif 1605 1798 if (!pInstr->aArgs[iArg].fPlain) … … 1733 1926 cchResult -= offStart; 1734 1927 kmk_cc_exp_stats_update(&pProg->Stats, cchResult); 1928 g_cVarForExpandExecs++; 1735 1929 1736 1930 return pchDst; … … 1760 1954 { 1761 1955 KMK_CC_ASSERT(pVar->expandprog); 1956 KMK_CC_ASSERT(pVar->expandprog->uInputHash == kmk_cc_debug_string_hash(0, pVar->value)); 1762 1957 return kmk_exec_expand_prog_to_var_buf(pVar->expandprog, pchDst); 1763 1958 } -
trunk/src/kmk/kmk_cc_exec.h
r2767 r2771 31 31 32 32 void kmk_cc_init(void); 33 void kmk_cc_print_stats(void); 33 34 34 35 extern struct kmk_cc_evalprog *kmk_cc_compile_variable_for_eval(struct variable *pVar); -
trunk/src/kmk/kmkbuiltin/append.c
r2757 r2771 218 218 if (!pVar) 219 219 continue; 220 if ( pVar->recursive 221 && memchr(pVar->value, '$', pVar->value_length)) 220 if ( !pVar->recursive 221 || IS_VARIABLE_RECURSIVE_WITHOUT_DOLLAR(pVar)) 222 fwrite(pVar->value, 1, pVar->value_length, pFile); 223 else 222 224 { 223 225 char *pszExpanded = allocated_variable_expand(pVar->value); … … 225 227 free(pszExpanded); 226 228 } 227 else228 fwrite(pVar->value, 1, pVar->value_length, pFile);229 229 } 230 230 else -
trunk/src/kmk/main.c
r2767 r2771 3832 3832 alloccache_print_all (); 3833 3833 #endif 3834 #ifdef CONFIG_WITH_COMPILER 3835 kmk_cc_print_stats (); 3836 #endif 3834 3837 3835 3838 when = time ((time_t *) 0); -
trunk/src/kmk/variable.c
r2770 r2771 449 449 v->export = v_default; 450 450 #ifdef CONFIG_WITH_COMPILER 451 v->recursive_without_dollar = 0; 451 452 v->evalprog = 0; 452 453 v->expandprog = 0; … … 617 618 v->export = v_default; 618 619 #ifdef CONFIG_WITH_COMPILER 620 v->recursive_without_dollar = 0; 619 621 v->evalprog = 0; 620 622 v->expandprog = 0; … … 2867 2869 static unsigned long var_stats_expands, var_stats_expanded; 2868 2870 #endif 2871 #ifdef CONFIG_WITH_COMPILER 2872 static unsigned long var_stats_expandprogs, var_stats_evalprogs; 2873 #endif 2869 2874 #ifdef CONFIG_WITH_MAKE_STATS 2870 2875 static unsigned long var_stats_changes, var_stats_changed; … … 2940 2945 #if defined (CONFIG_WITH_COMPILER) || defined (CONFIG_WITH_MAKE_STATS) 2941 2946 if (v->evalval_count != 0) 2947 { 2942 2948 # ifdef CONFIG_WITH_MAKE_STATS 2943 printf (_(", %u evalvals (%llu ticks)"), v->evalval_count, v->cTicksEvalVal);2949 printf (_(", %u evalvals (%llu ticks)"), v->evalval_count, v->cTicksEvalVal); 2944 2950 # else 2945 printf (_(", %u evalvals"), v->evalval_count);2951 printf (_(", %u evalvals"), v->evalval_count); 2946 2952 # endif 2953 var_stats_evalvaled++; 2954 } 2947 2955 var_stats_evalvals += v->evalval_count; 2948 var_stats_evalvaled += (v->evalval_count != 0);2949 2956 2950 2957 if (v->expand_count != 0) 2951 printf (_(", %u expands"), v->expand_count); 2958 { 2959 printf (_(", %u expands"), v->expand_count); 2960 var_stats_expanded++; 2961 } 2952 2962 var_stats_expands += v->expand_count; 2953 var_stats_expanded += (v->expand_count != 0); 2963 2954 2964 # ifdef CONFIG_WITH_COMPILER 2955 2965 if (v->evalprog != 0) 2956 printf (_(", evalprog")); 2966 { 2967 printf (_(", evalprog")); 2968 var_stats_evalprogs++; 2969 } 2957 2970 if (v->expandprog != 0) 2958 printf (_(", expandprog")); 2971 { 2972 printf (_(", expandprog")); 2973 var_stats_expandprogs++; 2974 } 2959 2975 # endif 2960 2976 #endif … … 2962 2978 #ifdef CONFIG_WITH_MAKE_STATS 2963 2979 if (v->changes != 0) 2964 printf (_(", %u changes"), v->changes); 2980 { 2981 printf (_(", %u changes"), v->changes); 2982 var_stats_changed++; 2983 } 2965 2984 var_stats_changes += v->changes; 2966 var_stats_changed += (v->changes != 0);2967 2985 2968 2986 if (v->reallocs != 0) 2969 printf (_(", %u reallocs"), v->reallocs); 2987 { 2988 printf (_(", %u reallocs"), v->reallocs); 2989 var_stats_realloced++; 2990 } 2970 2991 var_stats_reallocs += v->reallocs; 2971 var_stats_realloced += (v->reallocs != 0);2972 2992 2973 2993 if (v->references != 0) 2974 printf (_(", %u references"), v->references); 2994 { 2995 printf (_(", %u references"), v->references); 2996 var_stats_referenced++; 2997 } 2975 2998 var_stats_references += v->references; 2976 var_stats_referenced += (v->references != 0);2977 2999 2978 3000 var_stats_val_len += v->value_length; … … 3034 3056 = var_stats_evalvaled = 0; 3035 3057 #endif 3058 #ifdef CONFIG_WITH_COMPILER 3059 var_stats_expandprogs = var_stats_evalprogs = 0; 3060 #endif 3036 3061 #ifdef CONFIG_WITH_MAKE_STATS 3037 3062 var_stats_changes = var_stats_changed = var_stats_reallocs … … 3088 3113 var_stats_expands); 3089 3114 #endif 3115 #ifdef CONFIG_WITH_COMPILER 3116 if (var_stats_expandprogs || var_stats_evalprogs) 3117 printf(_("# eval progs %5lu (%2u%%), expand progs %6lu (%2u%%)\n"), 3118 var_stats_evalprogs, 3119 (unsigned int)((100.0 * var_stats_evalprogs) / set->table.ht_fill), 3120 var_stats_expandprogs, 3121 (unsigned int)((100.0 * var_stats_expandprogs) / set->table.ht_fill)); 3122 #endif 3090 3123 } 3091 3124 -
trunk/src/kmk/variable.h
r2770 r2771 18 18 19 19 #include "hash.h" 20 #ifdef CONFIG_WITH_COMPILER 21 # include "kmk_cc_exec.h" 22 #endif 20 23 21 24 /* Codes in a variable definition saying where the definition came from. … … 109 112 v_default /* Decide in target_environment. */ 110 113 } export ENUM_BITFIELD (2); 114 #ifdef CONFIG_WITH_COMPILER 115 int recursive_without_dollar : 2; /* 0 if undetermined, 1 if value has no '$' chars, -1 if it has. */ 116 #endif 111 117 #ifdef CONFIG_WITH_MAKE_STATS 112 118 unsigned int changes; /* Variable modification count. */ … … 133 139 (v)->expand_count = 0; \ 134 140 (v)->evalval_count = 0; \ 141 (v)->recursive_without_dollar = 0; \ 135 142 } while (0) 136 143 #else 137 144 # define VARIABLE_CHANGED(v) MAKE_STATS_2((v)->changes++) 145 #endif 146 147 /* Macro that avoids a lot of CONFIG_WITH_COMPILER checks when 148 accessing recursive_without_dollar. */ 149 #ifdef CONFIG_WITH_COMPILER 150 # define IS_VARIABLE_RECURSIVE_WITHOUT_DOLLAR(v) ((v)->recursive_without_dollar > 0) 151 #else 152 # define IS_VARIABLE_RECURSIVE_WITHOUT_DOLLAR(v) 0 138 153 #endif 139 154
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器