Changeset 1864 for trunk/src/kmk
- Timestamp:
- Oct 15, 2008, 3:00:57 AM (17 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/hash.c
r1858 r1864 246 246 } 247 247 248 #ifdef CONFIG_WITH_ALLOC_CACHES 249 void 250 hash_free_items_cached (struct hash_table *ht, struct alloccache *cache) 251 { 252 void **vec = ht->ht_vec; 253 void **end = &vec[ht->ht_size]; 254 for (; vec < end; vec++) 255 { 256 void *item = *vec; 257 if (!HASH_VACANT (item)) 258 alloccache_free (cache, item); 259 *vec = 0; 260 } 261 ht->ht_fill = 0; 262 ht->ht_empty_slots = ht->ht_size; 263 } 264 #endif /* CONFIG_WITH_ALLOC_CACHES */ 265 248 266 void 249 267 hash_delete_items (struct hash_table *ht) … … 275 293 } 276 294 295 #ifdef CONFIG_WITH_ALLOC_CACHES 296 void 297 hash_free_cached (struct hash_table *ht, int free_items, struct alloccache *cache) 298 { 299 if (free_items) 300 hash_free_items_cached (ht, cache); 301 else 302 { 303 ht->ht_fill = 0; 304 ht->ht_empty_slots = ht->ht_size; 305 } 306 free (ht->ht_vec); 307 ht->ht_vec = 0; 308 ht->ht_capacity = 0; 309 } 310 #endif /* CONFIG_WITH_ALLOC_CACHES */ 311 277 312 void 278 313 hash_map (struct hash_table *ht, hash_map_func_t map) -
trunk/src/kmk/hash.h
r1858 r1864 75 75 void hash_free_items __P((struct hash_table *ht)); 76 76 void hash_free __P((struct hash_table *ht, int free_items)); 77 #ifdef CONFIG_WITH_ALLOC_CACHES 78 void hash_free_items_cached __P((struct hash_table *ht, struct alloccache *cache)); 79 void hash_free_cached __P((struct hash_table *ht, int free_items, struct alloccache *cache)); 80 #endif 77 81 void hash_map __P((struct hash_table *ht, hash_map_func_t map)); 78 82 void hash_map_arg __P((struct hash_table *ht, hash_map_arg_func_t map, void *arg)); -
trunk/src/kmk/implicit.c
r1863 r1864 265 265 #ifdef CONFIG_WITH_ALLOC_CACHES 266 266 if (!idep_cache.size) 267 alloccache_init (&idep_cache, sizeof (struct idep), "dep", NULL, NULL);267 alloccache_init (&idep_cache, sizeof (struct idep), "idep", NULL, NULL); 268 268 #endif 269 269 -
trunk/src/kmk/main.c
r1863 r1864 648 648 struct alloccache nameseq_cache; 649 649 struct alloccache variable_cache; 650 struct alloccache variable_set_cache; 651 struct alloccache variable_set_list_cache; 650 652 651 653 static void 652 654 initialize_global_alloc_caches (void) 653 655 { 654 alloccache_init (&dep_cache, sizeof (struct dep), "dep", NULL, NULL); 655 alloccache_init (&nameseq_cache, sizeof (struct nameseq), "nameseq", NULL, NULL); 656 alloccache_init (&variable_cache, sizeof (struct variable), "variable", NULL, NULL); 656 alloccache_init (&dep_cache, sizeof (struct dep), "dep", NULL, NULL); 657 alloccache_init (&nameseq_cache, sizeof (struct nameseq), "nameseq", NULL, NULL); 658 alloccache_init (&variable_cache, sizeof (struct variable), "variable", NULL, NULL); 659 alloccache_init (&variable_set_cache, sizeof (struct variable_set), "variable_set", NULL, NULL); 660 alloccache_init (&variable_set_list_cache, sizeof (struct variable_set_list), "variable_set_list", NULL, NULL); 657 661 } 658 662 #endif … … 2933 2937 if (!remote_description || *remote_description == '\0') 2934 2938 printf (_("\nThis program is built for %s/%s/%s [" __DATE__ " " __TIME__ "]\n"), 2935 KBUILD_HOST, KBUILD_HOST_ARCH, KBUILD_HOST_CPU , remote_description);2939 KBUILD_HOST, KBUILD_HOST_ARCH, KBUILD_HOST_CPU); 2936 2940 else 2937 2941 printf (_("\nThis program is built for %s/%s/%s (%s) [" __DATE__ " " __TIME__ "]\n"), -
trunk/src/kmk/make.h
r1863 r1864 575 575 extern struct alloccache nameseq_cache; 576 576 extern struct alloccache variable_cache; 577 extern struct alloccache variable_set_cache; 578 extern struct alloccache variable_set_list_cache; 577 579 578 580 #endif /* CONFIG_WITH_ALLOC_CACHES */ -
trunk/src/kmk/misc.c
r1863 r1864 1286 1286 alloccache_print (struct alloccache *cache) 1287 1287 { 1288 printf (_("\n# Alloc Cache: %s item size: %u alloc: %d total: %u\n"), 1288 printf (_("\n# Alloc Cache: %s\n" 1289 "# Items: size = %-3u in-use = %-6d total = %-6u\n"), 1289 1290 cache->name, cache->size, (int)cache->alloc_count, cache->total_count); 1290 1291 } … … 1295 1296 { 1296 1297 struct alloccache *cur; 1298 puts (""); 1297 1299 for (cur = alloccache_head; cur; cur = cur->next) 1298 1300 alloccache_print (cur); -
trunk/src/kmk/variable.c
r1863 r1864 707 707 /* Create a new variable definition and add it to the hash table. */ 708 708 709 #ifndef CONFIG_WITH_ALLOC_CACHES 709 710 v = xmalloc (sizeof (struct variable)); 711 #else 712 v = alloccache_alloc (&variable_cache); 713 #endif 710 714 v->name = savestring (name, length); 711 715 v->length = length; … … 1016 1020 if (l == 0) 1017 1021 { 1022 #ifndef CONFIG_WITH_ALLOC_CACHES 1018 1023 l = (struct variable_set_list *) 1019 1024 xmalloc (sizeof (struct variable_set_list)); 1020 1025 l->set = xmalloc (sizeof (struct variable_set)); 1026 #else 1027 l = (struct variable_set_list *) 1028 alloccache_alloc (&variable_set_list_cache); 1029 l->set = (struct variable_set *) 1030 alloccache_alloc (&variable_set_cache); 1031 #endif 1021 1032 hash_init (&l->set->table, PERFILE_VARIABLE_BUCKETS, 1022 1033 variable_hash_1, variable_hash_2, variable_hash_cmp); … … 1121 1132 register struct variable_set *set; 1122 1133 1134 #ifndef CONFIG_WITH_ALLOC_CACHES 1123 1135 set = xmalloc (sizeof (struct variable_set)); 1136 #else 1137 set = (struct variable_set *) alloccache_alloc (&variable_set_cache); 1138 #endif 1124 1139 hash_init (&set->table, SMALL_SCOPE_VARIABLE_BUCKETS, 1125 1140 variable_hash_1, variable_hash_2, variable_hash_cmp); 1126 1141 1142 #ifndef CONFIG_WITH_ALLOC_CACHES 1127 1143 setlist = (struct variable_set_list *) 1128 1144 xmalloc (sizeof (struct variable_set_list)); 1145 #else 1146 setlist = (struct variable_set_list *) 1147 alloccache_alloc (&variable_set_list_cache); 1148 #endif 1129 1149 setlist->set = set; 1130 1150 setlist->next = current_variable_set_list; … … 1145 1165 { 1146 1166 hash_map (&list->set->table, free_variable_name_and_value); 1167 #ifndef CONFIG_WITH_ALLOC_CACHES 1147 1168 hash_free (&list->set->table, 1); 1148 1169 free (list->set); 1149 1170 free (list); 1171 #else 1172 hash_free_cached (&list->set->table, 1, &variable_cache); 1173 alloccache_free (&variable_set_cache, list->set); 1174 alloccache_free (&variable_set_list_cache, list); 1175 #endif 1150 1176 } 1151 1177 … … 1203 1229 1204 1230 /* Free the one we no longer need. */ 1231 #ifndef CONFIG_WITH_ALLOC_CACHES 1205 1232 free (setlist); 1206 1233 hash_map (&set->table, free_variable_name_and_value); 1207 1234 hash_free (&set->table, 1); 1208 1235 free (set); 1236 #else 1237 alloccache_free (&variable_set_list_cache, setlist); 1238 hash_map (&set->table, free_variable_name_and_value); 1239 hash_free_cached (&set->table, 1, &variable_cache); 1240 alloccache_free (&variable_set_cache, set); 1241 #endif 1209 1242 } 1210 1243
Note:
See TracChangeset
for help on using the changeset viewer.