Changeset 1854 for trunk/src/kmk/strcache.c
- Timestamp:
- Oct 13, 2008, 3:50:33 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/strcache.c
r1845 r1854 131 131 132 132 #ifdef CONFIG_WITH_VALUE_LENGTH 133 /* Hackish globals for passing data to the hash functions. 134 There isn't really any other way without running the 135 risk of breaking rehashing. */ 133 136 static const char *lookup_string; 134 137 static unsigned int lookup_string_len; 135 #endif 138 # ifdef CONFIG_WITH_INCLUDEDEP 139 static unsigned long lookup_string_hash1; 140 static unsigned long lookup_string_hash2; 141 # endif /* CONFIG_WITH_INCLUDEDEP */ 142 #endif /* CONFIG_WITH_VALUE_LENGTH */ 136 143 137 144 static unsigned long 138 145 str_hash_1 (const void *key) 139 146 { 147 #ifdef CONFIG_WITH_INCLUDEDEP 148 if ((const char *) key == lookup_string && lookup_string_hash1) 149 return lookup_string_hash1; 150 #endif 140 151 return_ISTRING_HASH_1 ((const char *) key); 141 152 } … … 144 155 str_hash_2 (const void *key) 145 156 { 157 #ifdef CONFIG_WITH_INCLUDEDEP 158 if ((const char *) key == lookup_string && lookup_string_hash2) 159 return lookup_string_hash2; 160 #endif 146 161 return_ISTRING_HASH_2 ((const char *) key); 147 162 } … … 157 172 kBuild scenario. */ 158 173 159 if ( x == lookup_string)174 if ((const char *) x == lookup_string) 160 175 { 161 176 assert (lookup_string_len == strlen ((const char *)x)); … … 237 252 } 238 253 254 #ifdef CONFIG_WITH_INCLUDEDEP 255 256 /* A special variant used by the includedep worker threads, it off loads 257 the main thread when it adds the strings to the cache later. */ 258 const char * 259 strcache_add_prehashed (const char *str, int len, unsigned long hash1, 260 unsigned long hash2) 261 { 262 const char *retstr; 263 264 assert (hash1 == str_hash_1 (str)); 265 assert (hash2 == str_hash_2 (str)); 266 267 lookup_string_hash1 = hash1; 268 lookup_string_hash2 = hash2; 269 270 retstr = add_hash (str, len); 271 272 lookup_string_hash1 = 0; 273 lookup_string_hash2 = 0; 274 275 return retstr; 276 } 277 278 /* Performs the prehashing for use with strcache_add_prehashed(). */ 279 void 280 strcache_prehash_str (const char *str, unsigned long *hash1p, 281 unsigned long *hash2p) 282 { 283 *hash1p = str_hash_1 (str); 284 *hash2p = str_hash_2 (str); 285 } 286 287 #endif /* CONFIG_WITH_INCLUDEDEP */ 288 239 289 int 240 290 strcache_setbufsize(int size)
Note:
See TracChangeset
for help on using the changeset viewer.