aboutsummaryrefslogtreecommitdiff
path: root/src/platform/posix
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-08-20 10:31:09 -0700
committerGarrett D'Amore <garrett@damore.org>2017-08-21 07:18:30 -0700
commit6305e16ab64e42fd9791819d416a6e3534439b0b (patch)
tree8dbb42a07140f0c12a61bf6d6bcf9590f8678ae6 /src/platform/posix
parentdd2eda5a90ab86bbde1a9da481a423d367586a73 (diff)
downloadnng-6305e16ab64e42fd9791819d416a6e3534439b0b.tar.gz
nng-6305e16ab64e42fd9791819d416a6e3534439b0b.tar.bz2
nng-6305e16ab64e42fd9791819d416a6e3534439b0b.zip
Conditional platform inclusion cleanups.
We only compile files that are appropriate for the platform. (We still have guards in place, to allow for a future single .C file to be built from all the sources.) We also remove the subsystem defines; if a new platform needs to deviate from POSIX in ways beyond what we intended here, then that platform should just copy those parts into a new platform directory, rather than cross including portions from POSIX.
Diffstat (limited to 'src/platform/posix')
-rw-r--r--src/platform/posix/posix_alloc.c9
-rw-r--r--src/platform/posix/posix_clock.c9
-rw-r--r--src/platform/posix/posix_config.h4
-rw-r--r--src/platform/posix/posix_debug.c9
-rw-r--r--src/platform/posix/posix_epdesc.c9
-rw-r--r--src/platform/posix/posix_impl.h40
-rw-r--r--src/platform/posix/posix_ipc.c9
-rw-r--r--src/platform/posix/posix_pipe.c9
-rw-r--r--src/platform/posix/posix_pipedesc.c9
-rw-r--r--src/platform/posix/posix_pollq.h4
-rw-r--r--src/platform/posix/posix_pollq_poll.c5
-rw-r--r--src/platform/posix/posix_rand.c17
-rw-r--r--src/platform/posix/posix_resolv_gai.c5
-rw-r--r--src/platform/posix/posix_sockaddr.c9
-rw-r--r--src/platform/posix/posix_tcp.c9
-rw-r--r--src/platform/posix/posix_thread.c9
-rw-r--r--src/platform/posix/posix_udp.c9
17 files changed, 51 insertions, 123 deletions
diff --git a/src/platform/posix/posix_alloc.c b/src/platform/posix/posix_alloc.c
index a3cd29b9..3321f49c 100644
--- a/src/platform/posix/posix_alloc.c
+++ b/src/platform/posix/posix_alloc.c
@@ -9,7 +9,7 @@
#include "core/nng_impl.h"
-#ifdef PLATFORM_POSIX_ALLOC
+#ifdef NNG_PLATFORM_POSIX
#include <stdlib.h>
@@ -27,9 +27,4 @@ nni_free(void *ptr, size_t size)
free(ptr);
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_posix_alloc_not_used = 0;
-
-#endif
+#endif // NNG_PLATFORM_POSIX
diff --git a/src/platform/posix/posix_clock.c b/src/platform/posix/posix_clock.c
index 93e0978c..3e46f787 100644
--- a/src/platform/posix/posix_clock.c
+++ b/src/platform/posix/posix_clock.c
@@ -10,7 +10,7 @@
// POSIX clock stuff.
#include "core/nng_impl.h"
-#ifdef PLATFORM_POSIX_CLOCK
+#ifdef NNG_PLATFORM_POSIX
#include <errno.h>
#include <string.h>
@@ -121,9 +121,4 @@ nni_plat_usleep(nni_duration usec)
#endif // NNG_USE_GETTIMEOFDAY
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_posix_clock_not_used = 0;
-
-#endif // PLATFORM_POSIX_CLOCK
+#endif // NNG_PLATFORM_POSIX
diff --git a/src/platform/posix/posix_config.h b/src/platform/posix/posix_config.h
index 8ed6387c..e22c033a 100644
--- a/src/platform/posix/posix_config.h
+++ b/src/platform/posix/posix_config.h
@@ -42,7 +42,7 @@
#include <time.h>
-#ifdef PLATFORM_POSIX
+#ifdef NNG_PLATFORM_POSIX
// It should never hurt to use DEVURANDOM, since if the device does not
// exist then we won't open it. (Provided: it would be bad if the device
@@ -63,4 +63,4 @@
#define NNG_USE_POSIX_POLLQ_POLL 1
#define NNG_USE_POSIX_RESOLV_GAI 1
-#endif // PLATFORM_POSIX
+#endif // NNG_PLATFORM_POSIX
diff --git a/src/platform/posix/posix_debug.c b/src/platform/posix/posix_debug.c
index 4af224c4..7619e8e8 100644
--- a/src/platform/posix/posix_debug.c
+++ b/src/platform/posix/posix_debug.c
@@ -9,7 +9,7 @@
#include "core/nng_impl.h"
-#ifdef PLATFORM_POSIX_DEBUG
+#ifdef NNG_PLATFORM_POSIX
#include <errno.h>
#include <stdio.h>
@@ -112,9 +112,4 @@ nni_plat_errno(int errnum)
return (NNG_ESYSERR + errnum);
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_posix_debug_not_used = 0;
-
-#endif // PLATFORM_POSIX_DEBUG
+#endif // NNG_PLATFORM_POSIX
diff --git a/src/platform/posix/posix_epdesc.c b/src/platform/posix/posix_epdesc.c
index f511f35f..867f57a7 100644
--- a/src/platform/posix/posix_epdesc.c
+++ b/src/platform/posix/posix_epdesc.c
@@ -10,7 +10,7 @@
#include "core/nng_impl.h"
-#ifdef PLATFORM_POSIX_EPDESC
+#ifdef NNG_PLATFORM_POSIX
#include "platform/posix/posix_aio.h"
#include "platform/posix/posix_pollq.h"
@@ -524,9 +524,4 @@ nni_posix_epdesc_fini(nni_posix_epdesc *ed)
NNI_FREE_STRUCT(ed);
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_posix_epdesc_not_used = 0;
-
-#endif // PLATFORM_POSIX_EPDESC
+#endif // NNG_PLATFORM_POSIX
diff --git a/src/platform/posix/posix_impl.h b/src/platform/posix/posix_impl.h
index 81fbd48b..0f238e45 100644
--- a/src/platform/posix/posix_impl.h
+++ b/src/platform/posix/posix_impl.h
@@ -12,41 +12,41 @@
// Some dependency notes:
//
-// PLATFORM_POSIX_THREAD depends on PLATFORM_POSIX_CLOCK. Furthermore,
-// when using PLATFORM_POSIX_CLOCK, your condition variable timeouts need
+// NNG_PLATFORM_POSIX_THREAD depends on NNG_PLATFORM_POSIX_CLOCK. Also,
+// when using NNG_PLATFORM_POSIX_CLOCK, your condition variable timeouts need
// to use the same base clock values. Normally these should be used
-// together. Almost everything depends on PLATFORM_POSIX_DEBUG.
-#ifdef PLATFORM_POSIX
-#define PLATFORM_POSIX_ALLOC
-#define PLATFORM_POSIX_DEBUG
-#define PLATFORM_POSIX_CLOCK
-#define PLATFORM_POSIX_IPC
-#define PLATFORM_POSIX_TCP
-#define PLATFORM_POSIX_PIPE
-#define PLATFORM_POSIX_RANDOM
-#define PLATFORM_POSIX_SOCKET
-#define PLATFORM_POSIX_THREAD
-#define PLATFORM_POSIX_PIPEDESC
-#define PLATFORM_POSIX_EPDESC
-#define PLATFORM_POSIX_SOCKADDR
-#define PLATFORM_POSIX_UDP
+// together. Almost everything depends on NNG_PLATFORM_POSIX_DEBUG.
+#ifdef NNG_PLATFORM_POSIX
+#define NNG_PLATFORM_POSIX_ALLOC
+#define NNG_PLATFORM_POSIX_DEBUG
+#define NNG_PLATFORM_POSIX_CLOCK
+#define NNG_PLATFORM_POSIX_IPC
+#define NNG_PLATFORM_POSIX_TCP
+#define NNG_PLATFORM_POSIX_PIPE
+#define NNG_PLATFORM_POSIX_RANDOM
+#define NNG_PLATFORM_POSIX_SOCKET
+#define NNG_PLATFORM_POSIX_THREAD
+#define NNG_PLATFORM_POSIX_PIPEDESC
+#define NNG_PLATFORM_POSIX_EPDESC
+#define NNG_PLATFORM_POSIX_SOCKADDR
+#define NNG_PLATFORM_POSIX_UDP
#include "platform/posix/posix_config.h"
#endif
-#ifdef PLATFORM_POSIX_SOCKADDR
+#ifdef NNG_PLATFORM_POSIX_SOCKADDR
#include <sys/socket.h>
extern int nni_posix_sockaddr2nn(nni_sockaddr *, const void *);
extern int nni_posix_nn2sockaddr(void *, const nni_sockaddr *);
#endif
-#ifdef PLATFORM_POSIX_DEBUG
+#ifdef NNG_PLATFORM_POSIX_DEBUG
extern int nni_plat_errno(int);
#endif
// Define types that this platform uses.
-#ifdef PLATFORM_POSIX_THREAD
+#ifdef NNG_PLATFORM_POSIX_THREAD
#include <pthread.h>
diff --git a/src/platform/posix/posix_ipc.c b/src/platform/posix/posix_ipc.c
index a362de6d..3aa9bda3 100644
--- a/src/platform/posix/posix_ipc.c
+++ b/src/platform/posix/posix_ipc.c
@@ -9,7 +9,7 @@
#include "core/nng_impl.h"
-#ifdef PLATFORM_POSIX_IPC
+#ifdef NNG_PLATFORM_POSIX
#include "platform/posix/posix_aio.h"
#include <errno.h>
@@ -177,9 +177,4 @@ nni_plat_ipc_pipe_recv(nni_plat_ipc_pipe *p, nni_aio *aio)
nni_posix_pipedesc_recv((void *) p, aio);
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_posix_ipc_not_used = 0;
-
-#endif // PLATFORM_POSIX_IPC
+#endif // NNG_PLATFORM_POSIX
diff --git a/src/platform/posix/posix_pipe.c b/src/platform/posix/posix_pipe.c
index 314e2f5e..bc42abec 100644
--- a/src/platform/posix/posix_pipe.c
+++ b/src/platform/posix/posix_pipe.c
@@ -10,7 +10,7 @@
// POSIX pipes.
#include "core/nng_impl.h"
-#ifdef PLATFORM_POSIX_PIPE
+#ifdef NNG_PLATFORM_POSIX
#include <errno.h>
@@ -124,9 +124,4 @@ nni_plat_pipe_close(int wfd, int rfd)
#endif // NNG_USE_EVENTFD
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_posix_pipe_not_used = 0;
-
-#endif // PLATFORM_POSIX_PIPE
+#endif // NNG_PLATFORM_POSIX
diff --git a/src/platform/posix/posix_pipedesc.c b/src/platform/posix/posix_pipedesc.c
index b2c1cb1f..8a087256 100644
--- a/src/platform/posix/posix_pipedesc.c
+++ b/src/platform/posix/posix_pipedesc.c
@@ -10,7 +10,7 @@
#include "core/nng_impl.h"
-#ifdef PLATFORM_POSIX_PIPEDESC
+#ifdef NNG_PLATFORM_POSIX
#include "platform/posix/posix_aio.h"
#include "platform/posix/posix_pollq.h"
@@ -338,9 +338,4 @@ nni_posix_pipedesc_fini(nni_posix_pipedesc *pd)
NNI_FREE_STRUCT(pd);
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_posix_pipedesc_not_used = 0;
-
-#endif // PLATFORM_POSIX_PIPEDESC
+#endif // NNG_PLATFORM_POSIX
diff --git a/src/platform/posix/posix_pollq.h b/src/platform/posix/posix_pollq.h
index c17ee800..258c6580 100644
--- a/src/platform/posix/posix_pollq.h
+++ b/src/platform/posix/posix_pollq.h
@@ -11,7 +11,7 @@
#ifndef PLATFORM_POSIX_POLLQ_H
#define PLATFORM_POSIX_POLLQ_H
-#ifdef PLATFORM_POSIX
+#ifdef NNG_PLATFORM_POSIX
// This file defines structures we will use for emulating asynchronous I/O
// on POSIX. POSIX lacks the support for callback based asynchronous I/O
@@ -46,6 +46,6 @@ extern void nni_posix_pollq_remove(nni_posix_pollq_node *);
extern void nni_posix_pollq_arm(nni_posix_pollq_node *, int);
extern void nni_posix_pollq_disarm(nni_posix_pollq_node *, int);
-#endif // PLATFORM_POSIX
+#endif // NNG_PLATFORM_POSIX
#endif // PLATFORM_POSIX_POLLQ_H
diff --git a/src/platform/posix/posix_pollq_poll.c b/src/platform/posix/posix_pollq_poll.c
index df5a1799..d8252af9 100644
--- a/src/platform/posix/posix_pollq_poll.c
+++ b/src/platform/posix/posix_pollq_poll.c
@@ -391,9 +391,4 @@ nni_posix_pollq_sysfini(void)
nni_posix_pollq_fini(&nni_posix_global_pollq);
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_posix_pollq_poll_used = 0;
-
#endif // NNG_USE_POSIX_POLLQ_POLL
diff --git a/src/platform/posix/posix_rand.c b/src/platform/posix/posix_rand.c
index 4322e491..3f353a74 100644
--- a/src/platform/posix/posix_rand.c
+++ b/src/platform/posix/posix_rand.c
@@ -10,7 +10,7 @@
// POSIX clock stuff.
#include "core/nng_impl.h"
-#ifdef PLATFORM_POSIX_RANDOM
+#ifdef NNG_PLATFORM_POSIX
#include <errno.h>
#include <fcntl.h>
@@ -21,11 +21,9 @@
#include <time.h>
#include <unistd.h>
-#ifdef NNG_USE_GETRANDOM
+#if defined(NNG_USE_GETRANDOM)
#include <linux/random.h>
-#endif
-
-#ifdef NNG_USE_GETENTROPY
+#elif defined(NNG_USE_GETENTROPY)
#include <sys/random.h>
#endif
@@ -70,7 +68,7 @@ nni_plat_seed_prng(void *buf, size_t bufsz)
}
#endif
- // As a speical extra guard, let's mixin the data from the
+ // As a special extra guard, let's mixin the data from the
// following system calls. This ensures that even on the most
// limited of systems, we have at least *some* level of randomness.
// The mixing is done in a way to avoid diminishing entropy we may
@@ -86,9 +84,4 @@ nni_plat_seed_prng(void *buf, size_t bufsz)
}
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_posix_rand_not_used = 0;
-
-#endif // PLATFORM_POSIX_RANDOM
+#endif // NNG_PLATFORM_POSIX
diff --git a/src/platform/posix/posix_resolv_gai.c b/src/platform/posix/posix_resolv_gai.c
index dce8270a..27c22c4a 100644
--- a/src/platform/posix/posix_resolv_gai.c
+++ b/src/platform/posix/posix_resolv_gai.c
@@ -295,9 +295,4 @@ nni_posix_resolv_sysfini(void)
nni_mtx_fini(&nni_posix_resolv_mtx);
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_posix_resolv_gai_not_used = 0;
-
#endif // NNG_USE_POSIX_RESOLV_GAI
diff --git a/src/platform/posix/posix_sockaddr.c b/src/platform/posix/posix_sockaddr.c
index d3ab9c6d..2514ea73 100644
--- a/src/platform/posix/posix_sockaddr.c
+++ b/src/platform/posix/posix_sockaddr.c
@@ -10,7 +10,7 @@
#include "core/nng_impl.h"
-#ifdef PLATFORM_POSIX_SOCKADDR
+#ifdef NNG_PLATFORM_POSIX
#include <arpa/inet.h>
#include <fcntl.h>
@@ -85,9 +85,4 @@ nni_posix_sockaddr2nn(nni_sockaddr *na, const void *sa)
return (0);
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_posix_sockaddr_not_used = 0;
-
-#endif // PLATFORM_POSIX_SOCKADDR
+#endif // NNG_PLATFORM_POSIX
diff --git a/src/platform/posix/posix_tcp.c b/src/platform/posix/posix_tcp.c
index 4efbf47d..185c4e2c 100644
--- a/src/platform/posix/posix_tcp.c
+++ b/src/platform/posix/posix_tcp.c
@@ -9,7 +9,7 @@
#include "core/nng_impl.h"
-#ifdef PLATFORM_POSIX_TCP
+#ifdef NNG_PLATFORM_POSIX
#include "platform/posix/posix_aio.h"
#include <errno.h>
@@ -160,9 +160,4 @@ nni_plat_tcp_pipe_recv(nni_plat_tcp_pipe *p, nni_aio *aio)
nni_posix_pipedesc_recv((void *) p, aio);
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_posix_net_not_used = 0;
-
-#endif // PLATFORM_POSIX_TCP
+#endif // NNG_PLATFORM_POSIX
diff --git a/src/platform/posix/posix_thread.c b/src/platform/posix/posix_thread.c
index 44bfbed2..4278a057 100644
--- a/src/platform/posix/posix_thread.c
+++ b/src/platform/posix/posix_thread.c
@@ -12,7 +12,7 @@
#include "core/nng_impl.h"
-#ifdef PLATFORM_POSIX_THREAD
+#ifdef NNG_PLATFORM_POSIX
#include <errno.h>
#include <fcntl.h>
@@ -511,9 +511,4 @@ nni_plat_fini(void)
pthread_mutex_unlock(&nni_plat_init_lock);
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_posix_thread_not_used = 0;
-
-#endif
+#endif // NNG_PLATFORM_POSIX
diff --git a/src/platform/posix/posix_udp.c b/src/platform/posix/posix_udp.c
index 2aa16b36..7bad2db4 100644
--- a/src/platform/posix/posix_udp.c
+++ b/src/platform/posix/posix_udp.c
@@ -10,7 +10,7 @@
#include "core/nng_impl.h"
-#ifdef PLATFORM_POSIX_UDP
+#ifdef NNG_PLATFORM_POSIX
#include "platform/posix/posix_aio.h"
#include "platform/posix/posix_pollq.h"
@@ -322,9 +322,4 @@ nni_plat_udp_send(nni_plat_udp *udp, nni_aio *aio)
nni_mtx_unlock(&udp->udp_mtx);
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_posix_udp_not_used = 0;
-
-#endif // PLATFORM_POSIX_UDP
+#endif // NNG_PLATFORM_POSIX