PR c++/83825
[official-gcc.git] / libgo / runtime / go-construct-map.c
blob0e71ba93aa24dbe6f4434a4ebdf79bc2c57845a5
1 /* go-construct-map.c -- construct a map from an initializer.
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. */
7 #include <stddef.h>
8 #include <stdint.h>
9 #include <stdlib.h>
11 #include "runtime.h"
12 #include "go-type.h"
14 extern void *makemap (const struct __go_map_type *, intgo hint,
15 void *)
16 __asm__ (GOSYM_PREFIX "runtime.makemap");
18 extern void *mapassign (const struct __go_map_type *, void *hmap,
19 const void *key)
20 __asm__ (GOSYM_PREFIX "runtime.mapassign");
22 void *
23 __go_construct_map (const struct __go_map_type *type,
24 uintptr_t count, uintptr_t entry_size,
25 uintptr_t val_offset, const void *ventries)
27 void *ret;
28 const unsigned char *entries;
29 uintptr_t i;
30 void *p;
32 ret = makemap(type, (intgo) count, NULL);
34 entries = (const unsigned char *) ventries;
35 for (i = 0; i < count; ++i)
37 p = mapassign (type, ret, entries);
38 typedmemmove (type->__val_type, p, entries + val_offset);
39 entries += entry_size;
42 return ret;