1 /* go-type-identity.c -- hash and equality identity functions.
3 Copyright 2009 The Go Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style
5 license that can be found in the LICENSE file. */
11 /* Typedefs for accesses of different sizes. */
13 typedef int QItype __attribute__ ((mode (QI)));
14 typedef int HItype __attribute__ ((mode (HI)));
15 typedef int SItype __attribute__ ((mode (SI)));
16 typedef int DItype __attribute__ ((mode (DI)));
18 /* An identity hash function for a type. This is used for types where
19 we can simply use the type value itself as a hash code. This is
20 true of, e.g., integers and pointers. */
23 __go_type_hash_identity (const void *key, size_t key_size)
28 return *(const QItype *) key;
30 return *(const HItype *) key;
36 return *(const SItype *) key;
38 return *(const DItype *) key;
42 /* An identity equality function for a type. This is used for types
43 where we can check for equality by checking that the values have
47 __go_type_equal_identity (const void *k1, const void *k2, size_t key_size)
49 return __builtin_memcmp (k1, k2, key_size) == 0;