annotate libgo/runtime/go-construct-map.c @ 136:4627f235cf2a

fix c-next example
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 08 Nov 2018 14:11:56 +0900
parents 84e7813d76e9
children 1830386684a0
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 #include "go-type.h"
kono
parents:
diff changeset
13
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
14 extern void *makemap (const struct __go_map_type *, intgo hint,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
15 void *)
111
kono
parents:
diff changeset
16 __asm__ (GOSYM_PREFIX "runtime.makemap");
kono
parents:
diff changeset
17
kono
parents:
diff changeset
18 extern void *mapassign (const struct __go_map_type *, void *hmap,
kono
parents:
diff changeset
19 const void *key)
kono
parents:
diff changeset
20 __asm__ (GOSYM_PREFIX "runtime.mapassign");
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 void *
kono
parents:
diff changeset
23 __go_construct_map (const struct __go_map_type *type,
kono
parents:
diff changeset
24 uintptr_t count, uintptr_t entry_size,
kono
parents:
diff changeset
25 uintptr_t val_offset, const void *ventries)
kono
parents:
diff changeset
26 {
kono
parents:
diff changeset
27 void *ret;
kono
parents:
diff changeset
28 const unsigned char *entries;
kono
parents:
diff changeset
29 uintptr_t i;
kono
parents:
diff changeset
30 void *p;
kono
parents:
diff changeset
31
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
32 ret = makemap(type, (intgo) count, NULL);
111
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 entries = (const unsigned char *) ventries;
kono
parents:
diff changeset
35 for (i = 0; i < count; ++i)
kono
parents:
diff changeset
36 {
kono
parents:
diff changeset
37 p = mapassign (type, ret, entries);
kono
parents:
diff changeset
38 typedmemmove (type->__val_type, p, entries + val_offset);
kono
parents:
diff changeset
39 entries += entry_size;
kono
parents:
diff changeset
40 }
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 return ret;
kono
parents:
diff changeset
43 }