set(HAVE_NET_IF_H 1)
set(HAVE_OPENDIR 1)
set(HAVE_PIPE 1)
+if(APPLE OR
+ CYGWIN)
+ set(HAVE_PIPE2 0)
+elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR
+ CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
+ CMAKE_SYSTEM_NAME STREQUAL "NetBSD" OR
+ CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
+ set(HAVE_PIPE2 1)
+endif()
set(HAVE_POLL 1)
set(HAVE_POLL_H 1)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(HAVE_NETINET_UDP_H 0)
set(HAVE_NET_IF_H 0)
set(HAVE_PIPE 0)
+set(HAVE_PIPE2 0)
set(HAVE_POLL 0)
set(HAVE_POLL_H 0)
set(HAVE_POSIX_STRERROR_R 0)
include(PickyWarnings)
-if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+if(CYGWIN OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
string(APPEND CMAKE_C_FLAGS " -D_GNU_SOURCE") # Required for sendmmsg() and accept4()
endif()
check_symbol_exists("getifaddrs" "${CURL_INCLUDES};stdlib.h" HAVE_GETIFADDRS) # ifaddrs.h
check_symbol_exists("freeaddrinfo" "${CURL_INCLUDES}" HAVE_FREEADDRINFO) # ws2tcpip.h sys/socket.h netdb.h
check_function_exists("pipe" HAVE_PIPE)
+check_function_exists("pipe2" HAVE_PIPE2)
check_function_exists("eventfd" HAVE_EVENTFD)
check_symbol_exists("ftruncate" "unistd.h" HAVE_FTRUNCATE)
check_symbol_exists("getpeername" "${CURL_INCLUDES}" HAVE_GETPEERNAME) # winsock2.h unistd.h proto/bsdsocket.h
# In order to detect support of sendmmsg() and accept4(), we need to escape the POSIX
# jail by defining _GNU_SOURCE or <sys/socket.h> will not expose it.
case $host_os in
- linux*)
+ linux*|cygwin*|msys*)
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
;;
esac
gettimeofday \
mach_absolute_time \
pipe \
+ pipe2 \
poll \
sendmmsg \
sendmsg \
/* Define to 1 if you have the `pipe' function. */
#cmakedefine HAVE_PIPE 1
+/* Define to 1 if you have the `pipe2' function. */
+#cmakedefine HAVE_PIPE2 1
+
/* Define to 1 if you have the `eventfd' function. */
#cmakedefine HAVE_EVENTFD 1
int Curl_pipe(curl_socket_t socks[2], bool nonblocking)
{
+#ifdef HAVE_PIPE2
+ int flags = nonblocking ? O_NONBLOCK | O_CLOEXEC : O_CLOEXEC;
+ if(pipe2(socks, flags))
+ return -1;
+#else
if(pipe(socks))
return -1;
#ifdef HAVE_FCNTL
return -1;
}
}
+#endif
return 0;
}