Skip to content

Commit

Permalink
cleanup: remove unneeded includes in C files.
Browse files Browse the repository at this point in the history
Before:
 Ten builds, laptop -j5, no ccache:

```
real	0m36.686000-38.956000(38.608+/-0.65)s
user	2m32.864000-42.253000(40.7545+/-2.7)s
sys	0m16.618000-18.316000(17.8531+/-0.48)s
```

 Ten builds, laptop -j5, ccache (warm):

```
real	0m8.212000-8.577000(8.39989+/-0.13)s
user	0m12.731000-13.212000(12.9751+/-0.17)s
sys	0m3.697000-3.902000(3.83722+/-0.064)s
```

After:
 Ten builds, laptop -j5, no ccache: 8% faster

```
real	0m33.802000-35.773000(35.468+/-0.54)s
user	2m19.073000-27.754000(26.2542+/-2.3)s
sys	0m15.784000-17.173000(16.7165+/-0.37)s
```

 Ten builds, laptop -j5, ccache (warm): 1% faster

```
real	0m8.200000-8.485000(8.30138+/-0.097)s
user	0m12.485000-13.100000(12.7344+/-0.19)s
sys	0m3.702000-3.889000(3.78787+/-0.056)s
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Sep 17, 2021
1 parent ea30c34 commit 7401b26
Show file tree
Hide file tree
Showing 250 changed files with 369 additions and 1,715 deletions.
4 changes: 0 additions & 4 deletions bitcoin/base58.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
#include "privkey.h"
#include "pubkey.h"
#include "shadouble.h"
#include <assert.h>
#include <ccan/build_assert/build_assert.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <string.h>
#include <wally_core.h>

static char *to_base58(const tal_t *ctx, u8 version,
Expand Down
3 changes: 1 addition & 2 deletions bitcoin/block.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#include "config.h"
#include <assert.h>
#include <bitcoin/block.h>
#include <bitcoin/chainparams.h>
#include <bitcoin/tx.h>
#include <ccan/mem/mem.h>
#include <ccan/str/hex/hex.h>
#include <common/type_to_string.h>
#include <wire/wire.h>
#include <bitcoin/block.h>

/* Sets *cursor to NULL and returns NULL when a pull fails. */
static const u8 *pull(const u8 **cursor, size_t *max, void *copy, size_t n)
Expand Down
2 changes: 0 additions & 2 deletions bitcoin/chainparams.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#include "chainparams.h"
#include <ccan/array_size/array_size.h>
#include <ccan/str/str.h>
#include <ccan/tal/str/str.h>
#include <common/utils.h>
#include <string.h>

/* Version codes for BIP32 extended keys in libwally-core.
* Stolen from wally_bip32.h in libwally-core*/
Expand Down
3 changes: 0 additions & 3 deletions bitcoin/feerate.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#include <bitcoin/feerate.h>
#include <bitcoin/varint.h>
#include <limits.h>
#include <stdlib.h>

u32 feerate_from_style(u32 feerate, enum feerate_style style)
{
Expand Down
2 changes: 0 additions & 2 deletions bitcoin/privkey.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#include "privkey.h"
#include <assert.h>
#include <ccan/mem/mem.h>
#include <ccan/str/hex/hex.h>
#include <common/type_to_string.h>
#include <wire/wire.h>
Expand Down
5 changes: 0 additions & 5 deletions bitcoin/psbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@
#include <bitcoin/psbt.h>
#include <bitcoin/pubkey.h>
#include <bitcoin/script.h>
#include <bitcoin/signature.h>
#include <ccan/ccan/array_size/array_size.h>
#include <ccan/ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/amount.h>
#include <common/type_to_string.h>
#include <common/utils.h>
#include <string.h>
#include <wally_psbt.h>
#include <wally_transaction.h>
#include <wire/wire.h>


Expand Down
1 change: 0 additions & 1 deletion bitcoin/pubkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <ccan/mem/mem.h>
#include <ccan/str/hex/hex.h>
#include <common/type_to_string.h>
#include <common/utils.h>
#include <wire/wire.h>

#ifndef SUPERVERBOSE
Expand Down
2 changes: 0 additions & 2 deletions bitcoin/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include "pubkey.h"
#include "script.h"
#include <assert.h>
#include <ccan/crypto/ripemd160/ripemd160.h>
#include <ccan/crypto/sha256/sha256.h>
#include <ccan/endian/endian.h>
#include <ccan/mem/mem.h>
#include <common/utils.h>
Expand Down
1 change: 0 additions & 1 deletion bitcoin/short_channel_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <ccan/tal/str/str.h>
#include <common/type_to_string.h>
#include <stdio.h>
#include <string.h>
#include <wire/wire.h>

/* BOLT#07:
Expand Down
2 changes: 0 additions & 2 deletions bitcoin/signature.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
#include "tx.h"
#include <assert.h>
#include <bitcoin/psbt.h>
#include <ccan/cast/cast.h>
#include <ccan/mem/mem.h>
#include <common/type_to_string.h>
#include <common/utils.h>
#include <wire/wire.h>

#undef DEBUG
Expand Down
1 change: 1 addition & 0 deletions bitcoin/test/run-bitcoin_block_from_hex.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "../varint.c"
#include <assert.h>
#include <common/setup.h>
#include <stdio.h>

/* AUTOGENERATED MOCKS START */
/* Generated stub for amount_asset_is_main */
Expand Down
1 change: 1 addition & 0 deletions bitcoin/test/run-tx-encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <ccan/str/hex/hex.h>
#include <common/setup.h>
#include <common/utils.h>
#include <stdio.h>

/* AUTOGENERATED MOCKS START */
/* Generated stub for amount_asset_is_main */
Expand Down
8 changes: 1 addition & 7 deletions bitcoin/tx.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
#include "config.h"
#include <assert.h>
#include <bitcoin/block.h>
#include <bitcoin/chainparams.h>
#include <bitcoin/psbt.h>
#include <bitcoin/script.h>
#include <bitcoin/tx.h>
#include <ccan/crypto/sha256/sha256.h>
#include <ccan/endian/endian.h>
#include <ccan/mem/mem.h>
#include <ccan/read_write_all/read_write_all.h>
#include <ccan/str/hex/hex.h>
#include <common/type_to_string.h>
#include <stdio.h>
#include <wally_psbt.h>
#include <wire/wire.h>
#include <bitcoin/tx.h>

#define SEGREGATED_WITNESS_FLAG 0x1

Expand Down
28 changes: 0 additions & 28 deletions channeld/channeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,67 +10,39 @@
* reading and writing synchronously we could deadlock if we hit buffer
* limits, unlikely as that is.
*/
#include <bitcoin/chainparams.h>
#include <bitcoin/privkey.h>
#include <bitcoin/psbt.h>
#include <bitcoin/script.h>
#include <ccan/array_size/array_size.h>
#include <ccan/asort/asort.h>
#include <ccan/cast/cast.h>
#include <ccan/container_of/container_of.h>
#include <ccan/crypto/hkdf_sha256/hkdf_sha256.h>
#include <ccan/crypto/shachain/shachain.h>
#include <ccan/err/err.h>
#include <ccan/fdpass/fdpass.h>
#include <ccan/mem/mem.h>
#include <ccan/take/take.h>
#include <ccan/tal/str/str.h>
#include <ccan/time/time.h>
#include <channeld/channeld_wiregen.h>
#include <channeld/commit_tx.h>
#include <channeld/full_channel.h>
#include <channeld/watchtower.h>
#include <common/billboard.h>
#include <common/blinding.h>
#include <common/bolt12.h>
#include <common/channel_type.h>
#include <common/coin_mvt.h>
#include <common/crypto_sync.h>
#include <common/dev_disconnect.h>
#include <common/ecdh_hsmd.h>
#include <common/gossip_constants.h>
#include <common/gossip_store.h>
#include <common/htlc_tx.h>
#include <common/key_derive.h>
#include <common/memleak.h>
#include <common/msg_queue.h>
#include <common/node_id.h>
#include <common/onionreply.h>
#include <common/peer_billboard.h>
#include <common/peer_failed.h>
#include <common/ping.h>
#include <common/private_channel_announcement.h>
#include <common/psbt_open.h>
#include <common/read_peer_msg.h>
#include <common/status.h>
#include <common/subdaemon.h>
#include <common/timeout.h>
#include <common/type_to_string.h>
#include <common/version.h>
#include <common/wire_error.h>
#include <errno.h>
#include <fcntl.h>
#include <gossipd/gossip_store_wiregen.h>
#include <gossipd/gossipd_peerd_wiregen.h>
#include <hsmd/hsmd_wiregen.h>
#include <inttypes.h>
#include <secp256k1.h>
#include <stdio.h>
#include <wire/common_wiregen.h>
#include <wire/onion_wire.h>
#include <wire/peer_wire.h>
#include <wire/wire.h>
#include <wire/wire_io.h>
#include <wire/wire_sync.h>

/* stdin == requests, 3 == peer, 4 = gossip, 5 = gossip_store, 6 = HSM */
Expand Down
3 changes: 0 additions & 3 deletions channeld/commit_tx.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#include <bitcoin/script.h>
#include <bitcoin/tx.h>
#include <ccan/endian/endian.h>
#include <channeld/commit_tx.h>
#include <common/htlc_trim.h>
#include <common/htlc_tx.h>
#include <common/keyset.h>
#include <common/permute_tx.h>
#include <common/utils.h>

#ifndef SUPERVERBOSE
#define SUPERVERBOSE(...)
Expand Down
15 changes: 0 additions & 15 deletions channeld/full_channel.c
Original file line number Diff line number Diff line change
@@ -1,34 +1,19 @@
#include "config.h"
#include <assert.h>
#include <bitcoin/chainparams.h>
#include <bitcoin/preimage.h>
#include <bitcoin/psbt.h>
#include <bitcoin/script.h>
#include <bitcoin/tx.h>
#include <ccan/array_size/array_size.h>
#include <ccan/cast/cast.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <channeld/commit_tx.h>
#include <channeld/full_channel.h>
#include <channeld/full_channel_error.h>
#include <common/blockheight_states.h>
#include <common/channel_config.h>
#include <common/features.h>
#include <common/fee_states.h>
#include <common/htlc.h>
#include <common/htlc_trim.h>
#include <common/htlc_tx.h>
#include <common/htlc_wire.h>
#include <common/key_derive.h>
#include <common/keyset.h>
#include <common/memleak.h>
#include <common/onionreply.h>
#include <common/status.h>
#include <common/type_to_string.h>
#include <inttypes.h>
#include <stdio.h>
#include <string.h>
/* Needs to be at end, since it doesn't include its own hdrs */
#include "full_channel_error_names_gen.h"

Expand Down
4 changes: 0 additions & 4 deletions channeld/test/run-commit_tx.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
#include <inttypes.h>
#include <stdio.h>
#include <common/channel_type.h>
#include <common/type_to_string.h>
static bool print_superverbose;
#define SUPERVERBOSE(...) \
do { if (print_superverbose) printf(__VA_ARGS__); } while(0)
#define PRINT_ACTUAL_FEE
#include "../commit_tx.c"
#include <bitcoin/preimage.h>
#include <bitcoin/privkey.h>
#include <bitcoin/pubkey.h>
#include <ccan/array_size/array_size.h>
#include <ccan/err/err.h>
#include <ccan/str/hex/hex.h>
#include <common/amount.h>
#include <common/channel_id.h>
#include <common/key_derive.h>
#include <common/setup.h>
Expand Down
9 changes: 0 additions & 9 deletions channeld/test/run-full_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,8 @@
#include "../../common/keyset.c"
#include "../full_channel.c"
#include "../commit_tx.c"
#include <bitcoin/preimage.h>
#include <bitcoin/privkey.h>
#include <bitcoin/pubkey.h>
#include <ccan/err/err.h>
#include <ccan/str/hex/hex.h>
#include <common/amount.h>
#include <common/setup.h>
#include <common/sphinx.h>
#include <common/type_to_string.h>
#include <stdio.h>
#include <wally_core.h>

/* AUTOGENERATED MOCKS START */
/* Generated stub for fromwire_bigsize */
Expand Down
3 changes: 0 additions & 3 deletions channeld/watchtower.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

#include <bitcoin/feerate.h>
#include <bitcoin/script.h>
#include <bitcoin/signature.h>
#include <bitcoin/tx.h>
#include <common/features.h>
#include <common/htlc_tx.h>
#include <common/key_derive.h>
#include <common/keyset.h>
#include <common/status.h>
#include <common/type_to_string.h>
Expand Down
5 changes: 0 additions & 5 deletions cli/lightning-cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,21 @@
* Helper to submit via JSON-RPC and get back response.
*/
#include "config.h"
#include <assert.h>
#include <ccan/asort/asort.h>
#include <ccan/err/err.h>
#include <ccan/json_escape/json_escape.h>
#include <ccan/opt/opt.h>
#include <ccan/read_write_all/read_write_all.h>
#include <ccan/str/str.h>
#include <ccan/tal/path/path.h>
#include <ccan/tal/str/str.h>
#include <common/configdir.h>
#include <common/json.h>
#include <common/json_command.h>
#include <common/memleak.h>
#include <common/status_levels.h>
#include <common/utils.h>
#include <common/version.h>
#include <libgen.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
#include <sys/wait.h>
#include <unistd.h>
Expand Down
5 changes: 0 additions & 5 deletions cli/test/run-human-mode.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
#include "config.h"
#include <assert.h>
#include <common/amount.h>
#include <common/bigsize.h>
#include <common/channel_id.h>
#include <common/json_stream.h>
#include <common/node_id.h>
#include <common/wireaddr.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

int test_main(int argc, char *argv[]);
ssize_t test_read(int fd, void *buf, size_t len);
Expand Down
5 changes: 0 additions & 5 deletions cli/test/run-large-input.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
#include "config.h"
#include <assert.h>
#include <common/amount.h>
#include <common/bigsize.h>
#include <common/channel_id.h>
#include <common/json_stream.h>
#include <common/node_id.h>
#include <common/wireaddr.h>
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

int test_main(int argc, char *argv[]);
ssize_t test_read(int fd, void *buf, size_t len);
Expand Down
5 changes: 0 additions & 5 deletions cli/test/run-remove-hint.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
#include "config.h"
#include <assert.h>
#include <common/amount.h>
#include <common/bigsize.h>
#include <common/channel_id.h>
#include <common/json_stream.h>
#include <common/node_id.h>
#include <common/wireaddr.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

int test_main(int argc, char *argv[]);
ssize_t test_read(int fd, void *buf, size_t len);
Expand Down
2 changes: 0 additions & 2 deletions common/amount.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#include "config.h"
#include <assert.h>
#include <bitcoin/chainparams.h>
#include <ccan/endian/endian.h>
#include <ccan/mem/mem.h>
#include <ccan/tal/str/str.h>
#include <common/amount.h>
#include <common/overflows.h>
#include <common/type_to_string.h>
#include <common/utils.h>
#include <inttypes.h>
#include <wire/wire.h>

Expand Down
Loading

0 comments on commit 7401b26

Please sign in to comment.