]> git.ipfire.org Git - thirdparty/gcc.git/blob - libgo/runtime/mheapmap32.h
Add Go frontend, libgo library, and Go testsuite.
[thirdparty/gcc.git] / libgo / runtime / mheapmap32.h
1 // Copyright 2009 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 // Free(v) must be able to determine the MSpan containing v.
6 // The MHeapMap is a 2-level radix tree mapping page numbers to MSpans.
7
8 typedef struct MHeapMapNode2 MHeapMapNode2;
9
10 enum
11 {
12 // 32 bit address - 12 bit page size = 20 bits to map
13 MHeapMap_Level1Bits = 10,
14 MHeapMap_Level2Bits = 10,
15
16 MHeapMap_TotalBits =
17 MHeapMap_Level1Bits +
18 MHeapMap_Level2Bits,
19
20 MHeapMap_Level1Mask = (1<<MHeapMap_Level1Bits) - 1,
21 MHeapMap_Level2Mask = (1<<MHeapMap_Level2Bits) - 1,
22 };
23
24 struct MHeapMap
25 {
26 void *(*allocator)(uintptr);
27 MHeapMapNode2 *p[1<<MHeapMap_Level1Bits];
28 };
29
30 struct MHeapMapNode2
31 {
32 MSpan *s[1<<MHeapMap_Level2Bits];
33 };
34
35 void runtime_MHeapMap_Init(MHeapMap *m, void *(*allocator)(uintptr));
36 bool runtime_MHeapMap_Preallocate(MHeapMap *m, PageID k, uintptr npages);
37 MSpan* runtime_MHeapMap_Get(MHeapMap *m, PageID k);
38 MSpan* runtime_MHeapMap_GetMaybe(MHeapMap *m, PageID k);
39 void runtime_MHeapMap_Set(MHeapMap *m, PageID k, MSpan *v);
40
41