Unverified Commit 17c47da0 authored by Luca Boccassi's avatar Luca Boccassi Committed by GitHub

Merge pull request #3452 from jacquesg/strnlen

Problem: strnlen may not be available
parents c1d2e718 b26542bb
...@@ -417,6 +417,10 @@ if(NOT MSVC) ...@@ -417,6 +417,10 @@ if(NOT MSVC)
set(CMAKE_REQUIRED_INCLUDES sys/socket.h) set(CMAKE_REQUIRED_INCLUDES sys/socket.h)
check_function_exists(accept4 HAVE_ACCEPT4) check_function_exists(accept4 HAVE_ACCEPT4)
set(CMAKE_REQUIRED_INCLUDES) set(CMAKE_REQUIRED_INCLUDES)
set(CMAKE_REQUIRED_INCLUDES string.h)
check_function_exists(strnlen HAVE_STRNLEN)
set(CMAKE_REQUIRED_INCLUDES)
endif() endif()
add_definitions(-D_REENTRANT -D_THREAD_SAFE) add_definitions(-D_REENTRANT -D_THREAD_SAFE)
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#cmakedefine ZMQ_HAVE_PTHREAD_SETNAME_3 #cmakedefine ZMQ_HAVE_PTHREAD_SETNAME_3
#cmakedefine ZMQ_HAVE_PTHREAD_SET_NAME #cmakedefine ZMQ_HAVE_PTHREAD_SET_NAME
#cmakedefine HAVE_ACCEPT4 #cmakedefine HAVE_ACCEPT4
#cmakedefine HAVE_STRNLEN
#cmakedefine ZMQ_HAVE_OPENPGM #cmakedefine ZMQ_HAVE_OPENPGM
#cmakedefine ZMQ_MAKE_VALGRIND_HAPPY #cmakedefine ZMQ_MAKE_VALGRIND_HAPPY
......
...@@ -675,7 +675,7 @@ AC_LANG_POP([C++]) ...@@ -675,7 +675,7 @@ AC_LANG_POP([C++])
# Checks for library functions. # Checks for library functions.
AC_TYPE_SIGNAL 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]) AC_CHECK_HEADERS([alloca.h])
# pthread_setname is non-posix, and there are at least 4 different implementations # pthread_setname is non-posix, and there are at least 4 different implementations
......
...@@ -37,6 +37,18 @@ ...@@ -37,6 +37,18 @@
#include <string> #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 () zmq::ipc_address_t::ipc_address_t ()
{ {
memset (&_address, 0, sizeof _address); memset (&_address, 0, sizeof _address);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment