Changeset 1871 in kBuild for trunk/src/kmk/incdep.c
- Timestamp:
- Oct 16, 2008 11:38:45 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/incdep.c
r1870 r1871 52 52 #include "rule.h" 53 53 #include "debug.h" 54 #include " hash.h"54 #include "strcache2.h" 55 55 56 56 #ifdef HAVE_FCNTL_H … … 89 89 * Structures and Typedefs * 90 90 *******************************************************************************/ 91 struct incdep_strcache_entry92 {93 unsigned int length;94 unsigned int alignment;95 unsigned long hash1;96 unsigned long hash2;97 char str[1];98 };99 100 91 struct incdep_variable_in_set 101 92 { 102 93 struct incdep_variable_in_set *next; 103 94 /* the parameters */ 104 struct incdep_strcache_entry *name_entry;95 struct strcache2_entry *name_entry; /* dep strcache */ 105 96 const char *value; /* xmalloc'ed */ 106 97 unsigned int value_length; … … 117 108 /* the parameters */ 118 109 const struct floc *flocp; /* NILF */ 119 struct incdep_strcache_entry *name_entry;110 struct strcache2_entry *name_entry; /* dep strcache */ 120 111 char *value; /* xmalloc'ed, free it */ 121 112 unsigned int value_length; … … 130 121 131 122 /* the parameters */ 132 struct incdep_strcache_entry *filename_entry; /* Converted to a nameseq record. */123 struct strcache2_entry *filename_entry; /* dep strcache; converted to a nameseq record. */ 133 124 const char *pattern; /* NULL */ 134 125 const char *pattern_percent; /* NULL */ 135 struct dep *deps; /* All the names are strcache entries. */126 struct dep *deps; /* All the names are dep strcache entries. */ 136 127 unsigned int cmds_started; /* 0 */ 137 128 char *commands; /* NULL */ … … 213 204 static pthread_t incdep_threads[1]; 214 205 static struct alloccache incdep_dep_caches[1]; 206 static struct strcache2 incdep_dep_strcaches[1]; 215 207 216 208 #elif defined (WINDOWS32) 217 209 static HANDLE incdep_threads[2]; 218 210 static struct alloccache incdep_dep_caches[2]; 211 static struct strcache2 incdep_dep_strcaches[2]; 219 212 220 213 #elif defined (__OS2__) 221 214 static TID incdep_threads[2]; 222 215 static struct alloccache incdep_dep_caches[2]; 216 static struct strcache2 incdep_dep_strcaches[2]; 223 217 #endif 224 218 static unsigned incdep_num_threads; … … 629 623 #endif 630 624 631 /* create the worker threads . */625 /* create the worker threads and associated per thread data. */ 632 626 633 627 incdep_terminate = 0; … … 637 631 for (i = 0; i < incdep_num_threads; i++) 638 632 { 633 /* init caches */ 639 634 alloccache_init (&incdep_dep_caches[i], sizeof(struct dep), "incdep dep", 640 635 incdep_cache_allocator, (void *)(size_t)i); 641 636 strcache2_init(&incdep_dep_strcaches[i], 637 "incdep dep", /* name */ 638 65536, /* hash size */ 639 0, /* default segment size*/ 640 #ifdef HAVE_CASE_INSENSITIVE_FS 641 1, /* case insensitive */ 642 #else 643 0, /* case insensitive */ 644 #endif 645 0); /* thread safe */ 646 647 /* create the thread. */ 642 648 #ifdef HAVE_PTHREAD 643 649 rc = pthread_attr_init (&attr); … … 701 707 702 708 alloccache_join (&dep_cache, &incdep_dep_caches[i]); 709 strcache2_term (&incdep_dep_strcaches[i]); 703 710 } 704 711 incdep_num_threads = 0; … … 715 722 The input is freed! */ 716 723 static const char * 717 incdep_flush_strcache_entry (const void *pv_entry) 718 { 719 struct incdep_strcache_entry *entry = (struct incdep_strcache_entry *)pv_entry; 720 const char *result; 721 result = strcache_add_prehashed (entry->str, entry->length, entry->hash1, entry->hash2); 722 free (entry); 723 return result; 724 incdep_flush_strcache_entry (struct strcache2_entry *entry) 725 { 726 if (!entry->user) 727 entry->user = (void *)strcache_add_prehashed ((const char *)(entry + 1), 728 entry->length, 729 entry->hash1, 730 entry->hash2); 731 return (const char *)entry->user; 724 732 } 725 733 … … 789 797 790 798 for (dep = rec_f->deps; dep; dep = dep->next) 791 dep->name = incdep_flush_strcache_entry ( dep->name);799 dep->name = incdep_flush_strcache_entry ((struct strcache2_entry *)dep->name); 792 800 793 801 filenames = (struct nameseq *) alloccache_alloc (&nameseq_cache); … … 844 852 else 845 853 { 846 /* Allocate a strcache record for it, pre-hashing the string to save 847 time later on in the main thread. */ 848 struct incdep_strcache_entry *entry = incdep_xmalloc (cur, sizeof (*entry) + len); 849 memcpy (entry->str, str, len); 850 entry->str[len] = '\0'; 851 entry->length = len; 852 strcache_prehash_str (entry->str, len, &entry->hash1, &entry->hash2); 853 854 ret = (const char *)entry; 854 /* Add it out the strcache of the thread. */ 855 ret = strcache2_add (&incdep_dep_strcaches[cur->worker_tid], str, len); 856 ret = (const char *)strcache2_get_entry(&incdep_dep_strcaches[cur->worker_tid], ret); 855 857 } 856 858 return ret; … … 880 882 { 881 883 struct incdep_variable_in_set *rec = incdep_xmalloc (cur, sizeof (*rec)); 882 rec->name_entry = (struct incdep_strcache_entry *)name;884 rec->name_entry = (struct strcache2_entry *)name; 883 885 rec->value = value; 884 886 rec->value_length = value_length; … … 919 921 struct incdep_variable_def *rec = incdep_xmalloc (cur, sizeof (*rec)); 920 922 rec->flocp = flocp; 921 rec->name_entry = (struct incdep_strcache_entry *)name;923 rec->name_entry = (struct strcache2_entry *)name; 922 924 rec->value = value; 923 925 rec->value_length = value_length; … … 960 962 struct incdep_recorded_files *rec = incdep_xmalloc (cur, sizeof (*rec)); 961 963 962 rec->filename_entry = (struct incdep_strcache_entry *)filename;964 rec->filename_entry = (struct strcache2_entry *)filename; 963 965 rec->pattern = pattern; 964 966 rec->pattern_percent = pattern_percent;
Note:
See TracChangeset
for help on using the changeset viewer.