From 8dafd6324d753626bb6214b1f789295faf02e4eb Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Mon, 19 Jan 2015 20:05:18 -0600 Subject: [PATCH] Go back to original SA_LEN macro. Due to some circular dependencies on Solaris, this needs to be defined as a macro. We should just remove SA_LEN usage here next. --- include/Makefile.am | 2 +- include/netinet/in.h | 24 ------------------------ include/sys/socket.h | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 25 deletions(-) delete mode 100644 include/netinet/in.h create mode 100644 include/sys/socket.h diff --git a/include/Makefile.am b/include/Makefile.am index bf2361e..10175a2 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,8 +1,8 @@ noinst_HEADERS = noinst_HEADERS += signal.h noinst_HEADERS += unistd.h -noinst_HEADERS += netinet/in.h noinst_HEADERS += sys/queue.h +noinst_HEADERS += sys/socket.h noinst_HEADERS += sys/types.h noinst_HEADERS += sys/time.h noinst_HEADERS += err.h diff --git a/include/netinet/in.h b/include/netinet/in.h deleted file mode 100644 index a7bc481..0000000 --- a/include/netinet/in.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Public domain - * netinet/in.h compatibility shim - */ - -#include_next - -#ifndef SA_LEN -static inline socklen_t sockaddr_len(void *a) -{ - struct sockaddr *sa = a; - switch (sa->sa_family) { - case AF_INET: - return sizeof(struct sockaddr_in); - case AF_INET6: - return sizeof(struct sockaddr_in6); - case AF_UNSPEC: - return sizeof(struct sockaddr); - default: - return 0; - } -} -#define SA_LEN(X) sockaddr_len(X) -#endif diff --git a/include/sys/socket.h b/include/sys/socket.h new file mode 100644 index 0000000..cf3ed72 --- /dev/null +++ b/include/sys/socket.h @@ -0,0 +1,14 @@ +/* + * Public domain + * sys/socket.h compatibility shim + */ + +#include_next + +#ifndef SA_LEN +#define SA_LEN(X) \ + (((struct sockaddr*)(X))->sa_family == AF_INET ? sizeof(struct sockaddr_in) : \ + ((struct sockaddr*)(X))->sa_family == AF_INET6 ? sizeof(struct sockaddr_in6) : \ + ((struct sockaddr*)(X))->sa_family == AF_UNSPEC ? sizeof(struct sockaddr) : \ + sizeof(struct sockaddr)) +#endif