2010-12-03 05:34:57 +01:00
|
|
|
/* go-construct-map.c -- construct a map from an initializer.
|
|
|
|
|
|
|
|
Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
Use of this source code is governed by a BSD-style
|
|
|
|
license that can be found in the LICENSE file. */
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2011-04-13 23:00:59 +02:00
|
|
|
#include <stdint.h>
|
2010-12-03 05:34:57 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2012-11-01 04:02:13 +01:00
|
|
|
#include "runtime.h"
|
2010-12-03 05:34:57 +01:00
|
|
|
#include "map.h"
|
|
|
|
|
|
|
|
struct __go_map *
|
|
|
|
__go_construct_map (const struct __go_map_descriptor *descriptor,
|
2011-04-13 23:00:59 +02:00
|
|
|
uintptr_t count, uintptr_t entry_size,
|
|
|
|
uintptr_t val_offset, uintptr_t val_size,
|
|
|
|
const void *ventries)
|
2010-12-03 05:34:57 +01:00
|
|
|
{
|
|
|
|
struct __go_map *ret;
|
|
|
|
const unsigned char *entries;
|
2011-04-13 23:00:59 +02:00
|
|
|
uintptr_t i;
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
ret = __go_new_map (descriptor, count);
|
|
|
|
|
|
|
|
entries = (const unsigned char *) ventries;
|
|
|
|
for (i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
void *val = __go_map_index (ret, entries, 1);
|
|
|
|
__builtin_memcpy (val, entries + val_offset, val_size);
|
|
|
|
entries += entry_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|