summary refs log tree commit diff stats
path: root/lib/system/bitmasks.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/system/bitmasks.nim')
-rw-r--r--lib/system/bitmasks.nim39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/system/bitmasks.nim b/lib/system/bitmasks.nim
new file mode 100644
index 000000000..0663247c2
--- /dev/null
+++ b/lib/system/bitmasks.nim
@@ -0,0 +1,39 @@
+#
+#
+#            Nim's Runtime Library
+#        (c) Copyright 2015 Andreas Rumpf
+#
+#    See the file "copying.txt", included in this
+#    distribution, for details about the copyright.
+#
+
+# Page size of the system; in most cases 4096 bytes. For exotic OS or
+# CPU this needs to be changed:
+const
+  PageShift = when defined(nimPage256) or defined(cpu16): 3
+              elif defined(nimPage512): 9
+              elif defined(nimPage1k): 10
+              else: 12 # \ # my tests showed no improvements for using larger page sizes.
+
+  PageSize = 1 shl PageShift
+  PageMask = PageSize-1
+
+
+  MemAlign = # also minimal allocatable memory block
+    when defined(nimMemAlignTiny): 4
+    elif defined(useMalloc):
+      when defined(amd64): 16 
+      else: 8
+    else: 16
+
+  BitsPerPage = PageSize div MemAlign
+  UnitsPerPage = BitsPerPage div (sizeof(int)*8)
+    # how many ints do we need to describe a page:
+    # on 32 bit systems this is only 16 (!)
+
+  TrunkShift = 9
+  BitsPerTrunk = 1 shl TrunkShift # needs to be power of 2 and divisible by 64
+  TrunkMask = BitsPerTrunk - 1
+  IntsPerTrunk = BitsPerTrunk div (sizeof(int)*8)
+  IntShift = 5 + ord(sizeof(int) == 8) # 5 or 6, depending on int width
+  IntMask = 1 shl IntShift - 1
8d779d4955637c6dd99aba3'>^
3b7ef2288 ^

e25474154 ^

a702524ae ^
e25474154 ^
f46870fe1 ^

e25474154 ^








f46870fe1 ^
f8dd74a07 ^



9f9f0f081 ^
6023e994f ^
5e5e4abfe ^

9f9f0f081 ^
e25474154 ^

a702524ae ^
ceb1f5e21 ^

f8dd74a07 ^

e25474154 ^

f8dd74a07 ^

e25474154 ^

f530bbd63 ^

e25474154 ^



3b7ef2288 ^
e25474154 ^




9f9f0f081 ^
e25474154 ^







e25474154 ^









e25474154 ^
a702524ae ^



c7b130b4e ^

e25474154 ^
a58a2f382 ^
e25474154 ^
7ebaf4489 ^
e25474154 ^

7ebaf4489 ^
922e216b8 ^
e25474154 ^
7ebaf4489 ^
922e216b8 ^
e25474154 ^
4e7a22cac ^
e25474154 ^


7ebaf4489 ^
f8dd74a07 ^
e25474154 ^


7ebaf4489 ^

134f24f57 ^
e25474154 ^

7ebaf4489 ^
e25474154 ^

3e9dcc8be ^
e25474154 ^

3e9dcc8be ^
e25474154 ^


3e9dcc8be ^
e25474154 ^

f46870fe1 ^
a58a2f382 ^
3e9dcc8be ^
e25474154 ^


c7b130b4e ^
351e89e70 ^

c7b130b4e ^
7ebaf4489 ^

e25474154 ^
7ebaf4489 ^


e25474154 ^
7ebaf4489 ^
e25474154 ^
7ebaf4489 ^

c7b130b4e ^
e25474154 ^





7ebaf4489 ^
e25474154 ^
f8dd74a07 ^





e25474154 ^
e25474154 ^


f8dd74a07 ^


e25474154 ^

7ebaf4489 ^
e25474154 ^


7ebaf4489 ^
e25474154 ^












1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205