Commit 2afd8555ad393c256dc9a451293092e57e31c764

Thomas de Grivel 2022-12-25T06:19:54

fix i386

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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
diff --git a/c3s/Makefile b/c3s/Makefile
index 838551d..1c8f2e0 100644
--- a/c3s/Makefile
+++ b/c3s/Makefile
@@ -20,7 +20,10 @@ DISTCLEANFILES = ${CLEANFILES} config.mk
 
 build: c3s
 
-all: build cov debug
+all:
+	${MAKE} build
+	if ${HAVE_GCOV}; then ${MAKE} cov; fi
+	${MAKE} debug
 	if ${HAVE_ASAN}; then ${MAKE} asan; fi
 
 asan: c3s.asan
diff --git a/c3s/configure b/c3s/configure
index a732f39..6769787 100755
--- a/c3s/configure
+++ b/c3s/configure
@@ -30,8 +30,10 @@ echo "OBJECTS = $OBJECTS" >> ${CONFIG_MK}
 OBJECTS_ASAN="$(c2ext .asan.lo "$SOURCES")"
 echo "OBJECTS_ASAN = $OBJECTS_ASAN" >> ${CONFIG_MK}
 
-OBJECTS_COV="$(c2ext .cov.lo "$SOURCES")"
-echo "OBJECTS_COV = $OBJECTS_COV" >> ${CONFIG_MK}
+if $HAVE_GCOV; then
+    OBJECTS_COV="$(c2ext .cov.lo "$SOURCES")"
+    echo "OBJECTS_COV = $OBJECTS_COV" >> ${CONFIG_MK}
+fi
 
 OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
 echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
@@ -86,10 +88,12 @@ echo >> ${CONFIG_MK}
 echo "CFLAGS_ASAN = $CFLAGS_ASAN" >> ${CONFIG_MK}
 echo "LDFLAGS_ASAN = $LDFLAGS_ASAN" >> ${CONFIG_MK}
 echo "LIBS_ASAN = $LIBS_ASAN" >> ${CONFIG_MK}
-echo >> ${CONFIG_MK}
-echo "CFLAGS_COV = $CFLAGS_COV" >> ${CONFIG_MK}
-echo "LDFLAGS_COV = $LDFLAGS_COV" >> ${CONFIG_MK}
-echo "LIBS_COV = $LIBS_COV" >> ${CONFIG_MK}
+if $HAVE_GCOV; then
+    echo >> ${CONFIG_MK}
+    echo "CFLAGS_COV = $CFLAGS_COV" >> ${CONFIG_MK}
+    echo "LDFLAGS_COV = $LDFLAGS_COV" >> ${CONFIG_MK}
+    echo "LIBS_COV = $LIBS_COV" >> ${CONFIG_MK}
+fi
 echo >> ${CONFIG_MK}
 echo "CFLAGS_DEBUG = $CFLAGS_DEBUG" >> ${CONFIG_MK}
 echo "LDFLAGS_DEBUG = $LDFLAGS_DEBUG" >> ${CONFIG_MK}
@@ -106,10 +110,12 @@ for SRC in $SOURCES; do
     ext_rule .asan.lo "$SRC" >> ${CONFIG_MK}
     echo "	${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS_ASAN} -c $SRC -o $SRC_ASAN_LO" >> ${CONFIG_MK}
 
-    echo >> ${CONFIG_MK}
-    SRC_COV_LO="$(c2ext .cov.lo "$SRC")"
-    ext_rule .cov.lo "$SRC" >> ${CONFIG_MK}
-    echo "	${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS_COV} -c $SRC -o $SRC_COV_LO" >> ${CONFIG_MK}
+    if $HAVE_GCOV; then
+        echo >> ${CONFIG_MK}
+        SRC_COV_LO="$(c2ext .cov.lo "$SRC")"
+        ext_rule .cov.lo "$SRC" >> ${CONFIG_MK}
+        echo "	${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS_COV} -c $SRC -o $SRC_COV_LO" >> ${CONFIG_MK}
+    fi
 
     echo >> ${CONFIG_MK}
     SRC_DEBUG_LO="$(c2ext .debug.lo "$SRC")"
@@ -125,9 +131,11 @@ echo >> ${CONFIG_MK}
 echo "$PROG_ASAN: $LIBC3_ASAN $OBJECTS_ASAN" >> ${CONFIG_MK}
 echo "	${LIBTOOL} --tag=CC --mode=link \${CC} \${CFLAGS_ASAN} \${LDFLAGS_ASAN} ${OBJECTS_ASAN} ${LIBS_ASAN} -o $PROG_ASAN" >> ${CONFIG_MK}
 
-echo >> ${CONFIG_MK}
-echo "$PROG_COV: $LIBC3_COV $OBJECTS_COV" >> ${CONFIG_MK}
-echo "	${LIBTOOL} --tag=CC --mode=link \${CC} \${CFLAGS_COV} \${LDFLAGS_COV} ${OBJECTS_COV} ${LIBS_COV} -o $PROG_COV" >> ${CONFIG_MK}
+if $HAVE_GCOV; then
+    echo >> ${CONFIG_MK}
+    echo "$PROG_COV: $LIBC3_COV $OBJECTS_COV" >> ${CONFIG_MK}
+    echo "	${LIBTOOL} --tag=CC --mode=link \${CC} \${CFLAGS_COV} \${LDFLAGS_COV} ${OBJECTS_COV} ${LIBS_COV} -o $PROG_COV" >> ${CONFIG_MK}
+fi
 
 echo >> ${CONFIG_MK}
 echo "$PROG_DEBUG: $LIBC3_DEBUG $OBJECTS_DEBUG" >> ${CONFIG_MK}
diff --git a/config.subr b/config.subr
index eef1b1e..03d468a 100644
--- a/config.subr
+++ b/config.subr
@@ -110,17 +110,23 @@ if test -z "$CC"; then
 fi
 echo "CC = $CC" >> ${CONFIG_MK}
 
-if test -z "$GCOV"; then
-    if test -x "$(which gcov)"; then
-        GCOV=gcov
-    elif test -x "$(which egcov)"; then
-        GCOV=egcov
-    else
-        GCOV=gcov
+if [ "x$GCOV" = "x" ]; then
+    if which gcov 2>/dev/null; then
+	GCOV=gcov
+        HAVE_GCOV=true
+    elif which egcov 2>/dev/null; then
+	GCOV=egcov
+        HAVE_GCOV=true
     fi
+    HAVE_GCOV=false
+else
+    HAVE_GCOV=true
+fi
+echo "HAVE_GCOV = $HAVE_GCOV" >> ${CONFIG_MK}
+if ${HAVE_GCOV}; then
+    echo "GCOV = $GCOV" >> ${CONFIG_MK}
 fi
-echo "GCOV = $GCOV" >> ${CONFIG_MK}
-    
+
 if test -z "$INSTALL"; then
     if test -x "$(which install)"; then
         INSTALL=install
diff --git a/ic3/Makefile b/ic3/Makefile
index 54a3699..05d1f9c 100644
--- a/ic3/Makefile
+++ b/ic3/Makefile
@@ -20,7 +20,10 @@ DISTCLEANFILES = ${CLEANFILES} config.mk
 
 build: ic3
 
-all: build cov debug
+all:
+	${MAKE} build
+	if ${HAVE_GCOV}; then ${MAKE} cov; fi
+	${MAKE} debug
 	if ${HAVE_ASAN}; then ${MAKE} asan; fi
 
 asan: ic3.asan
diff --git a/ic3/configure b/ic3/configure
index 8ed3b8c..b1c41e8 100755
--- a/ic3/configure
+++ b/ic3/configure
@@ -30,8 +30,10 @@ echo "OBJECTS = $OBJECTS" >> ${CONFIG_MK}
 OBJECTS_ASAN="$(c2ext .asan.lo "$SOURCES")"
 echo "OBJECTS_ASAN = $OBJECTS_ASAN" >> ${CONFIG_MK}
 
-OBJECTS_COV="$(c2ext .cov.lo "$SOURCES")"
-echo "OBJECTS_COV = $OBJECTS_COV" >> ${CONFIG_MK}
+if $HAVE_GCOV; then
+    OBJECTS_COV="$(c2ext .cov.lo "$SOURCES")"
+    echo "OBJECTS_COV = $OBJECTS_COV" >> ${CONFIG_MK}
+fi
 
 OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
 echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
@@ -86,10 +88,12 @@ echo >> ${CONFIG_MK}
 echo "CFLAGS_ASAN = $CFLAGS_ASAN" >> ${CONFIG_MK}
 echo "LDFLAGS_ASAN = $LDFLAGS_ASAN" >> ${CONFIG_MK}
 echo "LIBS_ASAN = $LIBS_ASAN" >> ${CONFIG_MK}
-echo >> ${CONFIG_MK}
-echo "CFLAGS_COV = $CFLAGS_COV" >> ${CONFIG_MK}
-echo "LDFLAGS_COV = $LDFLAGS_COV" >> ${CONFIG_MK}
-echo "LIBS_COV = $LIBS_COV" >> ${CONFIG_MK}
+if $HAVE_GCOV; then
+    echo >> ${CONFIG_MK}
+    echo "CFLAGS_COV = $CFLAGS_COV" >> ${CONFIG_MK}
+    echo "LDFLAGS_COV = $LDFLAGS_COV" >> ${CONFIG_MK}
+    echo "LIBS_COV = $LIBS_COV" >> ${CONFIG_MK}
+fi
 echo >> ${CONFIG_MK}
 echo "CFLAGS_DEBUG = $CFLAGS_DEBUG" >> ${CONFIG_MK}
 echo "LDFLAGS_DEBUG = $LDFLAGS_DEBUG" >> ${CONFIG_MK}
@@ -106,10 +110,12 @@ for SRC in $SOURCES; do
     ext_rule .asan.lo "$SRC" >> ${CONFIG_MK}
     echo "	${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS_ASAN} -c $SRC -o $SRC_ASAN_LO" >> ${CONFIG_MK}
 
-    echo >> ${CONFIG_MK}
-    SRC_COV_LO="$(c2ext .cov.lo "$SRC")"
-    ext_rule .cov.lo "$SRC" >> ${CONFIG_MK}
-    echo "	${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS_COV} -c $SRC -o $SRC_COV_LO" >> ${CONFIG_MK}
+    if $HAVE_GCOV; then
+        echo >> ${CONFIG_MK}
+        SRC_COV_LO="$(c2ext .cov.lo "$SRC")"
+        ext_rule .cov.lo "$SRC" >> ${CONFIG_MK}
+        echo "	${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS_COV} -c $SRC -o $SRC_COV_LO" >> ${CONFIG_MK}
+    fi
 
     echo >> ${CONFIG_MK}
     SRC_DEBUG_LO="$(c2ext .debug.lo "$SRC")"
@@ -125,9 +131,11 @@ echo >> ${CONFIG_MK}
 echo "$PROG_ASAN: $LIBC3_ASAN $OBJECTS_ASAN" >> ${CONFIG_MK}
 echo "	${LIBTOOL} --tag=CC --mode=link \${CC} \${CFLAGS_ASAN} \${LDFLAGS_ASAN} ${OBJECTS_ASAN} ${LIBS_ASAN} -o $PROG_ASAN" >> ${CONFIG_MK}
 
-echo >> ${CONFIG_MK}
-echo "$PROG_COV: $LIBC3_COV $OBJECTS_COV" >> ${CONFIG_MK}
-echo "	${LIBTOOL} --tag=CC --mode=link \${CC} \${CFLAGS_COV} \${LDFLAGS_COV} ${OBJECTS_COV} ${LIBS_COV} -o $PROG_COV" >> ${CONFIG_MK}
+if $HAVE_GCOV; then
+    echo >> ${CONFIG_MK}
+    echo "$PROG_COV: $LIBC3_COV $OBJECTS_COV" >> ${CONFIG_MK}
+    echo "	${LIBTOOL} --tag=CC --mode=link \${CC} \${CFLAGS_COV} \${LDFLAGS_COV} ${OBJECTS_COV} ${LIBS_COV} -o $PROG_COV" >> ${CONFIG_MK}
+fi
 
 echo >> ${CONFIG_MK}
 echo "$PROG_DEBUG: $LIBC3_DEBUG $OBJECTS_DEBUG" >> ${CONFIG_MK}
diff --git a/libc3/Makefile b/libc3/Makefile
index b0ea012..e243847 100644
--- a/libc3/Makefile
+++ b/libc3/Makefile
@@ -22,7 +22,7 @@ build: libc3.la libc3.a
 
 all:
 	${MAKE} build
-	${MAKE} cov
+	if ${HAVE_GCOV}; then ${MAKE} cov; fi
 	${MAKE} debug
 	if ${HAVE_ASAN}; then ${MAKE} asan; fi
 
diff --git a/libc3/buf_inspect.c b/libc3/buf_inspect.c
index 2608f7d..23f8641 100644
--- a/libc3/buf_inspect.c
+++ b/libc3/buf_inspect.c
@@ -1045,6 +1045,17 @@ sw buf_inspect_u64 (s_buf *buf, u64 x)
   return size;
 }
 
+sw buf_inspect_u32_hex (s_buf *buf, u32 i)
+{
+  const s8 basis[] = "0123456789ABCDEF";
+  uw shift = 32;
+  while (shift) {
+    shift -= 4;
+    buf_write_s8(buf, basis[(i >> shift) & 0xF]);
+  }
+  return 8;
+}
+
 sw buf_inspect_u64_hex (s_buf *buf, u64 i)
 {
   const s8 basis[] = "0123456789ABCDEF";
diff --git a/libc3/configure b/libc3/configure
index a4e9f51..567a0bc 100755
--- a/libc3/configure
+++ b/libc3/configure
@@ -100,10 +100,12 @@ for SRC in $SOURCES; do
     ext_rule .asan.lo "$SRC" >> ${CONFIG_MK}
     echo "	${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS_ASAN} -c $SRC -o $SRC_ASAN_LO" >> ${CONFIG_MK}
 
-    echo >> ${CONFIG_MK}
-    SRC_COV_LO="$(c2ext .cov.lo "$SRC")"
-    ext_rule .cov.lo "$SRC" >> ${CONFIG_MK}
-    echo "	${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS_COV} -c $SRC -o $SRC_COV_LO" >> ${CONFIG_MK}
+    if [ -n "$GCOV" ]; then
+	echo >> ${CONFIG_MK}
+	SRC_COV_LO="$(c2ext .cov.lo "$SRC")"
+	ext_rule .cov.lo "$SRC" >> ${CONFIG_MK}
+	echo "	${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS_COV} -c $SRC -o $SRC_COV_LO" >> ${CONFIG_MK}
+    fi
 
     echo >> ${CONFIG_MK}
     SRC_DEBUG_LO="$(c2ext .debug.lo "$SRC")"
@@ -119,9 +121,11 @@ echo >> ${CONFIG_MK}
 echo "$LIB_ASAN: $OBJECTS_ASAN" >> ${CONFIG_MK}
 echo "	${LIBTOOL} --tag=CC --mode=link \${CC} \${LDFLAGS_ASAN} ${OBJECTS_ASAN} \${LIBS_ASAN} -o ${LIB_ASAN}" >> ${CONFIG_MK}
 
-echo >> ${CONFIG_MK}
-echo "$LIB_COV: $OBJECTS_COV" >> ${CONFIG_MK}
-echo "	${LIBTOOL} --tag=CC --mode=link \${CC} \${LDFLAGS_COV} ${OBJECTS_COV} \${LIBS_COV} -o ${LIB_COV}" >> ${CONFIG_MK}
+if [ -n "$GCOV" ]; then
+    echo >> ${CONFIG_MK}
+    echo "$LIB_COV: $OBJECTS_COV" >> ${CONFIG_MK}
+    echo "	${LIBTOOL} --tag=CC --mode=link \${CC} \${LDFLAGS_COV} ${OBJECTS_COV} \${LIBS_COV} -o ${LIB_COV}" >> ${CONFIG_MK}
+fi
 
 echo >> ${CONFIG_MK}
 echo "$LIB_DEBUG: $OBJECTS_DEBUG" >> ${CONFIG_MK}
diff --git a/libc3/skiplist.c.in b/libc3/skiplist.c.in
index bd717e9..a7d0e02 100644
--- a/libc3/skiplist.c.in
+++ b/libc3/skiplist.c.in
@@ -95,7 +95,7 @@ skiplist_find___NAME$ (s_skiplist___NAME$ *skiplist, _TYPE$ _NAME$)
 
 static void skiplist_height_table_init___NAME$ (s_skiplist___NAME$ *skiplist, f64 spacing)
 {
-  sw *height_table;
+  t_skiplist_height *height_table;
   u8 h;
   f64 w = spacing;
   f64 end = w;
@@ -103,6 +103,7 @@ static void skiplist_height_table_init___NAME$ (s_skiplist___NAME$ *skiplist, f6
   for (h = 0; h < skiplist->max_height; h++) {
     w *= spacing;
     end += w;
+    assert(end <= (f64) SKIPLIST_HEIGHT_MAX);
     height_table[h] = end;
   }
 }
@@ -122,10 +123,12 @@ skiplist_init___NAME$ (s_skiplist___NAME$ *skiplist, u8 max_height, f64 spacing)
 s_skiplist_node___NAME$ *
 skiplist_insert___NAME$ (s_skiplist___NAME$ *skiplist, _TYPE$ _NAME$)
 {
-  s_skiplist_node___NAME$ *pred = skiplist_pred___NAME$(skiplist, _NAME$);
-  s_skiplist_node___NAME$ *next = SKIPLIST_NODE_NEXT___NAME$(pred, 0);
+  s_skiplist_node___NAME$ *pred;
+  s_skiplist_node___NAME$ *next;
   uw height;
   s_skiplist_node___NAME$ *node;
+  pred = skiplist_pred___NAME$(skiplist, _NAME$);
+  next = SKIPLIST_NODE_NEXT___NAME$(pred, 0);
   next = SKIPLIST_NODE_NEXT___NAME$(next, 0);
   if (next && skiplist->compare(_NAME$, next->_NAME$) == 0)
     return next;
@@ -149,13 +152,17 @@ skiplist_new___NAME$ (u8 max_height, f64 spacing)
 s_skiplist_node___NAME$ *
 skiplist_pred___NAME$ (s_skiplist___NAME$ *skiplist, _TYPE$ _NAME$)
 {
-  int level = skiplist->max_height;
-  s_skiplist_node___NAME$ *pred =
-    skiplist_node_new___NAME$(NULL, skiplist->max_height);
-  s_skiplist_node___NAME$ *node = skiplist->head;
+  int level;
+  s_skiplist_node___NAME$ *pred;
+  s_skiplist_node___NAME$ *n;
+  s_skiplist_node___NAME$ *node;
+  assert(skiplist);
+  level = skiplist->max_height;
+  pred = skiplist_node_new___NAME$(NULL, skiplist->max_height);
+  node = skiplist->head;
   assert(pred);
   while (level--) {
-    s_skiplist_node___NAME$ *n = node;
+    n = node;
     while (n && skiplist->compare(_NAME$, n->_NAME$) > 0) {
       node = n;
       n = SKIPLIST_NODE_NEXT___NAME$(node, level);
@@ -168,14 +175,20 @@ skiplist_pred___NAME$ (s_skiplist___NAME$ *skiplist, _TYPE$ _NAME$)
 u8
 skiplist_random_height___NAME$ (s_skiplist___NAME$ *skiplist)
 {
-  const sw *height_table = SKIPLIST_HEIGHT_TABLE___NAME$(skiplist);
-  sw max = height_table[skiplist->max_height - 1];
-
-  sw k = random() % max;
+  u8 height;
+  const t_skiplist_height *height_table;
+  sw max;
+  t_skiplist_height k;
   sw i;
-  for (i = 0; k > height_table[i]; i++)
+  assert(skiplist);
+  height_table = SKIPLIST_HEIGHT_TABLE___NAME$(skiplist);
+  max = height_table[skiplist->max_height - 1];
+  k = random() % max;
+  for (i = 0; i < skiplist->max_height && k > height_table[i]; i++)
     ;
-  return skiplist->max_height - i;
+  height = skiplist->max_height - i;
+  assert(height);
+  return height;
 }
 
 e_bool
diff --git a/libc3/skiplist.h.in b/libc3/skiplist.h.in
index 37f585e..0bf4676 100644
--- a/libc3/skiplist.h.in
+++ b/libc3/skiplist.h.in
@@ -24,10 +24,10 @@
 #include "types.h"
 
 #define SKIPLIST_HEIGHT_TABLE___NAME$(skiplist) \
-  ((sw *) (((s_skiplist___NAME$ *) skiplist) + 1))
+  ((t_skiplist_height *) (((s_skiplist___NAME$ *) skiplist) + 1))
 
 #define SKIPLIST_SIZE___NAME$(max_height) \
-  (sizeof(s_skiplist___NAME$) + (max_height) * sizeof(sw))
+  (sizeof(s_skiplist___NAME$) + (max_height) * sizeof(t_skiplist_height))
 
 #define SKIPLIST_INIT_ALLOCA___NAME$(max_height, spacing) \
   (skiplist_init___NAME$(alloca(SKIPLIST_SIZE___NAME$(max_height)), \
diff --git a/libc3/skiplist__fact.c b/libc3/skiplist__fact.c
index 18c86da..ca98ec3 100644
--- a/libc3/skiplist__fact.c
+++ b/libc3/skiplist__fact.c
@@ -95,7 +95,7 @@ skiplist_find__fact (s_skiplist__fact *skiplist, s_fact * fact)
 
 static void skiplist_height_table_init__fact (s_skiplist__fact *skiplist, f64 spacing)
 {
-  sw *height_table;
+  t_skiplist_height *height_table;
   u8 h;
   f64 w = spacing;
   f64 end = w;
@@ -103,6 +103,7 @@ static void skiplist_height_table_init__fact (s_skiplist__fact *skiplist, f64 sp
   for (h = 0; h < skiplist->max_height; h++) {
     w *= spacing;
     end += w;
+    assert(end <= (f64) SKIPLIST_HEIGHT_MAX);
     height_table[h] = end;
   }
 }
@@ -122,10 +123,12 @@ skiplist_init__fact (s_skiplist__fact *skiplist, u8 max_height, f64 spacing)
 s_skiplist_node__fact *
 skiplist_insert__fact (s_skiplist__fact *skiplist, s_fact * fact)
 {
-  s_skiplist_node__fact *pred = skiplist_pred__fact(skiplist, fact);
-  s_skiplist_node__fact *next = SKIPLIST_NODE_NEXT__fact(pred, 0);
+  s_skiplist_node__fact *pred;
+  s_skiplist_node__fact *next;
   uw height;
   s_skiplist_node__fact *node;
+  pred = skiplist_pred__fact(skiplist, fact);
+  next = SKIPLIST_NODE_NEXT__fact(pred, 0);
   next = SKIPLIST_NODE_NEXT__fact(next, 0);
   if (next && skiplist->compare(fact, next->fact) == 0)
     return next;
@@ -149,13 +152,17 @@ skiplist_new__fact (u8 max_height, f64 spacing)
 s_skiplist_node__fact *
 skiplist_pred__fact (s_skiplist__fact *skiplist, s_fact * fact)
 {
-  int level = skiplist->max_height;
-  s_skiplist_node__fact *pred =
-    skiplist_node_new__fact(NULL, skiplist->max_height);
-  s_skiplist_node__fact *node = skiplist->head;
+  int level;
+  s_skiplist_node__fact *pred;
+  s_skiplist_node__fact *n;
+  s_skiplist_node__fact *node;
+  assert(skiplist);
+  level = skiplist->max_height;
+  pred = skiplist_node_new__fact(NULL, skiplist->max_height);
+  node = skiplist->head;
   assert(pred);
   while (level--) {
-    s_skiplist_node__fact *n = node;
+    n = node;
     while (n && skiplist->compare(fact, n->fact) > 0) {
       node = n;
       n = SKIPLIST_NODE_NEXT__fact(node, level);
@@ -168,14 +175,20 @@ skiplist_pred__fact (s_skiplist__fact *skiplist, s_fact * fact)
 u8
 skiplist_random_height__fact (s_skiplist__fact *skiplist)
 {
-  const sw *height_table = SKIPLIST_HEIGHT_TABLE__fact(skiplist);
-  sw max = height_table[skiplist->max_height - 1];
-
-  sw k = random() % max;
+  u8 height;
+  const t_skiplist_height *height_table;
+  sw max;
+  t_skiplist_height k;
   sw i;
-  for (i = 0; k > height_table[i]; i++)
+  assert(skiplist);
+  height_table = SKIPLIST_HEIGHT_TABLE__fact(skiplist);
+  max = height_table[skiplist->max_height - 1];
+  k = random() % max;
+  for (i = 0; i < skiplist->max_height && k > height_table[i]; i++)
     ;
-  return skiplist->max_height - i;
+  height = skiplist->max_height - i;
+  assert(height);
+  return height;
 }
 
 e_bool
diff --git a/libc3/skiplist__fact.h b/libc3/skiplist__fact.h
index 971e53a..b2961f0 100644
--- a/libc3/skiplist__fact.h
+++ b/libc3/skiplist__fact.h
@@ -24,10 +24,10 @@
 #include "types.h"
 
 #define SKIPLIST_HEIGHT_TABLE__fact(skiplist) \
-  ((sw *) (((s_skiplist__fact *) skiplist) + 1))
+  ((t_skiplist_height *) (((s_skiplist__fact *) skiplist) + 1))
 
 #define SKIPLIST_SIZE__fact(max_height) \
-  (sizeof(s_skiplist__fact) + (max_height) * sizeof(sw))
+  (sizeof(s_skiplist__fact) + (max_height) * sizeof(t_skiplist_height))
 
 #define SKIPLIST_INIT_ALLOCA__fact(max_height, spacing) \
   (skiplist_init__fact(alloca(SKIPLIST_SIZE__fact(max_height)), \
diff --git a/libc3/skiplist_node.c.in b/libc3/skiplist_node.c.in
index 872aa0f..bd6d937 100644
--- a/libc3/skiplist_node.c.in
+++ b/libc3/skiplist_node.c.in
@@ -17,7 +17,7 @@
 #include "skiplist_node___NAME$.h"
 
 s_skiplist_node___NAME$ *
-skiplist_node_init (s_skiplist_node___NAME$ *node, _TYPE$ _NAME$, uw height)
+skiplist_node_init (s_skiplist_node___NAME$ *node, _TYPE$ _NAME$, u8 height)
 {
   node->_NAME$ = _NAME$;
   node->height = height;
@@ -27,7 +27,7 @@ skiplist_node_init (s_skiplist_node___NAME$ *node, _TYPE$ _NAME$, uw height)
 }
 
 s_skiplist_node___NAME$ *
-skiplist_node_new___NAME$ (_TYPE$ _NAME$, uw height)
+skiplist_node_new___NAME$ (_TYPE$ _NAME$, u8 height)
 {
   s_skiplist_node___NAME$ *node = malloc(SKIPLIST_NODE_SIZE___NAME$(height));
   if (node)
diff --git a/libc3/skiplist_node.h.in b/libc3/skiplist_node.h.in
index 39c129b..4d5d4ee 100644
--- a/libc3/skiplist_node.h.in
+++ b/libc3/skiplist_node.h.in
@@ -33,10 +33,10 @@
   (sizeof(s_skiplist_node___NAME$) + (height) * sizeof(_TYPE$))
 
 s_skiplist_node___NAME$ *
-skiplist_node_init (s_skiplist_node___NAME$ *node, _TYPE$ value, unsigned long height);
+skiplist_node_init (s_skiplist_node___NAME$ *node, _TYPE$ value, u8 height);
 
 s_skiplist_node___NAME$ *
-skiplist_node_new___NAME$ (_TYPE$ value, unsigned long height);
+skiplist_node_new___NAME$ (_TYPE$ value, u8 height);
 
 void
 skiplist_node_delete___NAME$ (s_skiplist_node___NAME$ *node);
diff --git a/libc3/skiplist_node__fact.c b/libc3/skiplist_node__fact.c
index eaac61c..065dcf5 100644
--- a/libc3/skiplist_node__fact.c
+++ b/libc3/skiplist_node__fact.c
@@ -17,7 +17,7 @@
 #include "skiplist_node__fact.h"
 
 s_skiplist_node__fact *
-skiplist_node_init (s_skiplist_node__fact *node, s_fact * fact, uw height)
+skiplist_node_init (s_skiplist_node__fact *node, s_fact * fact, u8 height)
 {
   node->fact = fact;
   node->height = height;
@@ -27,7 +27,7 @@ skiplist_node_init (s_skiplist_node__fact *node, s_fact * fact, uw height)
 }
 
 s_skiplist_node__fact *
-skiplist_node_new__fact (s_fact * fact, uw height)
+skiplist_node_new__fact (s_fact * fact, u8 height)
 {
   s_skiplist_node__fact *node = malloc(SKIPLIST_NODE_SIZE__fact(height));
   if (node)
diff --git a/libc3/skiplist_node__fact.h b/libc3/skiplist_node__fact.h
index e2b7acf..ea64f5c 100644
--- a/libc3/skiplist_node__fact.h
+++ b/libc3/skiplist_node__fact.h
@@ -33,10 +33,10 @@
   (sizeof(s_skiplist_node__fact) + (height) * sizeof(s_fact *))
 
 s_skiplist_node__fact *
-skiplist_node_init (s_skiplist_node__fact *node, s_fact * value, unsigned long height);
+skiplist_node_init (s_skiplist_node__fact *node, s_fact * value, u8 height);
 
 s_skiplist_node__fact *
-skiplist_node_new__fact (s_fact * value, unsigned long height);
+skiplist_node_new__fact (s_fact * value, u8 height);
 
 void
 skiplist_node_delete__fact (s_skiplist_node__fact *node);
diff --git a/libc3/types.h b/libc3/types.h
index 6ac238b..bf012df 100644
--- a/libc3/types.h
+++ b/libc3/types.h
@@ -14,21 +14,27 @@
 #ifndef TYPES_H
 #define TYPES_H
 
+#include <limits.h>
 #include <setjmp.h>
 #include <stdio.h>
+#include <sys/types.h>
 #include "../libtommath/tommath.h"
 
 /* Basic integer types. */
-typedef char                s8;
-typedef short               s16;
-typedef int                 s32;
-typedef long                sw;
-typedef long long           s64;
-typedef unsigned char       u8;
-typedef unsigned short      u16;
-typedef unsigned int        u32;
-typedef unsigned long       uw;
-typedef unsigned long long  u64;
+typedef char          s8;
+typedef int16_t       s16;
+typedef int32_t       s32;
+typedef long          sw;
+typedef int64_t       s64;
+typedef uint8_t       u8;
+typedef uint16_t      u16;
+typedef uint32_t      u32;
+typedef unsigned long uw;
+typedef uint64_t      u64;
+
+#define S32_MAX LONG_MAX
+#define S64_MAX LLONG_MAX
+#define U64_MAX ULLONG_MAX
 
 /* IEEE 754 floating point numbers. */
 typedef float               f32;
@@ -112,6 +118,10 @@ typedef s_tag      **p_facts_spec;
 typedef s_tag       *p_quote;
 typedef const s_tag *p_tag;
 typedef const s_tag *p_var;
+typedef u64          t_skiplist_height;
+
+#define CHARACTER_MAX S32_MAX
+#define SKIPLIST_HEIGHT_MAX U64_MAX
 
 /* 1 */
 struct buf_save {
diff --git a/test/Makefile b/test/Makefile
index 6c346bf..b97d009 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -20,7 +20,10 @@ DISTCLEANFILES = ${CLEANFILES} config.mk
 
 build: libc3_test
 
-all: build cov debug
+all:
+	${MAKE} build
+	if ${HAVE_GCOV}; then ${MAKE} cov; fi
+	${MAKE} debug
 	if ${HAVE_ASAN}; then ${MAKE} asan; fi
 
 asan: libc3_test.asan
diff --git a/test/buf_parse_test.c b/test/buf_parse_test.c
index b9424ce..7e8898c 100644
--- a/test/buf_parse_test.c
+++ b/test/buf_parse_test.c
@@ -789,9 +789,9 @@ void buf_parse_test_digit_dec ()
 
 void buf_parse_test_f32()
 {
-  BUF_PARSE_TEST_F32("123.123", 123.12299);
-  BUF_PARSE_TEST_F32("3.14159", 3.141589641571045);
-  BUF_PARSE_TEST_F32("2.1e+2", 209.9999847412109);
+  BUF_PARSE_TEST_F32("123.123", 123.123);
+  BUF_PARSE_TEST_F32("3.14159", 3.14159);
+  BUF_PARSE_TEST_F32("2.1e+2", 210);
 }
 
 void buf_parse_test_f64()
diff --git a/test/configure b/test/configure
index 44d4eeb..8d204bf 100755
--- a/test/configure
+++ b/test/configure
@@ -32,8 +32,10 @@ echo "OBJECTS = $OBJECTS" >> ${CONFIG_MK}
 OBJECTS_ASAN="$(c2ext .asan.lo "$SOURCES")"
 echo "OBJECTS_ASAN = $OBJECTS_ASAN" >> ${CONFIG_MK}
 
-OBJECTS_COV="$(c2ext .cov.lo "$SOURCES")"
-echo "OBJECTS_COV = $OBJECTS_COV" >> ${CONFIG_MK}
+if $HAVE_GCOV; then
+    OBJECTS_COV="$(c2ext .cov.lo "$SOURCES")"
+    echo "OBJECTS_COV = $OBJECTS_COV" >> ${CONFIG_MK}
+fi
 
 OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
 echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
@@ -88,10 +90,12 @@ echo >> ${CONFIG_MK}
 echo "CFLAGS_ASAN = $CFLAGS_ASAN" >> ${CONFIG_MK}
 echo "LDFLAGS_ASAN = $LDFLAGS_ASAN" >> ${CONFIG_MK}
 echo "LIBS_ASAN = $LIBS_ASAN" >> ${CONFIG_MK}
-echo >> ${CONFIG_MK}
-echo "CFLAGS_COV = $CFLAGS_COV" >> ${CONFIG_MK}
-echo "LDFLAGS_COV = $LDFLAGS_COV" >> ${CONFIG_MK}
-echo "LIBS_COV = $LIBS_COV" >> ${CONFIG_MK}
+if $HAVE_GCOV; then
+    echo >> ${CONFIG_MK}
+    echo "CFLAGS_COV = $CFLAGS_COV" >> ${CONFIG_MK}
+    echo "LDFLAGS_COV = $LDFLAGS_COV" >> ${CONFIG_MK}
+    echo "LIBS_COV = $LIBS_COV" >> ${CONFIG_MK}
+fi
 echo >> ${CONFIG_MK}
 echo "CFLAGS_DEBUG = $CFLAGS_DEBUG" >> ${CONFIG_MK}
 echo "LDFLAGS_DEBUG = $LDFLAGS_DEBUG" >> ${CONFIG_MK}
@@ -108,10 +112,12 @@ for SRC in $SOURCES; do
     ext_rule .asan.lo "$SRC" >> ${CONFIG_MK}
     echo "	${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS_ASAN} -c $SRC -o $SRC_ASAN_LO" >> ${CONFIG_MK}
 
-    echo >> ${CONFIG_MK}
-    SRC_COV_LO="$(c2ext .cov.lo "$SRC")"
-    ext_rule .cov.lo "$SRC" >> ${CONFIG_MK}
-    echo "	${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS_COV} -c $SRC -o $SRC_COV_LO" >> ${CONFIG_MK}
+    if $HAVE_GCOV; then
+        echo >> ${CONFIG_MK}
+        SRC_COV_LO="$(c2ext .cov.lo "$SRC")"
+        ext_rule .cov.lo "$SRC" >> ${CONFIG_MK}
+        echo "	${LIBTOOL} --tag=CC --mode=compile \${CC} \${CPPFLAGS} \${CFLAGS_COV} -c $SRC -o $SRC_COV_LO" >> ${CONFIG_MK}
+    fi
 
     echo >> ${CONFIG_MK}
     SRC_DEBUG_LO="$(c2ext .debug.lo "$SRC")"
@@ -127,9 +133,11 @@ echo >> ${CONFIG_MK}
 echo "$PROG_ASAN: $LIBC3_ASAN $OBJECTS_ASAN" >> ${CONFIG_MK}
 echo "	${LIBTOOL} --tag=CC --mode=link \${CC} \${CFLAGS_ASAN} \${LDFLAGS_ASAN} ${OBJECTS_ASAN} ${LIBS_ASAN} -o $PROG_ASAN" >> ${CONFIG_MK}
 
-echo >> ${CONFIG_MK}
-echo "$PROG_COV: $LIBC3_COV $OBJECTS_COV" >> ${CONFIG_MK}
-echo "	${LIBTOOL} --tag=CC --mode=link \${CC} \${CFLAGS_COV} \${LDFLAGS_COV} ${OBJECTS_COV} ${LIBS_COV} -o $PROG_COV" >> ${CONFIG_MK}
+if $HAVE_GCOV; then
+    echo >> ${CONFIG_MK}
+    echo "$PROG_COV: $LIBC3_COV $OBJECTS_COV" >> ${CONFIG_MK}
+    echo "	${LIBTOOL} --tag=CC --mode=link \${CC} \${CFLAGS_COV} \${LDFLAGS_COV} ${OBJECTS_COV} ${LIBS_COV} -o $PROG_COV" >> ${CONFIG_MK}
+fi
 
 echo >> ${CONFIG_MK}
 echo "$PROG_DEBUG: $LIBC3_DEBUG $OBJECTS_DEBUG" >> ${CONFIG_MK}
diff --git a/test/skiplist__fact_test.c b/test/skiplist__fact_test.c
index 702be6b..a47568a 100644
--- a/test/skiplist__fact_test.c
+++ b/test/skiplist__fact_test.c
@@ -85,7 +85,7 @@ void skiplist__fact_test_find ()
 {
   s_fact fact[24];
   const u8 *h;
-  const u8 height[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 64, 128, 255, 0};
+  const u8 height[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 0};
   sw i;
   s8 *p[24] = {
     "\"a\"",
@@ -141,7 +141,7 @@ void skiplist__fact_test_insert ()
 {
   sw i;
   const u8 *h;
-  const u8 height[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 64, 128, 255, 0};
+  const u8 height[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 0};
   const double *s;
   const double spacing[] = {2.0, 2.4, 3.0, 0.0};
   s8 *p[24] = {
@@ -198,7 +198,7 @@ void skiplist__fact_test_insert ()
 void skiplist__fact_test_init_clean ()
 {
   const u8 *h;
-  const u8  height[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 64, 128, 255, 0};
+  const u8  height[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 0};
   const double *s;
   const double  spacing[] = {2.0, 2.4, 3.0, 0.0};
   for (h = height; *h; h++) {
@@ -211,7 +211,7 @@ void skiplist__fact_test_init_clean ()
 void skiplist__fact_test_new_delete ()
 {
   const u8 *h;
-  const u8  height[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 64, 128, 255, 0};
+  const u8  height[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 0};
   const double *s;
   const double  spacing[] = {2.0, 2.4, 3.0, 0.0};
   for (h = height; *h; h++) {
@@ -225,7 +225,7 @@ void skiplist__fact_test_remove ()
 {
   s_fact fact[24];
   const u8 *h;
-  const u8 height[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 64, 128, 255, 0};
+  const u8 height[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 0};
   sw i;
   s8 *p[24] = {
     "\"a\"",