11#include <inttypes.h>
22#include "shared.h"
33
4+ #define S_MP_RAND_JENKINS_C
5+ #include "s_mp_rand_jenkins.c"
6+
47static long rand_long (void )
58{
69 long x ;
7- if (s_mp_rand_source (& x , sizeof (x )) != MP_OKAY ) {
10+ if (s_mp_rand_jenkins (& x , sizeof (x )) != MP_OKAY ) {
811 fprintf (stderr , "s_mp_rand_source failed\n" );
912 exit (EXIT_FAILURE );
1013 }
@@ -14,7 +17,7 @@ static long rand_long(void)
1417static int rand_int (void )
1518{
1619 int x ;
17- if (s_mp_rand_source (& x , sizeof (x )) != MP_OKAY ) {
20+ if (s_mp_rand_jenkins (& x , sizeof (x )) != MP_OKAY ) {
1821 fprintf (stderr , "s_mp_rand_source failed\n" );
1922 exit (EXIT_FAILURE );
2023 }
@@ -24,7 +27,7 @@ static int rand_int(void)
2427static int32_t rand_int32 (void )
2528{
2629 int32_t x ;
27- if (s_mp_rand_source (& x , sizeof (x )) != MP_OKAY ) {
30+ if (s_mp_rand_jenkins (& x , sizeof (x )) != MP_OKAY ) {
2831 fprintf (stderr , "s_mp_rand_source failed\n" );
2932 exit (EXIT_FAILURE );
3033 }
@@ -34,7 +37,7 @@ static int32_t rand_int32(void)
3437static int64_t rand_int64 (void )
3538{
3639 int64_t x ;
37- if (s_mp_rand_source (& x , sizeof (x )) != MP_OKAY ) {
40+ if (s_mp_rand_jenkins (& x , sizeof (x )) != MP_OKAY ) {
3841 fprintf (stderr , "s_mp_rand_source failed\n" );
3942 exit (EXIT_FAILURE );
4043 }
@@ -2134,15 +2137,20 @@ static int test_mp_pack_unpack(void)
21342137 return EXIT_FAILURE ;
21352138}
21362139
2140+ #ifndef LTM_TEST_DYNAMIC
2141+ #define ONLY_PUBLIC_API_C
2142+ #endif
2143+
21372144static int unit_tests (int argc , char * * argv )
21382145{
21392146 static const struct {
21402147 const char * name ;
21412148 int (* fn )(void );
21422149 } test [] = {
2143- #define T0 (n ) { #n , test_##n }
2144- #define T1 (n , o ) { #n, MP_HAS(o) ? test_##n : NULL }
2145- #define T2 (n , o1 , o2 ) { #n, (MP_HAS(o1) && MP_HAS(o2)) ? test_##n : NULL }
2150+ #define T0 (n ) { #n , test_##n }
2151+ #define T1 (n , o ) { #n, MP_HAS(o) ? test_##n : NULL }
2152+ #define T2 (n , o1 , o2 ) { #n, (MP_HAS(o1) && MP_HAS(o2)) ? test_##n : NULL }
2153+ #define T3 (n , o1 , o2 , o3 ) { #n, (MP_HAS(o1) && MP_HAS(o2) && MP_HAS(o3)) ? test_##n : NULL }
21462154 T0 (feature_detection ),
21472155 T0 (trivial_stuff ),
21482156 T2 (mp_get_set_i32 , MP_GET_I32 , MP_GET_MAG_U32 ),
@@ -2151,7 +2159,7 @@ static int unit_tests(int argc, char **argv)
21512159 T1 (mp_cnt_lsb , MP_CNT_LSB ),
21522160 T1 (mp_complement , MP_COMPLEMENT ),
21532161 T1 (mp_decr , MP_SUB_D ),
2154- T1 (s_mp_div_3 , S_MP_DIV_3 ),
2162+ T2 (s_mp_div_3 , ONLY_PUBLIC_API , S_MP_DIV_3 ),
21552163 T1 (mp_dr_reduce , MP_DR_REDUCE ),
21562164 T2 (mp_pack_unpack ,MP_PACK , MP_UNPACK ),
21572165 T2 (mp_fread_fwrite , MP_FREAD , MP_FWRITE ),
@@ -2176,21 +2184,22 @@ static int unit_tests(int argc, char **argv)
21762184 T1 (mp_reduce_2k , MP_REDUCE_2K ),
21772185 T1 (mp_reduce_2k_l , MP_REDUCE_2K_L ),
21782186 T1 (mp_radix_size , MP_RADIX_SIZE ),
2179- T1 (s_mp_radix_size_overestimate , S_MP_RADIX_SIZE_OVERESTIMATE ),
2187+ T2 (s_mp_radix_size_overestimate , ONLY_PUBLIC_API , S_MP_RADIX_SIZE_OVERESTIMATE ),
21802188#if defined(MP_HAS_SET_DOUBLE )
21812189 T1 (mp_set_double , MP_SET_DOUBLE ),
21822190#endif
21832191 T1 (mp_signed_rsh , MP_SIGNED_RSH ),
21842192 T2 (mp_sqrt , MP_SQRT , MP_ROOT_N ),
21852193 T1 (mp_sqrtmod_prime , MP_SQRTMOD_PRIME ),
21862194 T1 (mp_xor , MP_XOR ),
2187- T2 (s_mp_div_recursive , S_MP_DIV_RECURSIVE , S_MP_DIV_SCHOOL ),
2188- T2 (s_mp_div_small , S_MP_DIV_SMALL , S_MP_DIV_SCHOOL ),
2189- T1 (s_mp_mul_balance , S_MP_MUL_BALANCE ),
2190- T1 (s_mp_mul_karatsuba , S_MP_MUL_KARATSUBA ),
2191- T1 (s_mp_sqr_karatsuba , S_MP_SQR_KARATSUBA ),
2192- T1 (s_mp_mul_toom , S_MP_MUL_TOOM ),
2193- T1 (s_mp_sqr_toom , S_MP_SQR_TOOM )
2195+ T3 (s_mp_div_recursive , ONLY_PUBLIC_API , S_MP_DIV_RECURSIVE , S_MP_DIV_SCHOOL ),
2196+ T3 (s_mp_div_small , ONLY_PUBLIC_API , S_MP_DIV_SMALL , S_MP_DIV_SCHOOL ),
2197+ T2 (s_mp_mul_balance , ONLY_PUBLIC_API , S_MP_MUL_BALANCE ),
2198+ T2 (s_mp_mul_karatsuba , ONLY_PUBLIC_API , S_MP_MUL_KARATSUBA ),
2199+ T2 (s_mp_sqr_karatsuba , ONLY_PUBLIC_API , S_MP_SQR_KARATSUBA ),
2200+ T2 (s_mp_mul_toom , ONLY_PUBLIC_API , S_MP_MUL_TOOM ),
2201+ T2 (s_mp_sqr_toom , ONLY_PUBLIC_API , S_MP_SQR_TOOM )
2202+ #undef T3
21942203#undef T2
21952204#undef T1
21962205 };
0 commit comments