From da11217544727cda01a23db2198d24a591d993a3 Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sun, 12 May 2019 16:12:06 +0300 Subject: [PATCH] build: struct sockaddr_un detection (sys/un.h, afunix.h) - On UNIX: sys/un.h - Since win10: afunix.h And windows has AF_UNIX but do not have sockaddr_un (before windows build 17061 [1]), hence the sockaddr_un detection. [1]: https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/ --- CMakeLists.txt | 13 +++++++++++++ configure.ac | 6 +++++- event-config.h.cmake | 9 +++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aecff467..fd3375bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -357,6 +357,19 @@ if(EVENT__HAVE_NETINET_IN_H) list(APPEND CMAKE_EXTRA_INCLUDE_FILES netinet/in.h) endif() +CHECK_INCLUDE_FILE(sys/un.h EVENT__HAVE_SYS_UN_H) +if(EVENT__HAVE_SYS_UN_H) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES sys/un.h) +endif() + +if(WIN32) + CHECK_INCLUDE_FILE(afunix.h EVENT__HAVE_AFUNIX_H) + if(EVENT__HAVE_AFUNIX_H) + list(APPEND CMAKE_EXTRA_INCLUDE_FILES afunix.h) + endif() +endif() +CHECK_TYPE_SIZE("struct sockaddr_un" EVENT__HAVE_STRUCT_SOCKADDR_UN) + CHECK_INCLUDE_FILE(netinet/in6.h EVENT__HAVE_NETINET_IN6_H) if(EVENT__HAVE_NETINET_IN6_H) list(APPEND CMAKE_EXTRA_INCLUDE_FILES netinet/in6.h) diff --git a/configure.ac b/configure.ac index b68a0acb..4c17e553 100644 --- a/configure.ac +++ b/configure.ac @@ -230,6 +230,7 @@ AC_CHECK_HEADERS([ \ netinet/in.h \ netinet/in6.h \ netinet/tcp.h \ + sys/un.h \ poll.h \ port.h \ stdarg.h \ @@ -667,7 +668,7 @@ AC_CHECK_SIZEOF(void *) AC_CHECK_SIZEOF(off_t) AC_CHECK_SIZEOF(time_t) -AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t, struct addrinfo, struct sockaddr_storage], , , +AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, struct sockaddr_un, sa_family_t, struct addrinfo, struct sockaddr_storage], , , [#define _GNU_SOURCE 1 #include #ifdef HAVE_NETINET_IN_H @@ -676,6 +677,9 @@ AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t, struct addrin #ifdef HAVE_NETINET_IN6_H #include #endif +#ifdef HAVE_SYS_UN_H +#include +#endif #ifdef HAVE_SYS_SOCKET_H #include #endif diff --git a/event-config.h.cmake b/event-config.h.cmake index c13128a0..a1b39a11 100644 --- a/event-config.h.cmake +++ b/event-config.h.cmake @@ -202,6 +202,12 @@ /* Define to 1 if you have the header file. */ #cmakedefine EVENT__HAVE_NETINET_TCP_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine EVENT__HAVE_AFUNIX_H 1 + /* Define if the system has openssl */ #cmakedefine EVENT__HAVE_OPENSSL 1 @@ -310,6 +316,9 @@ /* Define to 1 if `sin_len' is member of `struct sockaddr_in'. */ #cmakedefine EVENT__HAVE_STRUCT_SOCKADDR_IN_SIN_LEN 1 +/* Define to 1 if the system has the type `struct sockaddr_un'. */ +#cmakedefine EVENT__HAVE_STRUCT_SOCKADDR_UN 1 + /* Define to 1 if the system has the type `struct sockaddr_storage'. */ #cmakedefine EVENT__HAVE_STRUCT_SOCKADDR_STORAGE 1 -- 2.40.0