Skip to content

Commit 54e6804

Browse files
committed
amalgamation: include ccan_config.h explicitly, protect from multiple inclusion
With this change, users of the amalgamation only need to provide wally-specific defines in their config.h.
1 parent dc0821d commit 54e6804

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/amalgamation/combined.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,19 @@
3333
#include "src/secp256k1/src/secp256k1.c"
3434
#include "src/secp256k1/src/precomputed_ecmult_gen.c"
3535
#include "src/secp256k1/src/precomputed_ecmult.c"
36-
#include "src/ccan/ccan/crypto/sha256/sha256.c"
36+
37+
/* Force the inclusion of our internal header first, so that
38+
* config.h (which must be provided by the amalgamation user)
39+
* is included.
40+
*/
41+
#include "src/internal.h"
42+
43+
/* The amalgamation user can provide their own defines and skip
44+
* providing a ccan_config.h if they define _WALLY_CCAN_CONFIG_H_.
45+
*/
46+
#ifndef _WALLY_CCAN_CONFIG_H_
47+
#include "src/ccan_config.h"
48+
#endif
3749

3850
#include "src/internal.c"
3951
#include "src/address.c"
@@ -66,6 +78,9 @@
6678
#include "src/wif.c"
6779
#include "src/wordlist.c"
6880

81+
/* ccan sources */
82+
#include "src/ccan/ccan/crypto/sha256/sha256.c"
83+
6984
/* Redefine internal names so sha-512 can be included without conflicts */
7085
#define Round Round_512
7186
#define Transform Transform_512

src/ccan_config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
#ifndef _WALLY_CCAN_CONFIG_H_
2+
#define _WALLY_CCAN_CONFIG_H_ 1
3+
14
/* Config directives for ccan */
5+
26
#include <stddef.h>
37

48
#ifdef WORDS_BIGENDIAN
@@ -55,3 +59,5 @@
5559
void wally_clear(void *p, size_t len);
5660

5761
#define CCAN_CLEAR_MEMORY(p, len) wally_clear(p, len)
62+
63+
#endif /*_WALLY_CCAN_CONFIG_H_ */

0 commit comments

Comments
 (0)