Skip to content

Commit 96f9edf

Browse files
authored
Merge pull request #536 from libtom/some-improvements
Some improvements
2 parents f3b8879 + 4de4e4f commit 96f9edf

27 files changed

+54
-39
lines changed

CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ endif()
6161
# What compiler do we have and what are their...uhm... peculiarities
6262
if(CMAKE_C_COMPILER_ID MATCHES "(C|c?)lang")
6363
list(APPEND LTM_C_FLAGS -Wno-typedef-redefinition -Wno-tautological-compare -Wno-builtin-requires-header)
64-
# Clang requires at least '-O1' for dead code eliminiation
64+
# Clang requires at least '-O1' for dead code elimination
6565
set(CMAKE_C_FLAGS_DEBUG "-O1 ${CMAKE_C_FLAGS_DEBUG}")
6666
endif()
6767
if(CMAKE_C_COMPILER MATCHES "mingw")
@@ -103,11 +103,17 @@ target_link_options(${PROJECT_NAME} BEFORE PRIVATE
103103
${LTM_LD_FLAGS}
104104
)
105105

106+
set(PUBLIC_HEADERS tommath.h)
107+
set(C89 False CACHE BOOL "(Usually maintained automatically) Enable when the library is in c89 mode to package the correct header files on install")
108+
if(C89)
109+
list(APPEND PUBLIC_HEADERS tommath_c89.h)
110+
endif()
111+
106112
set_target_properties(${PROJECT_NAME} PROPERTIES
107113
OUTPUT_NAME tommath
108114
VERSION ${PROJECT_VERSION}
109115
SOVERSION ${PROJECT_VERSION_MAJOR}
110-
PUBLIC_HEADER tommath.h
116+
PUBLIC_HEADER "${PUBLIC_HEADERS}"
111117
)
112118

113119
option(COMPILE_LTO "Build with LTO enabled")

astylerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# usage:
55
# astyle --options=astylerc *.[ch]
66

7-
# Do not create backup, annonying in the times of git
7+
# Do not create backup, annoying in the times of git
88
suffix=none
99

1010
## Bracket Style Options

changes.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ v1.2.0
1919
-- Unified, safer and improved API's
2020
-- Less magic numbers - return values (where appropriate) and most flags are now enums,
2121
this was implemented in a backwards compatible way where return values were int.
22-
-- API's with return values are now by default marked as "warn on unsused result", this
22+
-- API's with return values are now by default marked as "warn on unused result", this
2323
can be disabled if required (which will most likely hide bugs), c.f. MP_WUR in tommath.h
2424
-- Provide a whole set of setters&getters for different primitive types (long, uint32_t, etc.)
2525
-- All those primitive setters are now optimized.
@@ -412,8 +412,8 @@ v0.13 -- tons of minor speed-ups in low level add, sub, mul_2 and div_2 which p
412412
Jan 17th, 2003
413413
v0.12 -- re-wrote the majority of the makefile so its more portable and will
414414
install via "make install" on most *nix platforms
415-
-- Re-packaged all the source as seperate files. Means the library a single
416-
file packagage any more. Instead of just adding "bn.c" you have to add
415+
-- Re-packaged all the source as separate files. Means the library a single
416+
file package any more. Instead of just adding "bn.c" you have to add
417417
libtommath.a
418418
-- Renamed "bn.h" to "tommath.h"
419419
-- Changes to the manual to reflect all of this
@@ -444,7 +444,7 @@ v0.08 -- Sped up the multipliers by moving the inner loop variables into a smal
444444
-- add etc/pprime.c program which makes numbers which are provably prime.
445445

446446
Jan 1st, 2003
447-
v0.07 -- Removed alot of heap operations from core functions to speed them up
447+
v0.07 -- Removed a lot of heap operations from core functions to speed them up
448448
-- Added a root finding function [and mp_sqrt macro like from MPI]
449449
-- Added more to manual
450450

demo/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,6 @@ target_link_options(${LTM_TEST} BEFORE PUBLIC
6161
# CTest
6262
#-----------------------------------------------------------------------------
6363
add_test(NAME ${LTM_TEST} COMMAND ${LTM_TEST})
64+
65+
find_program(MEMORYCHECK_COMMAND valgrind)
66+
set(MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full")

demo/mtest_opponent.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static int mtest_opponent(void)
8282
#endif
8383

8484
for (;;) {
85-
/* randomly clear and re-init one variable, this has the affect of triming the alloc space */
85+
/* randomly clear and re-init one variable, this has the effect of trimming the alloc space */
8686
switch (abs(rand()) % 7) {
8787
case 0:
8888
mp_clear(&a);

demo/test.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,7 +1548,7 @@ static int test_mp_decr(void)
15481548
default(realprecision,1000);
15491549
for(n=3,100,r = floor(a^(1/n));printf("\"" r "\", "))
15501550
1551-
All numbers as strings to simplifiy things, especially for the
1551+
All numbers as strings to simplify things, especially for the
15521552
low-mp branch.
15531553
*/
15541554

@@ -2166,7 +2166,7 @@ static int test_mp_pack_unpack(void)
21662166
uint8_t *buf = NULL;
21672167

21682168
mp_order order = MP_LSB_FIRST;
2169-
mp_endian endianess = MP_NATIVE_ENDIAN;
2169+
mp_endian endianness = MP_NATIVE_ENDIAN;
21702170

21712171
DOR(mp_init_multi(&a, &b, NULL));
21722172
DO(mp_rand(&a, 15));
@@ -2180,9 +2180,9 @@ static int test_mp_pack_unpack(void)
21802180
}
21812181

21822182
DO(mp_pack((void *)buf, count, &written, order, 1uL,
2183-
endianess, 0uL, &a));
2183+
endianness, 0uL, &a));
21842184
DO(mp_unpack(&b, count, order, 1uL,
2185-
endianess, 0uL, (const void *)buf));
2185+
endianness, 0uL, (const void *)buf));
21862186

21872187
if (mp_cmp(&a, &b) != MP_EQ) {
21882188
fprintf(stderr, "pack/unpack cycle failed\n");

doc/bn.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ \subsubsection{OpenBSD}
210210
At this time two versions of \texttt{libtool} are installed and both are named \texttt{libtool},
211211
unfortunately but GNU \texttt{libtool} has been placed in \texttt{/usr/local/bin/} and the native
212212
version in \texttt{/usr/bin/}. The path might be different in other versions of OpenBSD but both
213-
programms differ in the output of \texttt{libtool --version}
213+
programs differ in the output of \texttt{libtool --version}
214214
\begin{alltt}
215215
$ /usr/local/bin/libtool --version
216216
libtool (GNU libtool) 2.4.2
@@ -519,7 +519,7 @@ \subsection{Single Initialization}
519519
\end{alltt}
520520

521521
This function expects a pointer to an \texttt{mp\_int} structure and will initialize the members
522-
ofthe structure so the \texttt{mp\_int} represents the default integer which is zero. If the
522+
of the structure so the \texttt{mp\_int} represents the default integer which is zero. If the
523523
functions returns \texttt{MP\_OKAY} then the \texttt{mp\_int} is ready to be used by the other
524524
LibTomMath functions.
525525

@@ -2213,7 +2213,7 @@ \subsection{Required Number of Tests}
22132213
Determining the probability needed to pick the right column is a bit harder. Fips 186.4, for
22142214
example has $2^{-80}$ for $512$ bit large numbers, $2^{-112}$ for $1024$ bits, and $2^{128}$ for
22152215
$1536$ bits. It can be seen in table \ref{table:millerrabinrunsp1} that those combinations follow
2216-
the diagonal from $(512,2^{-80})$ downwards and to the right to gain a lower probabilty of getting
2216+
the diagonal from $(512,2^{-80})$ downwards and to the right to gain a lower probability of getting
22172217
a composite declared a pseudoprime for the same amount of work or less.
22182218

22192219
If this version of the library has the strong Lucas--Selfridge and/or the Frobenius--Underwood test

doc/makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ manual: mandvi
4040

4141
# The file latexindent.pl is in several LaTeX distributions, if not:
4242
# https://ctan.org/pkg/latexindent
43-
# Its configuraion is well documented
43+
# Its configuration is well documented
4444
# http://mirrors.ctan.org/support/latexindent/documentation/latexindent.pdf
4545
pretty:
4646
latexindent -s -w -m -l=.latexindent.yaml bn.tex

logs/before_after.dem

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ plot 'sqr-before.log' smooth bezier title "Squaring (without Karatsuba) (before)
2323
set output "expt-ba.png"
2424
plot 'expt-before.log' smooth bezier title "Exptmod (Montgomery) (before)", \
2525
'expt-after.log' smooth bezier title "Exptmod (Montgomery) (after)", \
26-
'expt_dr-before.log' smooth bezier title "Exptmod (Dimminished Radix) (before)", \
27-
'expt_dr-after.log' smooth bezier title "Exptmod (Dimminished Radix) (after)", \
26+
'expt_dr-before.log' smooth bezier title "Exptmod (Diminished Radix) (before)", \
27+
'expt_dr-after.log' smooth bezier title "Exptmod (Diminished Radix) (after)", \
2828
'expt_2k-before.log' smooth bezier title "Exptmod (2k Reduction) (before)", \
2929
'expt_2k-after.log' smooth bezier title "Exptmod (2k Reduction) (after)", \
3030
'expt_2kl-before.log' smooth bezier title "Exptmod (2k-l Reduction) (before)", \

logs/graphs.dem

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ set output "mult.png"
99
plot 'sqr.log' smooth bezier title "Squaring (without Karatsuba)", 'sqr_kara.log' smooth bezier title "Squaring (Karatsuba)", 'mult.log' smooth bezier title "Multiplication (without Karatsuba)", 'mult_kara.log' smooth bezier title "Multiplication (Karatsuba)"
1010

1111
set output "expt.png"
12-
plot 'expt.log' smooth bezier title "Exptmod (Montgomery)", 'expt_dr.log' smooth bezier title "Exptmod (Dimminished Radix)", 'expt_2k.log' smooth bezier title "Exptmod (2k Reduction)"
12+
plot 'expt.log' smooth bezier title "Exptmod (Montgomery)", 'expt_dr.log' smooth bezier title "Exptmod (Diminished Radix)", 'expt_2k.log' smooth bezier title "Exptmod (2k Reduction)"
1313

1414
set output "invmod.png"
1515
plot 'invmod.log' smooth bezier title "Modular Inverse"

0 commit comments

Comments
 (0)