Skip to content
Merged
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
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ jobs:
cat valgrind_test.log || true
cat gcc_errors_*.log || true

amalgam:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: install dependencies
run: |
make amalgamated_timing

CMake:
runs-on: ${{ matrix.os }}
strategy:
Expand Down
4 changes: 3 additions & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ profiled:
make CFLAGS="$(CFLAGS) -fbranch-probabilities"

#make a single object profiled library
profiled_single: pre_gen
amalgamated_timing: pre_gen
$(CC) $(LTM_CFLAGS) -fprofile-arcs -c pre_gen/tommath_amalgam.c -o tommath_amalgam.o
$(CC) $(LTM_CFLAGS) -DMP_VERSION=\"before\" demo/timing.c tommath_amalgam.o -lgcov -o timing

profiled_single: amalgamated_timing
./timing
rm -f *.o timing
$(CC) $(LTM_CFLAGS) -fbranch-probabilities -c pre_gen/tommath_amalgam.c -o tommath_amalgam.o
Expand Down
10 changes: 5 additions & 5 deletions s_mp_fp_log_d.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* LibTomMath, multiple-precision integer library -- Tom St Denis */
/* SPDX-License-Identifier: Unlicense */

static mp_word s_mp_flog2_mp_word(mp_word value)
static mp_word s_mp_flog2_mp_word_d(mp_word value)
{
mp_word r = 0u;
while ((value >>= 1) != 0u) {
Expand All @@ -13,12 +13,12 @@ static mp_word s_mp_flog2_mp_word(mp_word value)
}

/* Fixed point bitwise logarithm base two of "x" with precision "p" */
static mp_err s_mp_fp_log_fraction(mp_word x, int p, mp_word *c)
static mp_err s_mp_fp_log_fraction_d(mp_word x, int p, mp_word *c)
{
mp_word b, L_out, L, a_bar, twoep;
int i;

L = s_mp_flog2_mp_word(x);
L = s_mp_flog2_mp_word_d(x);

if ((L + (mp_word)p) > MP_UPPER_LIMIT_FIXED_LOG) {
return MP_VAL;
Expand Down Expand Up @@ -60,14 +60,14 @@ mp_err s_mp_fp_log_d(const mp_int *a, mp_word *c)
if ((err = mp_div_2d(a, la - prec, &t, NULL)) != MP_OKAY) goto LTM_ERR;
tmp = mp_get_u64(&t);
/* Compute the low precision approximation for the fractional part */
if ((err = s_mp_fp_log_fraction(tmp, prec, &la_word)) != MP_OKAY) goto LTM_ERR;
if ((err = s_mp_fp_log_fraction_d(tmp, prec, &la_word)) != MP_OKAY) goto LTM_ERR;
/* Compute the integer part and add it */
tmp = ((mp_word)(la - prec))<<prec;
la_word += tmp;
mp_clear(&t);
} else {
tmp = mp_get_u64(a);
if ((err = s_mp_fp_log_fraction(tmp, prec, &la_word)) != MP_OKAY) {
if ((err = s_mp_fp_log_fraction_d(tmp, prec, &la_word)) != MP_OKAY) {
return err;
}
}
Expand Down
4 changes: 2 additions & 2 deletions tommath_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -1091,8 +1091,8 @@
# define MP_DIV_2D_C
# define MP_GET_I64_C
# define MP_INIT_C
# define S_MP_FLOG2_MP_WORD_C
# define S_MP_FP_LOG_FRACTION_C
# define S_MP_FLOG2_MP_WORD_D_C
# define S_MP_FP_LOG_FRACTION_D_C
#endif

#if defined(S_MP_GET_BIT_C)
Expand Down