Commit Graph

1315 Commits

Author SHA1 Message Date
czurnieden
244c698ecd corrected startvalue for sigma and cutoff in mp_div 2019-11-24 05:44:29 +01:00
Steffen Jaeckel
6e779e69a8
Merge pull request #462 from czurnieden/repair_div_recursive
Repair of sign handling in mp_div_recursive
2019-11-22 11:31:20 +01:00
czurnieden
5f3063fb2a correction of typo in test.c 2019-11-22 03:14:59 +01:00
czurnieden
642032ddc7 wrong sign in mp_div_recursive 2019-11-22 02:56:48 +01:00
Steffen Jaeckel
86d7d718e3
Merge pull request #457 from libtom/wrong-use-of-ull-for-develop
Wrong use of ull for develop
2019-11-14 14:22:06 +01:00
Jan Nijtmans
bb1e56e775
Fix compilation of demo/test.c using C++ 2019-11-14 14:18:45 +01:00
Jan Nijtmans
0730a31ab6
Make sure that c89 conversion doesn't produce LL or uLL postfix, since that isn't c89 at all 2019-11-14 14:18:45 +01:00
Jan Nijtmans
6804835181
more spacing around PRIu64, needed for C++ compatibility 2019-11-14 14:18:45 +01:00
Jan Nijtmans
9f2cd04301
more unnecessary type-casts, correct type-case for malloc 2019-11-14 14:18:45 +01:00
Jan Nijtmans
e9d54e9867
remove unnecessary type-casts 2019-11-14 14:18:45 +01:00
Jan Nijtmans
a91eb5a0d9
fix build (hopefully) 2019-11-14 14:18:45 +01:00
Jan Nijtmans
9cfb6c3298
use type-cast in stead of UINT64_C 2019-11-14 14:18:45 +01:00
Jan Nijtmans
02aa95c2b5
Fix wrong use of uLL suffix 2019-11-14 14:18:45 +01:00
Steffen Jaeckel
83b74bac6e
Merge pull request #446 from libtom/suffix-renamings2
Alternative 2: Suffix renamings (_n suffix)
2019-11-14 11:08:33 +01:00
Daniel Mendler
41eca3425f regen 2019-11-14 09:17:00 +01:00
Daniel Mendler
f6a7bedb95 suffix _u32 -> _n of mp_(expt|log|root) functions, use int for now 2019-11-14 09:16:00 +01:00
Steffen Jaeckel
86648a0d23
Merge pull request #456 from libtom/mp-has-comment
s_mp_rand_platform: add comment regarding MP_HAS requiring dead code elim
2019-11-13 15:55:01 +01:00
Daniel Mendler
c47d5e87b2
s_mp_rand_platform: add comment regarding MP_HAS requiring dead code elim 2019-11-12 01:16:33 +01:00
Steffen Jaeckel
59d62c9bf6
Merge pull request #454 from libtom/better-use-of-isneg
Better use of isneg
2019-11-11 21:53:00 +01:00
nijtmans
1cc289d215 better use of mp_isneg() and mp_iszero() 2019-11-11 21:52:20 +01:00
Steffen Jaeckel
0bc5c3292d
Merge pull request #450 from libtom/sqr-opt
make mp_sqr and mp_div_3 internal and add optimizations
2019-11-10 15:30:57 +01:00
Daniel Mendler
53becf6569
regen files 2019-11-09 06:43:59 +01:00
Daniel Mendler
6777baaf97
add macro MP_IS_2EXPT 2019-11-09 06:43:59 +01:00
Daniel Mendler
2e88b571c1
optimize mp_mul_d 2019-11-09 06:43:59 +01:00
Daniel Mendler
6ec36e0b9b
optimize mp_div_d 2019-11-09 06:43:59 +01:00
Daniel Mendler
4f00e75b8f
make mp_div_3 private 2019-11-09 06:43:58 +01:00
Daniel Mendler
0fa802f24b
make mp_sqr private (optimization of mp_mul) 2019-11-09 06:43:58 +01:00
Steffen Jaeckel
4077293f4a
Merge pull request #451 from libtom/simplify-mod
simplify mod functions
2019-11-07 21:12:56 +01:00
Daniel Mendler
61ebe7c047
simplify mod functions 2019-11-07 01:01:19 +01:00
Steffen Jaeckel
cc77fadb85
Merge pull request #444 from minad/lto
add COMPILE_LTO to test link time optimization
2019-11-05 23:11:36 +01:00
Steffen Jaeckel
67e1816822
Merge pull request #445 from libtom/fix-def-gen
fix generate_def, rename some internal files
2019-11-05 23:10:40 +01:00
Daniel Mendler
91d88ce3db
fix generate_def, rename some internal files 2019-11-05 21:11:58 +01:00
Daniel Mendler
3b98e82627
disable lto test for clang for now
it works on debian but not on the outdated travis ubuntu
2019-11-05 21:01:54 +01:00
Daniel Mendler
53a689d084
travis: install llvm-7 2019-11-05 20:29:59 +01:00
Daniel Mendler
74d828d526
don't use ranlib, ar s is equivalent 2019-11-05 20:28:59 +01:00
Daniel Mendler
e8e65119d1
add COMPILE_LTO to test link time optimization
the library performs best with lto since many small functions
can be inlined across objects.
2019-11-05 20:28:59 +01:00
Steffen Jaeckel
c893d217aa
Merge pull request #439 from libtom/radix-code-cleanup
mp_radix off-by-one error and other related code-cleanup
2019-11-05 20:16:01 +01:00
nijtmans
bbb178089d
mp_radix off-by-one error and other related code-cleanup 2019-11-05 20:15:24 +01:00
Steffen Jaeckel
7e47ae6550
Merge pull request #443 from libtom/rename-maxfast
rename MP_MAXFAST to MP_MAX_COMBA
2019-11-05 20:09:43 +01:00
Daniel Mendler
93f8e7603d
rename MP_MAXFAST to MP_MAX_COMBA 2019-11-05 20:09:23 +01:00
Steffen Jaeckel
b4c42576d7
Merge pull request #436 from fperrad/20191029_lint
some linting
2019-11-05 19:40:30 +01:00
Francois Perrad
40342807dc explicit operator precedence 2019-11-05 18:45:48 +01:00
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