aboutsummaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-04-23 07:39:59 -0700
committerGarrett D'Amore <garrett@damore.org>2024-04-23 07:39:59 -0700
commit01817988f4631bdd8ee5cec9c6b69039712a93fe (patch)
treec8c4259671fbb586a466a8c5d623fc8c183f8927 /src/tools
parentff00eac2401732e9efb6170ffb90100dcf6332a7 (diff)
downloadnng-01817988f4631bdd8ee5cec9c6b69039712a93fe.tar.gz
nng-01817988f4631bdd8ee5cec9c6b69039712a93fe.tar.bz2
nng-01817988f4631bdd8ee5cec9c6b69039712a93fe.zip
Move the rest of the functionality from platform.h into core.
This also deprecates supplemental/util/platform.h.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/nngcat/nngcat.c47
-rw-r--r--src/tools/perf/perf.c23
-rw-r--r--src/tools/perf/pubdrop.c15
3 files changed, 41 insertions, 44 deletions
diff --git a/src/tools/nngcat/nngcat.c b/src/tools/nngcat/nngcat.c
index 3f29f114..bdf6823c 100644
--- a/src/tools/nngcat/nngcat.c
+++ b/src/tools/nngcat/nngcat.c
@@ -1,5 +1,5 @@
//
-// Copyright 2022 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
// Copyright 2020 Lager Data, Inc. <support@lagerdata.com>
//
@@ -31,7 +31,6 @@
#include <nng/protocol/survey0/survey.h>
#include <nng/supplemental/tls/tls.h>
#include <nng/supplemental/util/options.h>
-#include <nng/supplemental/util/platform.h>
#include <nng/transport/zerotier/zerotier.h>
// Globals. We need this to avoid passing around everything.
@@ -42,18 +41,18 @@ int delay = 0;
nng_duration interval = NNG_DURATION_INFINITE;
nng_duration sendtimeo = NNG_DURATION_INFINITE;
nng_duration recvtimeo = NNG_DURATION_INFINITE;
-void * data = NULL;
+void *data = NULL;
size_t datalen = 0;
int compat = 0;
int async = 0;
int insecure = 0;
-void * cacert = NULL;
+void *cacert = NULL;
size_t cacertlen = 0;
-void * keyfile = NULL;
+void *keyfile = NULL;
size_t keylen = 0;
-void * certfile = NULL;
+void *certfile = NULL;
size_t certlen = 0;
-const char * zthome = NULL;
+const char *zthome = NULL;
int count = 0;
int recvmaxsz = -1;
@@ -310,11 +309,11 @@ intarg(const char *val, int maxv)
static void
loadfile(const char *path, void **datap, size_t *lenp)
{
- FILE * f;
+ FILE *f;
size_t total_read = 0;
size_t allocation_size = BUFSIZ;
- char * fdata;
- char * realloc_result;
+ char *fdata;
+ char *realloc_result;
if (strcmp(path, "-") == 0) {
f = stdin;
@@ -385,7 +384,7 @@ configtls(nng_tls_config *tls)
struct addr {
struct addr *next;
int mode;
- char * val;
+ char *val;
};
struct addr **
@@ -406,7 +405,7 @@ addaddr(struct addr **endp, int mode, const char *a)
struct topic {
struct topic *next;
- char * val;
+ char *val;
};
struct topic **
@@ -578,7 +577,7 @@ sendloop(nng_socket sock)
for (;;) {
int rv;
- nng_msg * msg;
+ nng_msg *msg;
nng_time start;
nng_time end;
nng_duration delta;
@@ -592,7 +591,7 @@ sendloop(nng_socket sock)
fatal("Send error: %s", nng_strerror(rv));
}
end = nng_clock();
- delta = (nng_duration)(end - start);
+ delta = (nng_duration) (end - start);
iters++;
// By default, we don't loop.
@@ -630,7 +629,7 @@ sendrecv(nng_socket sock)
// that we exit the receive loop, and can continue.
for (;;) {
int rv;
- nng_msg * msg;
+ nng_msg *msg;
nng_time start;
nng_time end;
nng_duration delta;
@@ -655,7 +654,7 @@ sendrecv(nng_socket sock)
// want to increment the iteration count.
for (;;) {
- delta = (nng_duration)(nng_clock() - start);
+ delta = (nng_duration) (nng_clock() - start);
nng_duration expire = interval - delta;
if ((recvtimeo >= 0) && (expire > recvtimeo)) {
@@ -688,7 +687,7 @@ sendrecv(nng_socket sock)
}
end = nng_clock();
- delta = (nng_duration)(end - start);
+ delta = (nng_duration) (end - start);
iters++;
if ((count > 0) && (iters >= count)) {
@@ -709,13 +708,13 @@ int
main(int ac, char **av)
{
int idx;
- char * arg;
+ char *arg;
int val;
int rv;
char scratch[512];
- struct addr * addrs = NULL;
- struct addr ** addrend;
- struct topic * topics = NULL;
+ struct addr *addrs = NULL;
+ struct addr **addrend;
+ struct topic *topics = NULL;
struct topic **topicend;
nng_socket sock;
int port;
@@ -1092,7 +1091,7 @@ main(int ac, char **av)
}
for (struct addr *a = addrs; a != NULL; a = a->next) {
- char * act;
+ char *act;
nng_listener l;
nng_dialer d;
nng_tls_config *tls;
@@ -1114,8 +1113,8 @@ main(int ac, char **av)
nng_strerror(rv));
}
if (zthome != NULL) {
- rv = nng_dialer_set(d, NNG_OPT_ZT_HOME,
- zthome, strlen(zthome) + 1);
+ rv = nng_dialer_set(d, NNG_OPT_ZT_HOME, zthome,
+ strlen(zthome) + 1);
if ((rv != 0) && (rv != NNG_ENOTSUP)) {
fatal("Unable to set ZT home: %s",
nng_strerror(rv));
diff --git a/src/tools/perf/perf.c b/src/tools/perf/perf.c
index 46d91cd8..2801ce51 100644
--- a/src/tools/perf/perf.c
+++ b/src/tools/perf/perf.c
@@ -1,5 +1,5 @@
//
-// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2024 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
@@ -17,7 +17,6 @@
#include <nng/nng.h>
#include <nng/supplemental/util/options.h>
-#include <nng/supplemental/util/platform.h>
static void die(const char *, ...);
static int
@@ -328,13 +327,13 @@ do_inproc(void *args)
void
do_inproc_lat(int argc, char **argv)
{
- nng_thread * thr;
+ nng_thread *thr;
struct inproc_args ia;
int rv;
int val;
int optidx;
- char * arg;
- char * addr;
+ char *arg;
+ char *addr;
addr = "inproc://latency_test";
@@ -392,13 +391,13 @@ do_inproc_lat(int argc, char **argv)
void
do_inproc_thr(int argc, char **argv)
{
- nng_thread * thr;
+ nng_thread *thr;
struct inproc_args ia;
int rv;
int optidx;
int val;
- char * arg;
- char * addr = "inproc://throughput-test";
+ char *arg;
+ char *addr = "inproc://throughput-test";
optidx = 0;
while ((rv = nng_opts_parse(argc, argv, opts, &val, &arg, &optidx)) ==
@@ -461,7 +460,7 @@ void
latency_client(const char *addr, size_t msgsize, int trips)
{
nng_socket s;
- nng_msg * msg;
+ nng_msg *msg;
nng_time start, end;
int rv;
int i;
@@ -511,7 +510,7 @@ void
latency_server(const char *addr, size_t msgsize, int trips)
{
nng_socket s;
- nng_msg * msg;
+ nng_msg *msg;
int rv;
int i;
@@ -553,7 +552,7 @@ void
throughput_server(const char *addr, size_t msgsize, int count)
{
nng_socket s;
- nng_msg * msg;
+ nng_msg *msg;
int rv;
int i;
uint64_t start, end;
@@ -611,7 +610,7 @@ void
throughput_client(const char *addr, size_t msgsize, int count)
{
nng_socket s;
- nng_msg * msg;
+ nng_msg *msg;
int rv;
int i;
diff --git a/src/tools/perf/pubdrop.c b/src/tools/perf/pubdrop.c
index f7e1dbfd..bc067d76 100644
--- a/src/tools/perf/pubdrop.c
+++ b/src/tools/perf/pubdrop.c
@@ -1,5 +1,5 @@
//
-// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -15,7 +15,6 @@
#include <string.h>
#include <nng/nng.h>
-#include <nng/supplemental/util/platform.h>
// pubdrop - this is a simple testing utility that lets us measure PUB/SUB
// performance, including dropped messages, delivery across multiple threads,
@@ -117,7 +116,7 @@ parse_int(const char *arg, const char *what)
}
struct pubdrop_args {
- const char * addr;
+ const char *addr;
bool start;
unsigned long long msgsize;
unsigned long long count;
@@ -128,8 +127,8 @@ struct pubdrop_args {
unsigned long long recvs;
nng_time beg;
nng_time end;
- nng_mtx * mtx;
- nng_cv * cv;
+ nng_mtx *mtx;
+ nng_cv *cv;
};
static void
@@ -138,7 +137,7 @@ pub_server(void *arg)
struct pubdrop_args *pa = arg;
nng_socket sock;
int rv;
- nng_msg * msg;
+ nng_msg *msg;
nng_time start;
nng_time end;
@@ -191,7 +190,7 @@ sub_client(void *arg)
struct pubdrop_args *pa = arg;
nng_socket sock;
int rv;
- nng_msg * msg;
+ nng_msg *msg;
unsigned long long recvs;
unsigned long long drops;
unsigned long long gaps;
@@ -255,7 +254,7 @@ sub_client(void *arg)
static void
do_pubdrop(int argc, char **argv)
{
- nng_thread ** thrs;
+ nng_thread **thrs;
struct pubdrop_args pa;
int rv;
int nsubs;