annotate libgo/runtime/go-construct-map.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* go-construct-map.c -- construct a map from an initializer.
kono
parents:
diff changeset
2
kono
parents:
diff changeset
3 Copyright 2009 The Go Authors. All rights reserved.
kono
parents:
diff changeset
4 Use of this source code is governed by a BSD-style
kono
parents:
diff changeset
5 license that can be found in the LICENSE file. */
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 #include <stddef.h>
kono
parents:
diff changeset
8 #include <stdint.h>
kono
parents:
diff changeset
9 #include <stdlib.h>
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 #include "runtime.h"
kono
parents:
diff changeset
12
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
13 extern void *makemap (const struct maptype *, intgo hint, void *)
111
kono
parents:
diff changeset
14 __asm__ (GOSYM_PREFIX "runtime.makemap");
kono
parents:
diff changeset
15
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
16 extern void *mapassign (const struct maptype *, void *hmap, const void *key)
111
kono
parents:
diff changeset
17 __asm__ (GOSYM_PREFIX "runtime.mapassign");
kono
parents:
diff changeset
18
kono
parents:
diff changeset
19 void *
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
20 __go_construct_map (const struct maptype *type, uintptr_t count,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
21 uintptr_t entry_size, uintptr_t val_offset,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
22 const void *ventries)
111
kono
parents:
diff changeset
23 {
kono
parents:
diff changeset
24 void *ret;
kono
parents:
diff changeset
25 const unsigned char *entries;
kono
parents:
diff changeset
26 uintptr_t i;
kono
parents:
diff changeset
27 void *p;
kono
parents:
diff changeset
28
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
29 ret = makemap(type, (intgo) count, NULL);
111
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 entries = (const unsigned char *) ventries;
kono
parents:
diff changeset
32 for (i = 0; i < count; ++i)
kono
parents:
diff changeset
33 {
kono
parents:
diff changeset
34 p = mapassign (type, ret, entries);
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
35 typedmemmove (type->elem, p, entries + val_offset);
111
kono
parents:
diff changeset
36 entries += entry_size;
kono
parents:
diff changeset
37 }
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 return ret;
kono
parents:
diff changeset
40 }