Commit Graph

1323 Commits

Author SHA1 Message Date
Francois Perrad
146becbd9a literal suffix 2019-11-05 18:43:37 +01:00
Steffen Jaeckel
3035e22fd3
Merge pull request #434 from libtom/simplifications
Simplifications
2019-11-05 17:55:04 +01:00
Steffen Jaeckel
80176de372 re-enable checks for memcpy&memset
[skip ci]
2019-11-05 17:53:08 +01:00
Daniel Mendler
410bf49385
apply a series of simplifications
* this is the final commit of a series of simplifications,
  containing only the regenerated files and the explanation in the
  commit message

* This is in preparation of the size_t change/a potential representation change to use
  full width as in tfm, if a (partial?) merge with tfm is desired.
  These changes have their own merits however.

* Remove obfuscating tmpx digit pointers (fewer variables, it is more obvious what is
  being manipulated)

* Reduce scope of variables where possible

* Stricter error handling/checking (for example handling in karatsuba
  was broken)

* In some cases the result was written even in the case of an error
  (e.g. s_mp_is_divisible). This will hide bugs, since the user should
  check the return value (enforced by MP_WUR). Furthermore if the user
  accesses the non-initialized result, valgrind will complain for
  example. Global static analysis like coverity will also detect the issue.
  Therefore this improves the status quo.

* Introduce generic, private MP_EXCH macro which can be used to swap values.

* Introduce s_mp_copy_digs/s_mp_zero_digs/s_mp_zero_buf

* Some control flow simplifications, e.g, loops instead of goto

* Renamings of variables/labels for consistency

* Renamings of mul/sqr functions for more consistency, e.g., comba
  instead of fast suffix

* I didn't read through some very complex functions.
  They are so complex, I am too afraid and lazy to touch them.
  Maybe someone resposible wants to simplify them if possible. Hint... Hint...
  - mp_prime_strong_lucas_selfridge.c
  - s_mp_exptmod.c
  - s_mp_exptmod_fast.c
2019-11-04 15:41:33 +01:00
Daniel Mendler
5c335f8407
rename mul/sqr functions for consistency, comba instead of fast suffix 2019-11-04 15:41:33 +01:00
Daniel Mendler
3b710fbd7e
simplify mp_complement 2019-11-04 15:41:33 +01:00
Daniel Mendler
bcda8fc696
simplifications: remove unnecessary optimization
* these double checks are not necessary
* the compiler will move the early return outside of the called
  function, basically the functions is partially inlined
* however lto/amalgamation needed for the optimization
2019-11-04 15:41:33 +01:00
Daniel Mendler
795cd2013f
simplifications: add s_mp_zero_(digs|buf) and s_mp_copy_digs
Originally I made those as macros. However we have many
other small functions like mp_clamp, mp_exch which are also not implemented
as macros right now.

If we would use c99, I would implement them as private static inline
functions. And mp_exch would be a public static inline function.

But since we are bound to c89, we simply use normal functions.
To achieve optimal performance one should either use link time
optimization or amalgamation.
2019-11-04 15:41:32 +01:00
Daniel Mendler
b1f9bff192
simplifications: invmod 2019-11-04 15:41:32 +01:00
Daniel Mendler
56144eed1e
simplifications: reduce functions 2019-11-04 15:41:32 +01:00
Daniel Mendler
448f35e2e1
simplifications: prime functions 2019-11-04 15:41:32 +01:00
Daniel Mendler
8ac493512c
simplifications: mul/sqr comba 2019-11-04 15:41:32 +01:00
Daniel Mendler
7b6c6965bb
simplifications: toom and karatsuba 2019-11-04 15:41:32 +01:00
Daniel Mendler
143e0376a1
simplifications: basic arithmetic functions 2019-11-04 15:41:31 +01:00
Daniel Mendler
e60149dec7
simplifications: replace mp_mod_d by macro 2019-11-04 15:41:31 +01:00
Steffen Jaeckel
2d3262af26
Merge pull request #442 from libtom/bug-min-prec
MP_MIN_PREC too small, test with MP_PREC=MP_MIN_PREC
2019-11-04 14:06:19 +01:00
Daniel Mendler
2bbdbd0651
MP_MIN_PREC>=3 is needed for s_mp_div_school
test with MP_PREC=MP_MIN_PREC
2019-11-03 17:23:59 +01:00
Steffen Jaeckel
820f4bb060
Merge pull request #435 from libtom/simple-simplifications
first batch of simplifications
2019-10-29 21:27:01 +01:00
Daniel Mendler
3cdcec43e6
first batch of simplifications 2019-10-29 19:30:23 +01:00
Daniel Mendler
b9977adfb8
use uint8_t instead of unsigned char 2019-10-29 17:40:59 +01:00
Steffen Jaeckel
98753c6718
Merge pull request #432 from libtom/no-deprecated-pragma
introduce MP_NO_DEPRECATED_PRAGMA
2019-10-29 17:20:40 +01:00
Steffen Jaeckel
af376edcde no more MP_WUR in timing.c 2019-10-29 16:37:56 +01:00
Steffen Jaeckel
8456782cc5 don't allow disabling of WUR checks 2019-10-29 15:40:47 +01:00
Steffen Jaeckel
57fbf5a880 also build support/ branches in CI
(cherry picked from commit 783ffb82dd5ddddce3d3bbd88661bcda44162458)
2019-10-29 15:39:00 +01:00
Steffen Jaeckel
e95dd24e4f introduce MP_NO_DEPRECATED_PRAGMA 2019-10-29 15:39:00 +01:00
Steffen Jaeckel
57ccd9f0c3
Merge pull request #431 from libtom/rework-tests
clean-up test.c
2019-10-29 15:38:31 +01:00
Steffen Jaeckel
4500d066c1 also no MP_WUR in mtest_opponent() 2019-10-29 14:41:33 +01:00
Steffen Jaeckel
b250ec44e0 clean-up test.c
* no more `MP_WUR` in test.c
* clean-up console output
2019-10-29 13:24:34 +01:00
Steffen Jaeckel
8bf82f9435
Merge pull request #425 from libtom/replace-gen-by-cat
replace gen.pl by cat, rename mpi.c to mp_all.c
2019-10-29 08:44:03 +01:00
Steffen Jaeckel
d800071e81 ignore&clean tommath_amalgam.c [skip ci] 2019-10-28 16:36:40 +01:00
Steffen Jaeckel
a598e61b90 rename to tommath_amalgam.c 2019-10-28 15:42:23 +01:00
Steffen Jaeckel
02f4ee114c compare logs before and after single-object profiling 2019-10-28 15:31:36 +01:00
Steffen Jaeckel
04ee1e75d7 improve demo/timing a bit
* less verbose output on console
* allow changing name for logs
* pre-heat caches before starting the timing
2019-10-28 15:31:36 +01:00
Steffen Jaeckel
8e3a440464
use pre_gen/mp_all.c for profiled_single
+ clean-up defines
2019-10-28 15:29:54 +01:00
Steffen Jaeckel
43804ed732
remove logs and generated PNG's
this fixes #423
2019-10-28 15:29:54 +01:00
Daniel Mendler
1ece193af2
replace gen.pl by cat, rename mpi.c to mp_all.c 2019-10-28 15:29:54 +01:00
Steffen Jaeckel
da8b978785
Merge pull request #426 from libtom/rework-read-radix
mp_read_radix and mp_fread should behave the same
2019-10-28 15:29:30 +01:00
Daniel Mendler
a5d5b10154
mp_read_radix and mp_fread should behave the same 2019-10-27 23:51:38 +01:00
Steffen Jaeckel
50abc11a26
Merge pull request #422 from libtom/remove-ltm-rng
remove ltm_rng (deprecated function)
2019-10-27 22:10:25 +01:00
Daniel Mendler
85699be1ac
remove ltm_rng (deprecated function) 2019-10-27 22:09:53 +01:00
Steffen Jaeckel
bde40c44a9
Merge pull request #421 from libtom/doc-fix
manual: don't mention obsolete MP_DIV_SMALL
2019-10-27 22:06:11 +01:00
Daniel Mendler
2122b51139
manual: don't mention obsolete MP_DIV_SMALL 2019-10-27 21:53:17 +01:00
Steffen Jaeckel
baabf5633f
Merge pull request #405 from libtom/add-sub-opt
stdbool/stdint refactoring, various optimizations/simplifications
2019-10-27 21:22:53 +01:00
Steffen Jaeckel
e2f8df3358 fix doc [skip ci]
+ ignore bak files generated by latexindent
+ silence latexindent
2019-10-27 21:19:37 +01:00
Daniel Mendler
7afecabd9d
regen files 2019-10-27 19:19:47 +01:00
Daniel Mendler
f662e1f7e1
fix c89 issues 2019-10-27 19:19:47 +01:00
Daniel Mendler
4376913928
remove inttypes.h includes in c89 mode 2019-10-27 18:41:59 +01:00
Daniel Mendler
d27dff92f0
update manual: replace mp_bool/MP_YES/MP_NO references by bool/true/false 2019-10-27 18:41:58 +01:00
Daniel Mendler
8ecf7eaea4
better comment in tommath_c89.h 2019-10-27 18:36:57 +01:00
Daniel Mendler
17d59c2c0f
replace PRIx64 by MP_PRIx64 for c89 mode 2019-10-27 18:36:57 +01:00