aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/defs.h82
-rw-r--r--src/core/platform.h8
2 files changed, 55 insertions, 35 deletions
diff --git a/src/core/defs.h b/src/core/defs.h
index 395335d6..be7f71f7 100644
--- a/src/core/defs.h
+++ b/src/core/defs.h
@@ -22,6 +22,7 @@ typedef struct nng_socket nni_sock;
typedef struct nng_endpoint nni_ep;
typedef struct nng_pipe nni_pipe;
typedef struct nng_msg nni_msg;
+typedef struct nng_sockaddr nni_sockaddr;
// These are our own names.
typedef struct nni_tran nni_tran;
@@ -31,10 +32,17 @@ typedef struct nni_tran_pipe nni_tran_pipe;
typedef struct nni_proto_pipe nni_proto_pipe;
typedef struct nni_proto nni_proto;
+
typedef int nni_signal; // Turnstile/wakeup channel.
typedef uint64_t nni_time; // Absolute time (usec).
typedef int64_t nni_duration; // Relative time (usec).
+// Used by transports for scatter gather I/O.
+typedef struct {
+ void * iov_buf;
+ size_t iov_len;
+} nni_iov;
+
// Some default timing things.
#define NNI_TIME_NEVER ((nni_time) -1)
#define NNI_TIME_ZERO ((nni_time) 0)
@@ -44,41 +52,45 @@ typedef int64_t nni_duration; // Relative time (usec).
#define NNI_ALLOC_STRUCT(s) nni_alloc(sizeof (*s))
#define NNI_FREE_STRUCT(s) nni_free((s), sizeof (*s))
-#define NNI_PUT32(ptr, u) \
- do { \
- ptr[0] = (uint8_t)(((uint32_t)u) >> 24); \
- ptr[1] = (uint8_t)(((uint32_t)u) >> 16); \
- ptr[2] = (uint8_t)(((uint32_t)u) >> 8); \
- ptr[3] = (uint8_t)((uint32_t)u); \
- } while (0)
-
-#define NNI_PUT64(ptr, u) \
- do { \
- ptr[0] = (uint8_t)(((uint64_t)u) >> 56); \
- ptr[1] = (uint8_t)(((uint64_t)u) >> 48); \
- ptr[2] = (uint8_t)(((uint64_t)u) >> 40); \
- ptr[3] = (uint8_t)(((uint64_t)u) >> 32); \
- ptr[4] = (uint8_t)(((uint64_t)u) >> 24); \
- ptr[5] = (uint8_t)(((uint64_t)u) >> 16); \
- ptr[6] = (uint8_t)(((uint64_t)u) >> 8); \
- ptr[7] = (uint8_t)((uint64_t)u); \
- } while (0)
-
-#define NNI_GET32(ptr, v) \
- v = (((uint32_t)((uint8_t)ptr[0])) << 24) + \
- (((uint32_t)((uint8_t)ptr[1])) << 16) + \
- (((uint32_t)((uint8_t)ptr[2])) << 8) + \
- (((uint32_t)(uint8_t)ptr[3]))
-
-#define NNI_GET64(ptr, v) \
- v = (((uint64_t)((uint8_t)ptr[0])) << 56) + \
- (((uint64_t)((uint8_t)ptr[1])) << 48) + \
- (((uint64_t)((uint8_t)ptr[2])) << 40) + \
- (((uint64_t)((uint8_t)ptr[3])) << 32) + \
- (((uint64_t)((uint8_t)ptr[4])) << 24) + \
- (((uint64_t)((uint8_t)ptr[5])) << 16) + \
- (((uint64_t)((uint8_t)ptr[6])) << 8) + \
- (((uint64_t)(uint8_t)ptr[7]))
+#define NNI_PUT32(ptr, u) \
+ do { \
+ ptr[0] = (uint8_t) (((uint32_t) u) >> 24); \
+ ptr[1] = (uint8_t) (((uint32_t) u) >> 16); \
+ ptr[2] = (uint8_t) (((uint32_t) u) >> 8); \
+ ptr[3] = (uint8_t) ((uint32_t) u); \
+ } \
+ while (0)
+
+#define NNI_PUT64(ptr, u) \
+ do { \
+ ptr[0] = (uint8_t) (((uint64_t) u) >> 56); \
+ ptr[1] = (uint8_t) (((uint64_t) u) >> 48); \
+ ptr[2] = (uint8_t) (((uint64_t) u) >> 40); \
+ ptr[3] = (uint8_t) (((uint64_t) u) >> 32); \
+ ptr[4] = (uint8_t) (((uint64_t) u) >> 24); \
+ ptr[5] = (uint8_t) (((uint64_t) u) >> 16); \
+ ptr[6] = (uint8_t) (((uint64_t) u) >> 8); \
+ ptr[7] = (uint8_t) ((uint64_t) u); \
+ } \
+ while (0)
+
+#define NNI_GET32(ptr, v) \
+ v = (((uint32_t) ((uint8_t) ptr[0])) << 24) + \
+ (((uint32_t) ((uint8_t) ptr[1])) << 16) + \
+ (((uint32_t) ((uint8_t) ptr[2])) << 8) + \
+ (((uint32_t) (uint8_t) ptr[3]))
+
+#define NNI_GET64(ptr, v) \
+ v = (((uint64_t) ((uint8_t) ptr[0])) << 56) + \
+ (((uint64_t) ((uint8_t) ptr[1])) << 48) + \
+ (((uint64_t) ((uint8_t) ptr[2])) << 40) + \
+ (((uint64_t) ((uint8_t) ptr[3])) << 32) + \
+ (((uint64_t) ((uint8_t) ptr[4])) << 24) + \
+ (((uint64_t) ((uint8_t) ptr[5])) << 16) + \
+ (((uint64_t) ((uint8_t) ptr[6])) << 8) + \
+ (((uint64_t) (uint8_t) ptr[7]))
+// A few assorted other items.
+#define NNI_FLAG_IPV4ONLY 1
#endif // CORE_DEFS_H
diff --git a/src/core/platform.h b/src/core/platform.h
index 15ef6843..2134ed97 100644
--- a/src/core/platform.h
+++ b/src/core/platform.h
@@ -158,6 +158,14 @@ extern void nni_plat_fini(void);
// or under a lock protection.)
extern uint32_t nni_plat_nextid(void);
+// nni_plat_strerror allows the platform to use additional error messages
+// for additional error codes. The err code passed in should be the
+// equivalent of errno or GetLastError, without the NNG_ESYSERR component.
+// The platform should make sure that the returned value will be valid
+// after the call returns. (If necessary, thread-local storage can be
+// used.)
+extern const char *nni_plat_strerror(int);
+
// 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(PLATFORM_POSIX)