Home | History | Annotate | Download | only in netperf
      1 
      2 dnl This comes from libcurl's acinclude.m4.  it is not clear if this
      3 dnl is original libcurl code, or other code, so we include the libcurl
      4 dnl copyright here
      5 dnl
      6 dnl 
      7 dnl Copyright (c) 1996 - 2005, Daniel Stenberg, <daniel (a] haxx.se>.
      8 dnl 
      9 dnl All rights reserved.
     10 dnl 
     11 dnl Permission to use, copy, modify, and distribute this software for any purpose
     12 dnl with or without fee is hereby granted, provided that the above copyright
     13 dnl notice and this permission notice appear in all copies.
     14 dnl 
     15 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16 dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17 dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN
     18 dnl NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
     19 dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
     20 dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
     21 dnl OR OTHER DEALINGS IN THE SOFTWARE.
     22 dnl 
     23 dnl Except as contained in this notice, the name of a copyright holder shall not
     24 dnl be used in advertising or otherwise to promote the sale, use or other dealings
     25 dnl in this Software without prior written authorization of the copyright holder.
     26 
     27 dnl Check for socklen_t: historically on BSD it is an int, and in
     28 dnl POSIX 1g it is a type of its own, but some platforms use different
     29 dnl types for the argument to getsockopt, getpeername, etc.  So we
     30 dnl have to test to find something that will work.
     31 
     32 dnl Remove the AC_CHECK_TYPE - on HP-UX it would find a socklen_t, but the 
     33 dnl function prototypes for getsockopt et al will not actually use 
     34 dnl socklen_t args unless _XOPEN_SOURCE_EXTENDED is defined. so, the
     35 dnl AC_CHECK_TYPE will find a socklen_t and think all is happiness and
     36 dnl joy when you will really get warnings about mismatch types - type
     37 dnl mismatches that would be possibly Bad (tm) in a 64-bit compile.
     38 dnl raj 2005-05-11 this change may be redistributed at will 
     39 
     40 dnl also, added "extern" to the "int getpeername" in an attempt to resolve
     41 dnl an issue with this code under Solaris 2.9.  this too may be 
     42 dnl redistributed at will
     43 
     44 
     45 AC_DEFUN([OLD_TYPE_SOCKLEN_T],
     46 [
     47       AC_MSG_CHECKING([for socklen_t equivalent])
     48       AC_CACHE_VAL([curl_cv_socklen_t_equiv],
     49       [
     50          # Systems have either "struct sockaddr *" or
     51          # "void *" as the second argument to getpeername
     52          curl_cv_socklen_t_equiv=
     53          for arg2 in "struct sockaddr" void; do
     54             for t in int size_t unsigned long "unsigned long" socklen_t; do
     55                AC_TRY_COMPILE([
     56                   #ifdef HAVE_SYS_TYPES_H
     57                   #include <sys/types.h>
     58                   #endif
     59                   #ifdef HAVE_SYS_SOCKET_H
     60                   #include <sys/socket.h>
     61                   #endif
     62 
     63                   extern int getpeername (int, $arg2 *, $t *);
     64                ],[
     65                   $t len;
     66                   getpeername(0,0,&len);
     67                ],[
     68                   curl_cv_socklen_t_equiv="$t"
     69                   break 2
     70                ])
     71             done
     72          done
     73 
     74          if test "x$curl_cv_socklen_t_equiv" = x; then
     75         # take a wild guess
     76             curl_cv_socklen_t_equiv="socklen_t"
     77             AC_MSG_WARN([Cannot find a type to use in place of socklen_t, guessing socklen_t])
     78          fi
     79       ])
     80       AC_MSG_RESULT($curl_cv_socklen_t_equiv)
     81       AC_DEFINE_UNQUOTED(netperf_socklen_t, $curl_cv_socklen_t_equiv,
     82                         [type to use in place of socklen_t if not defined])
     83 ])
     84 
     85 
     86 dnl *
     87 dnl * Copyright (c) 2001  Motoyuki Kasahara
     88 dnl *
     89 dnl * Redistribution and use in source and binary forms, with or without
     90 dnl * modification, are permitted provided that the following conditions
     91 dnl * are met:
     92 dnl * 1. Redistributions of source code must retain the above copyright
     93 dnl *    notice, this list of conditions and the following disclaimer.
     94 dnl * 2. Redistributions in binary form must reproduce the above copyright
     95 dnl *    notice, this list of conditions and the following disclaimer in the
     96 dnl *    documentation and/or other materials provided with the distribution.
     97 dnl * 3. Neither the name of the project nor the names of its contributors
     98 dnl *    may be used to endorse or promote products derived from this software
     99 dnl *    without specific prior written permission.
    100 dnl * 
    101 dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
    102 dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    103 dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    104 dnl * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE
    105 dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    106 dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    107 dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    108 dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    109 dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    110 dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
    111 dnl * THE POSSIBILITY OF SUCH DAMAGE.
    112 dnl *
    113 
    114 dnl * 
    115 dnl * Check for h_errno.
    116 dnl *
    117 AC_DEFUN([AC_DECL_H_ERRNO],
    118 [AC_CACHE_CHECK(for h_errno declaration in netdb.h, ac_cv_decl_h_errno,
    119 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
    120 #include <netdb.h>]], [[
    121 h_errno = 0;
    122 ]])],[ac_cv_decl_h_errno=yes],[ac_cv_decl_h_errno=no])])
    123 if test "$ac_cv_decl_h_errno" = yes; then
    124     AC_DEFINE(H_ERRNO_DECLARED, 1,
    125 [Define to 1 if `h_errno' is declared by <netdb.h>])
    126 fi])
    127 
    128 dnl *
    129 dnl * Copyright (c) 2001  Motoyuki Kasahara
    130 dnl *
    131 dnl * Redistribution and use in source and binary forms, with or without
    132 dnl * modification, are permitted provided that the following conditions
    133 dnl * are met:
    134 dnl * 1. Redistributions of source code must retain the above copyright
    135 dnl *    notice, this list of conditions and the following disclaimer.
    136 dnl * 2. Redistributions in binary form must reproduce the above copyright
    137 dnl *    notice, this list of conditions and the following disclaimer in the
    138 dnl *    documentation and/or other materials provided with the distribution.
    139 dnl * 3. Neither the name of the project nor the names of its contributors
    140 dnl *    may be used to endorse or promote products derived from this software
    141 dnl *    without specific prior written permission.
    142 dnl * 
    143 dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
    144 dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    145 dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    146 dnl * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE
    147 dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    148 dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    149 dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    150 dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    151 dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    152 dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
    153 dnl * THE POSSIBILITY OF SUCH DAMAGE.
    154 dnl *
    155 
    156 dnl * 
    157 dnl * Check for struct sockaddr_in6
    158 dnl *
    159 AC_DEFUN([AC_STRUCT_SOCKADDR_IN6],
    160 [AC_CACHE_CHECK(for struct sockaddr_in6, ac_cv_struct_sockaddr_in6,
    161 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
    162 #include <sys/types.h>
    163 #include <sys/socket.h>
    164 #include <netinet/in.h>]], [[
    165 struct sockaddr_in6 address;
    166 ]])],[ac_cv_struct_sockaddr_in6=yes],[ac_cv_struct_sockaddr_in6=no])])
    167 if test "$ac_cv_struct_sockaddr_in6" = yes; then
    168     AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1,
    169 [Define to 1 if <netinet/in.h> defines `struct sockaddr_in6'])
    170 fi])
    171 
    172 dnl * 
    173 dnl * Check for struct sockaddr_storage
    174 dnl * 
    175 AC_DEFUN([AC_STRUCT_SOCKADDR_STORAGE],
    176 [AC_CACHE_CHECK(for struct sockaddr_storage, ac_cv_struct_sockaddr_storage,
    177 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
    178 #include <sys/types.h>
    179 #include <sys/socket.h>
    180 #include <netinet/in.h>]], [[
    181 struct sockaddr_storage address;
    182 ]])],[ac_cv_struct_sockaddr_storage=yes],[ac_cv_struct_sockaddr_storage=no])])
    183 if test "$ac_cv_struct_sockaddr_storage" = yes; then
    184     AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1,
    185 [Define to 1 if <netinet/in.h> defines `struct sockaddr_storage'])
    186 fi])
    187 
    188 dnl *
    189 dnl * Copyright (c) 2001, 2003  Motoyuki Kasahara
    190 dnl *
    191 dnl * Redistribution and use in source and binary forms, with or without
    192 dnl * modification, are permitted provided that the following conditions
    193 dnl * are met:
    194 dnl * 1. Redistributions of source code must retain the above copyright
    195 dnl *    notice, this list of conditions and the following disclaimer.
    196 dnl * 2. Redistributions in binary form must reproduce the above copyright
    197 dnl *    notice, this list of conditions and the following disclaimer in the
    198 dnl *    documentation and/or other materials provided with the distribution.
    199 dnl * 3. Neither the name of the project nor the names of its contributors
    200 dnl *    may be used to endorse or promote products derived from this software
    201 dnl *    without specific prior written permission.
    202 dnl * 
    203 dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
    204 dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    205 dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    206 dnl * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE
    207 dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    208 dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    209 dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    210 dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    211 dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    212 dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
    213 dnl * THE POSSIBILITY OF SUCH DAMAGE.
    214 dnl *
    215 
    216 dnl * 
    217 dnl * Check for socklen_t.
    218 dnl * 
    219 AC_DEFUN([AC_TYPE_SOCKLEN_T],
    220 [AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t,
    221 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
    222 #include <sys/types.h>
    223 #include <sys/socket.h>]], [[
    224 socklen_t socklen;
    225 ]])],[ac_cv_type_socklen_t=yes],[ac_cv_type_socklen_t=no])])
    226 if test "$ac_cv_type_socklen_t" != yes; then
    227     AC_DEFINE(socklen_t, int,
    228 [Define to `int' if <sys/types.h> or <sys/socket.h> does not define.])
    229 fi])
    230 
    231 dnl * 
    232 dnl * Check for in_port_t.
    233 dnl * 
    234 AC_DEFUN([AC_TYPE_IN_PORT_T],
    235 [AC_CACHE_CHECK([for in_port_t], ac_cv_type_in_port_t,
    236 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
    237 #include <sys/types.h>
    238 #include <sys/socket.h>
    239 #include <netinet/in.h>]], [[
    240 in_port_t in_port;
    241 ]])],[ac_cv_type_in_port_t=yes],[ac_cv_type_in_port_t=no])])
    242 if test "$ac_cv_type_in_port_t" != yes; then
    243     ac_cv_sin_port_size=unknown
    244     AC_RUN_IFELSE([AC_LANG_SOURCE([[
    245     #include <sys/types.h>
    246     #include <sys/socket.h>
    247     #include <netinet/in.h>
    248     int main() {
    249 	struct sockaddr_in addr;
    250 	return (sizeof(addr.sin_port) == sizeof(long)) ? 0 : 1;
    251     }
    252     ]])],[ac_cv_sin_port_size=long],[],[])
    253     AC_RUN_IFELSE([AC_LANG_SOURCE([[
    254     #include <sys/types.h>
    255     #include <sys/socket.h>
    256     #include <netinet/in.h>
    257     int main() {
    258 	struct sockaddr_in addr;
    259 	return (sizeof(addr.sin_port) == sizeof(int)) ? 0 : 1;
    260     }
    261     ]])],[ac_cv_sin_port_size=int],[],[])
    262     AC_RUN_IFELSE([AC_LANG_SOURCE([[
    263     #include <sys/types.h>
    264     #include <sys/socket.h>
    265     #include <netinet/in.h>
    266     int main() {
    267 	struct sockaddr_in addr;
    268 	return (sizeof(addr.sin_port) == sizeof(short)) ? 0 : 1;
    269     }
    270     ]])],[ac_cv_sin_port_size=short],[],[])
    271     AC_RUN_IFELSE([AC_LANG_SOURCE([[
    272     #include <sys/types.h>
    273     #include <sys/socket.h>
    274     #include <netinet/in.h>
    275     int main() {
    276 	struct sockaddr_in addr;
    277 	return (sizeof(addr.sin_port) == sizeof(char)) ? 0 : 1;
    278     }
    279     ]])],[ac_cv_sin_port_size=char],[],[])
    280     if test "$ac_cv_sin_port_size" = unknown; then
    281 	AC_MSG_ERROR([Failed to get size of sin_port in struct sockaddr_in.])
    282     fi
    283     AC_DEFINE_UNQUOTED(in_port_t, unsigned $ac_cv_sin_port_size,
    284 [Define to `unsigned char', `unsigned short', `unsigned int' or
    285 `unsigned long' according with size of `sin_port' in `struct sockaddr_in',
    286 if <sys/types.h>, <sys/socket.h> or <netinet/in.h> does not define
    287 `in_port_t'.])
    288 fi])
    289 
    290 dnl * 
    291 dnl * Check for sa_family_t.
    292 dnl * 
    293 AC_DEFUN([AC_TYPE_SA_FAMILY_T],
    294 [AC_CACHE_CHECK([for sa_family_t], ac_cv_type_sa_family_t,
    295 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
    296 #include <sys/types.h>
    297 #include <sys/socket.h>]], [[
    298 sa_family_t sa_family;
    299 ]])],[ac_cv_type_sa_family_t=yes],[ac_cv_type_sa_family_t=no])])
    300 if test "$ac_cv_type_sa_family_t" != yes; then
    301     ac_cv_sa_family_size=unknown
    302     AC_RUN_IFELSE([AC_LANG_SOURCE([[
    303     #include <sys/types.h>
    304     #include <sys/socket.h>
    305     int main() {
    306 	struct sockaddr addr;
    307 	return (sizeof(addr.sa_family) == sizeof(long)) ? 0 : 1;
    308     }
    309     ]])],[ac_cv_sa_family_size=long],[],[])
    310     AC_RUN_IFELSE([AC_LANG_SOURCE([[
    311     #include <sys/types.h>
    312     #include <sys/socket.h>
    313     int main() {
    314 	struct sockaddr addr;
    315 	return (sizeof(addr.sa_family) == sizeof(int)) ? 0 : 1;
    316     }
    317     ]])],[ac_cv_sa_family_size=int],[],[])
    318     AC_RUN_IFELSE([AC_LANG_SOURCE([[
    319     #include <sys/types.h>
    320     #include <sys/socket.h>
    321     int main() {
    322 	struct sockaddr addr;
    323 	return (sizeof(addr.sa_family) == sizeof(short)) ? 0 : 1;
    324     }
    325     ]])],[ac_cv_sa_family_size=short],[],[])
    326     AC_RUN_IFELSE([AC_LANG_SOURCE([[
    327     #include <sys/types.h>
    328     #include <sys/socket.h>
    329     int main() {
    330 	struct sockaddr addr;
    331 	return (sizeof(addr.sa_family) == sizeof(char)) ? 0 : 1;
    332     }
    333     ]])],[ac_cv_sa_family_size=char],[],[])
    334     if test "$ac_cv_sa_family_size" = unknown; then
    335 	AC_MSG_ERROR([Failed to get size of sa_family in struct sockaddr.])
    336     fi
    337     AC_DEFINE_UNQUOTED(sa_family_t, unsigned $ac_cv_sa_family_size,
    338 [Define to `unsigned char', `unsigned short', `unsigned int' or
    339 `unsigned long' according with size of `sa_family' in `struct sockaddr',
    340 if <sys/types.h> or <sys/socket.h> does not define `sa_family_t'.])
    341 fi])
    342