Changeset 1862 in kBuild for trunk/src/kmk
- Timestamp:
- Oct 14, 2008 1:04:03 AM (16 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/incdep.c
r1854 r1862 150 150 const char *err_msg; 151 151 152 struct dep *dep_start; /* start of the current dep block. */ 153 struct dep *dep_end; /* end of the current dep block. */ 154 152 155 struct incdep_variable_in_set *recorded_variables_in_set_head; 153 156 struct incdep_variable_in_set *recorded_variables_in_set_tail; … … 233 236 For working around multithreaded performance problems found on Darwin, 234 237 Linux (glibc), and possibly other systems. */ 235 static void *incdep_xmalloc (struct incdep *cur, size_t size) 238 static void * 239 incdep_xmalloc (struct incdep *cur, size_t size) 236 240 { 237 241 void *ptr; … … 255 259 256 260 /* memset(malloc(sz),'\0',sz) wrapper. */ 257 static void *incdep_xcalloc (struct incdep *cur, size_t size) 261 static void * 262 incdep_xcalloc (struct incdep *cur, size_t size) 258 263 { 259 264 void *ptr; … … 275 280 276 281 /* free wrapper */ 277 static void incdep_xfree (struct incdep *cur, void *ptr) 282 static void 283 incdep_xfree (struct incdep *cur, void *ptr) 278 284 { 279 285 /* free() *must* work for the allocation hacks above because … … 283 289 } 284 290 291 /* alloc a dep structure. These are allocated in bunches to save time. */ 292 struct dep * 293 incdep_alloc_dep (struct incdep *cur) 294 { 295 if (cur->dep_start != cur->dep_end) 296 return cur->dep_start++; 297 298 cur->dep_start = (struct dep *)incdep_xcalloc (cur, sizeof(struct dep) * 256); 299 cur->dep_end = cur->dep_start + 256; 300 return cur->dep_start++; 301 } 285 302 286 303 … … 457 474 incdep_worker (void) 458 475 { 476 #ifdef PARSE_IN_WORKER 477 struct dep *dep_start = NULL; 478 struct dep *dep_end = NULL; 479 #endif 480 459 481 incdep_lock (); 460 482 … … 480 502 cur->is_worker = 1; 481 503 incdep_read_file (cur, NILF); 504 482 505 #ifdef PARSE_IN_WORKER 506 cur->dep_start = dep_start; 507 cur->dep_end = dep_end; 508 483 509 eval_include_dep_file (cur, NILF); 484 #endif 510 511 dep_start = cur->dep_start; 512 cur->dep_start = NULL; 513 dep_end = cur->dep_end; 514 cur->dep_end = NULL; 515 #endif 516 485 517 cur->is_worker = 0; 486 518 incdep_lock (); … … 1337 1369 1338 1370 /* add it to the list. */ 1339 *nextdep = dep = incdep_ xcalloc (curdep, sizeof (*dep));1371 *nextdep = dep = incdep_alloc_dep (curdep); 1340 1372 dep->name = incdep_record_strcache (curdep, cur, endp - cur); 1341 1373 dep->includedep = 1; … … 1441 1473 cur->err_line_no = 0; 1442 1474 cur->err_msg = NULL; 1475 cur->dep_start = NULL; 1476 cur->dep_end = NULL; 1443 1477 cur->recorded_variables_in_set_head = NULL; 1444 1478 cur->recorded_variables_in_set_tail = NULL; -
trunk/src/kmk/misc.c
r1859 r1862 712 712 /* Cache free struct dep to save time in free during snap_deps. 713 713 free is esp. slow on darwin for some reason. */ 714 static struct dep *free_deps; 714 static struct dep *free_deps = NULL; 715 static struct dep *free_deps_start = NULL; 716 static struct dep *free_deps_end = NULL; 715 717 716 718 static struct dep * 717 719 alloc_dep_int (void) 718 720 { 719 struct dep *d = free_deps; 720 if (d) 721 free_deps = d->next; 722 else 723 d = xmalloc (sizeof (struct dep)); 724 return d; 721 struct dep *d = free_deps; 722 if (MY_PREDICT_TRUE(d)) 723 free_deps = d->next; 724 else if (free_deps_start != free_deps_end) 725 d = free_deps_start++; 726 else 727 { 728 /* allocate another chunk block. */ 729 free_deps_start = xmalloc (sizeof (struct dep) * 256); 730 free_deps_end = free_deps_start + 256; 731 d = free_deps_start++; 732 } 733 return d; 725 734 } 726 735 -
trunk/src/kmk/read.c
r1861 r1862 3079 3079 3080 3080 /* Add it to the front of the chain. */ 3081 #if !defined(KMK) || !defined(NO_ARCHIVES) 3081 3082 new1 = xmalloc (size); 3083 #else 3084 if (sizeof (struct dep) == size) /* use the cache */ 3085 new1 = (struct nameseq *)alloc_dep (); 3086 else 3087 new1 = xmalloc (size); 3088 #endif 3082 3089 new1->name = name; 3083 3090 new1->next = new; … … 3889 3896 #endif /* !NO_ARCHIVES */ 3890 3897 { 3898 #if !defined(KMK) && !defined(NO_ARCHIVES) 3891 3899 struct nameseq *elt = xmalloc (size); 3900 #else 3901 struct nameseq *elt = size == sizeof(struct dep) 3902 ? (void *)alloc_dep() : xmalloc (size); 3903 #endif 3892 3904 memset (elt, '\0', size); 3893 3905 elt->name = strcache_add (gl.gl_pathv[i]); … … 3900 3912 #endif 3901 3913 globfree (&gl); 3914 #if !defined(KMK) && !defined(NO_ARCHIVES) 3902 3915 free (old); 3916 #else 3917 if (size == sizeof(struct dep)) 3918 free_dep ((struct dep *)old); 3919 else 3920 free (old); 3921 #endif 3903 3922 break; 3904 3923 } -
trunk/src/kmk/remake.c
r1857 r1862 240 240 241 241 /* Free the storage. */ 242 #ifndef KMK 242 243 free (g); 244 #else 245 free_dep (g); 246 #endif 243 247 244 248 g = lastgoal == 0 ? goals : lastgoal->next;
Note:
See TracChangeset
for help on using the changeset viewer.