Skip to content

add feature detection macros MP_DEFINED and MP_HAS #214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

minad
Copy link
Member

@minad minad commented Apr 8, 2019

additionally, make bn_mp_mul private

@minad minad force-pushed the feature-detection branch from a1e9b6f to 6e7027a Compare April 8, 2019 23:11
@sjaeckel
Copy link
Member

sjaeckel commented Apr 9, 2019

@karel-m can you please try this out on your various compilers?

@sjaeckel
Copy link
Member

sjaeckel commented Apr 9, 2019

@karel-m can you please try this out on your various compilers?

and most importantly, please also try it out with the following patch

diff --git a/tommath_superclass.h b/tommath_superclass.h
index c9090a8..8761f81 100644
--- a/tommath_superclass.h
+++ b/tommath_superclass.h
@@ -6,3 +6,5 @@
 /* default ... include all MPI */
+#ifndef LTM_NOT_ALL
 #define LTM_ALL
+#endif

compiling it with CFLAGS="-DLTM_NOT_ALL -DSC_RSA_1"

and check that the libraries created are different

@minad can you please include that patch in the branch? thx!

@sjaeckel sjaeckel requested a review from karel-m April 9, 2019 09:00
@minad minad mentioned this pull request Apr 9, 2019
@karel-m
Copy link
Member

karel-m commented Apr 9, 2019

1/ gcc 7.4.0 - Target: x86_64-pc-cygwin (the following warning does not appear with develop) do we really need -Wundef?

cc -c -I./ -Wall -Wsign-compare -Wextra -Wshadow -Wsystem-headers -Wdeclaration-after-statement -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wpointer-arith -Wundef -O3 -funroll-loops -fomit-frame-pointer bn_mp_add.c -o bn_mp_add.o
In file included from /usr/include/sys/config.h:5:0,
                 from /usr/include/_ansi.h:11,
                 from /usr/include/stdlib.h:11,
                 from tommath.h:7,
                 from tommath_private.h:7,
                 from bn_mp_add.c:1:
/usr/include/sys/features.h:274:36: warning: "_XOPEN_SOURCE" is not defined, evaluates to 0 [-Wundef]
 #if defined(_LARGEFILE_SOURCE) || (_XOPEN_SOURCE - 0) >= 500
                                    ^~~~~~~~~~~~~
/usr/include/sys/features.h:308:6: warning: "_XOPEN_SOURCE" is not defined, evaluates to 0 [-Wundef]
 #if (_XOPEN_SOURCE - 0) >= 700
      ^~~~~~~~~~~~~
/usr/include/sys/features.h:310:8: warning: "_XOPEN_SOURCE" is not defined, evaluates to 0 [-Wundef]
 #elif (_XOPEN_SOURCE - 0) >= 600
        ^~~~~~~~~~~~~
/usr/include/sys/features.h:312:8: warning: "_XOPEN_SOURCE" is not defined, evaluates to 0 [-Wundef]
 #elif (_XOPEN_SOURCE - 0) >= 500
        ^~~~~~~~~~~~~
/usr/include/sys/features.h:322:5: warning: "_FORTIFY_SOURCE" is not defined, evaluates to 0 [-Wundef]
 #if _FORTIFY_SOURCE > 0 && !defined(__cplusplus) && !defined(__lint__) && \
     ^~~~~~~~~~~~~~~

@karel-m
Copy link
Member

karel-m commented Apr 9, 2019

2/ HP-UX + C compiler by HP

$ make -f makefile.unix
        [...]
        cc -I. -O2 -c bn_mp_div_d.c -o bn_mp_div_d.o
cpp: "bn_mp_div_d.c", line 60: warning 2006: Parameter holes filled with a null string.
        [...]
        cc -I. -O2 -c bn_mp_exptmod.c -o bn_mp_exptmod.o
cpp: "bn_mp_exptmod.c", line 25: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_exptmod.c", line 55: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_exptmod.c", line 55: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_exptmod.c", line 55: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_exptmod.c", line 61: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_exptmod.c", line 64: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_exptmod.c", line 69: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_exptmod.c", line 71: warning 2006: Parameter holes filled with a null string.
        cc -I. -O2 -c bn_mp_exptmod_fast.c -o bn_mp_exptmod_fast.o
cpp: "bn_mp_exptmod_fast.c", line 73: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_exptmod_fast.c", line 84: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_exptmod_fast.c", line 88: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_exptmod_fast.c", line 96: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_exptmod_fast.c", line 104: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_exptmod_fast.c", line 104: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_exptmod_fast.c", line 128: warning 2006: Parameter holes filled with a null string.
        [...]
        cc -I. -O2 -c bn_mp_invmod.c -o bn_mp_invmod.o
cpp: "bn_mp_invmod.c", line 15: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_invmod.c", line 19: warning 2006: Parameter holes filled with a null string.
        [...]
        cc -I. -O2 -c bn_mp_mul.c -o bn_mp_mul.o
cpp: "bn_mp_mul.c", line 15: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_mul.c", line 28: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_mul.c", line 31: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_mul.c", line 34: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_mul.c", line 45: warning 2006: Parameter holes filled with a null string.
        [...]
        cc -I. -O2 -c bn_mp_reduce.c -o bn_mp_reduce.o
cpp: "bn_mp_reduce.c", line 28: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_reduce.c", line 32: warning 2006: Parameter holes filled with a null string.
        [...]
        cc -I. -O2 -c bn_mp_set_double.c -o bn_mp_set_double.o
cpp: "bn_mp_set_double.c", line 46: warning 2029: "mp_set_double implementation is only available on platforms with IEEE754 floating point format"
        [...]
        cc -I. -O2 -c bn_mp_sqr.c -o bn_mp_sqr.o
cpp: "bn_mp_sqr.c", line 11: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_sqr.c", line 14: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_sqr.c", line 17: warning 2006: Parameter holes filled with a null string.
cpp: "bn_mp_sqr.c", line 22: warning 2006: Parameter holes filled with a null string.
        [...]
        cc -I. -O2 -c bn_s_mp_mul_high_digs.c -o bn_s_mp_mul_high_digs.o
cpp: "bn_s_mp_mul_high_digs.c", line 18: warning 2006: Parameter holes filled with a null string.

@minad
Copy link
Member Author

minad commented Apr 9, 2019

@karel-m We can activate Wundef together with the Wconversion warnings in #204. We will only do it without -Wsystem-headers. Then this should be a non-issue. Besides that, its ok?

@karel-m
Copy link
Member

karel-m commented Apr 9, 2019

3/ AIX + IBM XL C compiler

$ make -f makefile.unix
        [...]
        cc -I. -O2 -c bn_mp_exptmod_fast.c -o bn_mp_exptmod_fast.o
"bn_mp_exptmod_fast.c", line 50.8: 1506-041 (E) The invocation of macro _MP_DEFINED3 contains fewer arguments than are required by the macro definition.
"bn_mp_exptmod_fast.c", line 96.34: 1506-041 (E) The invocation of macro _MP_DEFINED3 contains fewer arguments than are required by the macro definition.
        [...]
        cc -I. -O2 -c bn_mp_set_double.c -o bn_mp_set_double.o
"bn_mp_set_double.c", line 46.6: 1506-948 (W) #warning "mp_set_double implementation is only available on platforms with IEEE754 floating point format"
        [...]
        cc -I. -O2 -c bn_s_mp_exptmod.c -o bn_s_mp_exptmod.o
"bn_s_mp_exptmod.c", line 37.8: 1506-041 (E) The invocation of macro _MP_DEFINED3 contains fewer arguments than are required by the macro definition.

@karel-m
Copy link
Member

karel-m commented Apr 9, 2019

4/ pretty old gcc 3.4.4

$ make V=1 CC=gcc
[...]
gcc -c -I./ -Wall -Wsign-compare -Wextra -Wshadow -Wsystem-headers -Wdeclaration-after-statement -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wpointer-arith -Wundef -O3 -funroll-loops -fomit-frame-pointer bn_mp_exptmod_fast.c -o bn_mp_exptmod_fast.o
bn_mp_exptmod_fast.c: In function `mp_exptmod_fast':
bn_mp_exptmod_fast.c:30: warning: declaration of 'x' shadows a previous local
bn_mp_exptmod_fast.c:24: warning: shadowed declaration is here
[...]
gcc -c -I./ -Wall -Wsign-compare -Wextra -Wshadow -Wsystem-headers -Wdeclaration-after-statement -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wpointer-arith -Wundef -O3 -funroll-loops -fomit-frame-pointer bn_mp_prime_strong_lucas_selfridge.c -o bn_mp_prime_strong_lucas_selfridge.o
bn_mp_prime_strong_lucas_selfridge.c: In function `mp_prime_strong_lucas_selfridge':
bn_mp_prime_strong_lucas_selfridge.c:113: warning: passing arg 3 of `mp_kronecker' from incompatible pointer type
[...]
gcc -c -I./ -Wall -Wsign-compare -Wextra -Wshadow -Wsystem-headers -Wdeclaration-after-statement -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wpointer-arith -Wundef -O3 -funroll-loops -fomit-frame-pointer bn_mp_set_double.c -o bn_mp_set_double.o
bn_mp_set_double.c:46:6: warning: #warning "mp_set_double implementation is only available on platforms with IEEE754 floating point format"
[...]
gcc -c -I./ -Wall -Wsign-compare -Wextra -Wshadow -Wsystem-headers -Wdeclaration-after-statement -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wpointer-arith -Wundef -O3 -funroll-loops -fomit-frame-pointer bn_s_mp_exptmod.c -o bn_s_mp_exptmod.o
bn_s_mp_exptmod.c: In function `s_mp_exptmod':
bn_s_mp_exptmod.c:17: warning: declaration of 'x' shadows a previous local
bn_s_mp_exptmod.c:16: warning: shadowed declaration is here
bn_s_mp_exptmod.c:17: warning: declaration of 'mu' shadows a previous local
bn_s_mp_exptmod.c:14: warning: shadowed declaration is here

@karel-m
Copy link
Member

karel-m commented Apr 9, 2019

5/ Visual Studio 2017

1>------ Build started: Project: tommath, Configuration: Debug x64 ------
[...]
1>bn_s_mp_mul_high_digs.c
1>bn_s_mp_mul_high_digs.c(18): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
[...]
1>bn_mp_sqr.c
1>bn_mp_sqr.c(11): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_sqr.c(14): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_sqr.c(17): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_sqr.c(22): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
[...]
1>bn_mp_set_double.c
1>mp_set_double implementation is only available on platforms with IEEE754 floating point format
[...]
1>bn_mp_reduce.c
1>bn_mp_reduce.c(28): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_reduce.c(32): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
[...]
1>bn_mp_mul.c
1>bn_mp_mul.c(15): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_mul.c(28): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_mul.c(31): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_mul.c(34): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_mul.c(45): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
[...]
1>bn_mp_invmod.c
1>bn_mp_invmod.c(15): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_invmod.c(19): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
[...]
1>bn_mp_exptmod_fast.c
1>bn_mp_exptmod_fast.c(73): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_exptmod_fast.c(84): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_exptmod_fast.c(88): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_exptmod_fast.c(96): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_exptmod_fast.c(104): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_exptmod_fast.c(128): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_exptmod.c
1>bn_mp_exptmod.c(25): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_exptmod.c(55): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_exptmod.c(61): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_exptmod.c(64): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_exptmod.c(69): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
1>bn_mp_exptmod.c(71): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
[...]
1>bn_mp_div_d.c
1>bn_mp_div_d.c(60): warning C4003: not enough actual parameters for macro '_MP_DEFINED1'
[...]

1>libtommath_VS2008.vcxproj -> C:\cygwin64\home\bob\libtommath\MSVC_x64_Debug\tommath.lib
1>Done building project "libtommath_VS2008.vcxproj".
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

@karel-m
Copy link
Member

karel-m commented Apr 9, 2019

All from me for now.

@minad
Copy link
Member Author

minad commented Apr 9, 2019

Hmm, I think this requires C99. One could also try the GCC variadic argument extension args....

Enable together with Wconversion warnings in #204 with -Wno-system-headers!
@minad minad force-pushed the feature-detection branch from f7136e0 to 1566606 Compare April 9, 2019 12:20
@minad
Copy link
Member Author

minad commented Apr 12, 2019

@sjaeckel What is your opinion about this?

@minad minad mentioned this pull request Apr 18, 2019
@minad minad closed this May 14, 2019
@minad minad deleted the feature-detection branch May 14, 2019 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants