mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-26 06:41:03 +08:00
Problem: In rare cases, afunix.h doesn't contain a definition for struct sockaddr_un (#4310)
* Problem: In rare cases, afunix.h doesn't contain a definition for struct sockaddr_un
According to https://github.com/microsoft/vcpkg/issues/21623,
struct sockaddr_un might be unavailable on some machines even afunix.h exists.
For example, on some machines, the content of afunix.h looks like this:
typedef struct _SOCKADDR_UN
{
ADDRESS_FAMILY Family;
wchar_t Path[63];
} SOCKADDR_UN, *PSOCKADDR_UN;
but on other machines, it may looks like this:
#define UNIX_PATH_MAX 108
typedef struct sockaddr_un
{
ADDRESS_FAMILY sun_family;
char sun_path[UNIX_PATH_MAX];
} SOCKADDR_UN, *PSOCKADDR_UN;
Fixes #3949
References:
- [Enable Unix-domain sockets support on Windows](8f3ec75de4
)
- [AF_UNIX equivalent for Windows](https://stackoverflow.com/questions/9029174/af-unix-equivalent-for-windows)
- https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/
This commit is contained in:
parent
5a9c174dab
commit
5eb0b00c87
@ -15,6 +15,7 @@ include(CheckCSourceCompiles)
|
||||
include(CheckCSourceRuns)
|
||||
include(CMakeDependentOption)
|
||||
include(CheckCXXSymbolExists)
|
||||
include(CheckStructHasMember)
|
||||
include(CheckTypeSize)
|
||||
include(FindThreads)
|
||||
include(GNUInstallDirs)
|
||||
@ -495,8 +496,12 @@ endif()
|
||||
|
||||
if(NOT WIN32)
|
||||
set(ZMQ_HAVE_IPC 1)
|
||||
set(ZMQ_HAVE_STRUCT_SOCKADDR_UN 1)
|
||||
else()
|
||||
check_include_files("winsock2.h;afunix.h" ZMQ_HAVE_IPC)
|
||||
if(ZMQ_HAVE_IPC)
|
||||
check_struct_has_member("struct sockaddr_un" sun_path "winsock2.h;afunix.h" ZMQ_HAVE_STRUCT_SOCKADDR_UN)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# ##################### BEGIN condition_variable_t selection
|
||||
|
@ -59,6 +59,7 @@
|
||||
#cmakedefine ZMQ_HAVE_LIBBSD
|
||||
|
||||
#cmakedefine ZMQ_HAVE_IPC
|
||||
#cmakedefine ZMQ_HAVE_STRUCT_SOCKADDR_UN
|
||||
|
||||
#cmakedefine ZMQ_USE_BUILTIN_SHA1
|
||||
#cmakedefine ZMQ_USE_NSS
|
||||
|
@ -98,3 +98,13 @@ static inline int poll (struct pollfd *pfd, unsigned long nfds, int timeout)
|
||||
#define snprintf(buffer_, count_, format_, ...) \
|
||||
_snprintf_s (buffer_, count_, _TRUNCATE, format_, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
// Workaround missing struct sockaddr_un in afunix.h.
|
||||
// Fix #3949.
|
||||
#if defined(ZMQ_HAVE_IPC) && !defined(ZMQ_HAVE_STRUCT_SOCKADDR_UN)
|
||||
struct sockaddr_un
|
||||
{
|
||||
ADDRESS_FAMILY sun_family; /* AF_UNIX */
|
||||
char sun_path[108]; /* pathname */
|
||||
};
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user