aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-04-23 07:14:25 -0700
committerGarrett D'Amore <garrett@damore.org>2024-04-23 07:16:58 -0700
commitff00eac2401732e9efb6170ffb90100dcf6332a7 (patch)
treeedbef35bb4259a95f3624b88611d8daa0dcc2442 /include
parent29b73962b939a6fbbf6ea8d5d7680bb06d0eeb99 (diff)
downloadnng-ff00eac2401732e9efb6170ffb90100dcf6332a7.tar.gz
nng-ff00eac2401732e9efb6170ffb90100dcf6332a7.tar.bz2
nng-ff00eac2401732e9efb6170ffb90100dcf6332a7.zip
Move some supplemental APIs to reduce friction in using them.
The supplemental/util/platform.h is kind of a pain, so we move move the prototypes for commonly used functions out of there, into nng.h proper.
Diffstat (limited to 'include')
-rw-r--r--include/nng/nng.h18
-rw-r--r--include/nng/supplemental/util/options.h4
-rw-r--r--include/nng/supplemental/util/platform.h22
3 files changed, 24 insertions, 20 deletions
diff --git a/include/nng/nng.h b/include/nng/nng.h
index 95aaed7a..9192cc5e 100644
--- a/include/nng/nng.h
+++ b/include/nng/nng.h
@@ -1567,6 +1567,24 @@ NNG_DECL void nng_log_debug(const char *msgid, const char *msg, ...);
NNG_DECL void nng_log_auth(
nng_log_level level, const char *msgid, const char *msg, ...);
+// Return an absolute time from some arbitrary point. The value is
+// provided in milliseconds, and is of limited resolution based on the
+// system clock. (Do not use it for fine-grained performance measurements.)
+NNG_DECL nng_time nng_clock(void);
+
+// Sleep for specified msecs.
+NNG_DECL void nng_msleep(nng_duration);
+
+// nng_random returns a "strong" (cryptographic sense) random number.
+NNG_DECL uint32_t nng_random(void);
+
+// nng_socket_pair is used to create a bound pair of file descriptors
+// typically using the socketpair() call. The descriptors are backed
+// by reliable, bidirectional, byte streams. This will return NNG_ENOTSUP
+// if the platform lacks support for this. The argument is a pointer
+// to an array of file descriptors (or HANDLES or similar).
+NNG_DECL int nng_socket_pair(int[2]);
+
#ifdef __cplusplus
}
#endif
diff --git a/include/nng/supplemental/util/options.h b/include/nng/supplemental/util/options.h
index 83969a90..6d0a3c1a 100644
--- a/include/nng/supplemental/util/options.h
+++ b/include/nng/supplemental/util/options.h
@@ -1,5 +1,5 @@
//
-// Copyright 2018 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
@@ -13,6 +13,8 @@
#include <stdbool.h>
+#include <nng/nng.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/include/nng/supplemental/util/platform.h b/include/nng/supplemental/util/platform.h
index 26f910a3..70eee1b8 100644
--- a/include/nng/supplemental/util/platform.h
+++ b/include/nng/supplemental/util/platform.h
@@ -1,5 +1,5 @@
//
-// Copyright 2023 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
@@ -23,18 +23,12 @@
#include <stddef.h>
#include <stdint.h>
+#include <nng/nng.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-// Return an absolute time from some arbitrary point. The value is
-// provided in milliseconds, and is of limited resolution based on the
-// system clock. (Do not use it for fine-grained performance measurements.)
-NNG_DECL nng_time nng_clock(void);
-
-// Sleep for specified msecs.
-NNG_DECL void nng_msleep(nng_duration);
-
// nng_thread is a handle to a "thread", which may be a real system
// thread, or a coroutine on some platforms.
typedef struct nng_thread nng_thread;
@@ -97,16 +91,6 @@ NNG_DECL void nng_cv_wake(nng_cv *);
// that no waiter starves forever.
NNG_DECL void nng_cv_wake1(nng_cv *);
-// nng_random returns a "strong" (cryptographic sense) random number.
-NNG_DECL uint32_t nng_random(void);
-
-// nng_socket_pair is used to create a bound pair of file descriptors
-// typically using the socketpair() call. The descriptors are backed
-// by reliable, bidirectional, byte streams. This will return NNG_ENOTSUP
-// if the platform lacks support for this. The argument is a pointer
-// to an array of file descriptors (or HANDLES or similar).
-NNG_DECL int nng_socket_pair(int [2]);
-
#ifdef __cplusplus
}
#endif