diff options
author | Ben Cheng <bccheng@google.com> | 2013-03-28 11:14:20 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2013-03-28 12:40:33 -0700 |
commit | af0c51ac87ab2a87caa03fa108f0d164987a2764 (patch) | |
tree | 4b8b470f7c5b69642fdab8d0aa1fbc148d02196b /gcc-4.8/libgo/runtime/go-type-string.c | |
parent | d87cae247d39ebf4f5a6bf25c932a14d2fdb9384 (diff) | |
download | toolchain_gcc-af0c51ac87ab2a87caa03fa108f0d164987a2764.tar.gz toolchain_gcc-af0c51ac87ab2a87caa03fa108f0d164987a2764.tar.bz2 toolchain_gcc-af0c51ac87ab2a87caa03fa108f0d164987a2764.zip |
[GCC 4.8] Initial check-in of GCC 4.8.0
Change-Id: I0719d8a6d0f69b367a6ab6f10eb75622dbf12771
Diffstat (limited to 'gcc-4.8/libgo/runtime/go-type-string.c')
-rw-r--r-- | gcc-4.8/libgo/runtime/go-type-string.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gcc-4.8/libgo/runtime/go-type-string.c b/gcc-4.8/libgo/runtime/go-type-string.c new file mode 100644 index 000000000..a96af0290 --- /dev/null +++ b/gcc-4.8/libgo/runtime/go-type-string.c @@ -0,0 +1,43 @@ +/* go-type-string.c -- hash and equality string functions. + + Copyright 2009 The Go Authors. All rights reserved. + Use of this source code is governed by a BSD-style + license that can be found in the LICENSE file. */ + +#include "runtime.h" +#include "go-type.h" +#include "go-string.h" + +/* A string hash function for a map. */ + +uintptr_t +__go_type_hash_string (const void *vkey, + uintptr_t key_size __attribute__ ((unused))) +{ + uintptr_t ret; + const String *key; + intgo len; + intgo i; + const byte *p; + + ret = 5381; + key = (const String *) vkey; + len = key->len; + for (i = 0, p = key->str; i < len; i++, p++) + ret = ret * 33 + *p; + return ret; +} + +/* A string equality function for a map. */ + +_Bool +__go_type_equal_string (const void *vk1, const void *vk2, + uintptr_t key_size __attribute__ ((unused))) +{ + const String *k1; + const String *k2; + + k1 = (const String *) vk1; + k2 = (const String *) vk2; + return __go_ptr_strings_equal (k1, k2); +} |