aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/aio.c8
-rw-r--r--src/core/aio.h10
-rw-r--r--src/core/defs.h42
-rw-r--r--src/core/dialer.c4
-rw-r--r--src/core/list.h16
-rw-r--r--src/core/listener.c7
-rw-r--r--src/core/listener.h4
-rw-r--r--src/core/lmq.h2
-rw-r--r--src/core/message.h2
-rw-r--r--src/core/nng_impl.h59
-rw-r--r--src/core/pipe.h2
-rw-r--r--src/core/platform.h4
-rw-r--r--src/core/protocol.h6
-rw-r--r--src/core/reap.c2
-rw-r--r--src/core/reap.h4
-rw-r--r--src/core/socket.c10
-rw-r--r--src/core/sockimpl.h2
-rw-r--r--src/core/stats.h8
-rw-r--r--src/core/taskq.h9
-rw-r--r--src/core/thread.h8
-rw-r--r--src/core/url.h4
21 files changed, 108 insertions, 105 deletions
diff --git a/src/core/aio.c b/src/core/aio.c
index 76ca7726..510e568a 100644
--- a/src/core/aio.c
+++ b/src/core/aio.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
@@ -8,9 +8,9 @@
// found online at https://opensource.org/licenses/MIT.
//
-#include "core/aio.h"
-#include "core/nng_impl.h"
-#include "core/taskq.h"
+#include "aio.h"
+#include "nng_impl.h"
+#include "taskq.h"
#include <string.h>
struct nni_aio_expire_q {
diff --git a/src/core/aio.h b/src/core/aio.h
index 5884e253..6b806bf6 100644
--- a/src/core/aio.h
+++ b/src/core/aio.h
@@ -11,11 +11,11 @@
#ifndef CORE_AIO_H
#define CORE_AIO_H
-#include "core/defs.h"
-#include "core/list.h"
-#include "core/reap.h"
-#include "core/taskq.h"
-#include "core/thread.h"
+#include "defs.h"
+#include "list.h"
+#include "reap.h"
+#include "taskq.h"
+#include "thread.h"
typedef void (*nni_aio_cancel_fn)(nni_aio *, void *, nng_err);
diff --git a/src/core/defs.h b/src/core/defs.h
index 1cfeeaa4..64a43a04 100644
--- a/src/core/defs.h
+++ b/src/core/defs.h
@@ -22,6 +22,8 @@
#define NNI_ARG_UNUSED(x) ((void) x)
#ifndef NDEBUG
+extern void nni_panic(const char *fmt, ...);
+
#define NNI_ASSERT(x) \
if (!(x)) \
nni_panic("%s: %d: assert err: %s", __FILE__, __LINE__, #x)
@@ -125,30 +127,30 @@ typedef void (*nni_cb)(void *);
// Modern CPUs are all little endian. Let's stop paying the endian tax.
-#define NNI_PUT16LE(ptr, u) \
- do { \
- ((uint8_t *)ptr)[1] = (uint8_t) (((uint16_t) (u)) >> 8u); \
- ((uint8_t *)ptr)[0] = (uint8_t) ((uint16_t) (u)); \
+#define NNI_PUT16LE(ptr, u) \
+ do { \
+ ((uint8_t *) ptr)[1] = (uint8_t) (((uint16_t) (u)) >> 8u); \
+ ((uint8_t *) ptr)[0] = (uint8_t) ((uint16_t) (u)); \
} while (0)
-#define NNI_PUT32LE(ptr, u) \
- do { \
- ((uint8_t *)ptr)[3] = (uint8_t) (((uint32_t) (u)) >> 24u); \
- ((uint8_t *)ptr)[2] = (uint8_t) (((uint32_t) (u)) >> 16u); \
- ((uint8_t *)ptr)[1] = (uint8_t) (((uint32_t) (u)) >> 8u); \
- ((uint8_t *)ptr)[0] = (uint8_t) ((uint32_t) (u)); \
+#define NNI_PUT32LE(ptr, u) \
+ do { \
+ ((uint8_t *) ptr)[3] = (uint8_t) (((uint32_t) (u)) >> 24u); \
+ ((uint8_t *) ptr)[2] = (uint8_t) (((uint32_t) (u)) >> 16u); \
+ ((uint8_t *) ptr)[1] = (uint8_t) (((uint32_t) (u)) >> 8u); \
+ ((uint8_t *) ptr)[0] = (uint8_t) ((uint32_t) (u)); \
} while (0)
-#define NNI_PUT64LE(ptr, u) \
- do { \
- ((uint8_t *)ptr)[7] = (uint8_t) (((uint64_t) (u)) >> 56u); \
- ((uint8_t *)ptr)[6] = (uint8_t) (((uint64_t) (u)) >> 48u); \
- ((uint8_t *)ptr)[5] = (uint8_t) (((uint64_t) (u)) >> 40u); \
- ((uint8_t *)ptr)[4] = (uint8_t) (((uint64_t) (u)) >> 32u); \
- ((uint8_t *)ptr)[3] = (uint8_t) (((uint64_t) (u)) >> 24u); \
- ((uint8_t *)ptr)[2] = (uint8_t) (((uint64_t) (u)) >> 16u); \
- ((uint8_t *)ptr)[1] = (uint8_t) (((uint64_t) (u)) >> 8u); \
- ((uint8_t *)ptr)[0] = (uint8_t) ((uint64_t) (u)); \
+#define NNI_PUT64LE(ptr, u) \
+ do { \
+ ((uint8_t *) ptr)[7] = (uint8_t) (((uint64_t) (u)) >> 56u); \
+ ((uint8_t *) ptr)[6] = (uint8_t) (((uint64_t) (u)) >> 48u); \
+ ((uint8_t *) ptr)[5] = (uint8_t) (((uint64_t) (u)) >> 40u); \
+ ((uint8_t *) ptr)[4] = (uint8_t) (((uint64_t) (u)) >> 32u); \
+ ((uint8_t *) ptr)[3] = (uint8_t) (((uint64_t) (u)) >> 24u); \
+ ((uint8_t *) ptr)[2] = (uint8_t) (((uint64_t) (u)) >> 16u); \
+ ((uint8_t *) ptr)[1] = (uint8_t) (((uint64_t) (u)) >> 8u); \
+ ((uint8_t *) ptr)[0] = (uint8_t) ((uint64_t) (u)); \
} while (0)
#define NNI_GET16LE(ptr, v) \
diff --git a/src/core/dialer.c b/src/core/dialer.c
index 9b868224..50f9e072 100644
--- a/src/core/dialer.c
+++ b/src/core/dialer.c
@@ -9,9 +9,9 @@
// found online at https://opensource.org/licenses/MIT.
//
-#include "core/defs.h"
-#include "core/nng_impl.h"
+#include "defs.h"
#include "nng/nng.h"
+#include "nng_impl.h"
#include "sockimpl.h"
#include <stdio.h>
diff --git a/src/core/list.h b/src/core/list.h
index 28720564..b8feaa36 100644
--- a/src/core/list.h
+++ b/src/core/list.h
@@ -1,5 +1,5 @@
//
-// Copyright 2024 Garrett D'Amore <garrett@damore.org>
+// Copyright 2025 Garrett D'Amore <garrett@damore.org>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -10,7 +10,7 @@
#ifndef CORE_LIST_H
#define CORE_LIST_H
-#include "core/defs.h"
+#include "defs.h"
// In order to make life easy, we just define the list structures
// directly, and let consumers directly inline structures.
@@ -32,12 +32,10 @@ extern void nni_list_init_offset(nni_list *list, size_t offset);
// NNI_LIST_INITIALIZER is used to initialize structures at declaration time.
// The list argument is the structure being initialized and the type and
// offset determine where the node lives within each item.
-#define NNI_LIST_INITIALIZER(list, type, field) \
- { \
- .ll_head.ln_next = &(list).ll_head, \
- .ll_head.ln_prev = &(list).ll_head, \
- .ll_offset = offsetof(type, field) \
- }
+#define NNI_LIST_INITIALIZER(list, type, field) \
+ { .ll_head.ln_next = &(list).ll_head, \
+ .ll_head.ln_prev = &(list).ll_head, \
+ .ll_offset = offsetof(type, field) }
#define NNI_LIST_NODE_INIT(node) \
do { \
@@ -60,6 +58,6 @@ extern void nni_list_node_remove(nni_list_node *);
#define NNI_LIST_FOREACH(l, it) \
for (it = nni_list_first(l); it != NULL; \
- it = nni_list_next(l, (void *) it))
+ it = nni_list_next(l, (void *) it))
#endif // CORE_LIST_H
diff --git a/src/core/listener.c b/src/core/listener.c
index b8efd487..e9a853ed 100644
--- a/src/core/listener.c
+++ b/src/core/listener.c
@@ -9,9 +9,10 @@
// found online at https://opensource.org/licenses/MIT.
//
-#include "core/defs.h"
-#include "core/nng_impl.h"
-#include "core/strs.h"
+#include "defs.h"
+#include "nng_impl.h"
+#include "strs.h"
+
#include "nng/nng.h"
#include "sockimpl.h"
diff --git a/src/core/listener.h b/src/core/listener.h
index 8b9a4c03..3eae99e9 100644
--- a/src/core/listener.h
+++ b/src/core/listener.h
@@ -12,8 +12,8 @@
#ifndef CORE_LISTENER_H
#define CORE_LISTENER_H
-#include "core/defs.h"
-#include "core/stats.h"
+#include "defs.h"
+#include "stats.h"
extern int nni_listener_find(nni_listener **, uint32_t);
extern int nni_listener_hold(nni_listener *);
diff --git a/src/core/lmq.h b/src/core/lmq.h
index c44ca24c..eb687082 100644
--- a/src/core/lmq.h
+++ b/src/core/lmq.h
@@ -10,7 +10,7 @@
#ifndef CORE_LMQ_H
#define CORE_LMQ_H
-#include "core/defs.h"
+#include "defs.h"
// nni_lmq is a very lightweight message queue. Defining it this way allows
// us to share some common code. Locking must be supplied by the caller.
diff --git a/src/core/message.h b/src/core/message.h
index 9940dc9e..2da66ea8 100644
--- a/src/core/message.h
+++ b/src/core/message.h
@@ -11,7 +11,7 @@
#ifndef CORE_MESSAGE_H
#define CORE_MESSAGE_H
-#include "core/defs.h"
+#include "defs.h"
// Internally used message API. Again, this is not part of our public API.
// "trim" operations work from the front, and "chop" work from the end.
diff --git a/src/core/nng_impl.h b/src/core/nng_impl.h
index 4fe80e63..ef15ee45 100644
--- a/src/core/nng_impl.h
+++ b/src/core/nng_impl.h
@@ -1,5 +1,5 @@
//
-// Copyright 2023 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
@@ -24,38 +24,39 @@
// symbols should be found in the toplevel nng.h header.
#include "defs.h"
-#include "core/platform.h"
-
-#include "core/aio.h"
-#include "core/device.h"
-#include "core/file.h"
-#include "core/idhash.h"
-#include "core/init.h"
-#include "core/list.h"
-#include "core/lmq.h"
-#include "core/message.h"
-#include "core/msgqueue.h"
-#include "core/options.h"
-#include "core/panic.h"
-#include "core/pollable.h"
-#include "core/protocol.h"
-#include "core/reap.h"
-#include "core/refcnt.h"
-#include "core/stats.h"
-#include "core/stream.h"
-#include "core/strs.h"
-#include "core/taskq.h"
-#include "core/thread.h"
-#include "core/url.h"
+#include "platform.h"
+
+#include "aio.h"
+#include "device.h"
+#include "file.h"
+#include "idhash.h"
+#include "init.h"
+#include "list.h"
+#include "lmq.h"
+#include "message.h"
+#include "msgqueue.h"
+#include "options.h"
+#include "panic.h"
+#include "pollable.h"
+#include "protocol.h"
+#include "reap.h"
+#include "refcnt.h"
+#include "stats.h"
+
+#include "stream.h"
+#include "strs.h"
+#include "taskq.h"
+#include "thread.h"
+#include "url.h"
// transport needs to come after url
-#include "sp/transport.h"
+#include "../sp/transport.h"
// These have to come after the others - particularly transport.h
-#include "core/dialer.h"
-#include "core/listener.h"
-#include "core/pipe.h"
-#include "core/socket.h"
+#include "dialer.h"
+#include "listener.h"
+#include "pipe.h"
+#include "socket.h"
#endif // CORE_NNG_IMPL_H
diff --git a/src/core/pipe.h b/src/core/pipe.h
index fc7b7a1a..b9a13a68 100644
--- a/src/core/pipe.h
+++ b/src/core/pipe.h
@@ -19,7 +19,7 @@
#include "stats.h"
#include "thread.h"
-#include "sp/transport.h"
+#include "../sp/transport.h"
// AIO
extern void nni_pipe_recv(nni_pipe *, nni_aio *);
diff --git a/src/core/platform.h b/src/core/platform.h
index cdb0d887..6fe0c7eb 100644
--- a/src/core/platform.h
+++ b/src/core/platform.h
@@ -540,9 +540,9 @@ extern const char *nni_plat_file_basename(const char *);
// Actual platforms we support. This is included up front so that we can
// get the specific types that are supplied by the platform.
#if defined(NNG_PLATFORM_POSIX)
-#include "platform/posix/posix_impl.h"
+#include "../platform/posix/posix_impl.h"
#elif defined(NNG_PLATFORM_WINDOWS)
-#include "platform/windows/win_impl.h"
+#include "../platform/windows/win_impl.h"
#else
#error "unknown platform"
#endif
diff --git a/src/core/protocol.h b/src/core/protocol.h
index 109ec5ef..c128e676 100644
--- a/src/core/protocol.h
+++ b/src/core/protocol.h
@@ -1,5 +1,5 @@
//
-// Copyright 2021 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
@@ -11,7 +11,7 @@
#ifndef CORE_PROTOCOL_H
#define CORE_PROTOCOL_H
-#include "core/options.h"
+#include "options.h"
// Protocol implementation details. Protocols must implement the
// interfaces in this file. Note that implementing new protocols is
@@ -168,7 +168,7 @@ extern int nni_proto_open(nng_socket *, const nni_proto *);
// There are gaps in the list, which are obsolete or unsupported protocols.
// Protocol numbers are never more than 16 bits. Also, there will never be
// a valid protocol numbered 0 (NNG_PROTO_NONE).
-#define NNI_PROTO(major, minor) (((major) *16) + (minor))
+#define NNI_PROTO(major, minor) (((major) * 16) + (minor))
// Protocol major numbers. This is here for documentation only, and
// to serve as a "registry" for managing new protocol numbers. Consider
diff --git a/src/core/reap.c b/src/core/reap.c
index 61c6bdb9..c236e9ce 100644
--- a/src/core/reap.c
+++ b/src/core/reap.c
@@ -8,7 +8,7 @@
// found online at https://opensource.org/licenses/MIT.
//
-#include "core/nng_impl.h"
+#include "nng_impl.h"
#include "reap.h"
diff --git a/src/core/reap.h b/src/core/reap.h
index 221fd17f..f6da27ce 100644
--- a/src/core/reap.h
+++ b/src/core/reap.h
@@ -11,8 +11,8 @@
#ifndef CORE_REAP_H
#define CORE_REAP_H
-#include "core/defs.h"
-#include "core/list.h"
+#include "defs.h"
+#include "list.h"
// nni_reap_node is to be inserted inline into structures
// for subsystems that wish to support deferred reaping.
diff --git a/src/core/socket.c b/src/core/socket.c
index 12373a6a..2ef27dbc 100644
--- a/src/core/socket.c
+++ b/src/core/socket.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
@@ -8,12 +8,12 @@
// found online at https://opensource.org/licenses/MIT.
//
-#include "core/defs.h"
-#include "core/nng_impl.h"
-#include "core/options.h"
-#include "core/pipe.h"
+#include "defs.h"
#include "list.h"
#include "nng/nng.h"
+#include "nng_impl.h"
+#include "options.h"
+#include "pipe.h"
#include "sockimpl.h"
#include <stdio.h>
diff --git a/src/core/sockimpl.h b/src/core/sockimpl.h
index 5d41e8d7..dc8500fe 100644
--- a/src/core/sockimpl.h
+++ b/src/core/sockimpl.h
@@ -23,7 +23,7 @@
#include "stats.h"
#include "url.h"
-#include "sp/transport.h"
+#include "../sp/transport.h"
// This file contains stuff shared within the core between sockets, endpoints,
// and pipes. This must not be exposed to other subsystems -- these internals
diff --git a/src/core/stats.h b/src/core/stats.h
index ddd8a886..dd871c09 100644
--- a/src/core/stats.h
+++ b/src/core/stats.h
@@ -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
@@ -11,9 +11,9 @@
#ifndef CORE_STATS_H
#define CORE_STATS_H
-#include "core/defs.h"
-#include "core/list.h"
-#include "core/platform.h"
+#include "defs.h"
+#include "list.h"
+#include "platform.h"
// Statistics support. This is inspired in part by the Solaris
// kernel stats framework, but we've simplified and tuned it for our use.
diff --git a/src/core/taskq.h b/src/core/taskq.h
index 356ef725..cd27408c 100644
--- a/src/core/taskq.h
+++ b/src/core/taskq.h
@@ -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
@@ -11,9 +11,10 @@
#ifndef CORE_TASKQ_H
#define CORE_TASKQ_H
-#include "core/defs.h"
-#include "core/list.h"
-#include "core/platform.h"
+#include "defs.h"
+#include "list.h"
+#include "platform.h"
+
#include "nng/nng.h"
typedef struct nni_taskq nni_taskq;
diff --git a/src/core/thread.h b/src/core/thread.h
index 316acdc2..bc9a7411 100644
--- a/src/core/thread.h
+++ b/src/core/thread.h
@@ -1,5 +1,5 @@
//
-// Copyright 2020 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
@@ -11,15 +11,15 @@
#ifndef CORE_THREAD_H
#define CORE_THREAD_H
-#include "core/defs.h"
-#include "core/platform.h"
+#include "defs.h"
+#include "platform.h"
struct nni_thr {
nni_plat_thr thr;
nni_plat_mtx mtx;
nni_plat_cv cv;
nni_thr_func fn;
- void * arg;
+ void *arg;
int start;
int stop;
int done;
diff --git a/src/core/url.h b/src/core/url.h
index 4f387c5d..46e8ca5e 100644
--- a/src/core/url.h
+++ b/src/core/url.h
@@ -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
@@ -11,7 +11,7 @@
#ifndef CORE_URL_H
#define CORE_URL_H
-#include "core/defs.h"
+#include "defs.h"
struct nng_url {
const char *u_scheme; // never NULL