VirtualBox

Changeset 1886 in kBuild for trunk/src/kmk/variable.c


Ignore:
Timestamp:
Oct 19, 2008 10:27:49 PM (16 years ago)
Author:
bird
Message:

kmk: variable+strcache2 hacking.

File:
1 edited

Legend:

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

    r1877 r1886  
    108108#if defined(VARIABLE_HASH) || defined(CONFIG_WITH_OPTIMIZATION_HACKS)
    109109# ifdef _MSC_VER
    110 #  define inline _inline
    111110typedef signed int int32_t;
    112111# endif
    113 static inline unsigned long variable_hash_2i(register const char *var, register int length)
     112MY_INLINE unsigned long variable_hash_2i(register const char *var, register int length)
    114113{
    115114# define UPDATE_HASH(ch) hash = (ch) + (hash << 6) + (hash << 16) - hash
     
    170169}
    171170
    172 static inline unsigned long variable_hash_1i(register const char *var, register int length)
     171MY_INLINE unsigned long variable_hash_1i(register const char *var, register int length)
    173172{
    174173# define UPDATE_HASH(ch) hash = ((hash << 5) + hash) + (ch)
     
    339338}
    340339
    341 #ifndef VARIABLE_HASH
    342 static int
    343 variable_hash_cmp (const void *xv, const void *yv)
    344 {
    345   struct variable const *x = (struct variable const *) xv;
    346   struct variable const *y = (struct variable const *) yv;
    347   int result = x->length - y->length;
    348   if (result)
    349     return result;
    350   return_STRING_N_COMPARE (x->name, y->name, x->length);
    351 }
    352 #else /* VARIABLE_HASH */
    353 
    354 inline static int
     340#if defined(VARIABLE_HASH) || defined(KMK)
     341
     342MY_INLINE int
    355343variable_hash_cmp_2_memcmp (const char *xs, const char *ys, unsigned int length)
    356344{
     
    426414}
    427415
    428 inline static int
     416MY_INLINE int
    429417variable_hash_cmp_2_inlined (const char *xs, const char *ys, unsigned int length)
    430418{
     
    532520}
    533521
    534 inline static int
     522#endif /* VARIABLE_HASH || KMK */
     523
     524#ifndef VARIABLE_HASH
     525static int
     526variable_hash_cmp (const void *xv, const void *yv)
     527{
     528  struct variable const *x = (struct variable const *) xv;
     529  struct variable const *y = (struct variable const *) yv;
     530# ifndef CONFIG_WITH_STRCACHE2
     531  int result = x->length - y->length;
     532  if (result)
     533    return result;
     534# else  /* CONFIG_WITH_STRCACHE2 */
     535  int result;
     536
     537  if (x->value != (char *)x) /* hack: strcache indicator  */
     538    {
     539      assert (y->value != (char *)y);
     540      return x->name == y->name ? 0 : -1;
     541    }
     542
     543  /* lookup path:  */
     544  result = x->length - y->length;
     545  if (result)
     546    return result;
     547# endif /* CONFIG_WITH_STRCACHE2 */
     548
     549# ifndef KMK
     550  return_STRING_N_COMPARE (x->name, y->name, x->length);
     551# else  /* KMK */
     552#  if 0
     553  return variable_hash_cmp_2_memcmp(x->name, y->name, x->length);
     554#  else
     555  return variable_hash_cmp_2_inlined(x->name, y->name, x->length);
     556#  endif
     557# endif /* KMK */
     558}
     559
     560#else /* VARIABLE_HASH */
     561
     562MY_INLINE int
    535563variable_hash_cmp (const void *xv, const void *yv)
    536564{
     
    549577    __asm__("int3");
    550578# endif /* VARIABLE_HASH_STRICT */
     579
     580# ifdef CONFIG_WITH_STRCACHE2
     581  /* strcaching */
     582  if (x->value != (char *)x) /* hack: strcache indicator  */
     583    {
     584      assert (y->value != (char *)y);
     585      return x->name == y->name ? 0 : -1;
     586    }
     587#endif
    551588
    552589  /* hash 1 & length */
     
    649686    set = &global_variable_set;
    650687
     688#ifndef CONFIG_WITH_STRCACHE2
    651689  var_key.name = (char *) name;
     690#else
     691  var_key.value = NULL; /* hack: name cached. (value != var) */
     692  var_key.name = name = strcache2_add (&variable_strcache, name, length);
     693#endif
    652694  var_key.length = length;
    653695#ifdef VARIABLE_HASH /* bird */
     
    721763  v->name = savestring (name, length);
    722764#else
    723   v->name = strcache2_add (&variable_strcache, name, length);
     765  v->name = name; /* already cached. */
    724766#endif
    725767  v->length = length;
    726768#ifdef VARIABLE_HASH /* bird */
    727   v->hash1 = variable_hash_1i (name, length);
     769  v->hash1 = variable_hash_1i (name, length); /* FIXME: Unnecessary! */
    728770  v->hash2 = 0;
    729771#endif
     
    887929  var_key.hash1 = variable_hash_1i (name, length);
    888930  var_key.hash2 = 0;
     931#endif
     932#ifdef CONFIG_WITH_STRCACHE2
     933  var_key.value = (char *)&var_key; /* hack: name not cached */
    889934#endif
    890935
     
    10081053  var_key.hash1 = variable_hash_1i (name, length);
    10091054  var_key.hash2 = 0;
     1055#endif
     1056#ifdef CONFIG_WITH_STRCACHE2
     1057  var_key.value = (char *)&var_key; /* hack: name not cached */
    10101058#endif
    10111059
     
    17681816  makelevel_key.hash2 = 0;
    17691817#endif
     1818#ifdef CONFIG_WITH_STRCACHE2
     1819  makelevel_key.value = (char *)&makelevel_key; /* hack: name not cached */
     1820#endif
    17701821  hash_delete (&table, &makelevel_key);
    17711822
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