diff options
| author | Garrett D'Amore <garrett@damore.org> | 2025-10-09 19:24:37 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2025-10-10 06:51:58 -0700 |
| commit | ea65f9503c80c33fb236703a7e81747bcb94666b (patch) | |
| tree | be20fb0854295dd28d28c44f5d471506d5f79ecc /src | |
| parent | f41cd6a9edf4b9a680194b3fb4378f39d1ed1f34 (diff) | |
| download | nng-ea65f9503c80c33fb236703a7e81747bcb94666b.tar.gz nng-ea65f9503c80c33fb236703a7e81747bcb94666b.tar.bz2 nng-ea65f9503c80c33fb236703a7e81747bcb94666b.zip | |
header file refactoring for IWYU (protocols)
This changes the header files mostly in the protocols to include
directly rather than through the commmon nng_impl.h header. This
should lead to faster compiles, and by properly making all includes
relative should reduce friction with language servers and other tooling.
Diffstat (limited to 'src')
35 files changed, 159 insertions, 79 deletions
diff --git a/src/core/defs.h b/src/core/defs.h index 23c17d8b..97d3dd06 100644 --- a/src/core/defs.h +++ b/src/core/defs.h @@ -12,6 +12,7 @@ #define CORE_DEFS_H #include <stdbool.h> +#include <stddef.h> #include <stdint.h> #include "nng/nng.h" diff --git a/src/sp/protocol/bus0/bus.c b/src/sp/protocol/bus0/bus.c index 4f946365..0bbfb031 100644 --- a/src/sp/protocol/bus0/bus.c +++ b/src/sp/protocol/bus0/bus.c @@ -8,11 +8,13 @@ // found online at https://opensource.org/licenses/MIT. // -#include <stdbool.h> -#include <stdlib.h> - -#include "core/nng_impl.h" -#include <stdio.h> +#include "../../../core/aio.h" +#include "../../../core/defs.h" +#include "../../../core/lmq.h" +#include "../../../core/message.h" +#include "../../../core/pipe.h" +#include "../../../core/pollable.h" +#include "../../../core/protocol.h" // Bus protocol. The BUS protocol, each peer sends a message to its peers. // However, bus protocols do not "forward" (absent a device). So in order diff --git a/src/sp/protocol/bus0/bus_test.c b/src/sp/protocol/bus0/bus_test.c index b1141d93..d7f38255 100644 --- a/src/sp/protocol/bus0/bus_test.c +++ b/src/sp/protocol/bus0/bus_test.c @@ -7,8 +7,7 @@ // found online at https://opensource.org/licenses/MIT. // -#include "nng/nng.h" -#include <nuts.h> +#include "../../../testing/nuts.h" #define SECOND 1000 diff --git a/src/sp/protocol/pair0/pair.c b/src/sp/protocol/pair0/pair.c index 89bff7ce..bf895858 100644 --- a/src/sp/protocol/pair0/pair.c +++ b/src/sp/protocol/pair0/pair.c @@ -8,10 +8,13 @@ // found online at https://opensource.org/licenses/MIT. // -#include <stdlib.h> - -#include "core/nng_impl.h" -#include "core/pipe.h" +#include "../../../core/aio.h" +#include "../../../core/defs.h" +#include "../../../core/lmq.h" +#include "../../../core/message.h" +#include "../../../core/pipe.h" +#include "../../../core/pollable.h" +#include "../../../core/protocol.h" // Pair protocol. The PAIR protocol is a simple 1:1 messaging pattern. // While a peer is connected to the server, all other peer connection diff --git a/src/sp/protocol/pair1/pair.c b/src/sp/protocol/pair1/pair.c index 486b2a37..bddde6f8 100644 --- a/src/sp/protocol/pair1/pair.c +++ b/src/sp/protocol/pair1/pair.c @@ -8,9 +8,16 @@ // found online at https://opensource.org/licenses/MIT. // -#include <stdlib.h> - -#include "../../../core/nng_impl.h" +#include "../../../core/aio.h" +#include "../../../core/defs.h" +#include "../../../core/list.h" +#include "../../../core/lmq.h" +#include "../../../core/message.h" +#include "../../../core/pipe.h" +#include "../../../core/platform.h" +#include "../../../core/pollable.h" +#include "../../../core/protocol.h" +#include "../../../core/socket.h" // Pair protocol. The PAIRv1 protocol is a simple 1:1 messaging pattern. diff --git a/src/sp/protocol/pair1/pair1_poly.c b/src/sp/protocol/pair1/pair1_poly.c index af3ede3b..9c34cd00 100644 --- a/src/sp/protocol/pair1/pair1_poly.c +++ b/src/sp/protocol/pair1/pair1_poly.c @@ -8,9 +8,15 @@ // found online at https://opensource.org/licenses/MIT. // -#include <stdlib.h> - -#include "core/nng_impl.h" +#include "../../../core/aio.h" +#include "../../../core/defs.h" +#include "../../../core/idhash.h" +#include "../../../core/message.h" +#include "../../../core/msgqueue.h" +#include "../../../core/pipe.h" +#include "../../../core/protocol.h" +#include "../../../core/socket.h" +#include "../../../core/stats.h" #define PAIR1_SELF_NAME "pair1" #define PAIR1_PEER_NAME "pair1" diff --git a/src/sp/protocol/pair1/pair1_poly_test.c b/src/sp/protocol/pair1/pair1_poly_test.c index 40e84d30..516baf81 100644 --- a/src/sp/protocol/pair1/pair1_poly_test.c +++ b/src/sp/protocol/pair1/pair1_poly_test.c @@ -1,5 +1,5 @@ // -// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2017 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a @@ -8,7 +8,7 @@ // found online at https://opensource.org/licenses/MIT. // -#include <nuts.h> +#include "../../../testing/nuts.h" #define SECOND 1000 diff --git a/src/sp/protocol/pair1/pair1_test.c b/src/sp/protocol/pair1/pair1_test.c index 8baf139b..c0b2acd9 100644 --- a/src/sp/protocol/pair1/pair1_test.c +++ b/src/sp/protocol/pair1/pair1_test.c @@ -8,8 +8,7 @@ // found online at https://opensource.org/licenses/MIT. // -#include "nng/nng.h" -#include "nuts.h" +#include "../../../testing/nuts.h" #define SECOND 1000 diff --git a/src/sp/protocol/pipeline0/pull.c b/src/sp/protocol/pipeline0/pull.c index 559935b0..f295556d 100644 --- a/src/sp/protocol/pipeline0/pull.c +++ b/src/sp/protocol/pipeline0/pull.c @@ -8,9 +8,13 @@ // found online at https://opensource.org/licenses/MIT. // -#include <stdlib.h> - -#include "core/nng_impl.h" +#include "../../../core/aio.h" +#include "../../../core/defs.h" +#include "../../../core/list.h" +#include "../../../core/message.h" +#include "../../../core/pipe.h" +#include "../../../core/pollable.h" +#include "../../../core/protocol.h" // Pull protocol. The PULL protocol is the "read" side of a pipeline. diff --git a/src/sp/protocol/pipeline0/pull_test.c b/src/sp/protocol/pipeline0/pull_test.c index 32134082..2f538093 100644 --- a/src/sp/protocol/pipeline0/pull_test.c +++ b/src/sp/protocol/pipeline0/pull_test.c @@ -7,8 +7,7 @@ // found online at https://opensource.org/licenses/MIT. // -#include "nng/nng.h" -#include <nuts.h> +#include "../../../testing/nuts.h" static void test_pull_identity(void) diff --git a/src/sp/protocol/pipeline0/push.c b/src/sp/protocol/pipeline0/push.c index cd710480..3be746c9 100644 --- a/src/sp/protocol/pipeline0/push.c +++ b/src/sp/protocol/pipeline0/push.c @@ -10,7 +10,13 @@ #include <stdlib.h> -#include "core/nng_impl.h" +#include "../../../core/aio.h" +#include "../../../core/defs.h" +#include "../../../core/lmq.h" +#include "../../../core/message.h" +#include "../../../core/pipe.h" +#include "../../../core/pollable.h" +#include "../../../core/protocol.h" // Push protocol. The PUSH protocol is the "write" side of a pipeline. // Push distributes fairly, or tries to, by giving messages in round-robin diff --git a/src/sp/protocol/pipeline0/push_test.c b/src/sp/protocol/pipeline0/push_test.c index c2a99fb5..8e564215 100644 --- a/src/sp/protocol/pipeline0/push_test.c +++ b/src/sp/protocol/pipeline0/push_test.c @@ -7,8 +7,7 @@ // found online at https://opensource.org/licenses/MIT. // -#include "nng/nng.h" -#include <nuts.h> +#include "../../../testing/nuts.h" static void test_push_identity(void) diff --git a/src/sp/protocol/pubsub0/pub.c b/src/sp/protocol/pubsub0/pub.c index c753b8af..bc0e5d66 100644 --- a/src/sp/protocol/pubsub0/pub.c +++ b/src/sp/protocol/pubsub0/pub.c @@ -8,9 +8,14 @@ // found online at https://opensource.org/licenses/MIT. // -#include <string.h> - -#include "../../../core/nng_impl.h" +#include "../../../core/aio.h" +#include "../../../core/defs.h" +#include "../../../core/lmq.h" +#include "../../../core/message.h" +#include "../../../core/pipe.h" +#include "../../../core/pollable.h" +#include "../../../core/protocol.h" +#include "../../../core/socket.h" // Publish protocol. The PUB protocol simply sends messages out, as // a broadcast. It has nothing more sophisticated because it does not diff --git a/src/sp/protocol/pubsub0/pub_test.c b/src/sp/protocol/pubsub0/pub_test.c index 3018ced9..1cef9d1c 100644 --- a/src/sp/protocol/pubsub0/pub_test.c +++ b/src/sp/protocol/pubsub0/pub_test.c @@ -7,8 +7,7 @@ // found online at https://opensource.org/licenses/MIT. // -#include "nng/nng.h" -#include <nuts.h> +#include "../../../testing/nuts.h" static void test_pub_identity(void) diff --git a/src/sp/protocol/pubsub0/sub.c b/src/sp/protocol/pubsub0/sub.c index c426d46c..487d82c8 100644 --- a/src/sp/protocol/pubsub0/sub.c +++ b/src/sp/protocol/pubsub0/sub.c @@ -9,10 +9,16 @@ // found online at https://opensource.org/licenses/MIT. // -#include <stdbool.h> #include <string.h> -#include "core/nng_impl.h" +#include "../../../core/aio.h" +#include "../../../core/defs.h" +#include "../../../core/lmq.h" +#include "../../../core/message.h" +#include "../../../core/pipe.h" +#include "../../../core/pollable.h" +#include "../../../core/protocol.h" +#include "../../../core/socket.h" // Subscriber protocol. The SUB protocol receives messages sent to // it from publishers, and filters out those it is not interested in, diff --git a/src/sp/protocol/pubsub0/sub_test.c b/src/sp/protocol/pubsub0/sub_test.c index 7f4e4480..810003c1 100644 --- a/src/sp/protocol/pubsub0/sub_test.c +++ b/src/sp/protocol/pubsub0/sub_test.c @@ -7,8 +7,7 @@ // found online at https://opensource.org/licenses/MIT. // -#include "nng/nng.h" -#include <nuts.h> +#include "../../../testing/nuts.h" static void test_sub_identity(void) diff --git a/src/sp/protocol/pubsub0/xsub.c b/src/sp/protocol/pubsub0/xsub.c index cb2a5362..7fdcf341 100644 --- a/src/sp/protocol/pubsub0/xsub.c +++ b/src/sp/protocol/pubsub0/xsub.c @@ -1,5 +1,5 @@ // -// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a @@ -10,7 +10,13 @@ #include <stdlib.h> -#include "core/nng_impl.h" +#include "../../../core/aio.h" +#include "../../../core/defs.h" +#include "../../../core/message.h" +#include "../../../core/msgqueue.h" +#include "../../../core/pipe.h" +#include "../../../core/protocol.h" +#include "../../../core/socket.h" // Subscriber protocol. The SUB protocol receives messages sent to // it from publishers, and filters out those it is not interested in, diff --git a/src/sp/protocol/pubsub0/xsub_test.c b/src/sp/protocol/pubsub0/xsub_test.c index 859ab532..2f42a363 100644 --- a/src/sp/protocol/pubsub0/xsub_test.c +++ b/src/sp/protocol/pubsub0/xsub_test.c @@ -7,8 +7,7 @@ // found online at https://opensource.org/licenses/MIT. // -#include <nng/nng.h> -#include <nuts.h> +#include "../../../testing/nuts.h" static void test_xsub_identity(void) diff --git a/src/sp/protocol/reqrep0/rep.c b/src/sp/protocol/reqrep0/rep.c index 6df65df3..ea3e9558 100644 --- a/src/sp/protocol/reqrep0/rep.c +++ b/src/sp/protocol/reqrep0/rep.c @@ -10,7 +10,14 @@ #include <string.h> -#include "core/nng_impl.h" +#include "../../../core/aio.h" +#include "../../../core/defs.h" +#include "../../../core/idhash.h" +#include "../../../core/list.h" +#include "../../../core/message.h" +#include "../../../core/pipe.h" +#include "../../../core/pollable.h" +#include "../../../core/protocol.h" // Response protocol. The REP protocol is the "reply" side of a // request-reply pair. This is useful for building RPC servers, for diff --git a/src/sp/protocol/reqrep0/rep_test.c b/src/sp/protocol/reqrep0/rep_test.c index 7c788d96..a8370880 100644 --- a/src/sp/protocol/reqrep0/rep_test.c +++ b/src/sp/protocol/reqrep0/rep_test.c @@ -7,8 +7,7 @@ // found online at https://opensource.org/licenses/MIT. // -#include "nng/nng.h" -#include <nuts.h> +#include "../../../testing/nuts.h" #define REP0_SELF 0x31 #define REP0_PEER 0x30 diff --git a/src/sp/protocol/reqrep0/req.c b/src/sp/protocol/reqrep0/req.c index 85c2dfa4..451253bd 100644 --- a/src/sp/protocol/reqrep0/req.c +++ b/src/sp/protocol/reqrep0/req.c @@ -7,9 +7,17 @@ // file was obtained (LICENSE.txt). A copy of the license may also be // found online at https://opensource.org/licenses/MIT. // -#include <stdio.h> -#include "core/nng_impl.h" +#include "../../../core/aio.h" +#include "../../../core/defs.h" +#include "../../../core/idhash.h" +#include "../../../core/list.h" +#include "../../../core/message.h" +#include "../../../core/pipe.h" +#include "../../../core/platform.h" +#include "../../../core/pollable.h" +#include "../../../core/protocol.h" +#include "../../../core/socket.h" // Request protocol. The REQ protocol is the "request" side of a // request-reply pair. This is useful for building RPC clients, for example. diff --git a/src/sp/protocol/reqrep0/req_test.c b/src/sp/protocol/reqrep0/req_test.c index 1da63ffc..d77f06d0 100644 --- a/src/sp/protocol/reqrep0/req_test.c +++ b/src/sp/protocol/reqrep0/req_test.c @@ -8,8 +8,7 @@ // found online at https://opensource.org/licenses/MIT. // -#include "nng/nng.h" -#include <nuts.h> +#include "../../../testing/nuts.h" #define REQ0_SELF 0x30 #define REQ0_PEER 0x31 diff --git a/src/sp/protocol/reqrep0/reqstress_test.c b/src/sp/protocol/reqrep0/reqstress_test.c index 2b2e1980..db0da0d6 100644 --- a/src/sp/protocol/reqrep0/reqstress_test.c +++ b/src/sp/protocol/reqrep0/reqstress_test.c @@ -12,9 +12,7 @@ #include <string.h> #include <time.h> -#include "nng/nng.h" - -#include "nuts.h" +#include "../../../testing/nuts.h" #ifdef NDEBUG #define dprintf(...) diff --git a/src/sp/protocol/reqrep0/xrep.c b/src/sp/protocol/reqrep0/xrep.c index fe6c9fde..e0b5fece 100644 --- a/src/sp/protocol/reqrep0/xrep.c +++ b/src/sp/protocol/reqrep0/xrep.c @@ -8,9 +8,15 @@ // found online at https://opensource.org/licenses/MIT. // -#include <string.h> - -#include "core/nng_impl.h" +#include "../../../core/aio.h" +#include "../../../core/defs.h" +#include "../../../core/idhash.h" +#include "../../../core/message.h" +#include "../../../core/msgqueue.h" +#include "../../../core/pipe.h" +#include "../../../core/platform.h" +#include "../../../core/protocol.h" +#include "../../../core/socket.h" #define REP0_SELF 0x31 #define REP0_PEER 0x30 diff --git a/src/sp/protocol/reqrep0/xrep_test.c b/src/sp/protocol/reqrep0/xrep_test.c index d4e4ce26..ef9b9246 100644 --- a/src/sp/protocol/reqrep0/xrep_test.c +++ b/src/sp/protocol/reqrep0/xrep_test.c @@ -7,8 +7,7 @@ // found online at https://opensource.org/licenses/MIT. // -#include "nng/nng.h" -#include <nuts.h> +#include "../../../testing/nuts.h" #define REP0_SELF 0x31 #define REP0_PEER 0x30 diff --git a/src/sp/protocol/reqrep0/xreq.c b/src/sp/protocol/reqrep0/xreq.c index f80391dd..8939d8f4 100644 --- a/src/sp/protocol/reqrep0/xreq.c +++ b/src/sp/protocol/reqrep0/xreq.c @@ -8,9 +8,13 @@ // found online at https://opensource.org/licenses/MIT. // -#include <stdio.h> - -#include "core/nng_impl.h" +#include "../../../core/aio.h" +#include "../../../core/defs.h" +#include "../../../core/message.h" +#include "../../../core/msgqueue.h" +#include "../../../core/pipe.h" +#include "../../../core/protocol.h" +#include "../../../core/socket.h" #define REQ0_SELF 0x30 #define REQ0_PEER 0x31 diff --git a/src/sp/protocol/reqrep0/xreq_test.c b/src/sp/protocol/reqrep0/xreq_test.c index 7969ff0f..ef06c711 100644 --- a/src/sp/protocol/reqrep0/xreq_test.c +++ b/src/sp/protocol/reqrep0/xreq_test.c @@ -7,8 +7,7 @@ // found online at https://opensource.org/licenses/MIT. // -#include "nng/nng.h" -#include <nuts.h> +#include "../../../testing/nuts.h" #define REQ0_SELF 0x30 #define REQ0_PEER 0x31 diff --git a/src/sp/protocol/survey0/respond.c b/src/sp/protocol/survey0/respond.c index f50ccb6b..85c96843 100644 --- a/src/sp/protocol/survey0/respond.c +++ b/src/sp/protocol/survey0/respond.c @@ -8,10 +8,16 @@ // found online at https://opensource.org/licenses/MIT. // -#include <stdlib.h> #include <string.h> -#include "core/nng_impl.h" +#include "../../../core/aio.h" +#include "../../../core/defs.h" +#include "../../../core/idhash.h" +#include "../../../core/list.h" +#include "../../../core/message.h" +#include "../../../core/pipe.h" +#include "../../../core/pollable.h" +#include "../../../core/protocol.h" // Respondent protocol. The RESPONDENT protocol is the "replier" side of // the surveyor pattern. This is useful for building service discovery, or diff --git a/src/sp/protocol/survey0/respond_test.c b/src/sp/protocol/survey0/respond_test.c index 5b4bcff9..2a2b44bd 100644 --- a/src/sp/protocol/survey0/respond_test.c +++ b/src/sp/protocol/survey0/respond_test.c @@ -7,8 +7,7 @@ // found online at https://opensource.org/licenses/MIT. // -#include "nng/nng.h" -#include <nuts.h> +#include "../../../testing/nuts.h" #define RESPONDENT0_SELF 0x63 #define RESPONDENT0_PEER 0x62 diff --git a/src/sp/protocol/survey0/survey.c b/src/sp/protocol/survey0/survey.c index 716375a9..1c678d1e 100644 --- a/src/sp/protocol/survey0/survey.c +++ b/src/sp/protocol/survey0/survey.c @@ -8,9 +8,16 @@ // found online at https://opensource.org/licenses/MIT. // -#include <stdlib.h> - -#include "core/nng_impl.h" +#include "../../../core/aio.h" +#include "../../../core/defs.h" +#include "../../../core/idhash.h" +#include "../../../core/list.h" +#include "../../../core/lmq.h" +#include "../../../core/message.h" +#include "../../../core/pipe.h" +#include "../../../core/platform.h" +#include "../../../core/pollable.h" +#include "../../../core/protocol.h" // Surveyor protocol. The SURVEYOR protocol is the "survey" side of the // survey pattern. This is useful for building service discovery, voting, etc. diff --git a/src/sp/protocol/survey0/survey_test.c b/src/sp/protocol/survey0/survey_test.c index ac6767ba..fd7133d3 100644 --- a/src/sp/protocol/survey0/survey_test.c +++ b/src/sp/protocol/survey0/survey_test.c @@ -8,8 +8,7 @@ // found online at https://opensource.org/licenses/MIT. // -#include "nng/nng.h" -#include <nuts.h> +#include "../../../testing/nuts.h" #define SURVEYOR0_SELF 0x62 #define SURVEYOR0_PEER 0x63 diff --git a/src/sp/protocol/survey0/xrespond.c b/src/sp/protocol/survey0/xrespond.c index 0e04b516..e9fa209c 100644 --- a/src/sp/protocol/survey0/xrespond.c +++ b/src/sp/protocol/survey0/xrespond.c @@ -8,9 +8,14 @@ // found online at https://opensource.org/licenses/MIT. // -#include <stdlib.h> - -#include "core/nng_impl.h" +#include "../../../core/aio.h" +#include "../../../core/defs.h" +#include "../../../core/idhash.h" +#include "../../../core/message.h" +#include "../../../core/msgqueue.h" +#include "../../../core/pipe.h" +#include "../../../core/protocol.h" +#include "../../../core/socket.h" // Respondent protocol. The RESPONDENT protocol is the "replier" side of // the surveyor pattern. This is useful for building service discovery, or diff --git a/src/sp/protocol/survey0/xrespond_test.c b/src/sp/protocol/survey0/xrespond_test.c index bda924c3..1a3f110c 100644 --- a/src/sp/protocol/survey0/xrespond_test.c +++ b/src/sp/protocol/survey0/xrespond_test.c @@ -7,8 +7,7 @@ // found online at https://opensource.org/licenses/MIT. // -#include "nng/nng.h" -#include <nuts.h> +#include "../../../testing/nuts.h" #define RESPONDENT0_SELF 0x63 #define RESPONDENT0_PEER 0x62 diff --git a/src/sp/protocol/survey0/xsurvey.c b/src/sp/protocol/survey0/xsurvey.c index 3c78c392..c01c20c3 100644 --- a/src/sp/protocol/survey0/xsurvey.c +++ b/src/sp/protocol/survey0/xsurvey.c @@ -8,7 +8,15 @@ // found online at https://opensource.org/licenses/MIT. // -#include "core/nng_impl.h" +#include "../../../core/aio.h" +#include "../../../core/defs.h" +#include "../../../core/list.h" +#include "../../../core/message.h" +#include "../../../core/msgqueue.h" +#include "../../../core/pipe.h" +#include "../../../core/platform.h" +#include "../../../core/protocol.h" +#include "../../../core/socket.h" // Surveyor protocol. The SURVEYOR protocol is the "survey" side of the // survey pattern. This is useful for building service discovery, voting, etc. diff --git a/src/sp/protocol/survey0/xsurvey_test.c b/src/sp/protocol/survey0/xsurvey_test.c index 1b9c52fd..3a94e8ed 100644 --- a/src/sp/protocol/survey0/xsurvey_test.c +++ b/src/sp/protocol/survey0/xsurvey_test.c @@ -7,8 +7,7 @@ // found online at https://opensource.org/licenses/MIT. // -#include "nng/nng.h" -#include <nuts.h> +#include "../../../testing/nuts.h" #define SURVEYOR0_SELF 0x62 #define SURVEYOR0_PEER 0x63 |
