runtime: runtime.Caller should succeed even without debug info.
[gcc.git] / libgo / runtime / go-type-string.c
1 /* go-type-string.c -- hash and equality string functions.
2
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. */
6
7 #include <stddef.h>
8
9 #include "go-string.h"
10 #include "go-type.h"
11
12 /* A string hash function for a map. */
13
14 uintptr_t
15 __go_type_hash_string (const void *vkey,
16 uintptr_t key_size __attribute__ ((unused)))
17 {
18 uintptr_t ret;
19 const struct __go_string *key;
20 int len;
21 int i;
22 const unsigned char *p;
23
24 ret = 5381;
25 key = (const struct __go_string *) vkey;
26 len = key->__length;
27 for (i = 0, p = key->__data; i < len; i++, p++)
28 ret = ret * 33 + *p;
29 return ret;
30 }
31
32 /* A string equality function for a map. */
33
34 _Bool
35 __go_type_equal_string (const void *vk1, const void *vk2,
36 uintptr_t key_size __attribute__ ((unused)))
37 {
38 const struct __go_string *k1;
39 const struct __go_string *k2;
40
41 k1 = (const struct __go_string *) vk1;
42 k2 = (const struct __go_string *) vk2;
43 return (k1->__length == k2->__length
44 && __builtin_memcmp (k1->__data, k2->__data, k1->__length) == 0);
45 }