Commit 34e16d3c550e98cbd3222987e4d95649cac9bc20

Steffen Jaeckel 2020-09-13T19:06:43

allow testing of shared library * move jenkins' prng out of the library into the demo's. * add CI test for shared library

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
diff --git a/.travis.yml b/.travis.yml
index 4c6e557..0f3e7fb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -86,6 +86,13 @@ matrix:
           packages:
             - gcc-4.9
 
+    # Shared library build
+    - env: COMPILE_LTO=1 BUILDOPTIONS='--with-cc=gcc --make-option=-f --make-option=makefile.shared'
+      addons:
+        apt:
+          packages:
+            - libtool-bin
+
     # GCC for the 32-bit architecture (no valgrind)
     - env: BUILDOPTIONS='--with-cc=gcc-5 --with-m32'
       addons:
diff --git a/demo/s_mp_rand_jenkins.c b/demo/s_mp_rand_jenkins.c
new file mode 100644
index 0000000..9c77142
--- /dev/null
+++ b/demo/s_mp_rand_jenkins.c
@@ -0,0 +1,55 @@
+#include "tommath_private.h"
+#ifdef S_MP_RAND_JENKINS_C
+/* LibTomMath, multiple-precision integer library -- Tom St Denis */
+/* SPDX-License-Identifier: Unlicense */
+
+/* Bob Jenkins' http://burtleburtle.net/bob/rand/smallprng.html */
+/* Chosen for speed and a good "mix" */
+
+/* TODO: jenkins prng is not thread safe as of now */
+
+typedef struct {
+   uint64_t a;
+   uint64_t b;
+   uint64_t c;
+   uint64_t d;
+} ranctx;
+
+static ranctx jenkins_x;
+
+#define rot(x,k) (((x)<<(k))|((x)>>(64-(k))))
+static uint64_t s_rand_jenkins_val(void)
+{
+   uint64_t e = jenkins_x.a - rot(jenkins_x.b, 7);
+   jenkins_x.a = jenkins_x.b ^ rot(jenkins_x.c, 13);
+   jenkins_x.b = jenkins_x.c + rot(jenkins_x.d, 37);
+   jenkins_x.c = jenkins_x.d + e;
+   jenkins_x.d = e + jenkins_x.a;
+   return jenkins_x.d;
+}
+
+static void s_mp_rand_jenkins_init(uint64_t seed)
+{
+   int i;
+   jenkins_x.a = 0xF1EA5EEDuL;
+   jenkins_x.b = jenkins_x.c = jenkins_x.d = seed;
+   for (i = 0; i < 20; ++i) {
+      (void)s_rand_jenkins_val();
+   }
+}
+
+static mp_err s_mp_rand_jenkins(void *p, size_t n)
+{
+   char *q = (char *)p;
+   while (n > 0u) {
+      int i;
+      uint64_t x = s_rand_jenkins_val();
+      for (i = 0; (i < 8) && (n > 0u); ++i, --n) {
+         *q++ = (char)(x & 0xFFu);
+         x >>= 8;
+      }
+   }
+   return MP_OKAY;
+}
+
+#endif
diff --git a/demo/test.c b/demo/test.c
index f6b3c36..4ce8131 100644
--- a/demo/test.c
+++ b/demo/test.c
@@ -1,10 +1,13 @@
 #include <inttypes.h>
 #include "shared.h"
 
+#define S_MP_RAND_JENKINS_C
+#include "s_mp_rand_jenkins.c"
+
 static long rand_long(void)
 {
    long x;
-   if (s_mp_rand_source(&x, sizeof(x)) != MP_OKAY) {
+   if (s_mp_rand_jenkins(&x, sizeof(x)) != MP_OKAY) {
       fprintf(stderr, "s_mp_rand_source failed\n");
       exit(EXIT_FAILURE);
    }
@@ -14,7 +17,7 @@ static long rand_long(void)
 static int rand_int(void)
 {
    int x;
-   if (s_mp_rand_source(&x, sizeof(x)) != MP_OKAY) {
+   if (s_mp_rand_jenkins(&x, sizeof(x)) != MP_OKAY) {
       fprintf(stderr, "s_mp_rand_source failed\n");
       exit(EXIT_FAILURE);
    }
@@ -24,7 +27,7 @@ static int rand_int(void)
 static int32_t rand_int32(void)
 {
    int32_t x;
-   if (s_mp_rand_source(&x, sizeof(x)) != MP_OKAY) {
+   if (s_mp_rand_jenkins(&x, sizeof(x)) != MP_OKAY) {
       fprintf(stderr, "s_mp_rand_source failed\n");
       exit(EXIT_FAILURE);
    }
@@ -34,7 +37,7 @@ static int32_t rand_int32(void)
 static int64_t rand_int64(void)
 {
    int64_t x;
-   if (s_mp_rand_source(&x, sizeof(x)) != MP_OKAY) {
+   if (s_mp_rand_jenkins(&x, sizeof(x)) != MP_OKAY) {
       fprintf(stderr, "s_mp_rand_source failed\n");
       exit(EXIT_FAILURE);
    }
@@ -2134,15 +2137,20 @@ LBL_ERR:
    return EXIT_FAILURE;
 }
 
+#ifndef LTM_TEST_DYNAMIC
+#define ONLY_PUBLIC_API_C
+#endif
+
 static int unit_tests(int argc, char **argv)
 {
    static const struct {
       const char *name;
       int (*fn)(void);
    } test[] = {
-#define T0(n)           { #n, test_##n }
-#define T1(n, o)        { #n, MP_HAS(o) ? test_##n : NULL }
-#define T2(n, o1, o2)   { #n, (MP_HAS(o1) && MP_HAS(o2)) ? test_##n : NULL }
+#define T0(n)              { #n, test_##n }
+#define T1(n, o)           { #n, MP_HAS(o) ? test_##n : NULL }
+#define T2(n, o1, o2)      { #n, (MP_HAS(o1) && MP_HAS(o2)) ? test_##n : NULL }
+#define T3(n, o1, o2, o3)  { #n, (MP_HAS(o1) && MP_HAS(o2) && MP_HAS(o3)) ? test_##n : NULL }
       T0(feature_detection),
       T0(trivial_stuff),
       T2(mp_get_set_i32, MP_GET_I32, MP_GET_MAG_U32),
@@ -2151,7 +2159,7 @@ static int unit_tests(int argc, char **argv)
       T1(mp_cnt_lsb, MP_CNT_LSB),
       T1(mp_complement, MP_COMPLEMENT),
       T1(mp_decr, MP_SUB_D),
-      T1(s_mp_div_3, S_MP_DIV_3),
+      T2(s_mp_div_3, ONLY_PUBLIC_API, S_MP_DIV_3),
       T1(mp_dr_reduce, MP_DR_REDUCE),
       T2(mp_pack_unpack,MP_PACK, MP_UNPACK),
       T2(mp_fread_fwrite, MP_FREAD, MP_FWRITE),
@@ -2176,7 +2184,7 @@ static int unit_tests(int argc, char **argv)
       T1(mp_reduce_2k, MP_REDUCE_2K),
       T1(mp_reduce_2k_l, MP_REDUCE_2K_L),
       T1(mp_radix_size, MP_RADIX_SIZE),
-      T1(s_mp_radix_size_overestimate, S_MP_RADIX_SIZE_OVERESTIMATE),
+      T2(s_mp_radix_size_overestimate, ONLY_PUBLIC_API, S_MP_RADIX_SIZE_OVERESTIMATE),
 #if defined(MP_HAS_SET_DOUBLE)
       T1(mp_set_double, MP_SET_DOUBLE),
 #endif
@@ -2184,13 +2192,14 @@ static int unit_tests(int argc, char **argv)
       T2(mp_sqrt, MP_SQRT, MP_ROOT_N),
       T1(mp_sqrtmod_prime, MP_SQRTMOD_PRIME),
       T1(mp_xor, MP_XOR),
-      T2(s_mp_div_recursive, S_MP_DIV_RECURSIVE, S_MP_DIV_SCHOOL),
-      T2(s_mp_div_small, S_MP_DIV_SMALL, S_MP_DIV_SCHOOL),
-      T1(s_mp_mul_balance, S_MP_MUL_BALANCE),
-      T1(s_mp_mul_karatsuba, S_MP_MUL_KARATSUBA),
-      T1(s_mp_sqr_karatsuba, S_MP_SQR_KARATSUBA),
-      T1(s_mp_mul_toom, S_MP_MUL_TOOM),
-      T1(s_mp_sqr_toom, S_MP_SQR_TOOM)
+      T3(s_mp_div_recursive, ONLY_PUBLIC_API, S_MP_DIV_RECURSIVE, S_MP_DIV_SCHOOL),
+      T3(s_mp_div_small, ONLY_PUBLIC_API, S_MP_DIV_SMALL, S_MP_DIV_SCHOOL),
+      T2(s_mp_mul_balance, ONLY_PUBLIC_API, S_MP_MUL_BALANCE),
+      T2(s_mp_mul_karatsuba, ONLY_PUBLIC_API, S_MP_MUL_KARATSUBA),
+      T2(s_mp_sqr_karatsuba, ONLY_PUBLIC_API, S_MP_SQR_KARATSUBA),
+      T2(s_mp_mul_toom, ONLY_PUBLIC_API, S_MP_MUL_TOOM),
+      T2(s_mp_sqr_toom, ONLY_PUBLIC_API, S_MP_SQR_TOOM)
+#undef T3
 #undef T2
 #undef T1
    };
diff --git a/etc/makefile b/etc/makefile
index 85bb09e..52ad475 100644
--- a/etc/makefile
+++ b/etc/makefile
@@ -1,5 +1,4 @@
-LTM_CFLAGS += -Wall -W -Wextra -Wshadow -O3 -I../
-LTM_CFLAGS += $(CFLAGS)
+LTM_TUNE_CFLAGS = $(CFLAGS) $(LTM_CFLAGS) -Wall -W -Wextra -Wshadow -O3 -I../
 
 # default lib name (requires install with root)
 # LIBNAME=-ltommath
@@ -9,31 +8,31 @@ LIBNAME=../libtommath.a
 
 #provable primes
 pprime: pprime.o
-	$(CC) $(LTM_CFLAGS) pprime.o $(LIBNAME) -o pprime
+	$(CC) $(LTM_TUNE_CFLAGS) pprime.o $(LIBNAME) -o pprime
 
 # portable [well requires clock()] tuning app
 tune: tune.o
-	$(CC) $(LTM_CFLAGS) tune.o $(LIBNAME) -o tune
+	$(CC) $(LTM_TUNE_CFLAGS) tune.o $(LIBNAME) -o tune
 	./tune_it.sh
 
 test_standalone: tune.o
 	# The benchmark program works as a testtool, too
-	$(CC) $(LTM_CFLAGS) tune.o $(LIBNAME) -o test
+	$(CC) $(LTM_TUNE_CFLAGS) tune.o $(LIBNAME) -o test
 
 # spits out mersenne primes
 mersenne: mersenne.o
-	$(CC) $(LTM_CFLAGS) mersenne.o $(LIBNAME) -o mersenne
+	$(CC) $(LTM_TUNE_CFLAGS) mersenne.o $(LIBNAME) -o mersenne
 
 # finds DR safe primes for the given config
 drprime: drprime.o
-	$(CC) $(LTM_CFLAGS) drprime.o $(LIBNAME) -o drprime
+	$(CC) $(LTM_TUNE_CFLAGS) drprime.o $(LIBNAME) -o drprime
 
 # finds 2k safe primes for the given config
 2kprime: 2kprime.o
-	$(CC) $(LTM_CFLAGS) 2kprime.o $(LIBNAME) -o 2kprime
+	$(CC) $(LTM_TUNE_CFLAGS) 2kprime.o $(LIBNAME) -o 2kprime
 
 mont: mont.o
-	$(CC) $(LTM_CFLAGS) mont.o $(LIBNAME) -o mont
+	$(CC) $(LTM_TUNE_CFLAGS) mont.o $(LIBNAME) -o mont
 
 
 clean:
diff --git a/etc/tune.c b/etc/tune.c
index be06632..8ad2028 100644
--- a/etc/tune.c
+++ b/etc/tune.c
@@ -2,12 +2,14 @@
  *
  * Tom St Denis, tstdenis82@gmail.com
  */
-#include "../tommath.h"
-#include "../tommath_private.h"
+#include "tommath_private.h"
 #include <time.h>
 #include <inttypes.h>
 #include <errno.h>
 
+#define S_MP_RAND_JENKINS_C
+#include "../demo/s_mp_rand_jenkins.c"
+
 /*
    Please take in mind that both multiplicands are of the same size. The balancing
    mechanism in mp_balance works well but has some overhead itself. You can test
diff --git a/libtommath_VS2008.vcproj b/libtommath_VS2008.vcproj
index 6b0924d..1bf2f6b 100644
--- a/libtommath_VS2008.vcproj
+++ b/libtommath_VS2008.vcproj
@@ -897,10 +897,6 @@
 			>
 		</File>
 		<File
-			RelativePath="s_mp_rand_jenkins.c"
-			>
-		</File>
-		<File
 			RelativePath="s_mp_rand_platform.c"
 			>
 		</File>
diff --git a/makefile b/makefile
index 100f99a..a5e5bf1 100644
--- a/makefile
+++ b/makefile
@@ -48,8 +48,8 @@ s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_get_b
 s_mp_invmod_odd.o s_mp_log.o s_mp_log_2expt.o s_mp_log_d.o s_mp_montgomery_reduce_comba.o s_mp_mul.o \
 s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o s_mp_mul_high_comba.o s_mp_mul_karatsuba.o \
 s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_prime_tab.o s_mp_radix_map.o \
-s_mp_radix_size_overestimate.o s_mp_rand_jenkins.o s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o \
-s_mp_sqr_karatsuba.o s_mp_sqr_toom.o s_mp_sub.o s_mp_zero_buf.o s_mp_zero_digs.o
+s_mp_radix_size_overestimate.o s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o s_mp_sqr_karatsuba.o \
+s_mp_sqr_toom.o s_mp_sub.o s_mp_zero_buf.o s_mp_zero_digs.o
 
 #END_INS
 
@@ -104,7 +104,7 @@ timing: demo/timing.c $(LIBNAME)
 	$(CC) $(LTM_CFLAGS) $^ $(LTM_LFLAGS) -o timing
 
 tune: $(LIBNAME)
-	$(MAKE) -C etc tune CFLAGS="$(LTM_CFLAGS)"
+	$(MAKE) -C etc tune CFLAGS="$(LTM_CFLAGS) -I../"
 	$(MAKE)
 
 # You have to create a file .coveralls.yml with the content "repo_token: <the token>"
diff --git a/makefile.mingw b/makefile.mingw
index fde087a..a0192d6 100644
--- a/makefile.mingw
+++ b/makefile.mingw
@@ -50,8 +50,8 @@ s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_get_b
 s_mp_invmod_odd.o s_mp_log.o s_mp_log_2expt.o s_mp_log_d.o s_mp_montgomery_reduce_comba.o s_mp_mul.o \
 s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o s_mp_mul_high_comba.o s_mp_mul_karatsuba.o \
 s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_prime_tab.o s_mp_radix_map.o \
-s_mp_radix_size_overestimate.o s_mp_rand_jenkins.o s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o \
-s_mp_sqr_karatsuba.o s_mp_sqr_toom.o s_mp_sub.o s_mp_zero_buf.o s_mp_zero_digs.o
+s_mp_radix_size_overestimate.o s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o s_mp_sqr_karatsuba.o \
+s_mp_sqr_toom.o s_mp_sub.o s_mp_zero_buf.o s_mp_zero_digs.o
 
 HEADERS_PUB=tommath.h
 HEADERS=tommath_private.h tommath_class.h tommath_superclass.h tommath_cutoffs.h $(HEADERS_PUB)
diff --git a/makefile.msvc b/makefile.msvc
index a032455..e3d6e23 100644
--- a/makefile.msvc
+++ b/makefile.msvc
@@ -46,8 +46,8 @@ s_mp_div_school.obj s_mp_div_small.obj s_mp_exptmod.obj s_mp_exptmod_fast.obj s_
 s_mp_invmod_odd.obj s_mp_log.obj s_mp_log_2expt.obj s_mp_log_d.obj s_mp_montgomery_reduce_comba.obj s_mp_mul.obj \
 s_mp_mul_balance.obj s_mp_mul_comba.obj s_mp_mul_high.obj s_mp_mul_high_comba.obj s_mp_mul_karatsuba.obj \
 s_mp_mul_toom.obj s_mp_prime_is_divisible.obj s_mp_prime_tab.obj s_mp_radix_map.obj \
-s_mp_radix_size_overestimate.obj s_mp_rand_jenkins.obj s_mp_rand_platform.obj s_mp_sqr.obj s_mp_sqr_comba.obj \
-s_mp_sqr_karatsuba.obj s_mp_sqr_toom.obj s_mp_sub.obj s_mp_zero_buf.obj s_mp_zero_digs.obj
+s_mp_radix_size_overestimate.obj s_mp_rand_platform.obj s_mp_sqr.obj s_mp_sqr_comba.obj s_mp_sqr_karatsuba.obj \
+s_mp_sqr_toom.obj s_mp_sub.obj s_mp_zero_buf.obj s_mp_zero_digs.obj
 
 HEADERS_PUB=tommath.h
 HEADERS=tommath_private.h tommath_class.h tommath_superclass.h tommath_cutoffs.h $(HEADERS_PUB)
diff --git a/makefile.shared b/makefile.shared
index 2d8b32c..70543c1 100644
--- a/makefile.shared
+++ b/makefile.shared
@@ -45,8 +45,8 @@ s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_get_b
 s_mp_invmod_odd.o s_mp_log.o s_mp_log_2expt.o s_mp_log_d.o s_mp_montgomery_reduce_comba.o s_mp_mul.o \
 s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o s_mp_mul_high_comba.o s_mp_mul_karatsuba.o \
 s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_prime_tab.o s_mp_radix_map.o \
-s_mp_radix_size_overestimate.o s_mp_rand_jenkins.o s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o \
-s_mp_sqr_karatsuba.o s_mp_sqr_toom.o s_mp_sub.o s_mp_zero_buf.o s_mp_zero_digs.o
+s_mp_radix_size_overestimate.o s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o s_mp_sqr_karatsuba.o \
+s_mp_sqr_toom.o s_mp_sub.o s_mp_zero_buf.o s_mp_zero_digs.o
 
 #END_INS
 
@@ -75,7 +75,7 @@ uninstall:
 	rm $(DESTDIR)$(LIBPATH)/pkgconfig/libtommath.pc
 
 test mtest_opponent: demo/shared.o $(LIBNAME) | demo/test.o demo/mtest_opponent.o
-	$(LTLINK) $(LTM_LDFLAGS) demo/$@.o $^ -o $@
+	$(LTLINK) $(LTM_LDFLAGS) -DLTM_TEST_DYNAMIC demo/$@.o $^ -o $@
 
 .PHONY: mtest
 mtest:
diff --git a/makefile.unix b/makefile.unix
index 3304e7f..64fb580 100644
--- a/makefile.unix
+++ b/makefile.unix
@@ -51,8 +51,8 @@ s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_get_b
 s_mp_invmod_odd.o s_mp_log.o s_mp_log_2expt.o s_mp_log_d.o s_mp_montgomery_reduce_comba.o s_mp_mul.o \
 s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o s_mp_mul_high_comba.o s_mp_mul_karatsuba.o \
 s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_prime_tab.o s_mp_radix_map.o \
-s_mp_radix_size_overestimate.o s_mp_rand_jenkins.o s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o \
-s_mp_sqr_karatsuba.o s_mp_sqr_toom.o s_mp_sub.o s_mp_zero_buf.o s_mp_zero_digs.o
+s_mp_radix_size_overestimate.o s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o s_mp_sqr_karatsuba.o \
+s_mp_sqr_toom.o s_mp_sub.o s_mp_zero_buf.o s_mp_zero_digs.o
 
 
 HEADERS_PUB=tommath.h
diff --git a/s_mp_rand_jenkins.c b/s_mp_rand_jenkins.c
deleted file mode 100644
index 6aba0fb..0000000
--- a/s_mp_rand_jenkins.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "tommath_private.h"
-#ifdef S_MP_RAND_JENKINS_C
-/* LibTomMath, multiple-precision integer library -- Tom St Denis */
-/* SPDX-License-Identifier: Unlicense */
-
-/* Bob Jenkins' http://burtleburtle.net/bob/rand/smallprng.html */
-/* Chosen for speed and a good "mix" */
-typedef struct {
-   uint64_t a;
-   uint64_t b;
-   uint64_t c;
-   uint64_t d;
-} ranctx;
-
-static ranctx jenkins_x;
-
-#define rot(x,k) (((x)<<(k))|((x)>>(64-(k))))
-static uint64_t s_rand_jenkins_val(void)
-{
-   uint64_t e = jenkins_x.a - rot(jenkins_x.b, 7);
-   jenkins_x.a = jenkins_x.b ^ rot(jenkins_x.c, 13);
-   jenkins_x.b = jenkins_x.c + rot(jenkins_x.d, 37);
-   jenkins_x.c = jenkins_x.d + e;
-   jenkins_x.d = e + jenkins_x.a;
-   return jenkins_x.d;
-}
-
-void s_mp_rand_jenkins_init(uint64_t seed)
-{
-   int i;
-   jenkins_x.a = 0xF1EA5EEDuL;
-   jenkins_x.b = jenkins_x.c = jenkins_x.d = seed;
-   for (i = 0; i < 20; ++i) {
-      (void)s_rand_jenkins_val();
-   }
-}
-
-mp_err s_mp_rand_jenkins(void *p, size_t n)
-{
-   char *q = (char *)p;
-   while (n > 0u) {
-      int i;
-      uint64_t x = s_rand_jenkins_val();
-      for (i = 0; (i < 8) && (n > 0u); ++i, --n) {
-         *q++ = (char)(x & 0xFFu);
-         x >>= 8;
-      }
-   }
-   return MP_OKAY;
-}
-
-#endif
diff --git a/testme.sh b/testme.sh
index 41a165b..2d09d04 100755
--- a/testme.sh
+++ b/testme.sh
@@ -348,7 +348,7 @@ fi
 # default to CC environment variable if no compiler is defined but some other options
 if [[ "$COMPILERS" == "" ]] && [[ "$ARCHFLAGS$MAKE_OPTIONS$CFLAGS" != "" ]]
 then
-   COMPILERS="$CC"
+   COMPILERS="${CC:-cc}"
 # default to CC environment variable and run only default config if no option is given
 elif [[ "$COMPILERS" == "" ]]
 then
diff --git a/tommath_class.h b/tommath_class.h
index d6f7e7a..da9c5ea 100644
--- a/tommath_class.h
+++ b/tommath_class.h
@@ -157,7 +157,6 @@
 #   define S_MP_PRIME_TAB_C
 #   define S_MP_RADIX_MAP_C
 #   define S_MP_RADIX_SIZE_OVERESTIMATE_C
-#   define S_MP_RAND_JENKINS_C
 #   define S_MP_RAND_PLATFORM_C
 #   define S_MP_SQR_C
 #   define S_MP_SQR_COMBA_C
@@ -1194,10 +1193,6 @@
 #   define S_MP_LOG_2EXPT_C
 #endif
 
-#if defined(S_MP_RAND_JENKINS_C)
-#   define S_MP_RAND_JENKINS_INIT_C
-#endif
-
 #if defined(S_MP_RAND_PLATFORM_C)
 #endif
 
diff --git a/tommath_private.h b/tommath_private.h
index 624ba0a..4292051 100644
--- a/tommath_private.h
+++ b/tommath_private.h
@@ -208,10 +208,6 @@ MP_PRIVATE void s_mp_zero_buf(void *mem, size_t size);
 MP_PRIVATE void s_mp_zero_digs(mp_digit *d, int digits);
 MP_PRIVATE mp_err s_mp_radix_size_overestimate(const mp_int *a, const int radix, size_t *size);
 
-/* TODO: jenkins prng is not thread safe as of now */
-MP_PRIVATE mp_err s_mp_rand_jenkins(void *p, size_t n) MP_WUR;
-MP_PRIVATE void s_mp_rand_jenkins_init(uint64_t seed);
-
 #define MP_RADIX_MAP_REVERSE_SIZE 80u
 extern MP_PRIVATE const char s_mp_radix_map[];
 extern MP_PRIVATE const uint8_t s_mp_radix_map_reverse[];