FreeBSD/contrib/gcc/c-common.c
/* Hash function for the problem of multiple type definitions in
   different files.  This must hash all types that will compare
   equal via comptypes to the same value.  In practice it hashes
   on some of the simple stuff and leaves the details to comptypes.  */
Hash function for the problem of multiple type definitions in
different files.  This must hash all types that will compare
equal via comptypes to the same value.  In practice it hashes
on some of the simple stuff and leaves the details to comptypes.
Hash function for the problem of multiple type definitions in different files . This must hash all types that will compare equal via comptypes to the same value . In practice it hashes on some of the simple stuff and leaves the details to comptypes .
static hashval_t
c_type_hash (const void *p)
{
  int i = 0;
  int shift, size;
  tree t = (tree) p;
  tree t2;
  switch (TREE_CODE (t))
    {
    case POINTER_TYPE:
      return c_type_hash (TREE_TYPE (t)) ^ 0x3003003;
    case ENUMERAL_TYPE:
      shift = 3;
      t2 = TYPE_VALUES (t);
      break;
    case RECORD_TYPE:
      shift = 0;
      t2 = TYPE_FIELDS (t);
      break;
    case QUAL_UNION_TYPE:
      shift = 1;
      t2 = TYPE_FIELDS (t);
      break;
    case UNION_TYPE:
      shift = 2;
      t2 = TYPE_FIELDS (t);
      break;
    default:
      gcc_unreachable ();
    }
  for (; t2; t2 = TREE_CHAIN (t2))
    i++;
  size = TREE_INT_CST_LOW (TYPE_SIZE (t));
  return ((size << 24) | (i << shift));
}
static hashval_t c_type_hash ( const void * p ) { int i = 0 ; int shift , size ; tree t = ( tree ) p ; tree t2 ; switch ( TREE_CODE ( t ) ) { case POINTER_TYPE : return c_type_hash ( TREE_TYPE ( t ) ) ^ 0x3003003 ; case ENUMERAL_TYPE : shift = 3 ; t2 = TYPE_VALUES ( t ) ; break ; case RECORD_TYPE : shift = 0 ; t2 = TYPE_FIELDS ( t ) ; break ; case QUAL_UNION_TYPE : shift = 1 ; t2 = TYPE_FIELDS ( t ) ; break ; case UNION_TYPE : shift = 2 ; t2 = TYPE_FIELDS ( t ) ; break ; default : gcc_unreachable ( ) ; } for ( ; t2 ; t2 = TREE_CHAIN ( t2 ) ) i ++ ; size = TREE_INT_CST_LOW ( TYPE_SIZE ( t ) ) ; return ( ( size << 24 ) | ( i << shift ) ) ; }
Hash function for the problem of multiple type definitions in
different files.
Hash function for the problem of multiple type definitions in different files .
/* For pointers, hash on pointee type plus some swizzling.  */ /* Hash on number of elements and total size.  */