2016-10-07 Steven G. Kargl <kargl@gcc.gnu.org>
[official-gcc.git] / libgo / runtime / go-construct-map.c
blobc1a8bb72efac157a2c0095be18c57ac717d27a9c
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"
13 extern void *makemap (const struct __go_map_type *, int64_t hint,
14 void *, void *)
15 __asm__ (GOSYM_PREFIX "runtime.makemap");
17 extern void mapassign1 (const struct __go_map_type *, void *hmap,
18 const void *key, const void *val)
19 __asm__ (GOSYM_PREFIX "runtime.mapassign1");
21 void *
22 __go_construct_map (const struct __go_map_type *type,
23 uintptr_t count, uintptr_t entry_size,
24 uintptr_t val_offset, const void *ventries)
26 void *ret;
27 const unsigned char *entries;
28 uintptr_t i;
30 ret = makemap(type, (int64_t) count, NULL, NULL);
32 entries = (const unsigned char *) ventries;
33 for (i = 0; i < count; ++i)
35 mapassign1 (type, ret, entries, entries + val_offset);
36 entries += entry_size;
39 return ret;