Changeset 1892 for trunk/src/kmk/file.c
- Timestamp:
- Oct 20, 2008, 4:00:45 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/file.c
r1881 r1892 41 41 /* Hash table of files the makefile knows how to make. */ 42 42 43 #ifndef KMK44 43 static unsigned long 45 44 file_hash_1 (const void *key) 46 45 { 46 #ifndef CONFIG_WITH_STRCACHE2 47 47 return_ISTRING_HASH_1 (((struct file const *) key)->hname); 48 #else /* CONFIG_WITH_STRCACHE2 */ 49 return strcache_get_hash1 (((struct file const *) key)->hname); 50 #endif /* CONFIG_WITH_STRCACHE2 */ 48 51 } 49 52 … … 51 54 file_hash_2 (const void *key) 52 55 { 56 #ifndef CONFIG_WITH_STRCACHE2 53 57 return_ISTRING_HASH_2 (((struct file const *) key)->hname); 58 #else /* CONFIG_WITH_STRCACHE2 */ 59 return strcache_get_hash1 (((struct file const *) key)->hname); 60 #endif /* CONFIG_WITH_STRCACHE2 */ 54 61 } 55 62 … … 57 64 file_hash_cmp (const void *x, const void *y) 58 65 { 66 #ifndef CONFIG_WITH_STRCACHE2 59 67 return_ISTRING_COMPARE (((struct file const *) x)->hname, 60 68 ((struct file const *) y)->hname); 61 } 62 #else /* KMK */ 63 64 static unsigned long 65 file_hash_1 (const void *key) 66 { 67 struct file const *f = (struct file const *)key; 68 69 /* If it's cached, get the hash from the strcache. */ 70 if (f->name != (const char *)f) 71 return strcache_get_hash1 (f->hname); 72 73 return_ISTRING_HASH_1 (f->hname); 74 } 75 76 static unsigned long 77 file_hash_2 (const void *key) 78 { 79 struct file const *f = (struct file const *)key; 80 81 /* If it's cached, get the hash from the strcache. */ 82 if (f->name != (const char *)f) 83 return strcache_get_hash2 (f->hname); 84 85 return_ISTRING_HASH_2 (f->hname); 86 } 87 88 static int 89 file_hash_cmp (const void *x, const void *y) 90 { 91 struct file const *xf = ((struct file const *) x); 92 struct file const *yf = ((struct file const *) y); 93 94 /* The file name strings all live in the strcache. However, 95 lookup_file may or may not have a string from the cache. It indicates 96 that it's responsible for the lookup by setting file::name to point 97 to the file structure itself. So, when file::name points elsewhere 98 we can omit the string compare, while when it isn't we can only 99 check if they match that way. */ 100 101 if (xf->hname == yf->hname) 102 return 0; 103 if ( xf->name != (const char *)xf 104 && yf->name != (const char *)yf) 105 return 1; 106 107 return_ISTRING_COMPARE (xf->hname, yf->hname); 108 } 109 110 #endif /* KMK */ 69 #else /* CONFIG_WITH_STRCACHE2 */ 70 return ((struct file const *) x)->hname 71 == ((struct file const *) y)->hname ? 0 : -1; 72 #endif /* CONFIG_WITH_STRCACHE2 */ 73 } 111 74 112 75 #ifndef FILE_BUCKETS … … 177 140 #endif 178 141 179 #ifdef KMK 180 /* uncached lookup indicator hack. */ 181 file_key.name = !cached ? (const char *)&file_key : NULL; 182 #endif 142 #ifndef CONFIG_WITH_STRCACHE2 183 143 file_key.hname = name; 184 144 f = hash_find_item (&files, &file_key); 145 #else /* CONFIG_WITH_STRCACHE2 */ 146 if (!cached) 147 { 148 file_key.hname = strcache2_lookup (&file_strcache, name, strlen (name)); 149 if (file_key.hname) 150 f = hash_find_item (&files, &file_key); 151 else 152 f = NULL; 153 } 154 else 155 { 156 file_key.hname = name; 157 f = hash_find_item (&files, &file_key); 158 } 159 160 #endif /* CONFIG_WITH_STRCACHE2 */ 185 161 #if defined(VMS) && !defined(WANT_CASE_SENSITIVE_TARGETS) 186 162 if (*name != '.') … … 297 273 struct file *f; 298 274 299 #ifdef KMK275 #ifdef CONFIG_WITH_STRCACHE2 300 276 assert (strcache_iscached (to_hname)); 301 277 assert (strcache_iscached (from_file->hname)); 302 file_key.name = NULL; /* cached lookup indicator hack. */303 278 #endif 304 279
Note:
See TracChangeset
for help on using the changeset viewer.