OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [runtime/] [map.goc] - Blame information for rev 761

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2010 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
 
5
package runtime
6
#include "runtime.h"
7
#include "map.h"
8
 
9
typedef struct __go_map Hmap;
10
typedef struct __go_hash_iter hiter;
11
 
12
/* Access a value in a map, returning a value and a presence indicator.  */
13
 
14
func mapaccess2(t *MapType, h *Hmap, key *byte, val *byte) (present bool) {
15
        byte *mapval;
16
        size_t valsize;
17
 
18
        mapval = __go_map_index(h, key, 0);
19
        valsize = t->__val_type->__size;
20
        if (mapval == nil) {
21
                __builtin_memset(val, 0, valsize);
22
                present = 0;
23
        } else {
24
                __builtin_memcpy(val, mapval, valsize);
25
                present = 1;
26
        }
27
}
28
 
29
/* Optionally assign a value to a map (m[k] = v, p).  */
30
 
31
func mapassign2(h *Hmap, key *byte, val *byte, p bool) {
32
        if (!p) {
33
                __go_map_delete(h, key);
34
        } else {
35
                byte *mapval;
36
                size_t valsize;
37
 
38
                mapval = __go_map_index(h, key, 1);
39
                valsize = h->__descriptor->__map_descriptor->__val_type->__size;
40
                __builtin_memcpy(mapval, val, valsize);
41
        }
42
}
43
 
44
/* Delete a key from a map.  */
45
 
46
func mapdelete(h *Hmap, key *byte) {
47
        __go_map_delete(h, key);
48
}
49
 
50
/* Initialize a range over a map.  */
51
 
52
func mapiterinit(h *Hmap, it *hiter) {
53
        __go_mapiterinit(h, it);
54
}
55
 
56
/* Move to the next iteration, updating *HITER.  */
57
 
58
func mapiternext(it *hiter) {
59
        __go_mapiternext(it);
60
}
61
 
62
/* Get the key of the current iteration.  */
63
 
64
func mapiter1(it *hiter, key *byte) {
65
        __go_mapiter1(it, key);
66
}
67
 
68
/* Get the key and value of the current iteration.  */
69
 
70
func mapiter2(it *hiter, key *byte, val *byte) {
71
        __go_mapiter2(it, key, val);
72
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.