From 28a1eadb8eff4476078b6fd3fc425f0f4e5e9e45 Mon Sep 17 00:00:00 2001 From: Jason Gross Date: Fri, 3 Nov 2017 12:47:16 -0400 Subject: Add PRI{u,x}limb for printf formats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is to fix ``` src/Specific/Framework/bench/fibe.c: In function ‘fe_print’: src/Specific/Framework/bench/fibe.c:130:5: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint32_t’ [-Wformat=] printf("0x%016llx)<< %lu) + ", x[i], limb_weight_gaps[i-1]); ^ src/Specific/Framework/bench/fibe.c:130:5: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint32_t’ [-Wformat=] src/Specific/Framework/bench/fibe.c:132:3: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint32_t’ [-Wformat=] printf("0x%016llx", x[0]); ^ ``` --- generate_parameters.py | 2 ++ src/Specific/Framework/bench/fibe.c | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/generate_parameters.py b/generate_parameters.py index 76b50e0f4..9713f25ea 100644 --- a/generate_parameters.py +++ b/generate_parameters.py @@ -157,6 +157,8 @@ def get_extra_compiler_params(q, base, bitwidth, sz): 'a24_val' : repr(str(a24)), 'a24_hex' : repr(hex(a24)), 'limb_t' : 'uint%d_t' % bitwidth, + 'PRIxlimb' : 'PRIx%d' % bitwidth, + 'PRIulimb' : 'PRIu%d' % bitwidth, 'modulus_limbs' : repr(str(sz)), 'limb_weight_gaps_array' : limb_widths } diff --git a/src/Specific/Framework/bench/fibe.c b/src/Specific/Framework/bench/fibe.c index f52770037..bcc13d243 100644 --- a/src/Specific/Framework/bench/fibe.c +++ b/src/Specific/Framework/bench/fibe.c @@ -1,6 +1,7 @@ #include #include #include +#include typedef unsigned int uint128_t __attribute__((mode(TI))); #ifndef modulus_bytes_val @@ -11,6 +12,14 @@ typedef unsigned int uint128_t __attribute__((mode(TI))); #define limb_t uint64_t #endif +#ifndef PRIxlimb +#define PRIxlimb PRIx64 +#endif + +#ifndef PRIulimb +#define PRIulimb PRIu64 +#endif + #ifndef a24_val #define a24_val 121665 #endif @@ -122,9 +131,9 @@ static void fe_frombytes(limb_t x[modulus_limbs], const uint8_t s[modulus_bytes] static void fe_print(limb_t x[modulus_limbs]) { for (unsigned i=0; i 0; --i) { - printf("0x%016llx)<< %lu) + ", x[i], limb_weight_gaps[i-1]); + printf("0x%016"PRIxlimb")<< %"PRIulimb") + ", x[i], limb_weight_gaps[i-1]); } - printf("0x%016llx", x[0]); + printf("0x%016"PRIxlimb, x[0]); } static void fe_cswap(limb_t bit, limb_t x[modulus_limbs], limb_t y[modulus_limbs]) { -- cgit v1.2.3