diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b42462b1..457216a7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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: diff --git a/makefile b/makefile index e92e0e66..b2cb16a3 100644 --- a/makefile +++ b/makefile @@ -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 diff --git a/s_mp_fp_log_d.c b/s_mp_fp_log_d.c index cbe3b072..71d82dc4 100644 --- a/s_mp_fp_log_d.c +++ b/s_mp_fp_log_d.c @@ -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) { @@ -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; @@ -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))<