github.com/golang/gofrontend@v0.0.0-20240429183944-60f985a78526/libgo/runtime/go-construct-map.c (about) 1 /* go-construct-map.c -- construct a map from an initializer. 2 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. */ 6 7 #include <stddef.h> 8 #include <stdint.h> 9 #include <stdlib.h> 10 11 #include "runtime.h" 12 13 extern void *makemap (const struct maptype *, intgo hint, void *) 14 __asm__ (GOSYM_PREFIX "runtime.makemap"); 15 16 extern void *mapassign (const struct maptype *, void *hmap, const void *key) 17 __asm__ (GOSYM_PREFIX "runtime.mapassign"); 18 19 void * 20 __go_construct_map (const struct maptype *type, uintptr_t count, 21 uintptr_t entry_size, uintptr_t val_offset, 22 const void *ventries) 23 { 24 void *ret; 25 const unsigned char *entries; 26 uintptr_t i; 27 void *p; 28 29 ret = makemap(type, (intgo) count, NULL); 30 31 entries = (const unsigned char *) ventries; 32 for (i = 0; i < count; ++i) 33 { 34 p = mapassign (type, ret, entries); 35 typedmemmove (type->elem, p, entries + val_offset); 36 entries += entry_size; 37 } 38 39 return ret; 40 }