diff options
Diffstat (limited to 'src/socket')
| -rw-r--r-- | src/socket/net.h | 13 | ||||
| -rw-r--r-- | src/socket/socket.h | 12 | ||||
| -rw-r--r-- | src/socket/socket_linux.c | 4 | ||||
| -rw-r--r-- | src/socket/socket_windows.c | 1 |
4 files changed, 20 insertions, 10 deletions
diff --git a/src/socket/net.h b/src/socket/net.h new file mode 100644 index 0000000..6091bdc --- /dev/null +++ b/src/socket/net.h @@ -0,0 +1,13 @@ +#pragma once + +#ifdef NAUNET_ON_WINDOWS +#include "../winwrap.h" +#else +#include <al/macros.h> +#include <arpa/inet.h> +#endif + +#define nn_htons htons +#define nn_htonl htonl +#define nn_ntohs ntohs +#define nn_ntohl ntohl diff --git a/src/socket/socket.h b/src/socket/socket.h index bb1fa3f..57e3212 100644 --- a/src/socket/socket.h +++ b/src/socket/socket.h @@ -8,12 +8,8 @@ #else #include <unistd.h> #include <sys/un.h> -#include <sys/eventfd.h> -#include <arpa/inet.h> -#include <sys/fcntl.h> -#include <netinet/tcp.h> -#include <netdb.h> #include <poll.h> +#include <sys/eventfd.h> #endif enum { @@ -48,14 +44,10 @@ struct nn_socket { #define nn_write write #endif -#define nn_htons htons -#define nn_htonl htonl -#define nn_ntohs ntohs -#define nn_ntohl ntohl - #ifndef NAUNET_ON_WINDOWS // Posix-only helpers. #define nn_pollfd pollfd #define nn_nfds nfds_t +#define nn_eventfd eventfd void nn_fd_set_blocking(s32 fd, bool blocking); s32 nn_poll_fds(struct nn_pollfd *fds, nn_nfds nfds, s64 timeout_ns); #endif diff --git a/src/socket/socket_linux.c b/src/socket/socket_linux.c index 2d032f3..b8980be 100644 --- a/src/socket/socket_linux.c +++ b/src/socket/socket_linux.c @@ -1,4 +1,8 @@ #include <al/log.h> +#include <arpa/inet.h> +#include <netdb.h> +#include <netinet/tcp.h> +#include <sys/fcntl.h> #include "../util/error.h" diff --git a/src/socket/socket_windows.c b/src/socket/socket_windows.c index ef7f3bd..85c2853 100644 --- a/src/socket/socket_windows.c +++ b/src/socket/socket_windows.c @@ -2,6 +2,7 @@ #include "socket.h" #include "socket_internal.h" +#include "net.h" bool nn_socket_init(struct nn_socket *sock, s32 flags) { |