Changeset 1891 in kBuild for trunk/src/kmk/dir.c
- Timestamp:
- Oct 20, 2008 1:46:19 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/dir.c
r1878 r1891 231 231 * qualified name of the directory. Beware though, this is also 232 232 * unreliable. I'm open to suggestion on a better way to emulate inode. */ 233 # ifndef CONFIG_WITH_STRCACHE2 233 234 char *path_key; 235 # else 236 char const *path_key; /* strcache'ed */ 237 # endif 234 238 int ctime; 235 239 int mtime; /* controls check for stale directory cache */ … … 256 260 257 261 #ifdef WINDOWS32 262 # ifndef CONFIG_WITH_STRCACHE2 258 263 hash = 0; 259 264 ISTRING_HASH_1 (key->path_key, hash); 265 # else /* CONFIG_WITH_STRCACHE2 */ 266 hash = strcache_get_hash1 (key->path_key); 267 # endif /* CONFIG_WITH_STRCACHE2 */ 260 268 hash ^= ((unsigned int) key->dev << 4) ^ (unsigned int) key->ctime; 261 269 #else … … 279 287 280 288 #ifdef WINDOWS32 289 # ifndef CONFIG_WITH_STRCACHE2 281 290 hash = 0; 282 291 ISTRING_HASH_2 (key->path_key, hash); 292 # else /* CONFIG_WITH_STRCACHE2 */ 293 hash = strcache_get_hash2 (key->path_key); 294 # endif /* CONFIG_WITH_STRCACHE2 */ 283 295 hash ^= ((unsigned int) key->dev << 4) ^ (unsigned int) ~key->ctime; 284 296 #else … … 315 327 316 328 #ifdef WINDOWS32 329 # ifndef CONFIG_WITH_STRCACHE2 317 330 ISTRING_COMPARE (x->path_key, y->path_key, result); 318 331 if (result) 319 332 return result; 333 # else /* CONFIG_WITH_STRCACHE2 */ 334 if (x->path_key != y->path_key) 335 return -1; 336 # endif /* CONFIG_WITH_STRCACHE2 */ 320 337 result = MAKECMP(x->ctime, y->ctime); 321 338 if (result) … … 363 380 directory_hash_1 (const void *key) 364 381 { 382 #ifndef CONFIG_WITH_STRCACHE2 365 383 return_ISTRING_HASH_1 (((const struct directory *) key)->name); 384 #else 385 return strcache_get_hash1 (((const struct directory *) key)->name); 386 #endif 366 387 } 367 388 … … 369 390 directory_hash_2 (const void *key) 370 391 { 392 #ifndef CONFIG_WITH_STRCACHE2 371 393 return_ISTRING_HASH_2 (((const struct directory *) key)->name); 394 #else 395 return strcache_get_hash2 (((const struct directory *) key)->name); 396 #endif 372 397 } 373 398 … … 375 400 directory_hash_cmp (const void *x, const void *y) 376 401 { 402 #ifndef CONFIG_WITH_STRCACHE2 377 403 return_ISTRING_COMPARE (((const struct directory *) x)->name, 378 404 ((const struct directory *) y)->name); 405 #else 406 return ((const struct directory *) x)->name 407 == ((const struct directory *) y)->name ? 0 : -1; 408 #endif 379 409 } 380 410 … … 406 436 dirfile_hash_1 (const void *key) 407 437 { 438 #ifndef CONFIG_WITH_STRCACHE2 408 439 return_ISTRING_HASH_1 (((struct dirfile const *) key)->name); 440 #else 441 return strcache_get_hash1 (((struct dirfile const *) key)->name); 442 #endif 409 443 } 410 444 … … 412 446 dirfile_hash_2 (const void *key) 413 447 { 448 #ifndef CONFIG_WITH_STRCACHE2 414 449 return_ISTRING_HASH_2 (((struct dirfile const *) key)->name); 450 #else 451 return strcache_get_hash2 (((struct dirfile const *) key)->name); 452 #endif 415 453 } 416 454 … … 420 458 const struct dirfile *x = xv; 421 459 const struct dirfile *y = yv; 460 #ifndef CONFIG_WITH_STRCACHE2 422 461 int result = x->length - y->length; 423 462 if (result) 424 463 return result; 425 464 return_ISTRING_COMPARE (x->name, y->name); 465 #else 466 return x->name == y->name ? 0 : -1; 467 #endif 426 468 } 427 469 … … 466 508 #endif 467 509 510 #ifndef CONFIG_WITH_STRCACHE2 468 511 dir_key.name = name; 512 #else 513 p = name + strlen (name); 514 dir_key.name = strcache_add_len (name, p - name); 515 #endif 469 516 dir_slot = (struct directory **) hash_find_slot (&directories, &dir_key); 470 517 dir = *dir_slot; … … 476 523 /* The directory was not found. Create a new entry for it. */ 477 524 525 #ifndef CONFIG_WITH_STRCACHE2 478 526 p = name + strlen (name); 527 #endif 479 528 #ifndef CONFIG_WITH_ALLOC_CACHES 480 529 dir = xmalloc (sizeof (struct directory)); … … 482 531 dir = alloccache_alloc (&directories_cache); 483 532 #endif 533 #ifndef CONFIG_WITH_STRCACHE2 484 534 dir->name = strcache_add_len (name, p - name); 535 #else 536 dir->name = dir_key.name; 537 #endif 485 538 hash_insert_at (&directories, dir, dir_slot); 486 539 /* The directory is not in the name hash table. … … 523 576 dc_key.dev = st.st_dev; 524 577 #ifdef WINDOWS32 578 # ifndef CONFIG_WITH_STRCACHE2 525 579 dc_key.path_key = w32_path = w32ify (name, 1); 580 # else /* CONFIG_WITH_STRCACHE2 */ 581 w32_path = w32ify (name, 1); 582 dc_key.path_key = strcache_add (w32_path); 583 # endif /* CONFIG_WITH_STRCACHE2 */ 526 584 dc_key.ctime = st.st_ctime; 527 585 #else … … 552 610 dc->dev = st.st_dev; 553 611 #ifdef WINDOWS32 612 # ifndef CONFIG_WITH_STRCACHE2 554 613 dc->path_key = xstrdup (w32_path); 614 # else /* CONFIG_WITH_STRCACHE2 */ 615 dc->path_key = dc_key.path_key; 616 # endif /* CONFIG_WITH_STRCACHE2 */ 617 555 618 dc->ctime = st.st_ctime; 556 619 dc->mtime = st.st_mtime; … … 664 727 return 1; 665 728 } 729 #ifndef CONFIG_WITH_STRCACHE2 666 730 dirfile_key.name = filename; 667 731 dirfile_key.length = strlen (filename); 732 #else /* CONFIG_WITH_STRCACHE2 */ 733 dirfile_key.length = strlen (filename); 734 dirfile_key.name = filename 735 = strcache_add_len (filename, dirfile_key.length); 736 #endif /* CONFIG_WITH_STRCACHE2 */ 668 737 df = hash_find_item (&dir->dirfiles, &dirfile_key); 669 738 if (df) … … 758 827 759 828 len = NAMLEN (d); 829 #ifndef CONFIG_WITH_STRCACHE2 760 830 dirfile_key.name = d->d_name; 831 #else 832 dirfile_key.name = strcache_add_len (d->d_name, len); 833 #endif 761 834 dirfile_key.length = len; 762 835 dirfile_slot = (struct dirfile **) hash_find_slot (&dir->dirfiles, &dirfile_key); … … 774 847 df = alloccache_alloc (&dirfile_cache); 775 848 #endif 849 #ifndef CONFIG_WITH_STRCACHE2 776 850 df->name = strcache_add_len (d->d_name, len); 851 #else 852 df->name = dirfile_key.name; 853 #endif 777 854 df->length = len; 778 855 df->impossible = 0; … … 780 857 } 781 858 /* Check if the name matches the one we're searching for. */ 859 #ifndef CONFIG_WITH_STRCACHE2 782 860 if (filename != 0 && strieq (d->d_name, filename)) 861 #else 862 if (filename != 0 && dirfile_key.name == filename) 863 #endif 783 864 return 1; 784 865 } … … 1038 1119 #endif 1039 1120 1121 #ifndef CONFIG_WITH_STRCACHE2 1040 1122 dirfile_key.name = filename; 1041 1123 dirfile_key.length = strlen (filename); 1124 #else 1125 dirfile_key.length = strlen (filename); 1126 dirfile_key.name = strcache_add_len (filename, dirfile_key.length); 1127 #endif 1042 1128 dirfile = hash_find_item (&dir->dirfiles, &dirfile_key); 1043 1129 if (dirfile)
Note:
See TracChangeset
for help on using the changeset viewer.