VirtualBox

Changeset 1871 in kBuild for trunk/src/kmk/incdep.c


Ignore:
Timestamp:
Oct 16, 2008 11:38:45 PM (16 years ago)
Author:
bird
Message:

incdep: Use strcache2 for the dep and file names.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/incdep.c

    r1870 r1871  
    5252#include "rule.h"
    5353#include "debug.h"
    54 #include "hash.h"
     54#include "strcache2.h"
    5555
    5656#ifdef HAVE_FCNTL_H
     
    8989*   Structures and Typedefs                                                    *
    9090*******************************************************************************/
    91 struct incdep_strcache_entry
    92 {
    93     unsigned int length;
    94     unsigned int alignment;
    95     unsigned long hash1;
    96     unsigned long hash2;
    97     char str[1];
    98 };
    99 
    10091struct incdep_variable_in_set
    10192{
    10293    struct incdep_variable_in_set *next;
    10394    /* the parameters */
    104     struct incdep_strcache_entry *name_entry;
     95    struct strcache2_entry *name_entry; /* dep strcache */
    10596    const char *value;              /* xmalloc'ed */
    10697    unsigned int value_length;
     
    117108    /* the parameters */
    118109    const struct floc *flocp;       /* NILF */
    119     struct incdep_strcache_entry *name_entry;
     110    struct strcache2_entry *name_entry; /* dep strcache */
    120111    char *value;                    /* xmalloc'ed, free it */
    121112    unsigned int value_length;
     
    130121
    131122    /* 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. */
    133124    const char *pattern;            /* NULL */
    134125    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. */
    136127    unsigned int cmds_started;      /* 0 */
    137128    char *commands;                 /* NULL */
     
    213204static pthread_t incdep_threads[1];
    214205static struct alloccache incdep_dep_caches[1];
     206static struct strcache2 incdep_dep_strcaches[1];
    215207
    216208#elif defined (WINDOWS32)
    217209static HANDLE incdep_threads[2];
    218210static struct alloccache incdep_dep_caches[2];
     211static struct strcache2 incdep_dep_strcaches[2];
    219212
    220213#elif defined (__OS2__)
    221214static TID incdep_threads[2];
    222215static struct alloccache incdep_dep_caches[2];
     216static struct strcache2 incdep_dep_strcaches[2];
    223217#endif
    224218static unsigned incdep_num_threads;
     
    629623#endif
    630624
    631   /* create the worker threads. */
     625  /* create the worker threads and associated per thread data. */
    632626
    633627  incdep_terminate = 0;
     
    637631  for (i = 0; i < incdep_num_threads; i++)
    638632    {
     633      /* init caches */
    639634      alloccache_init (&incdep_dep_caches[i], sizeof(struct dep), "incdep dep",
    640635                       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. */
    642648#ifdef HAVE_PTHREAD
    643649      rc = pthread_attr_init (&attr);
     
    701707
    702708      alloccache_join (&dep_cache, &incdep_dep_caches[i]);
     709      strcache2_term (&incdep_dep_strcaches[i]);
    703710    }
    704711  incdep_num_threads = 0;
     
    715722   The input is freed! */
    716723static 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;
     724incdep_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;
    724732}
    725733
     
    789797
    790798        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);
    792800
    793801        filenames = (struct nameseq *) alloccache_alloc (&nameseq_cache);
     
    844852  else
    845853    {
    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);
    855857    }
    856858  return ret;
     
    880882    {
    881883      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;
    883885      rec->value = value;
    884886      rec->value_length = value_length;
     
    919921      struct incdep_variable_def *rec = incdep_xmalloc (cur, sizeof (*rec));
    920922      rec->flocp = flocp;
    921       rec->name_entry = (struct incdep_strcache_entry *)name;
     923      rec->name_entry = (struct strcache2_entry *)name;
    922924      rec->value = value;
    923925      rec->value_length = value_length;
     
    960962      struct incdep_recorded_files *rec = incdep_xmalloc (cur, sizeof (*rec));
    961963
    962       rec->filename_entry = (struct incdep_strcache_entry *)filename;
     964      rec->filename_entry = (struct strcache2_entry *)filename;
    963965      rec->pattern = pattern;
    964966      rec->pattern_percent = pattern_percent;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette