libtom / tomsfastmath

TomsFastMath is a fast public domain, open source, large integer arithmetic library written in portable ISO C.
http://www.libtom.net
Other
213 stars 66 forks source link

fix INNERMUL and PROPCARRY warnings for ARM inline asm #26

Closed aewag closed 3 years ago

aewag commented 3 years ago

Compiling with arm-none-eabi-gcc 6.3.1 leads to warnings regarding the asm macros for INNERMUL and PROPCARRY.

$ CFLAGS="-Os -DTFM_ALREADY_SET -DTFM_ARM" CC=arm-none-eabi-gcc make
...
src/mont/fp_montgomery_reduce.c:510:11: warning: matching constraint does not allow a register
           INNERMUL;
           ^~~~~~~~
src/mont/fp_montgomery_reduce.c:515:12: warning: matching constraint does not allow a register
            PROPCARRY;
...

This is due to the mismatch of the output & input constraint character. _c[0] is constrained to memory for output and to register for input.

I changed the input constraint to memory, "m".

I tested the implementation with the version showing the warning and the version with the proposed fix both on an Cortex-A5 SoC I have on my desk by verifying an RSA signature. Both worked. To see if there is any difference for the binary at all, I diffed the disassembly of both static libraries (develop branch vs fixed). There was no difference so I assume arm gcc compiler handeled the mismatch of the constraints already correctly.

aewag commented 3 years ago

Just came back to this PR. Is there anything missing for this to be merged?

sjaeckel commented 3 years ago

Nothing, sorry for the delay!

Can you please rebase and force-push.

aewag commented 3 years ago

Just did this. Thanks for merging :)