[BACK]Return to dir.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / make

Diff for /src/usr.bin/make/dir.c between version 1.50 and 1.51

version 1.50, 2007/09/16 12:19:15 version 1.51, 2007/09/16 12:30:35
Line 104 
Line 104 
  *      hampers the style of some makefiles, they must be changed.   *      hampers the style of some makefiles, they must be changed.
  *   *
  *      A list of all previously-read directories is kept in the   *      A list of all previously-read directories is kept in the
  *      openDirectories cache.   *      knownDirectories cache.
  *   *
  *      The need for the caching of whole directories is brought about by   *      The need for the caching of whole directories is brought about by
  *      the multi-level transformation code in suff.c, which tends to search   *      the multi-level transformation code in suff.c, which tends to search
Line 162 
Line 162 
  *      sense to replace the access() with a stat() and record the mtime   *      sense to replace the access() with a stat() and record the mtime
  *      in a cache for when Dir_MTime was actually called.  */   *      in a cache for when Dir_MTime was actually called.  */
   
 static LIST   thedirSearchPath;         /* main search path */  static LIST   theDefaultPath;           /* main search path */
 Lst           dirSearchPath= &thedirSearchPath;  Lst           defaultPath= &theDefaultPath;
   
 #ifdef DEBUG_DIRECTORY_CACHE  #ifdef DEBUG_DIRECTORY_CACHE
 /* Variables for gathering statistics on the efficiency of the hashing  /* Variables for gathering statistics on the efficiency of the hashing
Line 181 
Line 181 
         char name[1];                   /* ...for that file.  */          char name[1];                   /* ...for that file.  */
 };  };
   
 static struct ohash   openDirectories;  /* cache all open directories */  static struct ohash   knownDirectories; /* cache all open directories */
   
 /* Global structure used to cache mtimes.  XXX We don't cache an mtime  /* Global structure used to cache mtimes.  XXX We don't cache an mtime
  * before a caller actually looks up for the given time, because of the   * before a caller actually looks up for the given time, because of the
Line 194 
Line 194 
 /* There are three distinct hash structures:  /* There are three distinct hash structures:
  * - to collate files's last modification times (global mtimes)   * - to collate files's last modification times (global mtimes)
  * - to collate file names (in each PathEntry structure)   * - to collate file names (in each PathEntry structure)
  * - to collate known directories (global openDirectories).  */   * - to collate known directories (global knownDirectories).  */
 static struct ohash_info stamp_info = {  static struct ohash_info stamp_info = {
         offsetof(struct file_stamp, name), NULL, hash_alloc, hash_free,          offsetof(struct file_stamp, name), NULL, hash_alloc, hash_free,
         element_alloc };          element_alloc };
Line 282 
Line 282 
 {  {
         char *dotname = ".";          char *dotname = ".";
   
         Static_Lst_Init(dirSearchPath);          Static_Lst_Init(defaultPath);
         ohash_init(&openDirectories, 4, &dir_info);          ohash_init(&knownDirectories, 4, &dir_info);
         ohash_init(&mtimes, 4, &stamp_info);          ohash_init(&mtimes, 4, &stamp_info);
   
   
Line 306 
Line 306 
   
         dot->refCount--;          dot->refCount--;
         Dir_Destroy(dot);          Dir_Destroy(dot);
         Lst_Destroy(dirSearchPath, Dir_Destroy);          Lst_Destroy(defaultPath, Dir_Destroy);
         for (p = ohash_first(&openDirectories, &i); p != NULL;          for (p = ohash_first(&knownDirectories, &i); p != NULL;
             p = ohash_next(&openDirectories, &i))              p = ohash_next(&knownDirectories, &i))
                 Dir_Destroy(p);                  Dir_Destroy(p);
         ohash_delete(&openDirectories);          ohash_delete(&knownDirectories);
         free_hash(&mtimes);          free_hash(&mtimes);
 }  }
 #endif  #endif
Line 600 
Line 600 
         struct dirent *dp;          struct dirent *dp;
         unsigned int slot;          unsigned int slot;
   
         slot = ohash_qlookupi(&openDirectories, name, &ename);          slot = ohash_qlookupi(&knownDirectories, name, &ename);
         p = ohash_find(&openDirectories, slot);          p = ohash_find(&knownDirectories, slot);
   
         if (p != NULL)          if (p != NULL)
                 return p;                  return p;
Line 632 
Line 632 
         if (DEBUG(DIR))          if (DEBUG(DIR))
                 printf("done\n");                  printf("done\n");
   
         ohash_insert(&openDirectories, slot, p);          ohash_insert(&knownDirectories, slot, p);
         return p;          return p;
 }  }
   
Line 732 
Line 732 
         struct PathEntry *p = (struct PathEntry *)pp;          struct PathEntry *p = (struct PathEntry *)pp;
   
         if (--p->refCount == 0) {          if (--p->refCount == 0) {
                 ohash_remove(&openDirectories,                  ohash_remove(&knownDirectories,
                     ohash_qlookup(&openDirectories, p->name));                      ohash_qlookup(&knownDirectories, p->name));
                 free_hash(&p->files);                  free_hash(&p->files);
                 free(p);                  free(p);
         }          }
Line 775 
Line 775 
               (hits+bigmisses+nearmisses ?                (hits+bigmisses+nearmisses ?
                hits * 100 / (hits + bigmisses + nearmisses) : 0));                 hits * 100 / (hits + bigmisses + nearmisses) : 0));
         printf("# %-20s referenced\thits\n", "directory");          printf("# %-20s referenced\thits\n", "directory");
         for (p = ohash_first(&openDirectories, &i); p != NULL;          for (p = ohash_first(&knownDirectories, &i); p != NULL;
             p = ohash_next(&openDirectories, &i))              p = ohash_next(&knownDirectories, &i))
                 printf("# %-20s %10d\t%4d\n", p->name, p->refCount, p->hits);                  printf("# %-20s %10d\t%4d\n", p->name, p->refCount, p->hits);
 }  }
 #endif  #endif
Line 806 
Line 806 
                 return Arch_MTime(gn);                  return Arch_MTime(gn);
   
         if (gn->path == NULL) {          if (gn->path == NULL) {
                 fullName = Dir_FindFile(gn->name, dirSearchPath);                  fullName = Dir_FindFile(gn->name, defaultPath);
                 if (fullName == NULL)                  if (fullName == NULL)
                         fullName = estrdup(gn->name);                          fullName = estrdup(gn->name);
         } else          } else

Legend:
Removed from v.1.50  
changed lines
  Added in v.1.51