Skip to content

Commit e3b0c71

Browse files
committed
Merge branch 'release/0.13.1'
2 parents 09c7b2d + 3a7273b commit e3b0c71

File tree

11 files changed

+101
-13
lines changed

11 files changed

+101
-13
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ after_failure:
2828
after_script:
2929
- cat test_gcc_2.txt
3030
notifications:
31-
irc: "chat.freenode.net#libtom"
31+
irc: "chat.freenode.net#libtom-notifications"
3232

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ Project Status
99

1010
master: [![Build Status](https://travis-ci.org/libtom/tomsfastmath.svg?branch=master)](https://travis-ci.org/libtom/tomsfastmath)
1111

12+
develop: [![Build Status](https://travis-ci.org/libtom/tomsfastmath.svg?branch=develop)](https://travis-ci.org/libtom/tomsfastmath)

changes.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
April 4th, 2017
2+
v0.13.1
3+
-- Fix missing fp_rand symbol in shared library
4+
-- Fix some parameters in API signatures that should've been const
5+
-- Bugfixes and improvements contributed by Sebastian Siewior, Reiner Herrmann and Mathias Tausig
6+
17
October 24th, 2015
28
v0.13.0
39
-- Add fp_rand()

doc/tfm.pdf

1.96 KB
Binary file not shown.

libtfm.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ fp_mul_d
3131
fp_mulmod
3232
fp_prime_random_ex
3333
fp_radix_size
34+
fp_rand
3435
fp_read_radix
3536
fp_read_signed_bin
3637
fp_read_unsigned_bin

makefile

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#makefile for TomsFastMath
22
#
33
#
4-
VERSION=0.13
4+
VERSION=0.13.1
55

66
CFLAGS += -Wall -W -Wshadow -Isrc/headers
77

@@ -21,6 +21,22 @@ ifndef MAKE
2121
MAKE=make
2222
endif
2323

24+
ifeq ($V,1)
25+
silent=
26+
else
27+
silent=@
28+
endif
29+
30+
%.o: %.c
31+
ifneq ($V,1)
32+
@echo " * ${CC} $@"
33+
endif
34+
${silent} ${CC} ${CFLAGS} -c $< -o $@
35+
36+
ifdef COMPILE_DEBUG
37+
#debug
38+
CFLAGS += -g3
39+
else
2440
ifndef IGNORE_SPEED
2541

2642
CFLAGS += -O3 -funroll-loops
@@ -32,6 +48,7 @@ CFLAGS += -O3 -funroll-loops
3248
#speed
3349
CFLAGS += -fomit-frame-pointer
3450

51+
endif
3552
endif
3653

3754
#START_INS
@@ -103,6 +120,11 @@ install: $(LIBNAME)
103120
install -g $(GROUP) -o $(USER) $(LIBNAME) $(DESTDIR)$(LIBPATH)
104121
install -g $(GROUP) -o $(USER) $(HEADERS_PUB) $(DESTDIR)$(INCPATH)
105122

123+
HEADER_FILES=$(notdir $(HEADERS_PUB))
124+
uninstall:
125+
rm $(DESTDIR)$(LIBPATH)/$(LIBNAME)
126+
rm $(HEADER_FILES:%=$(DESTDIR)$(INCPATH)/%)
127+
106128
.PHONY: mtest
107129
mtest: $(LIBNAME)
108130
cd mtest; CC="$(CC)" CFLAGS="$(CFLAGS) -I../" MAKE=${MAKE} ${MAKE} mtest
@@ -189,9 +211,10 @@ zipup:
189211
rm -rf ../tomsfastmath-$(VERSION) && rm -f ../tfm-$(VERSION).zip ../tfm-$(VERSION).tar.bz2 && \
190212
expsrc.sh -i . -o ../tomsfastmath-$(VERSION) --svntags --no-fetch -p '*.c' -p '*.h' && \
191213
MAKE=${MAKE} ${MAKE} -C ../tomsfastmath-$(VERSION) docs && \
192-
tar -c ../tomsfastmath-$(VERSION)/* | bzip2 -9vvc > ../tfm-$(VERSION).tar.bz2 && \
214+
tar -c ../tomsfastmath-$(VERSION)/* | xz -cz > ../tfm-$(VERSION).tar.xz && \
215+
find ../tomsfastmath-$(VERSION)/ -type f -exec unix2dos -q {} \; && \
193216
zip -9 -r ../tfm-$(VERSION).zip ../tomsfastmath-$(VERSION)/* && \
194-
gpg -b -a ../tfm-$(VERSION).tar.bz2 && gpg -b -a ../tfm-$(VERSION).zip
217+
gpg -b -a ../tfm-$(VERSION).tar.xz && gpg -b -a ../tfm-$(VERSION).zip
195218

196219
new_file:
197220
bash updatemakes.sh

makefile.shared

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ src/sqr/fp_sqr_comba_48.o src/sqr/fp_sqr_comba_4.o src/sqr/fp_sqr_comba_64.o src
4747
src/sqr/fp_sqr_comba_7.o src/sqr/fp_sqr_comba_8.o src/sqr/fp_sqr_comba_9.o src/sqr/fp_sqr_comba.o \
4848
src/sqr/fp_sqr_comba_generic.o src/sqr/fp_sqr_comba_small_set.o src/sqr/fp_sqrmod.o
4949

50-
HEADERS=src/headers/tfm.h
50+
HEADERS_PUB:=src/headers/tfm.h
51+
HEADERS=src/headers/tfm_private.h $(HEADERS_PUB)
5152

5253
#END_INS
5354

@@ -88,13 +89,18 @@ $(OBJECTS): $(HEADERS)
8889
$(LTCOMPILE) $(CFLAGS) $(LDFLAGS) -o $@ -c $<
8990

9091
$(LIBNAME): $(OBJECTS)
91-
libtool --silent --mode=link --tag=CC $(CC) $(CFLAGS) $(LDFLAGS) `find . -type f | grep "[.]lo" | xargs` -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION) -export-symbols libtfm.symbols
92+
libtool --mode=link --tag=CC $(CC) $(CFLAGS) $(LDFLAGS) `find . -type f | LC_ALL=C sort | grep "[.]lo" | xargs` -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION) -export-symbols libtfm.symbols
9293

9394
install: $(LIBNAME)
9495
install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(LIBPATH)
95-
libtool --silent --mode=install install -c $(LIBNAME) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
96+
libtool --mode=install install -c $(LIBNAME) $(DESTDIR)$(LIBPATH)/$(LIBNAME)
9697
install -d -g $(GROUP) -o $(USER) $(DESTDIR)$(INCPATH)
97-
install -g $(GROUP) -o $(USER) $(HEADERS) $(DESTDIR)$(INCPATH)
98+
install -g $(GROUP) -o $(USER) $(HEADERS_PUB) $(DESTDIR)$(INCPATH)
99+
100+
HEADER_FILES=$(notdir $(HEADERS_PUB))
101+
uninstall:
102+
libtool --mode=uninstall rm $(DESTDIR)$(LIBPATH)/$(LIBNAME)
103+
rm $(HEADER_FILES:%=$(DESTDIR)$(INCPATH)/%)
98104

99105
mtest/mtest: mtest/mtest.c
100106
cd mtest ; make mtest

src/generators/comba_sqr_gen.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#include <stdio.h>
12+
#include <stdlib.h>
1213

1314
int main(int argc, char **argv)
1415
{

src/headers/tfm.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
* Patch
2323
* XX - undefined
2424
*/
25-
#define TFM_VERSION 0x000D0000
26-
#define TFM_VERSION_S "v0.13.0"
25+
#define TFM_VERSION 0x000D0100
26+
#define TFM_VERSION_S "v0.13.1"
2727

2828
#ifndef MIN
2929
#define MIN(x,y) ((x)<(y)?(x):(y))
@@ -252,6 +252,17 @@
252252
#endif
253253
#endif
254254

255+
/* use arc4random on platforms that support it */
256+
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
257+
#define FP_GEN_RANDOM() arc4random()
258+
#define FP_GEN_RANDOM_MAX 0xffffffff
259+
#endif
260+
261+
/* use rand() as fall-back if there's no better rand function */
262+
#ifndef FP_GEN_RANDOM
263+
#define FP_GEN_RANDOM() rand()
264+
#define FP_GEN_RANDOM_MAX RAND_MAX
265+
#endif
255266

256267
/* some default configurations.
257268
*/

src/misc/fp_rand.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,31 @@
99
*/
1010
#include <tfm_private.h>
1111

12+
#if FP_GEN_RANDOM_MAX == 0xffffffff
13+
#define FP_GEN_RANDOM_SHIFT 32
14+
#elif FP_GEN_RANDOM_MAX == 32767
15+
/* SHRT_MAX */
16+
#define FP_GEN_RANDOM_SHIFT 15
17+
#elif FP_GEN_RANDOM_MAX == 2147483647
18+
/* INT_MAX */
19+
#define FP_GEN_RANDOM_SHIFT 31
20+
#elif !defined(FP_GEN_RANDOM_SHIFT)
21+
#error Thou shalt define their own valid FP_GEN_RANDOM_SHIFT
22+
#endif
23+
1224
/* makes a pseudo-random int of a given size */
25+
static fp_digit fp_gen_random(void)
26+
{
27+
fp_digit d = 0, msk = 0;
28+
do {
29+
d <<= FP_GEN_RANDOM_SHIFT;
30+
d |= ((fp_digit) FP_GEN_RANDOM());
31+
msk <<= FP_GEN_RANDOM_SHIFT;
32+
msk |= FP_GEN_RANDOM_MAX;
33+
} while ((FP_MASK & msk) != FP_MASK);
34+
d &= FP_MASK;
35+
return d;
36+
}
1337

1438
void fp_rand(fp_int *a, int digits)
1539
{
@@ -22,14 +46,14 @@ void fp_rand(fp_int *a, int digits)
2246

2347
/* first place a random non-zero digit */
2448
do {
25-
d = ((fp_digit) abs (rand ())) & FP_MASK;
49+
d = fp_gen_random();
2650
} while (d == 0);
2751

2852
fp_add_d (a, d, a);
2953

3054
while (--digits > 0) {
3155
fp_lshd (a, 1);
32-
fp_add_d (a, ((fp_digit) abs (rand ())), a);
56+
fp_add_d (a, fp_gen_random(), a);
3357
}
3458

3559
return;

0 commit comments

Comments
 (0)