mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-14 01:37:56 +08:00
Problem: strnlen may not be available
Solution: Provide an implementation
This commit is contained in:
parent
bd6fa4bbb3
commit
b26542bbfc
@ -417,6 +417,10 @@ if(NOT MSVC)
|
||||
set(CMAKE_REQUIRED_INCLUDES sys/socket.h)
|
||||
check_function_exists(accept4 HAVE_ACCEPT4)
|
||||
set(CMAKE_REQUIRED_INCLUDES)
|
||||
|
||||
set(CMAKE_REQUIRED_INCLUDES string.h)
|
||||
check_function_exists(strnlen HAVE_STRNLEN)
|
||||
set(CMAKE_REQUIRED_INCLUDES)
|
||||
endif()
|
||||
|
||||
add_definitions(-D_REENTRANT -D_THREAD_SAFE)
|
||||
|
@ -49,6 +49,7 @@
|
||||
#cmakedefine ZMQ_HAVE_PTHREAD_SETNAME_3
|
||||
#cmakedefine ZMQ_HAVE_PTHREAD_SET_NAME
|
||||
#cmakedefine HAVE_ACCEPT4
|
||||
#cmakedefine HAVE_STRNLEN
|
||||
|
||||
#cmakedefine ZMQ_HAVE_OPENPGM
|
||||
#cmakedefine ZMQ_MAKE_VALGRIND_HAPPY
|
||||
|
@ -675,7 +675,7 @@ AC_LANG_POP([C++])
|
||||
|
||||
# Checks for library functions.
|
||||
AC_TYPE_SIGNAL
|
||||
AC_CHECK_FUNCS(perror gettimeofday clock_gettime memset socket getifaddrs freeifaddrs fork mkdtemp accept4)
|
||||
AC_CHECK_FUNCS(perror gettimeofday clock_gettime memset socket getifaddrs freeifaddrs fork mkdtemp accept4 strnlen)
|
||||
AC_CHECK_HEADERS([alloca.h])
|
||||
|
||||
# pthread_setname is non-posix, and there are at least 4 different implementations
|
||||
|
@ -37,6 +37,18 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifndef HAVE_STRNLEN
|
||||
static size_t strnlen (const char *s, size_t len)
|
||||
{
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
if (s[i] == '\0')
|
||||
return i + 1;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
#endif
|
||||
|
||||
zmq::ipc_address_t::ipc_address_t ()
|
||||
{
|
||||
memset (&_address, 0, sizeof _address);
|
||||
|
Loading…
x
Reference in New Issue
Block a user