- Timestamp:
- Oct 20, 2008, 1:31:38 AM (17 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/Makefile.am
r1870 r1889 114 114 -DKMK \ 115 115 -DKMK_HELPERS \ 116 -DVARIABLE_HASH \117 116 -DCONFIG_NO_DEFAULT_SUFFIXES \ 118 117 -DCONFIG_NO_DEFAULT_PATTERN_RULES \ -
trunk/src/kmk/make.h
r1885 r1889 150 150 #endif 151 151 152 #if defined(KMK) || defined(CONFIG_WITH_VALUE_LENGTH) || defined (VARIABLE_HASH)152 #if defined(KMK) || defined(CONFIG_WITH_VALUE_LENGTH) 153 153 # ifdef _MSC_VER 154 154 # define MY_INLINE _inline static -
trunk/src/kmk/variable.c
r1888 r1889 110 110 /* Hash table of all global variable definitions. */ 111 111 112 #if defined(VARIABLE_HASH) || defined(CONFIG_WITH_OPTIMIZATION_HACKS) || defined(CONFIG_WITH_STRCACHE2)113 MY_INLINE unsigned long variable_hash_2i(register const char *var, register int length)114 {115 /* all requests are served from the cache. */116 return strcache2_get_hash2 (&variable_strcache, var);117 }118 119 MY_INLINE unsigned long variable_hash_1i(register const char *var, register int length)120 {121 /* all requests are served from the cache. */122 return strcache2_get_hash1 (&variable_strcache, var);123 }124 #endif /* CONFIG_WITH_OPTIMIZATION_HACKS */125 126 112 static unsigned long 127 113 variable_hash_1 (const void *keyv) 128 114 { 129 115 struct variable const *key = (struct variable const *) keyv; 130 #ifdef VARIABLE_HASH /* bird */ 131 # ifdef VARIABLE_HASH_STRICT 132 if (key->hash1 != variable_hash_1i (key->name, key->length)) 133 __asm__("int3"); 134 if (key->hash2 && key->hash2 != variable_hash_2i (key->name, key->length)) 135 __asm__("int3"); 136 # endif 137 return key->hash1; 138 #else 139 # if defined(CONFIG_WITH_STRCACHE2) 140 return variable_hash_1i (key->name, key->length); 141 # else 116 #ifndef CONFIG_WITH_STRCACHE2 142 117 return_STRING_N_HASH_1 (key->name, key->length); 143 # endif 118 #else 119 /* all requests are served from the cache. */ 120 return strcache2_get_hash1 (&variable_strcache, key->name); 144 121 #endif 145 122 } … … 148 125 variable_hash_2 (const void *keyv) 149 126 { 150 #ifdef VARIABLE_HASH /* bird */151 struct variable *key = (struct variable *) keyv;152 if (!key->hash2)153 key->hash2 = variable_hash_2i (key->name, key->length);154 return key->hash2;155 #else156 127 struct variable const *key = (struct variable const *) keyv; 157 # ifdef CONFIG_WITH_STRCACHE2 158 return variable_hash_2i (key->name, key->length); 159 # else 128 #ifndef CONFIG_WITH_STRCACHE2 160 129 return_STRING_N_HASH_2 (key->name, key->length); 161 # endif 130 #else 131 /* all requests are served from the cache. */ 132 return strcache2_get_hash2 (&variable_strcache, key->name); 162 133 #endif 163 134 } … … 253 224 var_key.name = (char *) name; 254 225 #else 255 var_key.value = NULL; /* hack: name cached. (value != var) */256 226 var_key.name = name = strcache2_add (&variable_strcache, name, length); 257 227 #endif 258 228 var_key.length = length; 259 #ifdef VARIABLE_HASH /* bird */260 var_key.hash1 = variable_hash_1i (name, length);261 var_key.hash2 = 0;262 #endif263 229 var_slot = (struct variable **) hash_find_slot (&set->table, &var_key); 264 230 … … 330 296 #endif 331 297 v->length = length; 332 #ifdef VARIABLE_HASH /* bird */333 v->hash1 = variable_hash_1i (name, length); /* FIXME: Unnecessary! */334 v->hash2 = 0;335 #endif336 298 hash_insert_at (&set->table, v, var_slot); 337 299 #ifdef CONFIG_WITH_VALUE_LENGTH … … 487 449 const struct variable_set_list *setlist; 488 450 struct variable var_key; 489 #if defined(KMK) && !defined(VARIABLE_HASH)451 #ifdef KMK 490 452 unsigned int hash_2 = 0; 491 453 #endif … … 503 465 var_key.name = (char *) name; 504 466 var_key.length = length; 505 #ifdef VARIABLE_HASH /* bird */506 var_key.hash1 = variable_hash_1i (name, length);507 var_key.hash2 = 0;508 #endif509 467 #ifdef CONFIG_WITH_STRCACHE2 510 468 var_key.value = (char *)&var_key; /* hack: name not cached */ … … 514 472 setlist != 0; setlist = setlist->next) 515 473 { 516 #if defined(KMK)/* bird: speed */474 #ifdef KMK /* bird: speed */ 517 475 struct hash_table *ht = &setlist->set->table; 518 # ifdef VARIABLE_HASH519 unsigned int hash_1 = var_key.hash1;520 # else521 476 unsigned int hash_1 = strcache2_get_hash1 (&variable_strcache, name); 522 # endif523 477 struct variable *v; 524 478 … … 535 489 if (variable_hash_cmp(&var_key, v) == 0) 536 490 { 537 # if def VARIABLE_HASH_STRICT /* bird */491 # ifndef NDEBUG 538 492 struct variable *v2 = (struct variable *) hash_find_item ((struct hash_table *) &setlist->set->table, &var_key); 539 493 assert (v2 == v); … … 543 497 ht->ht_collisions++; 544 498 } 545 # ifdef VARIABLE_HASH546 if (!var_key.hash2)547 var_key.hash2 = variable_hash_2i(name, length);548 hash_1 += (var_key.hash2 | 1);549 # else550 499 if (!hash_2) 551 500 { 552 hash_2 = strcache2_get_hash2 (&variable_strcache, name , length);501 hash_2 = strcache2_get_hash2 (&variable_strcache, name); 553 502 assert (hash_2 & 1); 554 503 } 555 504 hash_1 += hash_2; 556 # endif557 505 } 558 506 559 #else /* ! VARIABLE_HASH*/507 #else /* !KMK */ 560 508 const struct variable_set *set = setlist->set; 561 509 struct variable *v; … … 564 512 if (v) 565 513 return v->special ? handle_special_var (v) : v; 566 #endif /* ! VARIABLE_HASH*/514 #endif /* !KMK */ 567 515 } 568 516 … … 650 598 var_key.name = (char *) name; 651 599 var_key.length = length; 652 #ifdef VARIABLE_HASH /* bird */653 var_key.hash1 = variable_hash_1i (name, length);654 var_key.hash2 = 0;655 #endif656 600 #ifdef CONFIG_WITH_STRCACHE2 657 601 var_key.value = (char *)&var_key; /* hack: name not cached */ … … 1326 1270 char **result_0; 1327 1271 char **result; 1272 #ifdef CONFIG_WITH_STRCACHE2 1273 const char *cached_name; 1274 #endif 1328 1275 1329 1276 if (file == 0) … … 1413 1360 makelevel_key.name = MAKELEVEL_NAME; 1414 1361 makelevel_key.length = MAKELEVEL_LENGTH; 1415 #ifdef VARIABLE_HASH /* bird */1416 makelevel_key.hash1 = variable_hash_1i (MAKELEVEL_NAME, MAKELEVEL_LENGTH);1417 makelevel_key.hash2 = 0;1418 #endif1419 #ifdef CONFIG_WITH_STRCACHE21420 makelevel_key.value = (char *)&makelevel_key; /* hack: name not cached */1421 #endif1422 1362 hash_delete (&table, &makelevel_key); 1423 1363 #else /* CONFIG_WITH_STRCACHE2 */ 1424 1364 /* lookup the name in the string case, if it's not there it won't 1425 1365 be in any of the sets either. */ 1426 { 1427 const char *cached_name = strcache2_lookup(&variable_strcache, 1428 MAKELEVEL_NAME, MAKELEVEL_LENGTH); 1429 if (cached_name) 1430 { 1431 makelevel_key.name = cached_name; 1432 makelevel_key.length = MAKELEVEL_LENGTH; 1433 #ifdef VARIABLE_HASH /* bird */ 1434 makelevel_key.hash1 = variable_hash_1i (MAKELEVEL_NAME, MAKELEVEL_LENGTH); 1435 makelevel_key.hash2 = 0; 1436 #endif 1437 makelevel_key.value = NULL; 1438 hash_delete (&table, &makelevel_key); 1439 } 1440 } 1366 cached_name = strcache2_lookup(&variable_strcache, 1367 MAKELEVEL_NAME, MAKELEVEL_LENGTH); 1368 if (cached_name) 1369 { 1370 makelevel_key.name = cached_name; 1371 makelevel_key.length = MAKELEVEL_LENGTH; 1372 hash_delete (&table, &makelevel_key); 1373 } 1441 1374 #endif /* CONFIG_WITH_STRCACHE2 */ 1442 1375 … … 2080 2013 #endif 2081 2014 2015 #ifndef CONFIG_WITH_STRCACHE2 2082 2016 free (v.name); 2017 #else 2018 free ((char *)v.name); 2019 #endif 2083 2020 2084 2021 return vp; -
trunk/src/kmk/variable.h
r1877 r1889 60 60 char *name; /* Variable name. */ 61 61 #else 62 const char *name; /* Variable name . */62 const char *name; /* Variable name (in varaible_strcache). */ 63 63 #endif 64 64 int length; /* strlen (name) */ 65 #ifdef VARIABLE_HASH /* bird */66 int hash1; /* the primary hash */67 int hash2; /* the secondary hash */68 #endif69 65 #ifdef CONFIG_WITH_VALUE_LENGTH 70 66 int value_length; /* The length of the value, usually unused. */
Note:
See TracChangeset
for help on using the changeset viewer.