Skip to content

Proposal of changes to #160 #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,22 @@ Tests are located in `demo/` and can be built in two flavors.
* `make test` creates a test binary that is intended to be run against `mtest`. `mtest` can be built with `make mtest` and test execution is done like `./mtest/mtest | ./test`. `mtest` is creating test vectors using an alternative MPI library and `test` is consuming these vectors to verify correct behavior of ltm
* `make test_standalone` creates a stand-alone test binary that executes several test routines.

[Valgrind](http://valgrind.org/) does not support `long double` but does not reset the limits in `float.h` accordingly. Please build `demo.c` with the additional compiler flag `-DLTM_MEMCHECK_VALGRIND`, e.g.:
[Valgrind](http://valgrind.org/) does not support `long double` but does not reset the limits in `float.h` accordingly.
Please build `test.c` with the additional compiler flag `-DLTM_MEMCHECK_VALGRIND`, e.g.:

`CFLAGS=" -DLTM_MEMCHECK_VALGRIND " make test_standalone`
```
CFLAGS=" -DLTM_MEMCHECK_VALGRIND " make test_standalone
````

It will skip the tests for `long double` and prints a reminder to compile and run the tests without that flag to assure numerical correctness.

In case your platform doesn't provide Valgrind at all and the auto-detection fails, please build `test.c` with the additional compiler flag `-DLTM_NO_VALGRIND`, e.g.:

```
CFLAGS=" -DLTM_NO_VALGRIND " make test_standalone
````


## Building and Installing

Building is straightforward for GNU Linux only, the section "Building LibTomMath" in the documentation in `doc/bn.pdf` has the details.
4 changes: 2 additions & 2 deletions bn_mp_get_float.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ float mp_get_float(const mp_int *a)
/* pragma message() not supported by several compilers (in mostly older but still used versions) */
# ifdef _MSC_VER
# pragma message("The type 'float' does not seem to be supported on your system.")
# pragma message("If that is wrong please contact the team at https://github.com/libtommath/")
# pragma message("If that is wrong please contact the team at https://github.com/libtom/libtommath")
# else
# warning "The type 'float' does not seem to be supported on your system."
# warning "If that is wrong please contact the team at https://github.com/libtommath/"
# warning "If that is wrong please contact the team at https://github.com/libtom/libtommath"
# endif
#endif
#endif
Expand Down
4 changes: 2 additions & 2 deletions bn_mp_get_long_double.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ long double mp_get_long_double(const mp_int *a)
/* pragma message() not supported by several compilers (in mostly older but still used versions) */
# ifdef _MSC_VER
# pragma message("The type 'long double' does not seem to be supported on your system.")
# pragma message("If that is wrong please contact the team at https://github.com/libtommath/")
# pragma message("If that is wrong please contact the team at https://github.com/libtom/libtommath")
# else
# warning "The type 'long double' does not seem to be supported on your system."
# warning "If that is wrong please contact the team at https://github.com/libtommath/"
# warning "If that is wrong please contact the team at https://github.com/libtom/libtommath"
# endif
#endif
#endif
Expand Down
6 changes: 3 additions & 3 deletions bn_mp_set_long_double.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int mp_set_long_double(mp_int *a, long double b)
double _b = (double) b;
return mp_set_double(a, _b);
}
/*
/*
The "long double" on a Sparc64 is either a quad-precision float with LDBL_MANT_DIG = 113
and LDBL_MAX_EXP = 16384, although in software only.
*/
Expand Down Expand Up @@ -254,10 +254,10 @@ int mp_set_long_double(mp_int *a, long double b)
/* pragma message() not supported by several compilers (in mostly older but still used versions) */
# ifdef _MSC_VER
# pragma message("The type 'long double' does not seem to be supported on your system.")
# pragma message("If that is wrong please contact the team at https://github.com/libtommath/")
# pragma message("If that is wrong please contact the team at https://github.com/libtom/libtommath")
# else
# warning "The type 'long double' does not seem to be supported on your system."
# warning "If that is wrong please contact the team at https://github.com/libtommath/"
# warning "If that is wrong please contact the team at https://github.com/libtom/libtommath"
# endif
#if (FLT_RADIX == 16)
# ifdef _MSC_VER
Expand Down
8 changes: 4 additions & 4 deletions demo/main.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "shared.h"

int mtest_opponent(void);
int unit_tests(void);
int unit_tests(int argc, char **argv);

void ndraw(mp_int* a, const char* name)
void ndraw(mp_int *a, const char *name)
{
char *buf;
int size;
Expand All @@ -24,7 +24,7 @@ void ndraw(mp_int* a, const char* name)
free(buf);
}

int main(void)
int main(int argc, char **argv)
{
srand(LTM_DEMO_RAND_SEED);

Expand All @@ -48,7 +48,7 @@ int main(void)
if (LTM_DEMO_TEST_VS_MTEST) {
return mtest_opponent();
}
return unit_tests();
return unit_tests(argc, argv);
}

/* ref: $Format:%D$ */
Expand Down
2 changes: 1 addition & 1 deletion demo/opponent.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ int mtest_opponent(void)
printf("\n");
return 0;

LBL_ERR:
LBL_ERR:
mp_clear_multi(&a, &b, &c, &d, &e, &f, NULL);
printf("\n");
return EXIT_FAILURE;
Expand Down
Loading