aboutsummaryrefslogtreecommitdiff
path: root/src/platform
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
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')
-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
-rw-r--r--src/platform/windows/win_clock.c9
-rw-r--r--src/platform/windows/win_debug.c9
-rw-r--r--src/platform/windows/win_impl.h4
-rw-r--r--src/platform/windows/win_iocp.c9
-rw-r--r--src/platform/windows/win_ipc.c9
-rw-r--r--src/platform/windows/win_net.c9
-rw-r--r--src/platform/windows/win_pipe.c16
-rw-r--r--src/platform/windows/win_rand.c9
-rw-r--r--src/platform/windows/win_resolv.c21
-rw-r--r--src/platform/windows/win_thread.c7
27 files changed, 87 insertions, 189 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
diff --git a/src/platform/windows/win_clock.c b/src/platform/windows/win_clock.c
index 5a874a71..949b2dfc 100644
--- a/src/platform/windows/win_clock.c
+++ b/src/platform/windows/win_clock.c
@@ -9,7 +9,7 @@
#include "core/nng_impl.h"
-#ifdef PLATFORM_WINDOWS
+#ifdef NNG_PLATFORM_WINDOWS
nni_time
nni_plat_clock(void)
@@ -41,9 +41,4 @@ nni_plat_usleep(nni_duration dur)
}
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_win_clock_not_used = 0;
-
-#endif // PLATFORM_WINDOWS
+#endif // NNG_PLATFORM_WINDOWS
diff --git a/src/platform/windows/win_debug.c b/src/platform/windows/win_debug.c
index cbf0a61c..c6ee3fed 100644
--- a/src/platform/windows/win_debug.c
+++ b/src/platform/windows/win_debug.c
@@ -9,7 +9,7 @@
#include "core/nng_impl.h"
-#ifdef PLATFORM_WINDOWS
+#ifdef NNG_PLATFORM_WINDOWS
#include <errno.h>
#include <stdio.h>
@@ -158,9 +158,4 @@ nni_win_error(int errnum)
return (NNG_ESYSERR + errnum);
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_win_debug_not_used = 0;
-
-#endif // PLATFORM_WINDOWS
+#endif // NNG_PLATFORM_WINDOWS
diff --git a/src/platform/windows/win_impl.h b/src/platform/windows/win_impl.h
index 6455fd5c..d1c5b2a2 100644
--- a/src/platform/windows/win_impl.h
+++ b/src/platform/windows/win_impl.h
@@ -11,7 +11,7 @@
#ifndef PLATFORM_WIN_IMPL_H
#define PLATFORM_WIN_IMPL_H
-#ifdef PLATFORM_WINDOWS
+#ifdef NNG_PLATFORM_WINDOWS
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
@@ -96,6 +96,6 @@ extern void nni_win_tcp_sysfini(void);
extern int nni_win_resolv_sysinit(void);
extern void nni_win_resolv_sysfini(void);
-#endif // PLATFORM_WINDOWS
+#endif // NNG_PLATFORM_WINDOWS
#endif // PLATFORM_WIN_IMPL_H
diff --git a/src/platform/windows/win_iocp.c b/src/platform/windows/win_iocp.c
index 9c3343b7..6d2438d3 100644
--- a/src/platform/windows/win_iocp.c
+++ b/src/platform/windows/win_iocp.c
@@ -10,7 +10,7 @@
#include "core/nng_impl.h"
-#ifdef PLATFORM_WINDOWS
+#ifdef NNG_PLATFORM_WINDOWS
#define NNI_WIN_IOCP_NTHREADS 4
#include <stdio.h>
@@ -270,9 +270,4 @@ nni_win_iocp_sysfini(void)
nni_mtx_fini(&nni_win_iocp_mtx);
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_win_iocp_not_used = 0;
-
-#endif // PLATFORM_WINDOWS
+#endif // NNG_PLATFORM_WINDOWS
diff --git a/src/platform/windows/win_ipc.c b/src/platform/windows/win_ipc.c
index a60815fa..20ae81b5 100644
--- a/src/platform/windows/win_ipc.c
+++ b/src/platform/windows/win_ipc.c
@@ -10,7 +10,7 @@
#include "core/nng_impl.h"
-#ifdef PLATFORM_WINDOWS
+#ifdef NNG_PLATFORM_WINDOWS
#include <stdio.h>
@@ -593,9 +593,4 @@ nni_win_ipc_sysfini(void)
nni_mtx_fini(&worker->mtx);
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_win_ipc_not_used = 0;
-
-#endif // PLATFORM_WINDOWS
+#endif // NNG_PLATFORM_WINDOWS
diff --git a/src/platform/windows/win_net.c b/src/platform/windows/win_net.c
index 80e3724d..dee9b745 100644
--- a/src/platform/windows/win_net.c
+++ b/src/platform/windows/win_net.c
@@ -10,7 +10,7 @@
#include "core/nng_impl.h"
-#ifdef PLATFORM_WINDOWS
+#ifdef NNG_PLATFORM_WINDOWS
#include <stdio.h>
@@ -694,9 +694,4 @@ nni_win_tcp_sysfini(void)
WSACleanup();
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_win_net_not_used = 0;
-
-#endif // PLATFORM_WINDOWS
+#endif // NNG_PLATFORM_WINDOWS
diff --git a/src/platform/windows/win_pipe.c b/src/platform/windows/win_pipe.c
index edc4df3f..c1690991 100644
--- a/src/platform/windows/win_pipe.c
+++ b/src/platform/windows/win_pipe.c
@@ -10,11 +10,16 @@
#include "core/nng_impl.h"
#include <stdio.h>
+
// Windows named pipes won't work for us; we *MUST* use sockets. This is
// a real sadness, but what can you do. We use an anonymous socket bound
-// to localhost and a connected peer.
+// to localhost and a connected peer. This is because folks that want to
+// use notification pipes (ugh) are expecting this to work with select(),
+// which only supports real winsock sockets. We use an ephemeral port,
+// bound to localhost; some care is taken to prevent other applications on
+// the same host from messing us up by accessing the same port.
-#ifdef PLATFORM_WINDOWS
+#ifdef NNG_PLATFORM_WINDOWS
int
nni_plat_pipe_open(int *wfdp, int *rfdp)
@@ -138,9 +143,4 @@ nni_plat_pipe_close(int wfd, int rfd)
closesocket((SOCKET) rfd);
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_win_pipe_not_used = 0;
-
-#endif // PLATFORM_WINDOWS
+#endif // NNG_PLATFORM_WINDOWS
diff --git a/src/platform/windows/win_rand.c b/src/platform/windows/win_rand.c
index 38c86572..afe703ef 100644
--- a/src/platform/windows/win_rand.c
+++ b/src/platform/windows/win_rand.c
@@ -9,7 +9,7 @@
#include "core/nng_impl.h"
-#ifdef PLATFORM_WINDOWS
+#ifdef NNG_PLATFORM_WINDOWS
#include <stdlib.h>
@@ -29,9 +29,4 @@ nni_plat_seed_prng(void *buf, size_t bufsz)
}
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_win_rand_not_used = 0;
-
-#endif // PLATFORM_WINDOWS
+#endif // NNG_PLATFORM_WINDOWS
diff --git a/src/platform/windows/win_resolv.c b/src/platform/windows/win_resolv.c
index 4ce12d84..d157cf0f 100644
--- a/src/platform/windows/win_resolv.c
+++ b/src/platform/windows/win_resolv.c
@@ -9,10 +9,13 @@
#include "core/nng_impl.h"
-#ifdef PLATFORM_WINDOWS
+#ifdef NNG_PLATFORM_WINDOWS
// Modern Windows has an asynchronous resolver, but there are problems
-// with it -- it only resolves Unicode names, and it does not support
+// with it, where looking up names in DNS can poison results for other
+// uses, because the asynchronous resolver *only* considers DNS -- ignoring
+// host file, WINS, or other naming services. As a result, we just build
+// our own limited asynchronous using a taskq.
// We use a single resolver taskq - but we allocate a few threads
// for it to ensure that names can be looked up concurrently. This isn't
@@ -249,6 +252,13 @@ nni_plat_tcp_resolv(
nni_win_resolv_ip(host, serv, passive, family, IPPROTO_TCP, aio);
}
+void
+nni_plat_udp_resolv(
+ const char *host, const char *serv, int family, int passive, nni_aio *aio)
+{
+ nni_win_resolv_ip(host, serv, passive, family, IPPROTO_UDP, aio);
+}
+
int
nni_win_resolv_sysinit(void)
{
@@ -273,9 +283,4 @@ nni_win_resolv_sysfini(void)
nni_mtx_fini(&nni_win_resolv_mtx);
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_win_resolv_not_used = 0;
-
-#endif // PLATFORM_WINDOWS
+#endif // NNG_PLATFORM_WINDOWS
diff --git a/src/platform/windows/win_thread.c b/src/platform/windows/win_thread.c
index 879cd772..12049139 100644
--- a/src/platform/windows/win_thread.c
+++ b/src/platform/windows/win_thread.c
@@ -12,7 +12,7 @@
#include "core/nng_impl.h"
-#ifdef PLATFORM_WINDOWS
+#ifdef NNG_PLATFORM_WINDOWS
void *
nni_alloc(size_t sz)
@@ -188,9 +188,4 @@ nni_plat_fini(void)
plat_inited = 0;
}
-#else
-
-// Suppress empty symbols warnings in ranlib.
-int nni_win_thread_not_used = 0;
-
#endif