Changeset 1897 for trunk/src/kmk
- Timestamp:
- Oct 21, 2008, 3:21:39 AM (17 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/dir.c
r1891 r1897 264 264 ISTRING_HASH_1 (key->path_key, hash); 265 265 # else /* CONFIG_WITH_STRCACHE2 */ 266 hash = strcache _get_hash1 (key->path_key);266 hash = strcache2_get_ptr_hash (&file_cache, key->path_key); 267 267 # endif /* CONFIG_WITH_STRCACHE2 */ 268 268 hash ^= ((unsigned int) key->dev << 4) ^ (unsigned int) key->ctime; … … 291 291 ISTRING_HASH_2 (key->path_key, hash); 292 292 # else /* CONFIG_WITH_STRCACHE2 */ 293 hash = strcache _get_hash2 (key->path_key);293 hash = strcache2_get_hash1 (&file_cache, key->path_key); 294 294 # endif /* CONFIG_WITH_STRCACHE2 */ 295 295 hash ^= ((unsigned int) key->dev << 4) ^ (unsigned int) ~key->ctime; … … 383 383 return_ISTRING_HASH_1 (((const struct directory *) key)->name); 384 384 #else 385 return strcache _get_hash1 (((const struct directory *) key)->name);385 return strcache2_get_ptr_hash (&file_cache, ((const struct directory *) key)->name); 386 386 #endif 387 387 } … … 393 393 return_ISTRING_HASH_2 (((const struct directory *) key)->name); 394 394 #else 395 return strcache _get_hash2 (((const struct directory *) key)->name);395 return strcache2_get_hash1 (&file_cache, ((const struct directory *) key)->name); 396 396 #endif 397 397 } … … 439 439 return_ISTRING_HASH_1 (((struct dirfile const *) key)->name); 440 440 #else 441 return strcache _get_hash1 (((struct dirfile const *) key)->name);441 return strcache2_get_ptr_hash (&file_cache, ((struct dirfile const *) key)->name); 442 442 #endif 443 443 } … … 449 449 return_ISTRING_HASH_2 (((struct dirfile const *) key)->name); 450 450 #else 451 return strcache _get_hash2 (((struct dirfile const *) key)->name);451 return strcache2_get_hash1 (&file_cache, ((struct dirfile const *) key)->name); 452 452 #endif 453 453 } -
trunk/src/kmk/file.c
r1892 r1897 47 47 return_ISTRING_HASH_1 (((struct file const *) key)->hname); 48 48 #else /* CONFIG_WITH_STRCACHE2 */ 49 return strcache _get_hash1 (((struct file const *) key)->hname);49 return strcache2_get_ptr_hash (&file_cache, ((struct file const *) key)->hname); 50 50 #endif /* CONFIG_WITH_STRCACHE2 */ 51 51 } … … 57 57 return_ISTRING_HASH_2 (((struct file const *) key)->hname); 58 58 #else /* CONFIG_WITH_STRCACHE2 */ 59 return strcache _get_hash1 (((struct file const *) key)->hname);59 return strcache2_get_ptr_hash (&file_cache, ((struct file const *) key)->hname); 60 60 #endif /* CONFIG_WITH_STRCACHE2 */ 61 61 } -
trunk/src/kmk/make.h
r1896 r1897 601 601 # define strcache_add(str) strcache2_add_file(&file_strcache, str, strlen (str)) 602 602 # define strcache_add_len(str, len) strcache2_add_file(&file_strcache, str, len) 603 # define strcache_get_len(str) strcache2_get_len(&file_strcache, str) 604 # define strcache_get_hash1(str) strcache2_get_hash1(&file_strcache, str) 605 # define strcache_get_hash2(str) strcache2_get_hash2(&file_strcache, str) 603 # define strcache_get_len(str) strcache2_get_len(&file_strcache, str) /* FIXME: replace this and related checks ... */ 606 604 607 605 #endif /* CONFIG_WITH_STRCACHE2 */ -
trunk/src/kmk/strcache2.c
r1888 r1897 526 526 527 527 size = length + 1 + sizeof (struct strcache2_entry); 528 size = (size + sizeof (void *) - 1) & ~(sizeof (void *)- 1U);528 size = (size + STRCACHE2_ENTRY_ALIGNMENT - 1) & ~(STRCACHE2_ENTRY_ALIGNMENT - 1U); 529 529 530 530 seg = cache->seg_head; -
trunk/src/kmk/strcache2.h
r1887 r1897 28 28 #define ___strcache2_h 29 29 30 #ifndef CHAR_BIT 31 # error "include after make.h!" 32 #endif 33 30 34 /* string cache memory segment. */ 31 35 struct strcache2_seg … … 46 50 unsigned int length; 47 51 }; 52 53 /* The entry alignment. 54 As it is very difficult to derive this from any #define or typedef, a 55 default value of 16 (chars) was choosen as this fits most platforms. 56 For odd platforms, just override this define. */ 57 #ifndef STRCACHE2_ENTRY_ALIGN_SHIFT 58 # define STRCACHE2_ENTRY_ALIGN_SHIFT 4 59 #endif 60 #define STRCACHE2_ENTRY_ALIGNMENT (1 << STRCACHE2_ENTRY_ALIGN_SHIFT) 61 48 62 49 63 struct strcache2 … … 123 137 } 124 138 139 /* Get the pointer hash value for the string. 140 141 This takes the string address, shift out the bits that are always zero 142 due to alignment, and then returns the unsigned integer value of it. 143 144 The results from using this is generally better than for any of the 145 other hash values. It is also sligtly faster code as it does not 146 involve any memory accesses, just a right SHIFT and an optional AND. */ 147 MY_INLINE unsigned int 148 strcache2_get_ptr_hash (struct strcache2 *cache, const char *str) 149 { 150 (void)cache; 151 return (size_t)str >> STRCACHE2_ENTRY_ALIGN_SHIFT; 152 } 153 125 154 /* Get the user value for the string. */ 126 155 MY_INLINE void * -
trunk/src/kmk/variable.c
r1890 r1897 118 118 #else 119 119 /* all requests are served from the cache. */ 120 return strcache2_get_ hash1(&variable_strcache, key->name);120 return strcache2_get_ptr_hash (&variable_strcache, key->name); 121 121 #endif 122 122 } … … 485 485 #ifdef KMK /* bird: speed */ 486 486 struct hash_table *ht = &setlist->set->table; 487 unsigned int hash_1 = strcache2_get_ hash1(&variable_strcache, name);487 unsigned int hash_1 = strcache2_get_ptr_hash (&variable_strcache, name); 488 488 struct variable *v; 489 489
Note:
See TracChangeset
for help on using the changeset viewer.