functypes: provide the recv and send arg and return types
This header is for providing the argument types for recv() and send() when built to not use a dedicated config-[platfor].h file. Remove the slow brute-force checks from configure and cmake. This change also removes the use of the types for select, as they were not used in code. Closes #9592
This commit is contained in:
parent
eb0167ff7d
commit
eb33ccd533
@ -48,158 +48,6 @@ endif()
|
||||
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
|
||||
function(curl_cv_func_recv_run_test recv_retv recv_arg1 recv_arg2 recv_arg3 recv_arg4)
|
||||
unset(curl_cv_func_recv_test CACHE)
|
||||
check_c_source_compiles("
|
||||
${_source_epilogue}
|
||||
#ifdef WINSOCK_API_LINKAGE
|
||||
WINSOCK_API_LINKAGE
|
||||
#endif
|
||||
extern ${recv_retv} ${signature_call_conv}
|
||||
recv(${recv_arg1}, ${recv_arg2}, ${recv_arg3}, ${recv_arg4});
|
||||
int main(void) {
|
||||
${recv_arg1} s=0;
|
||||
${recv_arg2} buf=0;
|
||||
${recv_arg3} len=0;
|
||||
${recv_arg4} flags=0;
|
||||
${recv_retv} res = recv(s, buf, len, flags);
|
||||
(void) res;
|
||||
return 0;
|
||||
}"
|
||||
curl_cv_func_recv_test)
|
||||
message(STATUS
|
||||
"Tested: ${recv_retv} recv(${recv_arg1}, ${recv_arg2}, ${recv_arg3}, ${recv_arg4})")
|
||||
if(curl_cv_func_recv_test)
|
||||
set(curl_cv_func_recv_args
|
||||
"${recv_arg1},${recv_arg2},${recv_arg3},${recv_arg4},${recv_retv}" PARENT_SCOPE)
|
||||
set(RECV_TYPE_ARG1 "${recv_arg1}" PARENT_SCOPE)
|
||||
set(RECV_TYPE_ARG2 "${recv_arg2}" PARENT_SCOPE)
|
||||
set(RECV_TYPE_ARG3 "${recv_arg3}" PARENT_SCOPE)
|
||||
set(RECV_TYPE_ARG4 "${recv_arg4}" PARENT_SCOPE)
|
||||
set(RECV_TYPE_RETV "${recv_retv}" PARENT_SCOPE)
|
||||
set(HAVE_RECV 1 PARENT_SCOPE)
|
||||
set(curl_cv_func_recv_done 1 PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
check_c_source_compiles("${_source_epilogue}
|
||||
int main(void) {
|
||||
recv(0, 0, 0, 0);
|
||||
return 0;
|
||||
}" curl_cv_recv)
|
||||
if(curl_cv_recv)
|
||||
if(NOT DEFINED curl_cv_func_recv_args OR curl_cv_func_recv_args STREQUAL "unknown")
|
||||
if(APPLE)
|
||||
curl_cv_func_recv_run_test("ssize_t" "int" "void *" "size_t" "int")
|
||||
endif()
|
||||
foreach(recv_retv "int" "ssize_t" )
|
||||
foreach(recv_arg1 "SOCKET" "int" )
|
||||
foreach(recv_arg2 "char *" "void *" )
|
||||
foreach(recv_arg3 "int" "size_t" "socklen_t" "unsigned int")
|
||||
foreach(recv_arg4 "int" "unsigned int")
|
||||
if(NOT curl_cv_func_recv_done)
|
||||
curl_cv_func_recv_run_test(${recv_retv} ${recv_arg1} ${recv_arg2} ${recv_arg3} ${recv_arg4})
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endforeach()
|
||||
else()
|
||||
string(REGEX REPLACE "^([^,]*),[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" RECV_TYPE_ARG1 "${curl_cv_func_recv_args}")
|
||||
string(REGEX REPLACE "^[^,]*,([^,]*),[^,]*,[^,]*,[^,]*$" "\\1" RECV_TYPE_ARG2 "${curl_cv_func_recv_args}")
|
||||
string(REGEX REPLACE "^[^,]*,[^,]*,([^,]*),[^,]*,[^,]*$" "\\1" RECV_TYPE_ARG3 "${curl_cv_func_recv_args}")
|
||||
string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,([^,]*),[^,]*$" "\\1" RECV_TYPE_ARG4 "${curl_cv_func_recv_args}")
|
||||
string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,[^,]*,([^,]*)$" "\\1" RECV_TYPE_RETV "${curl_cv_func_recv_args}")
|
||||
endif()
|
||||
|
||||
if(curl_cv_func_recv_args STREQUAL "unknown")
|
||||
message(FATAL_ERROR "Cannot find proper types to use for recv args")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Unable to link function recv")
|
||||
endif()
|
||||
set(curl_cv_func_recv_args "${curl_cv_func_recv_args}" CACHE INTERNAL "Arguments for recv")
|
||||
set(HAVE_RECV 1)
|
||||
|
||||
function(curl_cv_func_send_run_test send_retv send_arg1 send_arg2 send_arg3 send_arg4)
|
||||
unset(curl_cv_func_send_test CACHE)
|
||||
check_c_source_compiles("
|
||||
${_source_epilogue}
|
||||
#ifdef WINSOCK_API_LINKAGE
|
||||
WINSOCK_API_LINKAGE
|
||||
#endif
|
||||
extern ${send_retv} ${signature_call_conv}
|
||||
send(${send_arg1}, ${send_arg2}, ${send_arg3}, ${send_arg4});
|
||||
int main(void) {
|
||||
${send_arg1} s=0;
|
||||
${send_arg2} buf=0;
|
||||
${send_arg3} len=0;
|
||||
${send_arg4} flags=0;
|
||||
${send_retv} res = send(s, buf, len, flags);
|
||||
(void) res;
|
||||
return 0;
|
||||
}"
|
||||
curl_cv_func_send_test)
|
||||
message(STATUS
|
||||
"Tested: ${send_retv} send(${send_arg1}, ${send_arg2}, ${send_arg3}, ${send_arg4})")
|
||||
if(curl_cv_func_send_test)
|
||||
string(REGEX REPLACE "(const) .*" "\\1" send_qual_arg2 "${send_arg2}")
|
||||
string(REGEX REPLACE "const (.*)" "\\1" send_arg2 "${send_arg2}")
|
||||
set(curl_cv_func_send_args
|
||||
"${send_arg1},${send_arg2},${send_arg3},${send_arg4},${send_retv},${send_qual_arg2}" PARENT_SCOPE)
|
||||
set(SEND_TYPE_ARG1 "${send_arg1}" PARENT_SCOPE)
|
||||
set(SEND_TYPE_ARG2 "${send_arg2}" PARENT_SCOPE)
|
||||
set(SEND_TYPE_ARG3 "${send_arg3}" PARENT_SCOPE)
|
||||
set(SEND_TYPE_ARG4 "${send_arg4}" PARENT_SCOPE)
|
||||
set(SEND_TYPE_RETV "${send_retv}" PARENT_SCOPE)
|
||||
set(HAVE_SEND 1 PARENT_SCOPE)
|
||||
set(curl_cv_func_send_done 1 PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
check_c_source_compiles("${_source_epilogue}
|
||||
int main(void) {
|
||||
send(0, 0, 0, 0);
|
||||
return 0;
|
||||
}" curl_cv_send)
|
||||
if(curl_cv_send)
|
||||
if(NOT DEFINED curl_cv_func_send_args OR "${curl_cv_func_send_args}" STREQUAL "unknown")
|
||||
if(APPLE)
|
||||
curl_cv_func_send_run_test("ssize_t" "int" "const void *" "size_t" "int")
|
||||
endif()
|
||||
foreach(send_retv "int" "ssize_t" )
|
||||
foreach(send_arg1 "SOCKET" "int" "ssize_t" )
|
||||
foreach(send_arg2 "const char *" "const void *" "void *" "char *")
|
||||
foreach(send_arg3 "int" "size_t" "socklen_t" "unsigned int")
|
||||
foreach(send_arg4 "int" "unsigned int")
|
||||
if(NOT curl_cv_func_send_done)
|
||||
curl_cv_func_send_run_test("${send_retv}" "${send_arg1}" "${send_arg2}" "${send_arg3}" "${send_arg4}")
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endforeach()
|
||||
else()
|
||||
string(REGEX REPLACE "^([^,]*),[^,]*,[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG1 "${curl_cv_func_send_args}")
|
||||
string(REGEX REPLACE "^[^,]*,([^,]*),[^,]*,[^,]*,[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG2 "${curl_cv_func_send_args}")
|
||||
string(REGEX REPLACE "^[^,]*,[^,]*,([^,]*),[^,]*,[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG3 "${curl_cv_func_send_args}")
|
||||
string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,([^,]*),[^,]*,[^,]*$" "\\1" SEND_TYPE_ARG4 "${curl_cv_func_send_args}")
|
||||
string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,[^,]*,([^,]*),[^,]*$" "\\1" SEND_TYPE_RETV "${curl_cv_func_send_args}")
|
||||
string(REGEX REPLACE "^[^,]*,[^,]*,[^,]*,[^,]*,[^,]*,([^,]*)$" "\\1" SEND_QUAL_ARG2 "${curl_cv_func_send_args}")
|
||||
endif()
|
||||
|
||||
if("${curl_cv_func_send_args}" STREQUAL "unknown")
|
||||
message(FATAL_ERROR "Cannot find proper types to use for send args")
|
||||
endif()
|
||||
set(SEND_QUAL_ARG2 "const")
|
||||
else()
|
||||
message(FATAL_ERROR "Unable to link function send")
|
||||
endif()
|
||||
set(curl_cv_func_send_args "${curl_cv_func_send_args}" CACHE INTERNAL "Arguments for send")
|
||||
set(HAVE_SEND 1)
|
||||
|
||||
check_c_source_compiles("${_source_epilogue}
|
||||
int main(void) {
|
||||
int flag = MSG_NOSIGNAL;
|
||||
|
||||
@ -1037,6 +1037,8 @@ endif()
|
||||
check_symbol_exists(fchmod "${CURL_INCLUDES}" HAVE_FCHMOD)
|
||||
check_symbol_exists(basename "${CURL_INCLUDES}" HAVE_BASENAME)
|
||||
check_symbol_exists(socket "${CURL_INCLUDES}" HAVE_SOCKET)
|
||||
check_symbol_exists(recv "${CURL_INCLUDES}" HAVE_RECV)
|
||||
check_symbol_exists(send "${CURL_INCLUDES}" HAVE_SEND)
|
||||
check_symbol_exists(select "${CURL_INCLUDES}" HAVE_SELECT)
|
||||
check_symbol_exists(strdup "${CURL_INCLUDES}" HAVE_STRDUP)
|
||||
check_symbol_exists(strtok_r "${CURL_INCLUDES}" HAVE_STRTOK_R)
|
||||
|
||||
357
acinclude.m4
357
acinclude.m4
@ -804,12 +804,6 @@ AC_DEFUN([TYPE_SOCKADDR_STORAGE],
|
||||
dnl CURL_CHECK_FUNC_RECV
|
||||
dnl -------------------------------------------------
|
||||
dnl Test if the socket recv() function is available,
|
||||
dnl and check its return type and the types of its
|
||||
dnl arguments. If the function succeeds HAVE_RECV
|
||||
dnl will be defined, defining the types of the arguments
|
||||
dnl in RECV_TYPE_ARG1, RECV_TYPE_ARG2, RECV_TYPE_ARG3
|
||||
dnl and RECV_TYPE_ARG4, defining the type of the function
|
||||
dnl return value in RECV_TYPE_RETV.
|
||||
|
||||
AC_DEFUN([CURL_CHECK_FUNC_RECV], [
|
||||
AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
|
||||
@ -849,91 +843,9 @@ $curl_includes_bsdsocket
|
||||
])
|
||||
#
|
||||
if test "$curl_cv_recv" = "yes"; then
|
||||
AC_CACHE_CHECK([types of args and return type for recv],
|
||||
[curl_cv_func_recv_args], [
|
||||
if test "$curl_cv_native_windows" = "yes"; then
|
||||
# Win32: int (SOCKET, char *, int, int)
|
||||
retv_test1='int' ; arg1_test1='SOCKET' ; arg2_test1='char *'; arg3_test1='int'
|
||||
retv_test2='ssize_t'; arg1_test2='int' ; arg2_test2='void *'; arg3_test2='size_t'
|
||||
else
|
||||
# POSIX: ssize_t (int, void *, size_t, int)
|
||||
retv_test1='ssize_t'; arg1_test1='int' ; arg2_test1='void *'; arg3_test1='size_t'
|
||||
retv_test2='int' ; arg1_test2='ssize_t'; arg2_test2='char *'; arg3_test2='int'
|
||||
fi
|
||||
curl_cv_func_recv_args="unknown"
|
||||
# Brute-force tests: 2 * 3 * 2 * 4 * 2 -> 96 runs max
|
||||
for recv_retv in "${retv_test1}" "${retv_test2}"; do
|
||||
for recv_arg1 in "${arg1_test1}" "${arg1_test2}"; do
|
||||
for recv_arg2 in "${arg2_test1}" "${arg2_test2}"; do
|
||||
for recv_arg3 in "${arg3_test1}" "${arg3_test2}" 'socklen_t' 'unsigned int'; do
|
||||
for recv_arg4 in 'int' 'unsigned int'; do
|
||||
if test "$curl_cv_func_recv_args" = "unknown"; then
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
#undef inline
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
#define RECVCALLCONV PASCAL
|
||||
#else
|
||||
$curl_includes_bsdsocket
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#define RECVCALLCONV
|
||||
#endif
|
||||
#ifndef HAVE_PROTO_BSDSOCKET_H
|
||||
extern $recv_retv RECVCALLCONV
|
||||
recv($recv_arg1, $recv_arg2, $recv_arg3, $recv_arg4);
|
||||
#endif
|
||||
]],[[
|
||||
$recv_arg1 s=0;
|
||||
$recv_arg2 buf=0;
|
||||
$recv_arg3 len=0;
|
||||
$recv_arg4 flags=0;
|
||||
$recv_retv res = recv(s, buf, len, flags);
|
||||
]])
|
||||
],[
|
||||
curl_cv_func_recv_args="$recv_arg1,$recv_arg2,$recv_arg3,$recv_arg4,$recv_retv"
|
||||
])
|
||||
fi
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
]) # AC-CACHE-CHECK
|
||||
if test "$curl_cv_func_recv_args" = "unknown"; then
|
||||
AC_MSG_ERROR([Cannot find proper types to use for recv args])
|
||||
else
|
||||
recv_prev_IFS=$IFS; IFS=','
|
||||
set dummy `echo "$curl_cv_func_recv_args" | sed 's/\*/\*/g'`
|
||||
IFS=$recv_prev_IFS
|
||||
shift
|
||||
#
|
||||
AC_DEFINE_UNQUOTED(RECV_TYPE_ARG1, $[1],
|
||||
[Define to the type of arg 1 for recv.])
|
||||
AC_DEFINE_UNQUOTED(RECV_TYPE_ARG2, $[2],
|
||||
[Define to the type of arg 2 for recv.])
|
||||
AC_DEFINE_UNQUOTED(RECV_TYPE_ARG3, $[3],
|
||||
[Define to the type of arg 3 for recv.])
|
||||
AC_DEFINE_UNQUOTED(RECV_TYPE_ARG4, $[4],
|
||||
[Define to the type of arg 4 for recv.])
|
||||
AC_DEFINE_UNQUOTED(RECV_TYPE_RETV, $[5],
|
||||
[Define to the function return type for recv.])
|
||||
#
|
||||
AC_DEFINE_UNQUOTED(HAVE_RECV, 1,
|
||||
[Define to 1 if you have the recv function.])
|
||||
curl_cv_func_recv="yes"
|
||||
fi
|
||||
else
|
||||
AC_MSG_ERROR([Unable to link function recv])
|
||||
fi
|
||||
@ -943,13 +855,6 @@ $curl_includes_bsdsocket
|
||||
dnl CURL_CHECK_FUNC_SEND
|
||||
dnl -------------------------------------------------
|
||||
dnl Test if the socket send() function is available,
|
||||
dnl and check its return type and the types of its
|
||||
dnl arguments. If the function succeeds HAVE_SEND
|
||||
dnl will be defined, defining the types of the arguments
|
||||
dnl in SEND_TYPE_ARG1, SEND_TYPE_ARG2, SEND_TYPE_ARG3
|
||||
dnl and SEND_TYPE_ARG4, defining the type of the function
|
||||
dnl return value in SEND_TYPE_RETV, and also defining the
|
||||
dnl type qualifier of second argument in SEND_QUAL_ARG2.
|
||||
|
||||
AC_DEFUN([CURL_CHECK_FUNC_SEND], [
|
||||
AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
|
||||
@ -989,124 +894,9 @@ $curl_includes_bsdsocket
|
||||
])
|
||||
#
|
||||
if test "$curl_cv_send" = "yes"; then
|
||||
AC_CACHE_CHECK([types of args and return type for send],
|
||||
[curl_cv_func_send_args], [
|
||||
if test "$curl_cv_native_windows" = "yes"; then
|
||||
# Win32: int (SOCKET, const char *, int, int)
|
||||
retv_test1='int' ; arg1_test1='SOCKET' ; arg2_test1='const char *'; arg3_test1='int'
|
||||
retv_test2='ssize_t'; arg1_test2='int' ; arg2_test2='const void *'; arg3_test2='size_t'
|
||||
else
|
||||
# POSIX: ssize_t (int, const void *, size_t, int)
|
||||
retv_test1='ssize_t'; arg1_test1='int' ; arg2_test1='const void *'; arg3_test1='size_t'
|
||||
retv_test2='int' ; arg1_test2='ssize_t'; arg2_test2='const char *'; arg3_test2='int'
|
||||
fi
|
||||
curl_cv_func_send_args="unknown"
|
||||
# Brute-force tests: 2 * 3 * 4 * 4 * 2 -> 192 runs max
|
||||
for send_retv in "${retv_test1}" "${retv_test2}"; do
|
||||
for send_arg1 in "${arg1_test1}" "${arg1_test2}"; do
|
||||
for send_arg2 in "${arg2_test1}" "${arg2_test2}" 'void *' 'char *'; do
|
||||
for send_arg3 in "${arg3_test1}" "${arg3_test2}" 'socklen_t' 'unsigned int'; do
|
||||
for send_arg4 in 'int' 'unsigned int'; do
|
||||
if test "$curl_cv_func_send_args" = "unknown"; then
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
#undef inline
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
#define SENDCALLCONV PASCAL
|
||||
#else
|
||||
$curl_includes_bsdsocket
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#define SENDCALLCONV
|
||||
#endif
|
||||
#ifndef HAVE_PROTO_BSDSOCKET_H
|
||||
extern $send_retv SENDCALLCONV
|
||||
send($send_arg1, $send_arg2, $send_arg3, $send_arg4);
|
||||
#endif
|
||||
]],[[
|
||||
$send_arg1 s=0;
|
||||
$send_arg3 len=0;
|
||||
$send_arg4 flags=0;
|
||||
$send_retv res = send(s, 0, len, flags);
|
||||
]])
|
||||
],[
|
||||
curl_cv_func_send_args="$send_arg1,$send_arg2,$send_arg3,$send_arg4,$send_retv"
|
||||
])
|
||||
fi
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
]) # AC-CACHE-CHECK
|
||||
if test "$curl_cv_func_send_args" = "unknown"; then
|
||||
AC_MSG_ERROR([Cannot find proper types to use for send args])
|
||||
else
|
||||
send_prev_IFS=$IFS; IFS=','
|
||||
set dummy `echo "$curl_cv_func_send_args" | sed 's/\*/\*/g'`
|
||||
IFS=$send_prev_IFS
|
||||
shift
|
||||
#
|
||||
send_qual_type_arg2=$[2]
|
||||
#
|
||||
AC_DEFINE_UNQUOTED(SEND_TYPE_ARG1, $[1],
|
||||
[Define to the type of arg 1 for send.])
|
||||
AC_DEFINE_UNQUOTED(SEND_TYPE_ARG3, $[3],
|
||||
[Define to the type of arg 3 for send.])
|
||||
AC_DEFINE_UNQUOTED(SEND_TYPE_ARG4, $[4],
|
||||
[Define to the type of arg 4 for send.])
|
||||
AC_DEFINE_UNQUOTED(SEND_TYPE_RETV, $[5],
|
||||
[Define to the function return type for send.])
|
||||
#
|
||||
prev_sh_opts=$-
|
||||
#
|
||||
case $prev_sh_opts in
|
||||
*f*)
|
||||
;;
|
||||
*)
|
||||
set -f
|
||||
;;
|
||||
esac
|
||||
#
|
||||
case "$send_qual_type_arg2" in
|
||||
const*)
|
||||
send_qual_arg2=const
|
||||
send_type_arg2=`echo $send_qual_type_arg2 | sed 's/^const //'`
|
||||
;;
|
||||
*)
|
||||
send_qual_arg2=
|
||||
send_type_arg2=$send_qual_type_arg2
|
||||
;;
|
||||
esac
|
||||
#
|
||||
AC_DEFINE_UNQUOTED(SEND_QUAL_ARG2, $send_qual_arg2,
|
||||
[Define to the type qualifier of arg 2 for send.])
|
||||
AC_DEFINE_UNQUOTED(SEND_TYPE_ARG2, $send_type_arg2,
|
||||
[Define to the type of arg 2 for send.])
|
||||
#
|
||||
case $prev_sh_opts in
|
||||
*f*)
|
||||
;;
|
||||
*)
|
||||
set +f
|
||||
;;
|
||||
esac
|
||||
#
|
||||
AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
|
||||
[Define to 1 if you have the send function.])
|
||||
curl_cv_func_send="yes"
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(HAVE_SEND, 1,
|
||||
[Define to 1 if you have the send function.])
|
||||
curl_cv_func_send="yes"
|
||||
else
|
||||
AC_MSG_ERROR([Unable to link function send])
|
||||
fi
|
||||
@ -1538,15 +1328,7 @@ AC_DEFUN([CURL_CONFIGURE_PULL_SYS_POLL], [
|
||||
|
||||
dnl CURL_CHECK_FUNC_SELECT
|
||||
dnl -------------------------------------------------
|
||||
dnl Test if the socket select() function is available,
|
||||
dnl and check its return type and the types of its
|
||||
dnl arguments. If the function succeeds HAVE_SELECT
|
||||
dnl will be defined, defining the types of the
|
||||
dnl arguments in SELECT_TYPE_ARG1, SELECT_TYPE_ARG234
|
||||
dnl and SELECT_TYPE_ARG5, defining the type of the
|
||||
dnl function return value in SELECT_TYPE_RETV, and
|
||||
dnl also defining the type qualifier of fifth argument
|
||||
dnl in SELECT_QUAL_ARG5.
|
||||
dnl Test if the socket select() function is available.
|
||||
|
||||
AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
|
||||
AC_REQUIRE([CURL_CHECK_STRUCT_TIMEVAL])dnl
|
||||
@ -1596,134 +1378,9 @@ $curl_includes_bsdsocket
|
||||
])
|
||||
#
|
||||
if test "$curl_cv_select" = "yes"; then
|
||||
AC_CACHE_CHECK([types of args and return type for select],
|
||||
[curl_cv_func_select_args], [
|
||||
curl_cv_func_select_args="unknown"
|
||||
# POSIX/Win32: int (int, fd_set *, fd_set *, fd_set *, struct timeval *)
|
||||
# Brute-force tests: 2 * 5 * 3 * 2 -> 60 runs max
|
||||
for sel_retv in 'int' 'ssize_t'; do
|
||||
for sel_arg1 in 'int' 'ssize_t' 'size_t' 'unsigned long int' 'unsigned int'; do
|
||||
for sel_arg234 in 'fd_set *' 'int *' 'void *'; do
|
||||
for sel_arg5 in 'struct timeval *' 'const struct timeval *'; do
|
||||
if test "$curl_cv_func_select_args" = "unknown"; then
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
#undef inline
|
||||
#ifdef HAVE_WINDOWS_H
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#ifdef HAVE_WINSOCK2_H
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
#define SELECTCALLCONV PASCAL
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <time.h>
|
||||
#ifndef HAVE_WINDOWS_H
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#elif defined(HAVE_UNISTD_H)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
$curl_includes_bsdsocket
|
||||
#define SELECTCALLCONV
|
||||
#endif
|
||||
#ifndef HAVE_STRUCT_TIMEVAL
|
||||
struct timeval {
|
||||
long tv_sec;
|
||||
long tv_usec;
|
||||
};
|
||||
#endif
|
||||
#ifndef HAVE_PROTO_BSDSOCKET_H
|
||||
extern $sel_retv SELECTCALLCONV
|
||||
select($sel_arg1,
|
||||
$sel_arg234,
|
||||
$sel_arg234,
|
||||
$sel_arg234,
|
||||
$sel_arg5);
|
||||
#endif
|
||||
]],[[
|
||||
$sel_arg1 nfds=0;
|
||||
$sel_arg234 rfds=0;
|
||||
$sel_arg234 wfds=0;
|
||||
$sel_arg234 efds=0;
|
||||
$sel_retv res = select(nfds, rfds, wfds, efds, 0);
|
||||
]])
|
||||
],[
|
||||
curl_cv_func_select_args="$sel_arg1,$sel_arg234,$sel_arg5,$sel_retv"
|
||||
])
|
||||
fi
|
||||
done
|
||||
done
|
||||
done
|
||||
done
|
||||
]) # AC-CACHE-CHECK
|
||||
if test "$curl_cv_func_select_args" = "unknown"; then
|
||||
AC_MSG_WARN([Cannot find proper types to use for select args])
|
||||
AC_MSG_WARN([HAVE_SELECT will not be defined])
|
||||
else
|
||||
select_prev_IFS=$IFS; IFS=','
|
||||
set dummy `echo "$curl_cv_func_select_args" | sed 's/\*/\*/g'`
|
||||
IFS=$select_prev_IFS
|
||||
shift
|
||||
#
|
||||
sel_qual_type_arg5=$[3]
|
||||
#
|
||||
AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
|
||||
[Define to the type of arg 1 for select.])
|
||||
AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, $[2],
|
||||
[Define to the type of args 2, 3 and 4 for select.])
|
||||
AC_DEFINE_UNQUOTED(SELECT_TYPE_RETV, $[4],
|
||||
[Define to the function return type for select.])
|
||||
#
|
||||
prev_sh_opts=$-
|
||||
#
|
||||
case $prev_sh_opts in
|
||||
*f*)
|
||||
;;
|
||||
*)
|
||||
set -f
|
||||
;;
|
||||
esac
|
||||
#
|
||||
case "$sel_qual_type_arg5" in
|
||||
const*)
|
||||
sel_qual_arg5=const
|
||||
sel_type_arg5=`echo $sel_qual_type_arg5 | sed 's/^const //'`
|
||||
;;
|
||||
*)
|
||||
sel_qual_arg5=
|
||||
sel_type_arg5=$sel_qual_type_arg5
|
||||
;;
|
||||
esac
|
||||
#
|
||||
AC_DEFINE_UNQUOTED(SELECT_QUAL_ARG5, $sel_qual_arg5,
|
||||
[Define to the type qualifier of arg 5 for select.])
|
||||
AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, $sel_type_arg5,
|
||||
[Define to the type of arg 5 for select.])
|
||||
#
|
||||
case $prev_sh_opts in
|
||||
*f*)
|
||||
;;
|
||||
*)
|
||||
set +f
|
||||
;;
|
||||
esac
|
||||
#
|
||||
AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
|
||||
[Define to 1 if you have the select function.])
|
||||
curl_cv_func_select="yes"
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
|
||||
[Define to 1 if you have the select function.])
|
||||
curl_cv_func_select="yes"
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
@ -271,6 +271,7 @@ LIB_HFILES = \
|
||||
fileinfo.h \
|
||||
fopen.h \
|
||||
formdata.h \
|
||||
functypes.h \
|
||||
ftp.h \
|
||||
ftplistparser.h \
|
||||
getinfo.h \
|
||||
|
||||
@ -86,11 +86,6 @@
|
||||
#define PACKAGE_TARNAME "curl"
|
||||
#define PACKAGE_VERSION "-"
|
||||
#define CURL_CA_BUNDLE "s:curl-ca-bundle.crt"
|
||||
|
||||
#define SELECT_TYPE_ARG1 int
|
||||
#define SELECT_TYPE_ARG234 (fd_set *)
|
||||
#define SELECT_TYPE_ARG5 (struct timeval *)
|
||||
|
||||
#define STDC_HEADERS 1
|
||||
#define TIME_WITH_SYS_TIME 1
|
||||
|
||||
|
||||
@ -63,10 +63,6 @@
|
||||
#define RECV_TYPE_RETV int
|
||||
|
||||
#define HAVE_SELECT 1
|
||||
#define SELECT_TYPE_ARG1 int
|
||||
#define SELECT_TYPE_ARG234 fd_set *
|
||||
#define SELECT_TYPE_ARG5 struct timeval *
|
||||
#define SELECT_TYPE_RETV int
|
||||
|
||||
#define HAVE_SEND 1
|
||||
#define SEND_TYPE_ARG1 int
|
||||
|
||||
@ -640,54 +640,6 @@
|
||||
/* a suitable file to read random data from */
|
||||
#cmakedefine RANDOM_FILE "${RANDOM_FILE}"
|
||||
|
||||
/* Define to the type of arg 1 for recv. */
|
||||
#cmakedefine RECV_TYPE_ARG1 ${RECV_TYPE_ARG1}
|
||||
|
||||
/* Define to the type of arg 2 for recv. */
|
||||
#cmakedefine RECV_TYPE_ARG2 ${RECV_TYPE_ARG2}
|
||||
|
||||
/* Define to the type of arg 3 for recv. */
|
||||
#cmakedefine RECV_TYPE_ARG3 ${RECV_TYPE_ARG3}
|
||||
|
||||
/* Define to the type of arg 4 for recv. */
|
||||
#cmakedefine RECV_TYPE_ARG4 ${RECV_TYPE_ARG4}
|
||||
|
||||
/* Define to the function return type for recv. */
|
||||
#cmakedefine RECV_TYPE_RETV ${RECV_TYPE_RETV}
|
||||
|
||||
/* Define to the type qualifier of arg 5 for select. */
|
||||
#cmakedefine SELECT_QUAL_ARG5 ${SELECT_QUAL_ARG5}
|
||||
|
||||
/* Define to the type of arg 1 for select. */
|
||||
#cmakedefine SELECT_TYPE_ARG1 ${SELECT_TYPE_ARG1}
|
||||
|
||||
/* Define to the type of args 2, 3 and 4 for select. */
|
||||
#cmakedefine SELECT_TYPE_ARG234 ${SELECT_TYPE_ARG234}
|
||||
|
||||
/* Define to the type of arg 5 for select. */
|
||||
#cmakedefine SELECT_TYPE_ARG5 ${SELECT_TYPE_ARG5}
|
||||
|
||||
/* Define to the function return type for select. */
|
||||
#cmakedefine SELECT_TYPE_RETV ${SELECT_TYPE_RETV}
|
||||
|
||||
/* Define to the type qualifier of arg 2 for send. */
|
||||
#cmakedefine SEND_QUAL_ARG2 ${SEND_QUAL_ARG2}
|
||||
|
||||
/* Define to the type of arg 1 for send. */
|
||||
#cmakedefine SEND_TYPE_ARG1 ${SEND_TYPE_ARG1}
|
||||
|
||||
/* Define to the type of arg 2 for send. */
|
||||
#cmakedefine SEND_TYPE_ARG2 ${SEND_TYPE_ARG2}
|
||||
|
||||
/* Define to the type of arg 3 for send. */
|
||||
#cmakedefine SEND_TYPE_ARG3 ${SEND_TYPE_ARG3}
|
||||
|
||||
/* Define to the type of arg 4 for send. */
|
||||
#cmakedefine SEND_TYPE_ARG4 ${SEND_TYPE_ARG4}
|
||||
|
||||
/* Define to the function return type for send. */
|
||||
#cmakedefine SEND_TYPE_RETV ${SEND_TYPE_RETV}
|
||||
|
||||
/*
|
||||
Note: SIZEOF_* variables are fetched with CMake through check_type_size().
|
||||
As per CMake documentation on CheckTypeSize, C preprocessor code is
|
||||
|
||||
@ -87,6 +87,8 @@
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#include "functypes.h"
|
||||
|
||||
#ifdef __hpux
|
||||
# if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL)
|
||||
# ifdef OLD_APP32_64BIT_OFF_T
|
||||
@ -149,20 +151,10 @@ struct timeval {
|
||||
* SEND_TYPE_RETV must also be defined.
|
||||
*/
|
||||
|
||||
#if !defined(RECV_TYPE_ARG1) || \
|
||||
!defined(RECV_TYPE_ARG2) || \
|
||||
!defined(RECV_TYPE_ARG3) || \
|
||||
!defined(RECV_TYPE_ARG4) || \
|
||||
!defined(RECV_TYPE_RETV)
|
||||
/* */
|
||||
Error Missing_definition_of_return_and_arguments_types_of_recv
|
||||
/* */
|
||||
#else
|
||||
#define sread(x,y,z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \
|
||||
(RECV_TYPE_ARG2)(y), \
|
||||
(RECV_TYPE_ARG3)(z), \
|
||||
(RECV_TYPE_ARG4)(0))
|
||||
#endif
|
||||
#else /* HAVE_RECV */
|
||||
#ifndef sread
|
||||
/* */
|
||||
@ -179,21 +171,10 @@ struct timeval {
|
||||
(SEND_TYPE_ARG3)(z))
|
||||
|
||||
#elif defined(HAVE_SEND)
|
||||
#if !defined(SEND_TYPE_ARG1) || \
|
||||
!defined(SEND_QUAL_ARG2) || \
|
||||
!defined(SEND_TYPE_ARG2) || \
|
||||
!defined(SEND_TYPE_ARG3) || \
|
||||
!defined(SEND_TYPE_ARG4) || \
|
||||
!defined(SEND_TYPE_RETV)
|
||||
/* */
|
||||
Error Missing_definition_of_return_and_arguments_types_of_send
|
||||
/* */
|
||||
#else
|
||||
#define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \
|
||||
(SEND_QUAL_ARG2 SEND_TYPE_ARG2)(y), \
|
||||
(SEND_TYPE_ARG3)(z), \
|
||||
(SEND_TYPE_ARG4)(SEND_4TH_ARG))
|
||||
#endif
|
||||
#else /* HAVE_SEND */
|
||||
#ifndef swrite
|
||||
/* */
|
||||
|
||||
115
lib/functypes.h
Normal file
115
lib/functypes.h
Normal file
@ -0,0 +1,115 @@
|
||||
#ifndef HEADER_CURL_FUNCTYPES_H
|
||||
#define HEADER_CURL_FUNCTYPES_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "curl_setup.h"
|
||||
|
||||
/* defaults:
|
||||
|
||||
ssize_t recv(int, void *, size_t, int);
|
||||
ssize_t send(int, const void *, size_t, int);
|
||||
|
||||
If other argument or return types are needed:
|
||||
|
||||
1. For systems that run configure or cmake, the alternatives are provided
|
||||
here.
|
||||
2. For systems with config-*.h files, define them there.
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
/* int recv(SOCKET, char *, int, int) */
|
||||
#define RECV_TYPE_ARG1 SOCKET
|
||||
#define RECV_TYPE_ARG2 char *
|
||||
#define RECV_TYPE_ARG3 int
|
||||
#define RECV_TYPE_RETV int
|
||||
|
||||
/* int send(SOCKET, const char *, int, int); */
|
||||
#define SEND_TYPE_ARG1 SOCKET
|
||||
#define SEND_TYPE_ARG2 char *
|
||||
#define SEND_TYPE_ARG3 int
|
||||
#define SEND_TYPE_RETV int
|
||||
|
||||
#elif defined(__AMIGA__) /* Any AmigaOS flavour */
|
||||
|
||||
/* long recv(long, char *, long, long); */
|
||||
#define RECV_TYPE_ARG1 long
|
||||
#define RECV_TYPE_ARG2 char *
|
||||
#define RECV_TYPE_ARG3 long
|
||||
#define RECV_TYPE_ARG4 long
|
||||
#define RECV_TYPE_RETV long
|
||||
|
||||
/* int send(int, const char *, int, int); */
|
||||
#define SEND_TYPE_ARG1 int
|
||||
#define SEND_TYPE_ARG2 char *
|
||||
#define SEND_TYPE_ARG3 int
|
||||
#define SEND_TYPE_RETV int
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef RECV_TYPE_ARG1
|
||||
#define RECV_TYPE_ARG1 int
|
||||
#endif
|
||||
|
||||
#ifndef RECV_TYPE_ARG2
|
||||
#define RECV_TYPE_ARG2 void *
|
||||
#endif
|
||||
|
||||
#ifndef RECV_TYPE_ARG3
|
||||
#define RECV_TYPE_ARG3 size_t
|
||||
#endif
|
||||
|
||||
#ifndef RECV_TYPE_ARG4
|
||||
#define RECV_TYPE_ARG4 int
|
||||
#endif
|
||||
|
||||
#ifndef RECV_TYPE_RETV
|
||||
#define RECV_TYPE_RETV ssize_t
|
||||
#endif
|
||||
|
||||
#ifndef SEND_QUAL_ARG2
|
||||
#define SEND_QUAL_ARG2 const
|
||||
#endif
|
||||
|
||||
#ifndef SEND_TYPE_ARG1
|
||||
#define SEND_TYPE_ARG1 int
|
||||
#endif
|
||||
|
||||
#ifndef SEND_TYPE_ARG2
|
||||
#define SEND_TYPE_ARG2 void *
|
||||
#endif
|
||||
|
||||
#ifndef SEND_TYPE_ARG3
|
||||
#define SEND_TYPE_ARG3 size_t
|
||||
#endif
|
||||
|
||||
#ifndef SEND_TYPE_ARG4
|
||||
#define SEND_TYPE_ARG4 int
|
||||
#endif
|
||||
|
||||
#ifndef SEND_TYPE_RETV
|
||||
#define SEND_TYPE_RETV ssize_t
|
||||
#endif
|
||||
|
||||
#endif /* HEADER_CURL_FUNCTYPES_H */
|
||||
@ -31,6 +31,7 @@
|
||||
*/
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include "functypes.h"
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
# define ALLOC_FUNC __attribute__((malloc))
|
||||
|
||||
@ -36,7 +36,8 @@
|
||||
|
||||
#include <gsasl.h>
|
||||
|
||||
/* The last #include files should be: */
|
||||
/* The last 3 #include files should be in this order */
|
||||
#include "curl_printf.h"
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
||||
@ -1661,55 +1661,6 @@ $ goto cfgh_in_loop1
|
||||
$ endif
|
||||
$ endif
|
||||
$!
|
||||
$!
|
||||
$! Process SELECT directives
|
||||
$!-------------------------------------
|
||||
$ if key2a .eqs. "SELECT"
|
||||
$ then
|
||||
$ if key2 .eqs. "SELECT_QUAL_ARG5"
|
||||
$ then
|
||||
$ write tf "#ifndef ''key2'"
|
||||
$ write tf "#define ''key2' const"
|
||||
$ write tf "#endif"
|
||||
$ goto cfgh_in_loop1
|
||||
$ endif
|
||||
$ if key2 .eqs. "SELECT_TYPE_ARG1"
|
||||
$ then
|
||||
$ write tf "#ifndef ''key2'"
|
||||
$ write tf "#define ''key2' int"
|
||||
$ write tf "#endif"
|
||||
$ goto cfgh_in_loop1
|
||||
$ endif
|
||||
$ if key2 .eqs. "SELECT_TYPE_ARG2"
|
||||
$ then
|
||||
$ write tf "#ifndef ''key2'"
|
||||
$ write tf "#define ''key2' void *"
|
||||
$ write tf "#endif"
|
||||
$ goto cfgh_in_loop1
|
||||
$ endif
|
||||
$ if key2 .eqs. "SELECT_TYPE_ARG234"
|
||||
$ then
|
||||
$ write tf "#ifndef ''key2'"
|
||||
$ write tf "#define ''key2' fd_set *"
|
||||
$ write tf "#endif"
|
||||
$ goto cfgh_in_loop1
|
||||
$ endif
|
||||
$ if key2 .eqs. "SELECT_TYPE_ARG5"
|
||||
$ then
|
||||
$ write tf "#ifndef ''key2'"
|
||||
$ write tf "#define ''key2' struct timeval *"
|
||||
$ write tf "#endif"
|
||||
$ goto cfgh_in_loop1
|
||||
$ endif
|
||||
$ if key2 .eqs. "SELECT_TYPE_RETV"
|
||||
$ then
|
||||
$ write tf "#ifndef ''key2'"
|
||||
$ write tf "#define ''key2' int"
|
||||
$ write tf "#endif"
|
||||
$ goto cfgh_in_loop1
|
||||
$ endif
|
||||
$ endif
|
||||
$!
|
||||
$! Process SEND directives
|
||||
$!-------------------------------------
|
||||
$ if key2a .eqs. "SEND"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user