Changeset 1886 in kBuild for trunk/src/kmk/variable.c
- Timestamp:
- Oct 19, 2008 10:27:49 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/variable.c
r1877 r1886 108 108 #if defined(VARIABLE_HASH) || defined(CONFIG_WITH_OPTIMIZATION_HACKS) 109 109 # ifdef _MSC_VER 110 # define inline _inline111 110 typedef signed int int32_t; 112 111 # endif 113 static inlineunsigned long variable_hash_2i(register const char *var, register int length)112 MY_INLINE unsigned long variable_hash_2i(register const char *var, register int length) 114 113 { 115 114 # define UPDATE_HASH(ch) hash = (ch) + (hash << 6) + (hash << 16) - hash … … 170 169 } 171 170 172 static inlineunsigned long variable_hash_1i(register const char *var, register int length)171 MY_INLINE unsigned long variable_hash_1i(register const char *var, register int length) 173 172 { 174 173 # define UPDATE_HASH(ch) hash = ((hash << 5) + hash) + (ch) … … 339 338 } 340 339 341 #ifndef VARIABLE_HASH 342 static int 343 variable_hash_cmp (const void *xv, const void *yv) 344 { 345 struct variable const *x = (struct variable const *) xv; 346 struct variable const *y = (struct variable const *) yv; 347 int result = x->length - y->length; 348 if (result) 349 return result; 350 return_STRING_N_COMPARE (x->name, y->name, x->length); 351 } 352 #else /* VARIABLE_HASH */ 353 354 inline static int 340 #if defined(VARIABLE_HASH) || defined(KMK) 341 342 MY_INLINE int 355 343 variable_hash_cmp_2_memcmp (const char *xs, const char *ys, unsigned int length) 356 344 { … … 426 414 } 427 415 428 inline staticint416 MY_INLINE int 429 417 variable_hash_cmp_2_inlined (const char *xs, const char *ys, unsigned int length) 430 418 { … … 532 520 } 533 521 534 inline static int 522 #endif /* VARIABLE_HASH || KMK */ 523 524 #ifndef VARIABLE_HASH 525 static int 526 variable_hash_cmp (const void *xv, const void *yv) 527 { 528 struct variable const *x = (struct variable const *) xv; 529 struct variable const *y = (struct variable const *) yv; 530 # ifndef CONFIG_WITH_STRCACHE2 531 int result = x->length - y->length; 532 if (result) 533 return result; 534 # else /* CONFIG_WITH_STRCACHE2 */ 535 int result; 536 537 if (x->value != (char *)x) /* hack: strcache indicator */ 538 { 539 assert (y->value != (char *)y); 540 return x->name == y->name ? 0 : -1; 541 } 542 543 /* lookup path: */ 544 result = x->length - y->length; 545 if (result) 546 return result; 547 # endif /* CONFIG_WITH_STRCACHE2 */ 548 549 # ifndef KMK 550 return_STRING_N_COMPARE (x->name, y->name, x->length); 551 # else /* KMK */ 552 # if 0 553 return variable_hash_cmp_2_memcmp(x->name, y->name, x->length); 554 # else 555 return variable_hash_cmp_2_inlined(x->name, y->name, x->length); 556 # endif 557 # endif /* KMK */ 558 } 559 560 #else /* VARIABLE_HASH */ 561 562 MY_INLINE int 535 563 variable_hash_cmp (const void *xv, const void *yv) 536 564 { … … 549 577 __asm__("int3"); 550 578 # endif /* VARIABLE_HASH_STRICT */ 579 580 # ifdef CONFIG_WITH_STRCACHE2 581 /* strcaching */ 582 if (x->value != (char *)x) /* hack: strcache indicator */ 583 { 584 assert (y->value != (char *)y); 585 return x->name == y->name ? 0 : -1; 586 } 587 #endif 551 588 552 589 /* hash 1 & length */ … … 649 686 set = &global_variable_set; 650 687 688 #ifndef CONFIG_WITH_STRCACHE2 651 689 var_key.name = (char *) name; 690 #else 691 var_key.value = NULL; /* hack: name cached. (value != var) */ 692 var_key.name = name = strcache2_add (&variable_strcache, name, length); 693 #endif 652 694 var_key.length = length; 653 695 #ifdef VARIABLE_HASH /* bird */ … … 721 763 v->name = savestring (name, length); 722 764 #else 723 v->name = strcache2_add (&variable_strcache, name, length);765 v->name = name; /* already cached. */ 724 766 #endif 725 767 v->length = length; 726 768 #ifdef VARIABLE_HASH /* bird */ 727 v->hash1 = variable_hash_1i (name, length); 769 v->hash1 = variable_hash_1i (name, length); /* FIXME: Unnecessary! */ 728 770 v->hash2 = 0; 729 771 #endif … … 887 929 var_key.hash1 = variable_hash_1i (name, length); 888 930 var_key.hash2 = 0; 931 #endif 932 #ifdef CONFIG_WITH_STRCACHE2 933 var_key.value = (char *)&var_key; /* hack: name not cached */ 889 934 #endif 890 935 … … 1008 1053 var_key.hash1 = variable_hash_1i (name, length); 1009 1054 var_key.hash2 = 0; 1055 #endif 1056 #ifdef CONFIG_WITH_STRCACHE2 1057 var_key.value = (char *)&var_key; /* hack: name not cached */ 1010 1058 #endif 1011 1059 … … 1768 1816 makelevel_key.hash2 = 0; 1769 1817 #endif 1818 #ifdef CONFIG_WITH_STRCACHE2 1819 makelevel_key.value = (char *)&makelevel_key; /* hack: name not cached */ 1820 #endif 1770 1821 hash_delete (&table, &makelevel_key); 1771 1822
Note:
See TracChangeset
for help on using the changeset viewer.