libjudy: remove JudyLTablesGen (#14984)
JudyLTablesGen could be replaced with a pregenerated file with 32-bit / 64-bit specific macros. Fixes #14185
Zephyr Lykos committed
May 11, 2023 at 14:27 UTC
024e08d2807a8ccb7b22e9a4a8e97954cec530b9
5 files changed
+340
-343
.gitignore
-4
@@ -229,10 +229,6 @@ Session.*.vim
229
# Jupyter notebook checkpoints
230
.ipynb_checkpoints
231
232
-# Judy stuff
233
-JudyLTables.c
234
-judyltablesgen
235
-
232
# m4 generated ksys
233
database/engine/journalfile_v2.ksy
234
database/engine/journalfile_v2_virtmemb.ksy
CMakeLists.txt
+1
-22
@@ -386,35 +386,14 @@ set(LIBJUDY_SOURCES
386
libnetdata/libjudy/src/JudyL/JudyLNextEmpty.c
387
libnetdata/libjudy/src/JudyL/JudyLPrev.c
388
libnetdata/libjudy/src/JudyL/JudyLPrevEmpty.c
389
- JudyLTables.c
389
+ libnetdata/libjudy/src/JudyL/JudyLTables.c
390
libnetdata/libjudy/src/JudyHS/JudyHS.c)
391
392
ADD_LIBRARY(judy STATIC
393
${LIBJUDY_SOURCES})
394
395
-ADD_EXECUTABLE(judyltablesgen
396
- libnetdata/libjudy/src/JudyL/JudyLTablesGen.c)
397
-
398
-target_include_directories(judyltablesgen PUBLIC
399
- libnetdata/libjudy/src
400
- libnetdata/libjudy/src/JudyCommon)
401
-
402
-target_compile_options(judyltablesgen PUBLIC
403
- -Wno-format
404
- -Wno-format-security)
405
-
395
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/libnetdata/libjudy/src)
396
408
-target_compile_definitions(judyltablesgen PUBLIC
409
- JU_64BIT
410
- JUDYL)
411
-
412
-add_custom_command(
413
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/JudyLTables.c
414
- COMMAND judyltablesgen
415
- DEPENDS judyltablesgen
416
- )
417
-
397
target_include_directories(judy PUBLIC
398
libnetdata/libjudy/src
399
libnetdata/libjudy/src/JudyCommon)
Makefile.am
+1
-16
@@ -501,15 +501,10 @@ libjudy_a_SOURCES = libnetdata/libjudy/src/Judy.h \
501
libnetdata/libjudy/src/JudyL/JudyLNextEmpty.c \
502
libnetdata/libjudy/src/JudyL/JudyLPrev.c \
503
libnetdata/libjudy/src/JudyL/JudyLPrevEmpty.c \
504
+ libnetdata/libjudy/src/JudyL/JudyLTables.c \
505
libnetdata/libjudy/src/JudyHS/JudyHS.c \
506
$(NULL)
507
507
-nodist_libjudy_a_SOURCES = JudyLTables.c
508
-
509
-BUILT_SOURCES += JudyLTables.c
510
-
511
-CLEANFILES += JudyLTables.c
512
-
508
libjudy_a_CFLAGS = $(LIBJUDY_CFLAGS) -DJUDYL -I$(abs_top_srcdir)/libnetdata/libjudy/src -I$(abs_top_srcdir)/libnetdata/libjudy/src/JudyCommon -Wno-sign-compare -Wno-implicit-fallthrough
509
510
libnetdata/libjudy/src/JudyL/libjudy_a-JudyLPrev.$(OBJEXT) : CFLAGS += -DJUDYPREV
@@ -519,16 +514,6 @@ libnetdata/libjudy/src/JudyL/libjudy_a-JudyLNextEmpty.$(OBJEXT) : CFLAGS += -DJU
514
libnetdata/libjudy/src/JudyL/libjudy_a-JudyLByCount.$(OBJEXT) : CFLAGS += -DNOSMARTJBB -DNOSMARTJBU -DNOSMARTJLB
515
libnetdata/libjudy/src/JudyL/libjudy_a-j__udyLGet.$(OBJEXT) : CFLAGS += -DJUDYGETINLINE
516
522
-noinst_PROGRAMS = judyltablesgen
523
-
524
-judyltablesgen_SOURCES = libnetdata/libjudy/src/JudyL/JudyLTablesGen.c
525
-judyltablesgen_CFLAGS = $(LIBJUDY_CFLAGS) -DJUDYL -I$(abs_top_srcdir)/libnetdata/libjudy/src -I$(abs_top_srcdir)/libnetdata/libjudy/src/JudyCommon -Wno-sign-compare -Wno-implicit-fallthrough
526
-
527
-$(builddir)/judyltablesgen$(EXEEXT) : CFLAGS += -Wno-format -Wno-format-security
528
-
529
-JudyLTables.c: $(abs_top_srcdir)/libnetdata/libjudy/src/JudyL/JudyLTablesGen.c $(builddir)/judyltablesgen$(EXEEXT)
530
- $(builddir)/judyltablesgen$(EXEEXT)
531
-
517
libjudy_a-JudyLTables.$(OBJEXT) : CFLAGS += -I$(abs_top_srcdir)/libnetdata/libjudy/src/JudyL
518
519
if ENABLE_DBENGINE
libnetdata/libjudy/src/JudyL/JudyLTables.c
new
+338
@@ -0,0 +1,338 @@
1
+// @(#) From generation tool: $Revision: 4.37 $ $Source: /judy/src/JudyCommon/JudyTables.c $
2
+// Pregenerated and modified by hand. Do not overwrite!
3
+
4
+#include "JudyL.h"
5
+// Leave the malloc() sizes readable in the binary (via strings(1)):
6
+#ifdef JU_64BIT
7
+const char * JudyLMallocSizes = "JudyLMallocSizes = 3, 5, 7, 11, 15, 23, 32, 47, 64, Leaf1 = 13";
8
+#else // JU_32BIT
9
+const char * JudyLMallocSizes = "JudyLMallocSizes = 3, 5, 7, 11, 15, 23, 32, 47, 64, Leaf1 = 25";
10
+#endif // JU_64BIT
11
+
12
+#ifdef JU_64BIT
13
+// object uses 64 words
14
+// cJU_BITSPERSUBEXPB = 32
15
+const uint8_t
16
+j__L_BranchBJPPopToWords[cJU_BITSPERSUBEXPB + 1] =
17
+{
18
+ 0,
19
+ 3, 5, 7, 11, 11, 15, 15, 23,
20
+ 23, 23, 23, 32, 32, 32, 32, 32,
21
+ 47, 47, 47, 47, 47, 47, 47, 64,
22
+ 64, 64, 64, 64, 64, 64, 64, 64
23
+};
24
+
25
+// object uses 15 words
26
+// cJL_LEAF1_MAXPOP1 = 13
27
+const uint8_t
28
+j__L_Leaf1PopToWords[cJL_LEAF1_MAXPOP1 + 1] =
29
+{
30
+ 0,
31
+ 3, 3, 5, 5, 7, 7, 11, 11,
32
+ 11, 15, 15, 15, 15
33
+};
34
+const uint8_t
35
+j__L_Leaf1Offset[cJL_LEAF1_MAXPOP1 + 1] =
36
+{
37
+ 0,
38
+ 1, 1, 1, 1, 1, 1, 2, 2,
39
+ 2, 2, 2, 2, 2
40
+};
41
+
42
+// object uses 64 words
43
+// cJL_LEAF2_MAXPOP1 = 51
44
+const uint8_t
45
+j__L_Leaf2PopToWords[cJL_LEAF2_MAXPOP1 + 1] =
46
+{
47
+ 0,
48
+ 3, 3, 5, 5, 7, 11, 11, 11,
49
+ 15, 15, 15, 15, 23, 23, 23, 23,
50
+ 23, 23, 32, 32, 32, 32, 32, 32,
51
+ 32, 47, 47, 47, 47, 47, 47, 47,
52
+ 47, 47, 47, 47, 47, 64, 64, 64,
53
+ 64, 64, 64, 64, 64, 64, 64, 64,
54
+ 64, 64, 64
55
+};
56
+const uint8_t
57
+j__L_Leaf2Offset[cJL_LEAF2_MAXPOP1 + 1] =
58
+{
59
+ 0,
60
+ 1, 1, 1, 1, 2, 3, 3, 3,
61
+ 3, 3, 3, 3, 5, 5, 5, 5,
62
+ 5, 5, 7, 7, 7, 7, 7, 7,
63
+ 7, 10, 10, 10, 10, 10, 10, 10,
64
+ 10, 10, 10, 10, 10, 13, 13, 13,
65
+ 13, 13, 13, 13, 13, 13, 13, 13,
66
+ 13, 13, 13
67
+};
68
+
69
+// object uses 64 words
70
+// cJL_LEAF3_MAXPOP1 = 46
71
+const uint8_t
72
+j__L_Leaf3PopToWords[cJL_LEAF3_MAXPOP1 + 1] =
73
+{
74
+ 0,
75
+ 3, 3, 5, 7, 7, 11, 11, 11,
76
+ 15, 15, 23, 23, 23, 23, 23, 23,
77
+ 32, 32, 32, 32, 32, 32, 32, 47,
78
+ 47, 47, 47, 47, 47, 47, 47, 47,
79
+ 47, 47, 64, 64, 64, 64, 64, 64,
80
+ 64, 64, 64, 64, 64, 64
81
+};
82
+const uint8_t
83
+j__L_Leaf3Offset[cJL_LEAF3_MAXPOP1 + 1] =
84
+{
85
+ 0,
86
+ 1, 1, 2, 2, 2, 3, 3, 3,
87
+ 4, 4, 6, 6, 6, 6, 6, 6,
88
+ 9, 9, 9, 9, 9, 9, 9, 13,
89
+ 13, 13, 13, 13, 13, 13, 13, 13,
90
+ 13, 13, 18, 18, 18, 18, 18, 18,
91
+ 18, 18, 18, 18, 18, 18
92
+};
93
+
94
+// object uses 63 words
95
+// cJL_LEAF4_MAXPOP1 = 42
96
+const uint8_t
97
+j__L_Leaf4PopToWords[cJL_LEAF4_MAXPOP1 + 1] =
98
+{
99
+ 0,
100
+ 3, 3, 5, 7, 11, 11, 11, 15,
101
+ 15, 15, 23, 23, 23, 23, 23, 32,
102
+ 32, 32, 32, 32, 32, 47, 47, 47,
103
+ 47, 47, 47, 47, 47, 47, 47, 63,
104
+ 63, 63, 63, 63, 63, 63, 63, 63,
105
+ 63, 63
106
+};
107
+const uint8_t
108
+j__L_Leaf4Offset[cJL_LEAF4_MAXPOP1 + 1] =
109
+{
110
+ 0,
111
+ 1, 1, 2, 2, 4, 4, 4, 5,
112
+ 5, 5, 8, 8, 8, 8, 8, 11,
113
+ 11, 11, 11, 11, 11, 16, 16, 16,
114
+ 16, 16, 16, 16, 16, 16, 16, 21,
115
+ 21, 21, 21, 21, 21, 21, 21, 21,
116
+ 21, 21
117
+};
118
+
119
+// object uses 64 words
120
+// cJL_LEAF5_MAXPOP1 = 39
121
+const uint8_t
122
+j__L_Leaf5PopToWords[cJL_LEAF5_MAXPOP1 + 1] =
123
+{
124
+ 0,
125
+ 3, 5, 5, 7, 11, 11, 15, 15,
126
+ 15, 23, 23, 23, 23, 23, 32, 32,
127
+ 32, 32, 32, 47, 47, 47, 47, 47,
128
+ 47, 47, 47, 47, 64, 64, 64, 64,
129
+ 64, 64, 64, 64, 64, 64, 64
130
+};
131
+const uint8_t
132
+j__L_Leaf5Offset[cJL_LEAF5_MAXPOP1 + 1] =
133
+{
134
+ 0,
135
+ 2, 2, 2, 3, 4, 4, 6, 6,
136
+ 6, 9, 9, 9, 9, 9, 12, 12,
137
+ 12, 12, 12, 18, 18, 18, 18, 18,
138
+ 18, 18, 18, 18, 25, 25, 25, 25,
139
+ 25, 25, 25, 25, 25, 25, 25
140
+};
141
+
142
+// object uses 63 words
143
+// cJL_LEAF6_MAXPOP1 = 36
144
+const uint8_t
145
+j__L_Leaf6PopToWords[cJL_LEAF6_MAXPOP1 + 1] =
146
+{
147
+ 0,
148
+ 3, 5, 7, 7, 11, 11, 15, 15,
149
+ 23, 23, 23, 23, 23, 32, 32, 32,
150
+ 32, 32, 47, 47, 47, 47, 47, 47,
151
+ 47, 47, 63, 63, 63, 63, 63, 63,
152
+ 63, 63, 63, 63
153
+};
154
+const uint8_t
155
+j__L_Leaf6Offset[cJL_LEAF6_MAXPOP1 + 1] =
156
+{
157
+ 0,
158
+ 1, 3, 3, 3, 5, 5, 6, 6,
159
+ 10, 10, 10, 10, 10, 14, 14, 14,
160
+ 14, 14, 20, 20, 20, 20, 20, 20,
161
+ 20, 20, 27, 27, 27, 27, 27, 27,
162
+ 27, 27, 27, 27
163
+};
164
+
165
+// object uses 64 words
166
+// cJL_LEAF7_MAXPOP1 = 34
167
+const uint8_t
168
+j__L_Leaf7PopToWords[cJL_LEAF7_MAXPOP1 + 1] =
169
+{
170
+ 0,
171
+ 3, 5, 7, 11, 11, 15, 15, 15,
172
+ 23, 23, 23, 23, 32, 32, 32, 32,
173
+ 32, 47, 47, 47, 47, 47, 47, 47,
174
+ 47, 64, 64, 64, 64, 64, 64, 64,
175
+ 64, 64
176
+};
177
+const uint8_t
178
+j__L_Leaf7Offset[cJL_LEAF7_MAXPOP1 + 1] =
179
+{
180
+ 0,
181
+ 1, 3, 3, 5, 5, 7, 7, 7,
182
+ 11, 11, 11, 11, 15, 15, 15, 15,
183
+ 15, 22, 22, 22, 22, 22, 22, 22,
184
+ 22, 30, 30, 30, 30, 30, 30, 30,
185
+ 30, 30
186
+};
187
+
188
+// object uses 63 words
189
+// cJL_LEAFW_MAXPOP1 = 31
190
+const uint8_t
191
+j__L_LeafWPopToWords[cJL_LEAFW_MAXPOP1 + 1] =
192
+{
193
+ 0,
194
+ 3, 5, 7, 11, 11, 15, 15, 23,
195
+ 23, 23, 23, 32, 32, 32, 32, 47,
196
+ 47, 47, 47, 47, 47, 47, 47, 63,
197
+ 63, 63, 63, 63, 63, 63, 63
198
+};
199
+const uint8_t
200
+j__L_LeafWOffset[cJL_LEAFW_MAXPOP1 + 1] =
201
+{
202
+ 0,
203
+ 2, 3, 4, 6, 6, 8, 8, 12,
204
+ 12, 12, 12, 16, 16, 16, 16, 24,
205
+ 24, 24, 24, 24, 24, 24, 24, 32,
206
+ 32, 32, 32, 32, 32, 32, 32
207
+};
208
+
209
+// object uses 64 words
210
+// cJU_BITSPERSUBEXPL = 64
211
+const uint8_t
212
+j__L_LeafVPopToWords[cJU_BITSPERSUBEXPL + 1] =
213
+{
214
+ 0,
215
+ 3, 3, 3, 5, 5, 7, 7, 11,
216
+ 11, 11, 11, 15, 15, 15, 15, 23,
217
+ 23, 23, 23, 23, 23, 23, 23, 32,
218
+ 32, 32, 32, 32, 32, 32, 32, 32,
219
+ 47, 47, 47, 47, 47, 47, 47, 47,
220
+ 47, 47, 47, 47, 47, 47, 47, 64,
221
+ 64, 64, 64, 64, 64, 64, 64, 64,
222
+ 64, 64, 64, 64, 64, 64, 64, 64
223
+};
224
+#else // JU_32BIT
225
+// object uses 64 words
226
+// cJU_BITSPERSUBEXPB = 32
227
+const uint8_t
228
+j__L_BranchBJPPopToWords[cJU_BITSPERSUBEXPB + 1] =
229
+{
230
+ 0,
231
+ 3, 5, 7, 11, 11, 15, 15, 23,
232
+ 23, 23, 23, 32, 32, 32, 32, 32,
233
+ 47, 47, 47, 47, 47, 47, 47, 64,
234
+ 64, 64, 64, 64, 64, 64, 64, 64
235
+};
236
+
237
+// object uses 32 words
238
+// cJL_LEAF1_MAXPOP1 = 25
239
+const uint8_t
240
+j__L_Leaf1PopToWords[cJL_LEAF1_MAXPOP1 + 1] =
241
+{
242
+ 0,
243
+ 3, 3, 5, 5, 7, 11, 11, 11,
244
+ 15, 15, 15, 15, 23, 23, 23, 23,
245
+ 23, 23, 32, 32, 32, 32, 32, 32,
246
+ 32
247
+};
248
+const uint8_t
249
+j__L_Leaf1Offset[cJL_LEAF1_MAXPOP1 + 1] =
250
+{
251
+ 0,
252
+ 1, 1, 1, 1, 2, 3, 3, 3,
253
+ 3, 3, 3, 3, 5, 5, 5, 5,
254
+ 5, 5, 7, 7, 7, 7, 7, 7,
255
+ 7
256
+};
257
+
258
+// object uses 63 words
259
+// cJL_LEAF2_MAXPOP1 = 42
260
+const uint8_t
261
+j__L_Leaf2PopToWords[cJL_LEAF2_MAXPOP1 + 1] =
262
+{
263
+ 0,
264
+ 3, 3, 5, 7, 11, 11, 11, 15,
265
+ 15, 15, 23, 23, 23, 23, 23, 32,
266
+ 32, 32, 32, 32, 32, 47, 47, 47,
267
+ 47, 47, 47, 47, 47, 47, 47, 63,
268
+ 63, 63, 63, 63, 63, 63, 63, 63,
269
+ 63, 63
270
+};
271
+const uint8_t
272
+j__L_Leaf2Offset[cJL_LEAF2_MAXPOP1 + 1] =
273
+{
274
+ 0,
275
+ 1, 1, 2, 2, 4, 4, 4, 5,
276
+ 5, 5, 8, 8, 8, 8, 8, 11,
277
+ 11, 11, 11, 11, 11, 16, 16, 16,
278
+ 16, 16, 16, 16, 16, 16, 16, 21,
279
+ 21, 21, 21, 21, 21, 21, 21, 21,
280
+ 21, 21
281
+};
282
+
283
+// object uses 63 words
284
+// cJL_LEAF3_MAXPOP1 = 36
285
+const uint8_t
286
+j__L_Leaf3PopToWords[cJL_LEAF3_MAXPOP1 + 1] =
287
+{
288
+ 0,
289
+ 3, 5, 7, 7, 11, 11, 15, 15,
290
+ 23, 23, 23, 23, 23, 32, 32, 32,
291
+ 32, 32, 47, 47, 47, 47, 47, 47,
292
+ 47, 47, 63, 63, 63, 63, 63, 63,
293
+ 63, 63, 63, 63
294
+};
295
+const uint8_t
296
+j__L_Leaf3Offset[cJL_LEAF3_MAXPOP1 + 1] =
297
+{
298
+ 0,
299
+ 1, 3, 3, 3, 5, 5, 6, 6,
300
+ 10, 10, 10, 10, 10, 14, 14, 14,
301
+ 14, 14, 20, 20, 20, 20, 20, 20,
302
+ 20, 20, 27, 27, 27, 27, 27, 27,
303
+ 27, 27, 27, 27
304
+};
305
+
306
+// object uses 63 words
307
+// cJL_LEAFW_MAXPOP1 = 31
308
+const uint8_t
309
+j__L_LeafWPopToWords[cJL_LEAFW_MAXPOP1 + 1] =
310
+{
311
+ 0,
312
+ 3, 5, 7, 11, 11, 15, 15, 23,
313
+ 23, 23, 23, 32, 32, 32, 32, 47,
314
+ 47, 47, 47, 47, 47, 47, 47, 63,
315
+ 63, 63, 63, 63, 63, 63, 63
316
+};
317
+const uint8_t
318
+j__L_LeafWOffset[cJL_LEAFW_MAXPOP1 + 1] =
319
+{
320
+ 0,
321
+ 2, 3, 4, 6, 6, 8, 8, 12,
322
+ 12, 12, 12, 16, 16, 16, 16, 24,
323
+ 24, 24, 24, 24, 24, 24, 24, 32,
324
+ 32, 32, 32, 32, 32, 32, 32
325
+};
326
+
327
+// object uses 32 words
328
+// cJU_BITSPERSUBEXPL = 32
329
+const uint8_t
330
+j__L_LeafVPopToWords[cJU_BITSPERSUBEXPL + 1] =
331
+{
332
+ 0,
333
+ 3, 3, 3, 5, 5, 7, 7, 11,
334
+ 11, 11, 11, 15, 15, 15, 15, 23,
335
+ 23, 23, 23, 23, 23, 23, 23, 32,
336
+ 32, 32, 32, 32, 32, 32, 32, 32
337
+};
338
+#endif // JU_64BIT
libnetdata/libjudy/src/JudyL/JudyLTablesGen.c
deleted
-301
@@ -1,301 +0,0 @@
1
-// Copyright (C) 2000 - 2002 Hewlett-Packard Company
2
-//
3
-// This program is free software; you can redistribute it and/or modify it
4
-// under the term of the GNU Lesser General Public License as published by the
5
-// Free Software Foundation; either version 2 of the License, or (at your
6
-// option) any later version.
7
-//
8
-// This program is distributed in the hope that it will be useful, but WITHOUT
9
-// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
-// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11
-// for more details.
12
-//
13
-// You should have received a copy of the GNU Lesser General Public License
14
-// along with this program; if not, write to the Free Software Foundation,
15
-// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
-// _________________
17
-
18
-// @(#) $Revision: 4.37.1-netdata $ $Source: JudyTables.c $
19
-
20
-#ifndef JU_WIN
21
-#include <unistd.h> // unavailable on win_*.
22
-#endif
23
-
24
-#include <stdlib.h>
25
-#include <stdio.h>
26
-
27
-#if (! (defined(JUDY1) || defined(JUDYL)))
28
-#error: One of -DJUDY1 or -DJUDYL must be specified.
29
-#endif
30
-
31
-#define TERMINATOR 999 // terminator for Alloc tables
32
-
33
-// define bytes per word
34
-#ifdef JU_64BIT
35
-#define BPW 8UL
36
-#else
37
-#define BPW 4UL
38
-#endif
39
-
40
-#ifdef JUDY1
41
-#include "Judy1.h"
42
-#else
43
-#include "JudyL.h"
44
-#endif
45
-
46
-FILE *fd;
47
-
48
-// Definitions come from header files Judy1.h and JudyL.h:
49
-
50
-int AllocSizes[] = ALLOCSIZES;
51
-
52
-#define ROUNDUP(BYTES,BPW,OFFSETW) \
53
- ((((BYTES) + (BPW) - 1) / (BPW)) + (OFFSETW))
54
-
55
-
56
-// ****************************************************************************
57
-// G E N T A B L E
58
-//
59
-// Note: "const" is required for newer compilers.
60
-
61
-FUNCTION void GenTable(
62
- const char * TableName, // name of table string
63
- const char * TableSize, // dimentioned size string
64
- int IndexBytes, // bytes per Index
65
- int LeafSize, // number elements in object
66
- int ValueBytes, // bytes per Value
67
- int OffsetWords) // 1 for LEAFW
68
-{
69
- int * PAllocSizes = AllocSizes;
70
- int OWord;
71
- int CurWord;
72
- int IWord;
73
- int ii;
74
- int BytesOfIndex;
75
- int BytesOfObject;
76
- int Index;
77
- int LastWords;
78
- int Words [1000] = { 0 };
79
- int Offset[1000] = { 0 };
80
- int MaxWords;
81
-
82
- MaxWords = ROUNDUP((IndexBytes + ValueBytes) * LeafSize, BPW, OffsetWords);
83
- Words[0] = 0;
84
- Offset[0] = 0;
85
- CurWord = TERMINATOR;
86
-
87
-// Walk through all number of Indexes in table:
88
-
89
- for (Index = 1; /* null */; ++Index)
90
- {
91
-
92
-// Calculate byte required for next size:
93
-
94
- BytesOfIndex = IndexBytes * Index;
95
- BytesOfObject = (IndexBytes + ValueBytes) * Index;
96
-
97
-// Round up and calculate words required for next size:
98
-
99
- OWord = ROUNDUP(BytesOfObject, BPW, OffsetWords);
100
- IWord = ROUNDUP(BytesOfIndex, BPW, OffsetWords);
101
-
102
-// Root-level leaves of population of 1 and 2 do not have the 1 word offset:
103
-
104
-// Save minimum value of offset:
105
-
106
- Offset[Index] = IWord;
107
-
108
-// Round up to next available size of words:
109
-
110
- while (OWord > *PAllocSizes) PAllocSizes++;
111
-
112
- if (Index == LeafSize)
113
- {
114
- CurWord = Words[Index] = OWord;
115
- break;
116
- }
117
-// end of available sizes ?
118
-
119
- if (*PAllocSizes == TERMINATOR)
120
- {
121
- fprintf(stderr, "BUG, in %sPopToWords, sizes not big enough for object\n", TableName);
122
- exit(1);
123
- }
124
-
125
-// Save words required and last word:
126
-
127
- if (*PAllocSizes < MaxWords) { CurWord = Words[Index] = *PAllocSizes; }
128
- else { CurWord = Words[Index] = MaxWords; }
129
-
130
- } // for each index
131
-
132
- LastWords = TERMINATOR;
133
-
134
-// Round up to largest size in each group of malloc sizes:
135
-
136
- for (ii = LeafSize; ii > 0; ii--)
137
- {
138
- if (LastWords > (Words[ii] - ii)) LastWords = Offset[ii];
139
- else Offset[ii] = LastWords;
140
- }
141
-
142
-// Print the PopToWords[] table:
143
-
144
- fprintf(fd,"\n//\tobject uses %d words\n", CurWord);
145
- fprintf(fd,"//\t%s = %d\n", TableSize, LeafSize);
146
-
147
- fprintf(fd,"const uint8_t\n");
148
- fprintf(fd,"%sPopToWords[%s + 1] =\n", TableName, TableSize);
149
- fprintf(fd,"{\n\t 0,");
150
-
151
- for (ii = 1; ii <= LeafSize; ii++)
152
- {
153
-
154
-// 8 columns per line, starting with 1:
155
-
156
- if ((ii % 8) == 1) fprintf(fd,"\n\t");
157
-
158
- fprintf(fd,"%2d", Words[ii]);
159
-
160
-// If not last number place comma:
161
-
162
- if (ii != LeafSize) fprintf(fd,", ");
163
- }
164
- fprintf(fd,"\n};\n");
165
-
166
-// Print the Offset table if needed:
167
-
168
- if (! ValueBytes) return;
169
-
170
- fprintf(fd,"const uint8_t\n");
171
- fprintf(fd,"%sOffset[%s + 1] =\n", TableName, TableSize);
172
- fprintf(fd,"{\n");
173
- fprintf(fd,"\t 0,");
174
-
175
- for (ii = 1; ii <= LeafSize; ii++)
176
- {
177
- if ((ii % 8) == 1) fprintf(fd,"\n\t");
178
-
179
- fprintf(fd,"%2d", Offset[ii]);
180
-
181
- if (ii != LeafSize) fprintf(fd,", ");
182
- }
183
- fprintf(fd,"\n};\n");
184
-
185
-} // GenTable()
186
-
187
-
188
-// ****************************************************************************
189
-// M A I N
190
-
191
-FUNCTION int main()
192
-{
193
- int ii;
194
-
195
-#ifdef JUDY1
196
- char *fname = "Judy1Tables.c";
197
-#else
198
- char *fname = "JudyLTables.c";
199
-#endif
200
-
201
- if ((fd = fopen(fname, "w")) == NULL){
202
- perror("FATAL ERROR: could not write to Judy[1L]Tables.c file\n");
203
- return (-1);
204
- }
205
-
206
-
207
- fprintf(fd,"// @(#) From generation tool: $Revision: 4.37.1-netdata $ $Source: JudyTables.c $\n");
208
- fprintf(fd,"//\n\n");
209
-
210
-
211
-// ================================ Judy1 =================================
212
-#ifdef JUDY1
213
-
214
- fprintf(fd,"#include \"Judy1.h\"\n");
215
-
216
- fprintf(fd,"// Leave the malloc() sizes readable in the binary (via "
217
- "strings(1)):\n");
218
- fprintf(fd,"const char * Judy1MallocSizes = \"Judy1MallocSizes =");
219
-
220
- for (ii = 0; AllocSizes[ii] != TERMINATOR; ii++)
221
- fprintf(fd," %d,", AllocSizes[ii]);
222
-
223
-#ifndef JU_64BIT
224
- fprintf(fd," Leaf1 = %d\";\n\n", cJ1_LEAF1_MAXPOP1);
225
-#else
226
- fprintf(fd,"\";\n\n"); // no Leaf1 in this case.
227
-#endif
228
-
229
-// ================================ 32 bit ================================
230
-#ifndef JU_64BIT
231
-
232
- GenTable("j__1_BranchBJP","cJU_BITSPERSUBEXPB", 8, cJU_BITSPERSUBEXPB,0,0);
233
-
234
- GenTable("j__1_Leaf1", "cJ1_LEAF1_MAXPOP1", 1, cJ1_LEAF1_MAXPOP1, 0, 0);
235
- GenTable("j__1_Leaf2", "cJ1_LEAF2_MAXPOP1", 2, cJ1_LEAF2_MAXPOP1, 0, 0);
236
- GenTable("j__1_Leaf3", "cJ1_LEAF3_MAXPOP1", 3, cJ1_LEAF3_MAXPOP1, 0, 0);
237
- GenTable("j__1_LeafW", "cJ1_LEAFW_MAXPOP1", 4, cJ1_LEAFW_MAXPOP1, 0, 1);
238
-
239
-#endif
240
-
241
-// ================================ 64 bit ================================
242
-#ifdef JU_64BIT
243
- GenTable("j__1_BranchBJP","cJU_BITSPERSUBEXPB",16, cJU_BITSPERSUBEXPB,0,0);
244
-
245
- GenTable("j__1_Leaf2", "cJ1_LEAF2_MAXPOP1", 2, cJ1_LEAF2_MAXPOP1, 0, 0);
246
- GenTable("j__1_Leaf3", "cJ1_LEAF3_MAXPOP1", 3, cJ1_LEAF3_MAXPOP1, 0, 0);
247
- GenTable("j__1_Leaf4", "cJ1_LEAF4_MAXPOP1", 4, cJ1_LEAF4_MAXPOP1, 0, 0);
248
- GenTable("j__1_Leaf5", "cJ1_LEAF5_MAXPOP1", 5, cJ1_LEAF5_MAXPOP1, 0, 0);
249
- GenTable("j__1_Leaf6", "cJ1_LEAF6_MAXPOP1", 6, cJ1_LEAF6_MAXPOP1, 0, 0);
250
- GenTable("j__1_Leaf7", "cJ1_LEAF7_MAXPOP1", 7, cJ1_LEAF7_MAXPOP1, 0, 0);
251
- GenTable("j__1_LeafW", "cJ1_LEAFW_MAXPOP1", 8, cJ1_LEAFW_MAXPOP1, 0, 1);
252
-#endif
253
-#endif // JUDY1
254
-
255
-
256
-// ================================ JudyL =================================
257
-#ifdef JUDYL
258
-
259
- fprintf(fd,"#include \"JudyL.h\"\n");
260
-
261
- fprintf(fd,"// Leave the malloc() sizes readable in the binary (via "
262
- "strings(1)):\n");
263
- fprintf(fd,"const char * JudyLMallocSizes = \"JudyLMallocSizes =");
264
-
265
- for (ii = 0; AllocSizes[ii] != TERMINATOR; ii++)
266
- fprintf(fd," %d,", AllocSizes[ii]);
267
-
268
- fprintf(fd," Leaf1 = %ld\";\n\n", (Word_t)cJL_LEAF1_MAXPOP1);
269
-
270
-#ifndef JU_64BIT
271
-// ================================ 32 bit ================================
272
- GenTable("j__L_BranchBJP","cJU_BITSPERSUBEXPB", 8, cJU_BITSPERSUBEXPB, 0,0);
273
-
274
- GenTable("j__L_Leaf1", "cJL_LEAF1_MAXPOP1", 1, cJL_LEAF1_MAXPOP1, BPW,0);
275
- GenTable("j__L_Leaf2", "cJL_LEAF2_MAXPOP1", 2, cJL_LEAF2_MAXPOP1, BPW,0);
276
- GenTable("j__L_Leaf3", "cJL_LEAF3_MAXPOP1", 3, cJL_LEAF3_MAXPOP1, BPW,0);
277
- GenTable("j__L_LeafW", "cJL_LEAFW_MAXPOP1", 4, cJL_LEAFW_MAXPOP1, BPW,1);
278
- GenTable("j__L_LeafV", "cJU_BITSPERSUBEXPL", 4, cJU_BITSPERSUBEXPL, 0,0);
279
-#endif // 32 BIT
280
-
281
-#ifdef JU_64BIT
282
-// ================================ 64 bit ================================
283
- GenTable("j__L_BranchBJP","cJU_BITSPERSUBEXPB",16, cJU_BITSPERSUBEXPB, 0,0);
284
-
285
- GenTable("j__L_Leaf1", "cJL_LEAF1_MAXPOP1", 1, cJL_LEAF1_MAXPOP1, BPW,0);
286
- GenTable("j__L_Leaf2", "cJL_LEAF2_MAXPOP1", 2, cJL_LEAF2_MAXPOP1, BPW,0);
287
- GenTable("j__L_Leaf3", "cJL_LEAF3_MAXPOP1", 3, cJL_LEAF3_MAXPOP1, BPW,0);
288
- GenTable("j__L_Leaf4", "cJL_LEAF4_MAXPOP1", 4, cJL_LEAF4_MAXPOP1, BPW,0);
289
- GenTable("j__L_Leaf5", "cJL_LEAF5_MAXPOP1", 5, cJL_LEAF5_MAXPOP1, BPW,0);
290
- GenTable("j__L_Leaf6", "cJL_LEAF6_MAXPOP1", 6, cJL_LEAF6_MAXPOP1, BPW,0);
291
- GenTable("j__L_Leaf7", "cJL_LEAF7_MAXPOP1", 7, cJL_LEAF7_MAXPOP1, BPW,0);
292
- GenTable("j__L_LeafW", "cJL_LEAFW_MAXPOP1", 8, cJL_LEAFW_MAXPOP1, BPW,1);
293
- GenTable("j__L_LeafV", "cJU_BITSPERSUBEXPL", 8, cJU_BITSPERSUBEXPL, 0,0);
294
-#endif // 64 BIT
295
-
296
-#endif // JUDYL
297
- fclose(fd);
298
-
299
- return(0);
300
-
301
-} // main()