2014-07-29 Ed Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / libgo / runtime / go-construct-map.c
blob4bd79d2005887b1c9032adfc305e215a11e398d9
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 "map.h"
14 struct __go_map *
15 __go_construct_map (const struct __go_map_descriptor *descriptor,
16 uintptr_t count, uintptr_t entry_size,
17 uintptr_t val_offset, uintptr_t val_size,
18 const void *ventries)
20 struct __go_map *ret;
21 const unsigned char *entries;
22 uintptr_t i;
24 ret = __go_new_map (descriptor, count);
26 entries = (const unsigned char *) ventries;
27 for (i = 0; i < count; ++i)
29 void *val = __go_map_index (ret, entries, 1);
30 __builtin_memcpy (val, entries + val_offset, val_size);
31 entries += entry_size;
34 return ret;