Changeset 1872 in kBuild for trunk/src/kmk/incdep.c
- Timestamp:
- Oct 17, 2008 12:05:27 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/incdep.c
r1871 r1872 93 93 struct incdep_variable_in_set *next; 94 94 /* the parameters */ 95 struct strcache2_entry *name_entry; /* dep strcache*/96 const char *value; /* xmalloc'ed */95 struct strcache2_entry *name_entry; /* dep strcache - WRONG */ 96 const char *value; /* xmalloc'ed */ 97 97 unsigned int value_length; 98 int duplicate_value; /* 0 */98 int duplicate_value; /* 0 */ 99 99 enum variable_origin origin; 100 100 int recursive; 101 101 struct variable_set *set; 102 const struct floc *flocp; /* NILF */102 const struct floc *flocp; /* NILF */ 103 103 }; 104 104 … … 107 107 struct incdep_variable_def *next; 108 108 /* the parameters */ 109 const struct floc *flocp; /* NILF */110 struct strcache2_entry *name_entry; /* dep strcache*/111 char *value; /* xmalloc'ed, free it */109 const struct floc *flocp; /* NILF */ 110 struct strcache2_entry *name_entry; /* dep strcache - WRONG */ 111 char *value; /* xmalloc'ed, free it */ 112 112 unsigned int value_length; 113 113 enum variable_origin origin; … … 122 122 /* the parameters */ 123 123 struct strcache2_entry *filename_entry; /* dep strcache; converted to a nameseq record. */ 124 const char *pattern; /* NULL */125 const char *pattern_percent; /* NULL */126 struct dep *deps; /* All the names are dep strcache entries. */127 unsigned int cmds_started; /* 0 */128 char *commands; /* NULL */129 unsigned int commands_idx; /* 0 */130 int two_colon; /* 0 */131 const struct floc *flocp; /* NILF */124 const char *pattern; /* NULL */ 125 const char *pattern_percent; /* NULL */ 126 struct dep *deps; /* All the names are dep strcache entries. */ 127 unsigned int cmds_started; /* 0 */ 128 char *commands; /* NULL */ 129 unsigned int commands_idx; /* 0 */ 130 int two_colon; /* 0 */ 131 const struct floc *flocp; /* NILF */ 132 132 }; 133 133 … … 202 202 /* The handles to the worker threads. */ 203 203 #ifdef HAVE_PTHREAD 204 static pthread_t incdep_threads[1]; 205 static struct alloccache incdep_dep_caches[1]; 206 static struct strcache2 incdep_dep_strcaches[1]; 204 # define INCDEP_MAX_THREADS 1 205 static pthread_t incdep_threads[INCDEP_MAX_THREADS]; 207 206 208 207 #elif defined (WINDOWS32) 209 static HANDLE incdep_threads[2]; 210 static struct alloccache incdep_dep_caches[2]; 211 static struct strcache2 incdep_dep_strcaches[2]; 208 # define INCDEP_MAX_THREADS 2 209 static HANDLE incdep_threads[INCDEP_MAX_THREADS]; 212 210 213 211 #elif defined (__OS2__) 214 static TID incdep_threads[2]; 215 static struct alloccache incdep_dep_caches[2]; 216 static struct strcache2 incdep_dep_strcaches[2]; 217 #endif 212 # define INCDEP_MAX_THREADS 2 213 static TID incdep_threads[INCDEP_MAX_THREADS]; 214 #endif 215 216 static struct alloccache incdep_rec_caches[INCDEP_MAX_THREADS]; 217 static struct alloccache incdep_dep_caches[INCDEP_MAX_THREADS]; 218 static struct strcache2 incdep_dep_strcaches[INCDEP_MAX_THREADS]; 218 219 static unsigned incdep_num_threads; 219 220 … … 304 305 } 305 306 307 /* allocate a record. */ 308 static void * 309 incdep_alloc_rec (struct incdep *cur) 310 { 311 return alloccache_alloc (&incdep_rec_caches[cur->worker_tid]); 312 } 313 314 306 315 /* grow a cache. */ 307 316 static void * … … 314 323 return xmalloc (size); 315 324 #endif 325 } 326 327 /* term a cache. */ 328 static void 329 incdep_cache_deallocator (void *thrd, void *ptr, unsigned int size) 330 { 331 (void)thrd; 332 (void)size; 333 free (ptr); 316 334 } 317 335 … … 632 650 { 633 651 /* init caches */ 652 unsigned rec_size = sizeof (struct incdep_variable_in_set); 653 if (rec_size < sizeof (struct incdep_variable_def)) 654 rec_size = sizeof (struct incdep_variable_def); 655 if (rec_size < sizeof (struct incdep_recorded_files)) 656 rec_size = sizeof (struct incdep_recorded_files); 657 alloccache_init (&incdep_rec_caches[i], rec_size, "incdep rec", 658 incdep_cache_allocator, (void *)(size_t)i); 634 659 alloccache_init (&incdep_dep_caches[i], sizeof(struct dep), "incdep dep", 635 660 incdep_cache_allocator, (void *)(size_t)i); … … 706 731 /* more later? */ 707 732 733 /* terminate or join up the allocation caches. */ 734 alloccache_term (&incdep_rec_caches[i], incdep_cache_deallocator, (void *)(size_t)i); 708 735 alloccache_join (&dep_cache, &incdep_dep_caches[i]); 709 736 strcache2_term (&incdep_dep_strcaches[i]); … … 747 774 do 748 775 { 749 void *free_me = rec_vis;750 776 unsigned int name_length = rec_vis->name_entry->length; 751 777 define_variable_in_set (incdep_flush_strcache_entry (rec_vis->name_entry), … … 759 785 rec_vis->flocp); 760 786 rec_vis = rec_vis->next; 761 incdep_xfree (cur, free_me);762 787 } 763 788 while (rec_vis); … … 770 795 do 771 796 { 772 void *free_me = rec_vd;773 797 do_variable_definition_2 (rec_vd->flocp, 774 798 incdep_flush_strcache_entry (rec_vd->name_entry), … … 781 805 rec_vd->target_var); 782 806 rec_vd = rec_vd->next; 783 incdep_xfree (cur, free_me);784 807 } 785 808 while (rec_vd); … … 792 815 do 793 816 { 794 void *free_me = rec_f;795 817 struct dep *dep; 796 818 struct nameseq *filenames; … … 814 836 815 837 rec_f = rec_f->next; 816 incdep_xfree (cur, free_me);817 838 } 818 839 while (rec_f); … … 881 902 else 882 903 { 883 struct incdep_variable_in_set *rec = incdep_xmalloc (cur, sizeof (*rec)); 904 struct incdep_variable_in_set *rec = 905 (struct incdep_variable_in_set *)incdep_alloc_rec (cur); 884 906 rec->name_entry = (struct strcache2_entry *)name; 885 907 rec->value = value; … … 919 941 else 920 942 { 921 struct incdep_variable_def *rec = incdep_xmalloc (cur, sizeof (*rec)); 943 struct incdep_variable_def *rec = 944 (struct incdep_variable_def *)incdep_alloc_rec (cur); 922 945 rec->flocp = flocp; 923 946 rec->name_entry = (struct strcache2_entry *)name; … … 960 983 else 961 984 { 962 struct incdep_recorded_files *rec = incdep_xmalloc (cur, sizeof (*rec)); 985 struct incdep_recorded_files *rec = 986 (struct incdep_recorded_files *) incdep_alloc_rec (cur); 963 987 964 988 rec->filename_entry = (struct strcache2_entry *)filename;
Note:
See TracChangeset
for help on using the changeset viewer.