aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/core/init.c19
-rw-r--r--src/core/init.h32
-rw-r--r--src/core/list.c58
-rw-r--r--src/core/list.h5
-rw-r--r--src/core/pipe.h26
-rw-r--r--src/core/platform.c22
-rw-r--r--src/core/socket.h4
-rw-r--r--src/transport/inproc/inproc.c10
9 files changed, 72 insertions, 105 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 88c1e332..d8b045c9 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -42,7 +42,6 @@ set (NNG_SOURCES
core/panic.h
core/pipe.c
core/pipe.h
- core/platform.c
core/platform.h
core/protocol.c
core/protocol.h
diff --git a/src/core/init.c b/src/core/init.c
index debfbbbe..500a0b54 100644
--- a/src/core/init.c
+++ b/src/core/init.c
@@ -1,11 +1,11 @@
-/*
- * Copyright 2016 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
- * file was obtained (LICENSE.txt). A copy of the license may also be
- * found online at https://opensource.org/licenses/MIT.
- */
+//
+// Copyright 2016 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
+// file was obtained (LICENSE.txt). A copy of the license may also be
+// found online at https://opensource.org/licenses/MIT.
+//
#include "core/nng_impl.h"
#include <stdlib.h>
@@ -14,7 +14,7 @@
static int
init_helper(void)
{
- /* This would be where we would initialize transports, etc. */
+ nni_transport_init();
return (0);
}
@@ -29,5 +29,6 @@ nni_init(void)
void
nni_fini(void)
{
+ nni_transport_fini();
nni_plat_fini();
}
diff --git a/src/core/init.h b/src/core/init.h
index 3f36abe6..856faa3c 100644
--- a/src/core/init.h
+++ b/src/core/init.h
@@ -1,28 +1,24 @@
-/*
- * Copyright 2016 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
- * file was obtained (LICENSE.txt). A copy of the license may also be
- * found online at https://opensource.org/licenses/MIT.
- */
+//
+// Copyright 2016 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
+// file was obtained (LICENSE.txt). A copy of the license may also be
+// found online at https://opensource.org/licenses/MIT.
+//
#ifndef CORE_INIT_H
#define CORE_INIT_H
#include "core/nng_impl.h"
-/*
- * nni_init is called each time the user enters the library. It ensures that
- * the library is initlialized properly, and also deals with checks such as
- * whether the process has forked since last initialization.
- */
+// nni_init is called each time the user enters the library. It ensures that
+// the library is initlialized properly, and also deals with checks such as
+// whether the process has forked since last initialization.
extern int nni_init(void);
-/*
- * nni_fini tears everything down. In the future it may be used to ensure
- * that all resources used by the library are released back to the system.
- */
+// nni_fini tears everything down. In the future it may be used to ensure
+// that all resources used by the library are released back to the system.
extern void nni_fini(void);
-#endif /* CORE_INIT_H */
+#endif // CORE_INIT_H
diff --git a/src/core/list.c b/src/core/list.c
index eb3f73d2..69a74db6 100644
--- a/src/core/list.c
+++ b/src/core/list.c
@@ -1,29 +1,27 @@
-/*
- * Copyright 2016 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
- * file was obtained (LICENSE.txt). A copy of the license may also be
- * found online at https://opensource.org/licenses/MIT.
- */
+//
+// Copyright 2016 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
+// file was obtained (LICENSE.txt). A copy of the license may also be
+// found online at https://opensource.org/licenses/MIT.
+//
#include <stdlib.h>
#include <string.h>
#include "core/nng_impl.h"
-/*
- * Linked list implementation. We implement a doubly linked list.
- * Using pointer arithmetic, we can operate as a list of "anything".
- */
+// Linked list implementation. We implement a doubly linked list.
+// Using pointer arithmetic, we can operate as a list of "anything".
#define NODE(list, item) \
- (nni_list_node_t *) (void *) (((char *) item) + list->ll_offset)
+ (nni_list_node *) (void *) (((char *) item) + list->ll_offset)
#define ITEM(list, node) \
(void *) (((char *) node) - list->ll_offset)
void
-nni_list_init_offset(nni_list_t *list, size_t offset)
+nni_list_init_offset(nni_list *list, size_t offset)
{
list->ll_offset = offset;
list->ll_head.ln_next = &list->ll_head;
@@ -32,9 +30,9 @@ nni_list_init_offset(nni_list_t *list, size_t offset)
void *
-nni_list_first(nni_list_t *list)
+nni_list_first(nni_list *list)
{
- nni_list_node_t *node = list->ll_head.ln_next;
+ nni_list_node *node = list->ll_head.ln_next;
if (node == &list->ll_head) {
return (NULL);
@@ -44,9 +42,9 @@ nni_list_first(nni_list_t *list)
void *
-nni_list_last(nni_list_t *list)
+nni_list_last(nni_list *list)
{
- nni_list_node_t *node = list->ll_head.ln_prev;
+ nni_list_node *node = list->ll_head.ln_prev;
if (node == &list->ll_head) {
return (NULL);
@@ -56,9 +54,9 @@ nni_list_last(nni_list_t *list)
void
-nni_list_append(nni_list_t *list, void *item)
+nni_list_append(nni_list *list, void *item)
{
- nni_list_node_t *node = NODE(list, item);
+ nni_list_node *node = NODE(list, item);
node->ln_prev = list->ll_head.ln_prev;
node->ln_next = &list->ll_head;
@@ -68,9 +66,9 @@ nni_list_append(nni_list_t *list, void *item)
void
-nni_list_prepend(nni_list_t *list, void *item)
+nni_list_prepend(nni_list *list, void *item)
{
- nni_list_node_t *node = NODE(list, item);
+ nni_list_node *node = NODE(list, item);
node->ln_next = list->ll_head.ln_next;
node->ln_prev = &list->ll_head;
@@ -80,9 +78,9 @@ nni_list_prepend(nni_list_t *list, void *item)
void *
-nni_list_next(nni_list_t *list, void *item)
+nni_list_next(nni_list *list, void *item)
{
- nni_list_node_t *node = NODE(list, item);
+ nni_list_node *node = NODE(list, item);
if ((node = node->ln_next) == &list->ll_head) {
return (NULL);
@@ -92,9 +90,9 @@ nni_list_next(nni_list_t *list, void *item)
void *
-nni_list_prev(nni_list_t *list, void *item)
+nni_list_prev(nni_list *list, void *item)
{
- nni_list_node_t *node = NODE(list, item);
+ nni_list_node *node = NODE(list, item);
if ((node = node->ln_prev) == &list->ll_head) {
return (NULL);
@@ -104,9 +102,9 @@ nni_list_prev(nni_list_t *list, void *item)
void
-nni_list_remove(nni_list_t *list, void *item)
+nni_list_remove(nni_list *list, void *item)
{
- nni_list_node_t *node = NODE(list, item);
+ nni_list_node *node = NODE(list, item);
node->ln_prev->ln_next = node->ln_next;
node->ln_next->ln_prev = node->ln_prev;
@@ -114,9 +112,9 @@ nni_list_remove(nni_list_t *list, void *item)
void
-nni_list_node_init(nni_list_t *list, void *item)
+nni_list_node_init(nni_list *list, void *item)
{
- nni_list_node_t *node = NODE(list, item);
+ nni_list_node *node = NODE(list, item);
node->ln_prev = node->ln_next = NULL;
}
diff --git a/src/core/list.h b/src/core/list.h
index 68e6080d..822d9621 100644
--- a/src/core/list.h
+++ b/src/core/list.h
@@ -24,9 +24,6 @@ typedef struct nni_list {
size_t ll_offset;
} nni_list;
-typedef nni_list nni_list_t;
-typedef nni_list_node nni_list_node_t;
-
extern void nni_list_init_offset(nni_list *list, size_t offset);
#define NNI_LIST_INIT(list, type, field) \
@@ -43,4 +40,4 @@ extern void nni_list_node_init(nni_list *, void *);
#define NNI_LIST_FOREACH(l, it) \
for (it = nni_list_first(l); it != NULL; it = nni_list_next(l, it))
-#endif /* CORE_LIST_H */
+#endif // CORE_LIST_H
diff --git a/src/core/pipe.h b/src/core/pipe.h
index 3d0e07e7..4bd11a17 100644
--- a/src/core/pipe.h
+++ b/src/core/pipe.h
@@ -1,20 +1,18 @@
-/*
- * Copyright 2016 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
- * file was obtained (LICENSE.txt). A copy of the license may also be
- * found online at https://opensource.org/licenses/MIT.
- */
+//
+// Copyright 2016 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
+// file was obtained (LICENSE.txt). A copy of the license may also be
+// found online at https://opensource.org/licenses/MIT.
+//
#ifndef CORE_PIPE_H
#define CORE_PIPE_H
-/*
- * NB: This structure is supplied here for use by the CORE. Use of this library
- * OUSIDE of the core is STRICTLY VERBOTEN. NO DIRECT ACCESS BY PROTOCOLS OR
- * TRANSPORTS.
- */
+// NB: This structure is supplied here for use by the CORE. Use of this
+// OUSIDE of the core is STRICTLY VERBOTEN. NO DIRECT ACCESS BY PROTOCOLS OR
+// TRANSPORTS.
#include "core/transport.h"
@@ -39,4 +37,4 @@ extern int nni_pipe_create(nni_pipe **, const nni_pipe_ops *);
extern void nni_pipe_destroy(nni_pipe *);
-#endif /* CORE_PIPE_H */
+#endif // CORE_PIPE_H
diff --git a/src/core/platform.c b/src/core/platform.c
deleted file mode 100644
index 755dfe5e..00000000
--- a/src/core/platform.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright 2016 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
- * file was obtained (LICENSE.txt). A copy of the license may also be
- * found online at https://opensource.org/licenses/MIT.
- */
-
-/*
- * This file pulls in the correct platform implementation.
- */
-
-#include "core/nng_impl.h"
-
-#if 0
-#if defined(PLATFORM_POSIX)
-#include "platform/posix/posix_impl.h"
-#else
-#error "unknown platform"
-#endif
-#endif
diff --git a/src/core/socket.h b/src/core/socket.h
index 05113489..1376c454 100644
--- a/src/core/socket.h
+++ b/src/core/socket.h
@@ -27,8 +27,8 @@ struct nng_socket {
// XXX: options
nni_duration s_linger;
- nni_list_t s_eps; // active endpoints
- nni_list_t s_pipes; // pipes for this socket
+ nni_list s_eps; // active endpoints
+ nni_list s_pipes; // pipes for this socket
int s_closing; // Socket is closing
int s_besteffort; // Best effort mode delivery
diff --git a/src/transport/inproc/inproc.c b/src/transport/inproc/inproc.c
index a4da2b14..467eacf1 100644
--- a/src/transport/inproc/inproc.c
+++ b/src/transport/inproc/inproc.c
@@ -24,7 +24,7 @@ typedef struct nni_inproc_ep nni_inproc_ep;
typedef struct {
nni_mutex mx;
nni_cond cv;
- nni_list_t eps;
+ nni_list eps;
} nni_inproc_global;
// nni_inproc_pipe represents one half of a connection.
@@ -50,7 +50,7 @@ struct nni_inproc_ep {
char addr[NNG_MAXADDRLEN+1];
int mode;
int closed;
- nni_list_node_t node;
+ nni_list_node node;
uint16_t proto;
void * cpipe; // connected pipe (DIAL only)
};
@@ -238,7 +238,7 @@ nni_inproc_ep_dial(void *arg, void **pipep)
{
nni_inproc_ep *ep = arg;
nni_inproc_ep *srch;
- nni_list_t *list = &nni_inproc.eps;
+ nni_list *list = &nni_inproc.eps;
if (ep->mode != NNI_INPROC_EP_IDLE) {
return (NNG_EINVAL);
@@ -284,7 +284,7 @@ nni_inproc_ep_listen(void *arg)
{
nni_inproc_ep *ep = arg;
nni_inproc_ep *srch;
- nni_list_t *list = &nni_inproc.eps;
+ nni_list *list = &nni_inproc.eps;
if (ep->mode != NNI_INPROC_EP_IDLE) {
return (NNG_EINVAL);
@@ -316,7 +316,7 @@ nni_inproc_ep_accept(void *arg, void **pipep)
nni_inproc_ep *ep = arg;
nni_inproc_ep *srch;
nni_inproc_pair *pair;
- nni_list_t *list = &nni_inproc.eps;
+ nni_list *list = &nni_inproc.eps;
int rv;
if (ep->mode != NNI_INPROC_EP_LISTEN) {