From ff00eac2401732e9efb6170ffb90100dcf6332a7 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Tue, 23 Apr 2024 07:14:25 -0700 Subject: 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. --- include/nng/nng.h | 18 ++++++++++++++++++ include/nng/supplemental/util/options.h | 4 +++- include/nng/supplemental/util/platform.h | 22 +++------------------- 3 files changed, 24 insertions(+), 20 deletions(-) (limited to 'include') 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. +// Copyright 2024 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -13,6 +13,8 @@ #include +#include + #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. +// Copyright 2024 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -23,18 +23,12 @@ #include #include +#include + #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 -- cgit v1.2.3-70-g09d2