Skip to content

Commit b0d2fe0

Browse files
int128: Tidy #includes of int128.h and int128_impl.h
After this commit, int128.h and int128_impl.h are included as follows: - .c files which use int128 include int128_impl.h (after util.h) - .h files which use int128 include int128.h (after util.h) This list is exhaustive. util.h needs to included first because it sets up necessary #defines.
1 parent fdae996 commit b0d2fe0

8 files changed

+31
-23
lines changed

src/field_5x52_int128_impl.h

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
#include <stdint.h>
1111

12+
#include "int128.h"
13+
1214
#ifdef VERIFY
1315
#define VERIFY_BITS(x, n) VERIFY_CHECK(((x) >> (n)) == 0)
1416
#define VERIFY_BITS_128(x, n) VERIFY_CHECK(secp256k1_u128_check_bits((x), (n)))

src/int128.h

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
#ifndef SECP256K1_INT128_H
22
#define SECP256K1_INT128_H
33

4-
#if defined HAVE_CONFIG_H
5-
#include "libsecp256k1-config.h"
6-
#endif
7-
84
#include "util.h"
95

10-
#if defined(SECP256K1_INT128_NATIVE)
11-
#include "int128_native.h"
12-
#elif defined(SECP256K1_INT128_STRUCT)
13-
#include "int128_struct.h"
14-
#else
15-
#error "Please select int128 implementation"
16-
#endif
6+
#if defined(SECP256K1_WIDEMUL_INT128)
7+
# if defined(SECP256K1_INT128_NATIVE)
8+
# include "int128_native.h"
9+
# elif defined(SECP256K1_INT128_STRUCT)
10+
# include "int128_struct.h"
11+
# else
12+
# error "Please select int128 implementation"
13+
# endif
1714

1815
static SECP256K1_INLINE void secp256k1_u128_mul(secp256k1_uint128 *r, uint64_t a, uint64_t b);
1916

@@ -54,3 +51,5 @@ static SECP256K1_INLINE int secp256k1_i128_eq(const secp256k1_int128 *a, const s
5451
static SECP256K1_INLINE int secp256k1_i128_check_bit(secp256k1_int128 *r, unsigned int n);
5552

5653
#endif
54+
55+
#endif

src/int128_impl.h

+9-10
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,18 @@
77
#ifndef SECP256K1_INT128_IMPL_H
88
#define SECP256K1_INT128_IMPL_H
99

10-
#include "int128.h"
1110
#include "util.h"
1211

13-
#if defined HAVE_CONFIG_H
14-
#include "libsecp256k1-config.h"
15-
#endif
12+
#include "int128.h"
1613

17-
#if defined(SECP256K1_INT128_NATIVE)
18-
#include "int128_native_impl.h"
19-
#elif defined(SECP256K1_INT128_STRUCT)
20-
#include "int128_struct_impl.h"
21-
#else
22-
#error "Please select int128 implementation"
14+
#if defined(SECP256K1_WIDEMUL_INT128)
15+
# if defined(SECP256K1_INT128_NATIVE)
16+
# include "int128_native_impl.h"
17+
# elif defined(SECP256K1_INT128_STRUCT)
18+
# include "int128_struct_impl.h"
19+
# else
20+
# error "Please select int128 implementation"
21+
# endif
2322
#endif
2423

2524
#endif

src/modinv64_impl.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
#ifndef SECP256K1_MODINV64_IMPL_H
88
#define SECP256K1_MODINV64_IMPL_H
99

10+
#include "int128.h"
1011
#include "modinv64.h"
1112

12-
#include "int128_impl.h"
13-
1413
/* This file implements modular inversion based on the paper "Fast constant-time gcd computation and
1514
* modular inversion" by Daniel J. Bernstein and Bo-Yin Yang.
1615
*

src/precompute_ecmult.c

+3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414
#endif
1515

1616
#include "../include/secp256k1.h"
17+
1718
#include "assumptions.h"
1819
#include "util.h"
20+
1921
#include "field_impl.h"
2022
#include "group_impl.h"
23+
#include "int128_impl.h"
2124
#include "ecmult.h"
2225
#include "ecmult_compute_table_impl.h"
2326

src/precompute_ecmult_gen.c

+3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
#include <stdio.h>
99

1010
#include "../include/secp256k1.h"
11+
1112
#include "assumptions.h"
1213
#include "util.h"
14+
1315
#include "group.h"
16+
#include "int128_impl.h"
1417
#include "ecmult_gen.h"
1518
#include "ecmult_gen_compute_table_impl.h"
1619

src/scalar_4x64_impl.h

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef SECP256K1_SCALAR_REPR_IMPL_H
88
#define SECP256K1_SCALAR_REPR_IMPL_H
99

10+
#include "int128.h"
1011
#include "modinv64_impl.h"
1112

1213
/* Limbs of the secp256k1 order. */

src/secp256k1.c

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "assumptions.h"
1313
#include "util.h"
14+
1415
#include "field_impl.h"
1516
#include "scalar_impl.h"
1617
#include "group_impl.h"
@@ -20,6 +21,7 @@
2021
#include "ecdsa_impl.h"
2122
#include "eckey_impl.h"
2223
#include "hash_impl.h"
24+
#include "int128_impl.h"
2325
#include "scratch_impl.h"
2426
#include "selftest.h"
2527

0 commit comments

Comments
 (0)