1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 08:08:50 -05:00

Initial step towards a configure time curl_socklen_t definition

This commit is contained in:
Yang Tse 2009-04-26 18:51:03 +00:00
parent bd27401311
commit 0daeab3b8d
5 changed files with 186 additions and 5 deletions

View File

@ -3053,6 +3053,110 @@ AC_DEFUN([CURL_CONFIGURE_CURL_OFF_T], [
])
dnl CURL_CONFIGURE_CURL_SOCKLEN_T
dnl -------------------------------------------------
dnl Find out suitable curl_socklen_t data type definition and size, making
dnl appropriate definitions for template file include/curl/curlbuild.h.in
dnl to properly configure and use the library.
dnl
dnl The need for the curl_socklen_t definition arises mainly to properly
dnl interface HP-UX systems which on one hand have a typedef'ed socklen_t
dnl data type which is 32 or 64-Bit wide depending on the data model being
dnl used, and that on the other hand is only actually used when interfacing
dnl the X/Open sockets provided in the xnet library.
AC_DEFUN([CURL_CONFIGURE_CURL_SOCKLEN_T], [
AC_REQUIRE([CURL_INCLUDES_WS2TCPIP])dnl
AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl
AC_REQUIRE([CURL_PREPROCESS_CALLCONV])dnl
#
AC_MSG_CHECKING([for curl_socklen_t data type])
curl_typeof_curl_socklen_t="unknown"
for arg1 in int SOCKET; do
for arg2 in 'struct sockaddr' void; do
for t in socklen_t int size_t 'unsigned int' long 'unsigned long'; do
if test "$curl_typeof_curl_socklen_t" = "unknown"; then
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
$curl_includes_ws2tcpip
$curl_includes_sys_socket
$curl_preprocess_callconv
extern int FUNCALLCONV getpeername($arg1, $arg2 *, $t *);
]],[[
$t len = 0;
getpeername(0, 0, &len);
]])
],[
curl_typeof_curl_socklen_t="$t"
])
fi
done
done
done
AC_MSG_RESULT([$curl_typeof_curl_socklen_t])
if test "$curl_typeof_curl_socklen_t" = "unknown"; then
AC_MSG_ERROR([cannot find data type for curl_socklen_t.])
fi
#
AC_MSG_CHECKING([size of curl_socklen_t])
curl_sizeof_curl_socklen_t="unknown"
curl_pull_headers_socklen_t="unknown"
for tst_pull_headers in 'none' 'ws2tcpip' 'systypes' 'syssocket'; do
if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
case $tst_pull_headers in
none)
tmp_includes=""
;;
ws2tcpip)
tmp_includes="$curl_includes_ws2tcpip"
;;
systypes)
tmp_includes="$curl_includes_sys_types"
;;
syssocket)
tmp_includes="$curl_includes_sys_socket"
;;
esac
for tst_size in 8 4 2; do
if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
$tmp_includes
typedef $curl_typeof_curl_socklen_t curl_socklen_t;
typedef char dummy_arr[sizeof(curl_socklen_t) == $tst_size ? 1 : -1];
]],[[
curl_socklen_t dummy;
]])
],[
curl_sizeof_curl_socklen_t="$tst_size"
curl_pull_headers_socklen_t="$tst_pull_headers"
])
fi
done
fi
done
AC_MSG_RESULT([$curl_sizeof_curl_socklen_t])
if test "$curl_sizeof_curl_socklen_t" = "unknown"; then
AC_MSG_ERROR([cannot find out size of curl_socklen_t.])
fi
#
case $curl_pull_headers_socklen_t in
ws2tcpip)
CURL_DEFINE_UNQUOTED([CURL_PULL_WS2TCPIP_H])
;;
systypes)
CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
;;
syssocket)
CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_TYPES_H])
CURL_DEFINE_UNQUOTED([CURL_PULL_SYS_SOCKET_H])
;;
esac
CURL_DEFINE_UNQUOTED([CURL_TYPEOF_CURL_SOCKLEN_T], [$curl_typeof_curl_socklen_t])
CURL_DEFINE_UNQUOTED([CURL_SIZEOF_CURL_SOCKLEN_T], [$curl_sizeof_curl_socklen_t])
])
dnl CURL_CHECK_WIN32_LARGEFILE
dnl -------------------------------------------------
dnl Check if curl's WIN32 large file will be used

View File

@ -1,7 +1,7 @@
#***************************************************************************
# $Id$
#
# Copyright (C) 2008 by Daniel Stenberg et al
# Copyright (C) 2008 - 2009 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
@ -16,7 +16,7 @@
#***************************************************************************
# File version for 'aclocal' use. Keep it a single number.
# serial 26
# serial 28
dnl CARES_INCLUDES_ARPA_INET
@ -284,6 +284,23 @@ cares_includes_ws2tcpip="\
])
dnl CARES_PREPROCESS_CALLCONV
dnl -------------------------------------------------
dnl Set up variable with a preprocessor block which
dnl defines function calling convention.
AC_DEFUN([CARES_PREPROCESS_CALLCONV], [
cares_preprocess_callconv="\
/* preprocess start */
#ifdef HAVE_WINDOWS_H
# define FUNCALLCONV __stdcall
#else
# define FUNCALLCONV
#endif
/* preprocess end */"
])
dnl CARES_CHECK_FUNC_FCNTL
dnl -------------------------------------------------
dnl Verify if fcntl is available, prototyped, and

View File

@ -2000,6 +2000,8 @@ AC_CHECK_TYPE([bool],[
# Check for socklen_t or equivalent
CURL_CHECK_TYPE_SOCKLEN_T
CURL_CONFIGURE_CURL_SOCKLEN_T
TYPE_IN_ADDR_T
TYPE_SOCKADDR_STORAGE

View File

@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2009, 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
@ -63,6 +63,16 @@
Error Compilation_aborted_CURL_SIZEOF_LONG_already_defined
#endif
#ifdef CURL_TYPEOF_CURL_SOCKLEN_T
# error "CURL_TYPEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h"
Error Compilation_aborted_CURL_TYPEOF_CURL_SOCKLEN_T_already_defined
#endif
#ifdef CURL_SIZEOF_CURL_SOCKLEN_T
# error "CURL_SIZEOF_CURL_SOCKLEN_T shall not be defined except in curlbuild.h"
Error Compilation_aborted_CURL_SIZEOF_CURL_SOCKLEN_T_already_defined
#endif
#ifdef CURL_TYPEOF_CURL_OFF_T
# error "CURL_TYPEOF_CURL_OFF_T shall not be defined except in curlbuild.h"
Error Compilation_aborted_CURL_TYPEOF_CURL_OFF_T_already_defined
@ -123,9 +133,22 @@
# include <inttypes.h>
#endif
/* Configure process defines this to 1 when it finds out that system */
/* header file sys/socket.h must be included by the external interface. */
#undef CURL_PULL_SYS_SOCKET_H
#ifdef CURL_PULL_SYS_SOCKET_H
# include <sys/socket.h>
#endif
/* The size of `long', as computed by sizeof. */
#undef CURL_SIZEOF_LONG
/* Integral data type used for curl_socklen_t. */
#undef CURL_TYPEOF_CURL_SOCKLEN_T
/* The size of `curl_socklen_t', as computed by sizeof. */
#undef CURL_SIZEOF_CURL_SOCKLEN_T
/* Signed integral data type used for curl_off_t. */
#undef CURL_TYPEOF_CURL_OFF_T

View File

@ -5,7 +5,7 @@
# | (__| |_| | _ <| |___
# \___|\___/|_| \_\_____|
#
# Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
# Copyright (C) 1998 - 2009, 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
@ -22,7 +22,7 @@
#***************************************************************************
# File version for 'aclocal' use. Keep it a single number.
# serial 45
# serial 46
dnl CURL_INCLUDES_ARPA_INET
@ -307,6 +307,24 @@ curl_includes_sys_socket="\
])
dnl CURL_INCLUDES_SYS_TYPES
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
dnl included when sys/types.h is to be included.
AC_DEFUN([CURL_INCLUDES_SYS_TYPES], [
curl_includes_sys_types="\
/* includes start */
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
/* includes end */"
AC_CHECK_HEADERS(
sys/types.h,
[], [], [$curl_includes_sys_types])
])
dnl CURL_INCLUDES_SYS_UIO
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
@ -433,6 +451,23 @@ curl_includes_ws2tcpip="\
])
dnl CURL_PREPROCESS_CALLCONV
dnl -------------------------------------------------
dnl Set up variable with a preprocessor block which
dnl defines function calling convention.
AC_DEFUN([CURL_PREPROCESS_CALLCONV], [
curl_preprocess_callconv="\
/* preprocess start */
#ifdef HAVE_WINDOWS_H
# define FUNCALLCONV __stdcall
#else
# define FUNCALLCONV
#endif
/* preprocess end */"
])
dnl CURL_CHECK_FUNC_ALARM
dnl -------------------------------------------------
dnl Verify if alarm is available, prototyped, and