/[cvs]/ccvs/m4/socklen.m4
ViewVC logotype

Diff of /ccvs/m4/socklen.m4

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by dprice, Tue Oct 4 02:33:12 2005 UTC revision 1.2 by mdb, Wed Dec 7 10:50:43 2005 UTC
# Line 1  Line 1 
1  # socklen.m4 serial 1  # socklen.m4 serial 2
2  dnl Copyright (C) 2005 Free Software Foundation, Inc.  dnl Copyright (C) 2005 Free Software Foundation, Inc.
3  dnl This file is free software; the Free Software Foundation  dnl This file is free software; the Free Software Foundation
4  dnl gives unlimited permission to copy and/or distribute it,  dnl gives unlimited permission to copy and/or distribute it,
5  dnl with or without modifications, as long as this notice is preserved.  dnl with or without modifications, as long as this notice is preserved.
6    
7  dnl From Simon Josefsson.  dnl From Albert Chin.
8    
9  AC_DEFUN([gl_SOCKLEN_T],  dnl Check for socklen_t: historically on BSD it is an int, and in
10  [  dnl POSIX 1g it is a type of its own, but some platforms use different
11    AC_CHECK_HEADERS_ONCE(sys/types.h sys/socket.h)  dnl types for the argument to getsockopt, getpeername, etc.  So we
12    AC_CHECK_TYPE([socklen_t],, [AC_DEFINE([socklen_t], [int],  dnl have to test to find something that will work.
13                  [Map `socklen_t' to `int' if it is missing.])], [  AC_DEFUN([gl_TYPE_SOCKLEN_T],
14  #ifdef HAVE_SYS_TYPES_H    [AC_CHECK_TYPE([socklen_t], ,
15  # include <sys/types.h>       [AC_MSG_CHECKING([for socklen_t equivalent])
16  #endif        AC_CACHE_VAL([gl_cv_gl_cv_socklen_t_equiv],
17  #ifdef HAVE_SYS_SOCKET_H          [# Systems have either "struct sockaddr *" or
18  # include <sys/socket.h>           # "void *" as the second argument to getpeername
19  #endif)           gl_cv_socklen_t_equiv=
20  ])           for arg2 in "struct sockaddr" void; do
21  ])             for t in int size_t "unsigned int" "long int" "unsigned long int"; do
22                 AC_TRY_COMPILE(
23                   [#include <sys/types.h>
24                    #include <sys/socket.h>
25    
26                    int getpeername (int, $arg2 *, $t *);],
27                   [$t len;
28                    getpeername (0, 0, &len);],
29                   [gl_cv_socklen_t_equiv="$t"])
30                 test "$gl_cv_socklen_t_equiv" != "" && break
31               done
32               test "$gl_cv_socklen_t_equiv" != "" && break
33             done
34          ])
35          if test "$gl_cv_socklen_t_equiv" = ""; then
36            AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
37          fi
38          AC_MSG_RESULT([$gl_cv_socklen_t_equiv])
39          AC_DEFINE_UNQUOTED([socklen_t], [$gl_cv_socklen_t_equiv],
40            [type to use in place of socklen_t if not defined])],
41         [#include <sys/types.h>
42          #include <sys/socket.h>])])

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26