diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-08-20 10:31:09 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-08-21 07:18:30 -0700 |
| commit | 6305e16ab64e42fd9791819d416a6e3534439b0b (patch) | |
| tree | 8dbb42a07140f0c12a61bf6d6bcf9590f8678ae6 /src/platform/windows | |
| parent | dd2eda5a90ab86bbde1a9da481a423d367586a73 (diff) | |
| download | nng-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/windows')
| -rw-r--r-- | src/platform/windows/win_clock.c | 9 | ||||
| -rw-r--r-- | src/platform/windows/win_debug.c | 9 | ||||
| -rw-r--r-- | src/platform/windows/win_impl.h | 4 | ||||
| -rw-r--r-- | src/platform/windows/win_iocp.c | 9 | ||||
| -rw-r--r-- | src/platform/windows/win_ipc.c | 9 | ||||
| -rw-r--r-- | src/platform/windows/win_net.c | 9 | ||||
| -rw-r--r-- | src/platform/windows/win_pipe.c | 16 | ||||
| -rw-r--r-- | src/platform/windows/win_rand.c | 9 | ||||
| -rw-r--r-- | src/platform/windows/win_resolv.c | 21 | ||||
| -rw-r--r-- | src/platform/windows/win_thread.c | 7 |
10 files changed, 36 insertions, 66 deletions
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 |
