add `MP_SMALL_STACK_SIZE` option
commitbd66fccee4bddfb9334fd419444665abeaea6034
authorSteffen Jaeckel <s@jaeckel.eu>
Tue, 12 Apr 2022 13:03:47 +0000 (12 15:03 +0200)
committerSteffen Jaeckel <s@jaeckel.eu>
Wed, 27 Mar 2024 15:12:02 +0000 (27 16:12 +0100)
tree8c6118f18907d94298379bca066d78a96d645863
parent4929f09f4304d3a131c11d4e17915db51dfc71d5
add `MP_SMALL_STACK_SIZE` option

This adds an option to use a heap-buffer for the usually stack-based
`MP_WARRAY`-sized temporary buffers.

Per default it will reserve a single buffer, which can be modified
* at compile-time via the `MP_WARRAY_NUM` define
* at run-time by calling `mp_warray_init()`

The internal structure can only be created once. If one wants to modify
the maximum number of elements, the entire structure has to be free'd
by calling `mp_warray_free()`.

In case one wants to use this option with multiple threads, one shall
use the `mp_warray_init()` function and pass appropriate locking functions.

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
20 files changed:
.github/workflows/main.yml
CMakeLists.txt
demo/test.c
doc/bn.tex
helper.pl
mp_warray_free.c [new file with mode: 0644]
mp_warray_init.c [new file with mode: 0644]
s_mp_montgomery_reduce_comba.c
s_mp_mul_comba.c
s_mp_mul_high_comba.c
s_mp_sqr_comba.c
s_mp_warray.c [new file with mode: 0644]
s_mp_warray_free.c [new file with mode: 0644]
s_mp_warray_get.c [new file with mode: 0644]
s_mp_warray_put.c [new file with mode: 0644]
tommath.def
tommath.h
tommath_class.h
tommath_private.h
tommath_superclass.h