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 /* The 64-bit type. */
13 typedef unsigned int DItype
__attribute__ ((mode (DI
)));
15 /* An identity hash function for a type. This is used for types where
16 we can simply use the type value itself as a hash code. This is
17 true of, e.g., integers and pointers. */
20 __go_type_hash_identity (const void *key
, uintptr_t key_size
)
24 const unsigned char *p
;
34 __builtin_memcpy (&u
.a
, key
, key_size
);
35 return (uintptr_t) u
.v
;
39 for (i
= 0, p
= (const unsigned char *) key
; i
< key_size
; i
++, p
++)
44 /* An identity equality function for a type. This is used for types
45 where we can check for equality by checking that the values have
49 __go_type_equal_identity (const void *k1
, const void *k2
, uintptr_t key_size
)
51 return __builtin_memcmp (k1
, k2
, key_size
) == 0;