summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2008-07-16 19:16:41 +0000
committerYang Tse <yangsita@gmail.com>2008-07-16 19:16:41 +0000
commit7dd6d7cbe13a7b55a52be0bdf6499ca809ea8523 (patch)
treeeea630e5f9f1755ec6fdc2116457da6615b3698d
parent6b84d9ff24e5d4921fb12f43b66f2b668b42bd06 (diff)
downloadc-ares-7dd6d7cbe13a7b55a52be0bdf6499ca809ea8523.tar.gz
c-ares-7dd6d7cbe13a7b55a52be0bdf6499ca809ea8523.tar.bz2
c-ares-7dd6d7cbe13a7b55a52be0bdf6499ca809ea8523.zip
Configure process now checks availability of recvfrom() socket function and
finds out its return type and the types of its arguments. Added definitions for non-configure systems config files, and introduced macro sreadfrom which will be used on udp sockets as a recvfrom() wrapper.
-rw-r--r--CHANGES5
-rw-r--r--Makefile.dj6
-rw-r--r--Makefile.netware15
-rw-r--r--acinclude.m4146
-rw-r--r--config-win32.h24
-rw-r--r--configure.ac3
-rw-r--r--setup_once.h33
7 files changed, 228 insertions, 4 deletions
diff --git a/CHANGES b/CHANGES
index 91430ac..0067357 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,11 @@
- Improved configure detection of number of arguments for getservbyport_r.
Detection is now based on compilation checks instead of linker ones.
+- Configure process now checks availability of recvfrom() socket function and
+ finds out its return type and the types of its arguments. Added definitions
+ for non-configure systems config files, and introduced macro sreadfrom which
+ will be used on udp sockets as a recvfrom() wrapper.
+
* Jul 15 2008 (Yang Tse)
- Introduce definition of _REENTRANT symbol in setup.h to improve library
usability. Previously the configure process only used the AC_SYS_LARGEFILE
diff --git a/Makefile.dj b/Makefile.dj
index 804b0a7..0539e4b 100644
--- a/Makefile.dj
+++ b/Makefile.dj
@@ -23,7 +23,11 @@ CFLAGS += -DWATT32 -DHAVE_AF_INET6 -DHAVE_PF_INET6 -DHAVE_IOCTLSOCKET \
-DRECV_TYPE_ARG1='int' -DRECV_TYPE_ARG2='void*' \
-DRECV_TYPE_ARG3='int' -DRECV_TYPE_ARG4='int' \
-DRECV_TYPE_RETV='int' -DHAVE_STRUCT_TIMEVAL \
- -Dselect=select_s -Dsocklen_t=int -UHAVE_CONFIG_H
+ -Dselect=select_s -Dsocklen_t=int -UHAVE_CONFIG_H \
+ -DRECVFROM_TYPE_ARG1='int' -DRECVFROM_TYPE_ARG2='void*' \
+ -DRECVFROM_TYPE_ARG3='int' -DRECVFROM_TYPE_ARG4='int' \
+ -DRECVFROM_TYPE_ARG6='int*' -DRECVFROM_TYPE_RETV='int' \
+ -DRECVFROM_TYPE_ARG5='struct sockaddr*' -DHAVE_RECVFROM
LDFLAGS = -s
diff --git a/Makefile.netware b/Makefile.netware
index 2f2b8ec..874e59d 100644
--- a/Makefile.netware
+++ b/Makefile.netware
@@ -288,6 +288,13 @@ ifeq ($(LIBARCH),CLIB)
@echo $(DL)#define RECV_TYPE_ARG3 int$(DL) >> $@
@echo $(DL)#define RECV_TYPE_ARG4 int$(DL) >> $@
@echo $(DL)#define RECV_TYPE_RETV int$(DL) >> $@
+ @echo $(DL)#define RECVFROM_TYPE_ARG1 int$(DL) >> $@
+ @echo $(DL)#define RECVFROM_TYPE_ARG2 char *$(DL) >> $@
+ @echo $(DL)#define RECVFROM_TYPE_ARG3 int$(DL) >> $@
+ @echo $(DL)#define RECVFROM_TYPE_ARG4 int$(DL) >> $@
+ @echo $(DL)#define RECVFROM_TYPE_ARG5 struct sockaddr *$(DL) >> $@
+ @echo $(DL)#define RECVFROM_TYPE_ARG6 int *$(DL) >> $@
+ @echo $(DL)#define RECVFROM_TYPE_RETV int$(DL) >> $@
@echo $(DL)#define SEND_QUAL_ARG2$(DL) >> $@
@echo $(DL)#define SEND_TYPE_ARG1 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_ARG2 char *$(DL) >> $@
@@ -324,6 +331,13 @@ else
@echo $(DL)#define RECV_TYPE_ARG3 size_t$(DL) >> $@
@echo $(DL)#define RECV_TYPE_ARG4 int$(DL) >> $@
@echo $(DL)#define RECV_TYPE_RETV ssize_t$(DL) >> $@
+ @echo $(DL)#define RECVFROM_TYPE_ARG1 int$(DL) >> $@
+ @echo $(DL)#define RECVFROM_TYPE_ARG2 void *$(DL) >> $@
+ @echo $(DL)#define RECVFROM_TYPE_ARG3 size_t$(DL) >> $@
+ @echo $(DL)#define RECVFROM_TYPE_ARG4 int$(DL) >> $@
+ @echo $(DL)#define RECVFROM_TYPE_ARG5 struct sockaddr *$(DL) >> $@
+ @echo $(DL)#define RECVFROM_TYPE_ARG6 int *$(DL) >> $@
+ @echo $(DL)#define RECVFROM_TYPE_RETV ssize_t$(DL) >> $@
@echo $(DL)#define SEND_QUAL_ARG2$(DL) >> $@
@echo $(DL)#define SEND_TYPE_ARG1 int$(DL) >> $@
@echo $(DL)#define SEND_TYPE_ARG2 void *$(DL) >> $@
@@ -349,6 +363,7 @@ endif
@echo $(DL)#define HAVE_MALLOC_H 1$(DL) >> $@
@echo $(DL)#define HAVE_NETINET_IN_H 1$(DL) >> $@
@echo $(DL)#define HAVE_RECV 1$(DL) >> $@
+ @echo $(DL)#define HAVE_RECVFROM 1$(DL) >> $@
@echo $(DL)#define HAVE_SELECT 1$(DL) >> $@
@echo $(DL)#define HAVE_SEND 1$(DL) >> $@
@echo $(DL)#define HAVE_SETJMP_H 1$(DL) >> $@
diff --git a/acinclude.m4 b/acinclude.m4
index bd39985..95ab7a3 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1049,6 +1049,152 @@ AC_DEFUN([CURL_CHECK_FUNC_SEND], [
]) # AC_DEFUN
+dnl CURL_CHECK_FUNC_RECVFROM
+dnl -------------------------------------------------
+dnl Test if the socket recvfrom() function is available,
+dnl and check its return type and the types of its
+dnl arguments. If the function succeeds HAVE_RECVFROM
+dnl will be defined, defining the types of the arguments
+dnl in RECVFROM_TYPE_ARG1, RECVFROM_TYPE_ARG2, and so on
+dnl to RECVFROM_TYPE_ARG6, defining also the type of the
+dnl function return value in RECVFROM_TYPE_RETV.
+
+AC_DEFUN([CURL_CHECK_FUNC_RECVFROM], [
+ AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
+ AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
+ AC_CHECK_HEADERS(sys/types.h sys/socket.h)
+ #
+ AC_MSG_CHECKING([for recvfrom])
+ AC_LINK_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>
+#else
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#endif
+#else
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#endif
+ ]],[[
+ recvfrom(0, 0, 0, 0, 0, 0);
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ curl_cv_recvfrom="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ curl_cv_recvfrom="no"
+ ])
+ #
+ if test "$curl_cv_recvfrom" = "yes"; then
+ AC_CACHE_CHECK([types of args and return type for recvfrom],
+ [curl_cv_func_recvfrom_args], [
+ curl_cv_func_recvfrom_args="unknown"
+ for recvfrom_retv in 'int' 'ssize_t'; do
+ for recvfrom_arg1 in 'int' 'ssize_t' 'SOCKET'; do
+ for recvfrom_arg2 in 'char *' 'void *'; do
+ for recvfrom_arg3 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do
+ for recvfrom_arg4 in 'int' 'unsigned int'; do
+ for recvfrom_arg5 in 'struct sockaddr *' 'void *'; do
+ for recvfrom_arg6 in 'socklen_t *' 'int *' 'unsigned int *' 'size_t *'; do
+ if test "$curl_cv_func_recvfrom_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>
+#else
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#endif
+#define RECVFROMCALLCONV PASCAL
+#else
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#define RECVFROMCALLCONV
+#endif
+ extern $recvfrom_retv RECVFROMCALLCONV
+ recvfrom($recvfrom_arg1, $recvfrom_arg2,
+ $recvfrom_arg3, $recvfrom_arg4,
+ $recvfrom_arg5, $recvfrom_arg6);
+ ]],[[
+ $recvfrom_arg1 s=0;
+ $recvfrom_arg2 buf=0;
+ $recvfrom_arg3 len=0;
+ $recvfrom_arg4 flags=0;
+ $recvfrom_arg5 addr=0;
+ $recvfrom_arg6 addrlen=0;
+ $recvfrom_retv res=0;
+ res = recvfrom(s, buf, len, flags, addr, addrlen);
+ ]])
+ ],[
+ curl_cv_func_recvfrom_args="$recvfrom_arg1,$recvfrom_arg2,$recvfrom_arg3,$recvfrom_arg4,$recvfrom_arg5,$recvfrom_arg6,$recvfrom_retv"
+ ])
+ fi
+ done
+ done
+ done
+ done
+ done
+ done
+ done
+ ]) # AC_CACHE_CHECK
+ if test "$curl_cv_func_recvfrom_args" = "unknown"; then
+ AC_MSG_ERROR([Cannot find proper types to use for recvfrom args])
+ else
+ recvfrom_prev_IFS=$IFS; IFS=','
+ set dummy `echo "$curl_cv_func_recvfrom_args" | sed 's/\*/\*/g'`
+ IFS=$recvfrom_prev_IFS
+ shift
+ #
+ AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG1, $[1],
+ [Define to the type of arg 1 for recvfrom.])
+ AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG2, $[2],
+ [Define to the type of arg 2 for recvfrom.])
+ AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG3, $[3],
+ [Define to the type of arg 3 for recvfrom.])
+ AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG4, $[4],
+ [Define to the type of arg 4 for recvfrom.])
+ AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG5, $[5],
+ [Define to the type of arg 5 for recvfrom.])
+ AC_DEFINE_UNQUOTED(RECVFROM_TYPE_ARG6, $[6],
+ [Define to the type of arg 6 for recvfrom.])
+ AC_DEFINE_UNQUOTED(RECVFROM_TYPE_RETV, $[7],
+ [Define to the function return type for recvfrom.])
+ #
+ AC_DEFINE_UNQUOTED(HAVE_RECVFROM, 1,
+ [Define to 1 if you have the recvfrom function.])
+ ac_cv_func_recvfrom="yes"
+ fi
+ else
+ AC_MSG_ERROR([Unable to link function recvfrom])
+ fi
+]) # AC_DEFUN
+
+
dnl CURL_CHECK_MSG_NOSIGNAL
dnl -------------------------------------------------
dnl Check for MSG_NOSIGNAL
diff --git a/config-win32.h b/config-win32.h
index 854143d..8e621a4 100644
--- a/config-win32.h
+++ b/config-win32.h
@@ -97,6 +97,30 @@
/* Define to the function return type for recv. */
#define RECV_TYPE_RETV int
+/* Define if you have the recvfrom function. */
+#define HAVE_RECVFROM 1
+
+/* Define to the type of arg 1 for recvfrom. */
+#define RECVFROM_TYPE_ARG1 SOCKET
+
+/* Define to the type of arg 2 for recvfrom. */
+#define RECVFROM_TYPE_ARG2 char *
+
+/* Define to the type of arg 3 for recvfrom. */
+#define RECVFROM_TYPE_ARG3 int
+
+/* Define to the type of arg 4 for recvfrom. */
+#define RECVFROM_TYPE_ARG4 int
+
+/* Define to the type of arg 5 for recvfrom. */
+#define RECVFROM_TYPE_ARG5 struct sockaddr *
+
+/* Define to the type of arg 6 for recvfrom. */
+#define RECVFROM_TYPE_ARG6 int *
+
+/* Define to the function return type for recvfrom. */
+#define RECVFROM_TYPE_RETV int
+
/* Define if you have the send function. */
#define HAVE_SEND 1
diff --git a/configure.ac b/configure.ac
index 57f16c3..2f7f6c9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -623,9 +623,8 @@ TYPE_SIG_ATOMIC_T
AC_TYPE_SIGNAL
CURL_CHECK_FUNC_RECV
-
+CURL_CHECK_FUNC_RECVFROM
CURL_CHECK_FUNC_SEND
-
CURL_CHECK_MSG_NOSIGNAL
dnl check for AF_INET6
diff --git a/setup_once.h b/setup_once.h
index 59ed25c..85a291a 100644
--- a/setup_once.h
+++ b/setup_once.h
@@ -3,7 +3,7 @@
/* $Id$ */
-/* Copyright (C) 2004 - 2007 by Daniel Stenberg et al
+/* Copyright (C) 2004 - 2008 by Daniel Stenberg et al
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
@@ -191,6 +191,37 @@ struct timeval {
#endif /* HAVE_SEND */
+#if defined(HAVE_RECVFROM)
+/*
+ * Currently recvfrom is only used on udp sockets.
+ */
+#if !defined(RECVFROM_TYPE_ARG1) || \
+ !defined(RECVFROM_TYPE_ARG2) || \
+ !defined(RECVFROM_TYPE_ARG3) || \
+ !defined(RECVFROM_TYPE_ARG4) || \
+ !defined(RECVFROM_TYPE_ARG5) || \
+ !defined(RECVFROM_TYPE_ARG6) || \
+ !defined(RECVFROM_TYPE_RETV)
+ /* */
+ Error Missing_definition_of_return_and_arguments_types_of_recvfrom
+ /* */
+#else
+#define sreadfrom(s,b,bl,f,fl) (ssize_t)recvfrom((RECVFROM_TYPE_ARG1)(s), \
+ (RECVFROM_TYPE_ARG2)(b), \
+ (RECVFROM_TYPE_ARG3)(bl), \
+ (RECVFROM_TYPE_ARG4)(0), \
+ (RECVFROM_TYPE_ARG5)(f), \
+ (RECVFROM_TYPE_ARG6)(fl))
+#endif
+#else /* HAVE_RECVFROM */
+#ifndef sreadfrom
+ /* */
+ Error Missing_definition_of_macro_sreadfrom
+ /* */
+#endif
+#endif /* HAVE_RECVFROM */
+
+
/*
* Uppercase macro versions of ANSI/ISO is*() functions/macros which
* avoid negative number inputs with argument byte codes > 127.