Skip to content
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

Improve C89 compliance #746

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
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ esac

CFLAGS="-W $CFLAGS"

warn_CFLAGS="-std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function -Wno-long-long -Wno-overlength-strings"
warn_CFLAGS="-std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function"
saved_CFLAGS="$CFLAGS"
CFLAGS="$warn_CFLAGS $CFLAGS"
AC_MSG_CHECKING([if ${CC} supports ${warn_CFLAGS}])
Expand Down Expand Up @@ -196,7 +196,7 @@ if test x"$use_ecmult_static_precomputation" != x"no"; then
SAVE_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS_FOR_BUILD"

warn_CFLAGS_FOR_BUILD="-Wall -Wextra -Wno-unused-function"
warn_CFLAGS_FOR_BUILD="-std=c89 -pedantic -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes -Wno-unused-function"
saved_CFLAGS="$CFLAGS"
CFLAGS="$warn_CFLAGS_FOR_BUILD $CFLAGS"
AC_MSG_CHECKING([if native ${CC_FOR_BUILD} supports ${warn_CFLAGS_FOR_BUILD}])
Expand Down
8 changes: 4 additions & 4 deletions src/bench.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
static int64_t gettime_i64(void) {
struct timeval tv;
gettimeofday(&tv, NULL);
return (int64_t)tv.tv_usec + (int64_t)tv.tv_sec * 1000000LL;
return (int64_t)tv.tv_usec + (int64_t)tv.tv_sec * INT64_C(1000000);
}

#define FP_EXP (6)
#define FP_MULT (1000000LL)
#define FP_MULT (INT64_C(1000000))

/* Format fixed point number. */
void print_number(const int64_t x) {
Expand All @@ -39,8 +39,8 @@ void print_number(const int64_t x) {
* sense). */
y = x_abs;
c = 0;
while (y > 0LL && y < 100LL * FP_MULT && c < FP_EXP) {
y *= 10LL;
while (y > INT64_C(0) && y < INT64_C(100) * FP_MULT && c < FP_EXP) {
y *= INT64_C(10);
c++;
}

Expand Down
6 changes: 3 additions & 3 deletions src/ecdsa_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
* 'fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141'
*/
static const secp256k1_fe secp256k1_ecdsa_const_order_as_fe = SECP256K1_FE_CONST(
0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFFUL, 0xFFFFFFFEUL,
0xBAAEDCE6UL, 0xAF48A03BUL, 0xBFD25E8CUL, 0xD0364141UL
UINT32_C(0xFFFFFFFF), UINT32_C(0xFFFFFFFF), UINT32_C(0xFFFFFFFF), UINT32_C(0xFFFFFFFE),
UINT32_C(0xBAAEDCE6), UINT32_C(0xAF48A03B), UINT32_C(0xBFD25E8C), UINT32_C(0xD0364141)
);

/** Difference between field and order, values 'p' and 'n' values defined in
Expand All @@ -43,7 +43,7 @@ static const secp256k1_fe secp256k1_ecdsa_const_order_as_fe = SECP256K1_FE_CONST
* '14551231950b75fc4402da1722fc9baee'
*/
static const secp256k1_fe secp256k1_ecdsa_const_p_minus_order = SECP256K1_FE_CONST(
0, 0, 0, 1, 0x45512319UL, 0x50B75FC4UL, 0x402DA172UL, 0x2FC9BAEEUL
0, 0, 0, 1, UINT32_C(0x45512319), UINT32_C(0x50B75FC4), UINT32_C(0x402DA172), UINT32_C(0x2FC9BAEE)
);

static int secp256k1_der_read_len(size_t *len, const unsigned char **sigp, const unsigned char *sigend) {
Expand Down
18 changes: 9 additions & 9 deletions src/field_10x26.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ typedef struct {

/* Unpacks a constant into a overlapping multi-limbed FE element. */
#define SECP256K1_FE_CONST_INNER(d7, d6, d5, d4, d3, d2, d1, d0) { \
(d0) & 0x3FFFFFFUL, \
(((uint32_t)d0) >> 26) | (((uint32_t)(d1) & 0xFFFFFUL) << 6), \
(((uint32_t)d1) >> 20) | (((uint32_t)(d2) & 0x3FFFUL) << 12), \
(((uint32_t)d2) >> 14) | (((uint32_t)(d3) & 0xFFUL) << 18), \
(((uint32_t)d3) >> 8) | (((uint32_t)(d4) & 0x3UL) << 24), \
(((uint32_t)d4) >> 2) & 0x3FFFFFFUL, \
(((uint32_t)d4) >> 28) | (((uint32_t)(d5) & 0x3FFFFFUL) << 4), \
(((uint32_t)d5) >> 22) | (((uint32_t)(d6) & 0xFFFFUL) << 10), \
(((uint32_t)d6) >> 16) | (((uint32_t)(d7) & 0x3FFUL) << 16), \
(d0) & UINT32_C(0x3FFFFFF), \
(((uint32_t)d0) >> 26) | (((uint32_t)(d1) & UINT32_C(0xFFFFF)) << 6), \
(((uint32_t)d1) >> 20) | (((uint32_t)(d2) & UINT32_C(0x3FFF)) << 12), \
(((uint32_t)d2) >> 14) | (((uint32_t)(d3) & UINT32_C(0xFF)) << 18), \
(((uint32_t)d3) >> 8) | (((uint32_t)(d4) & UINT32_C(0x3)) << 24), \
(((uint32_t)d4) >> 2) & UINT32_C(0x3FFFFFF), \
(((uint32_t)d4) >> 28) | (((uint32_t)(d5) & UINT32_C(0x3FFFFF)) << 4), \
(((uint32_t)d5) >> 22) | (((uint32_t)(d6) & UINT32_C(0xFFFF)) << 10), \
(((uint32_t)d6) >> 16) | (((uint32_t)(d7) & UINT32_C(0x3FF)) << 16), \
(((uint32_t)d7) >> 10) \
}

Expand Down
Loading