|
| 1 | +dnl Check for socklen_t: historically on BSD it is an int, and in |
| 2 | +dnl POSIX 1g it is a type of its own, but some platforms use different |
| 3 | +dnl types for the argument to getsockopt, getpeername, etc. So we |
| 4 | +dnl have to test to find something that will work. |
| 5 | +AC_DEFUN([TYPE_SOCKLEN_T], |
| 6 | +[ |
| 7 | + AC_CHECK_TYPE([socklen_t], ,[ |
| 8 | + AC_MSG_CHECKING([for socklen_t equivalent]) |
| 9 | + AC_CACHE_VAL([git_cv_socklen_t_equiv], |
| 10 | + [ |
| 11 | + # Systems have either "struct sockaddr *" or |
| 12 | + # "void *" as the second argument to getpeername |
| 13 | + git_cv_socklen_t_equiv= |
| 14 | + for arg2 in "struct sockaddr" void; do |
| 15 | + for t in int size_t unsigned long "unsigned long"; do |
| 16 | + AC_TRY_COMPILE([ |
| 17 | + #include <sys/types.h> |
| 18 | + #include <sys/socket.h> |
| 19 | +
|
| 20 | + int getpeername (int, $arg2 *, $t *); |
| 21 | + ],[ |
| 22 | + $t len; |
| 23 | + getpeername(0,0,&len); |
| 24 | + ],[ |
| 25 | + git_cv_socklen_t_equiv="$t" |
| 26 | + break 2 |
| 27 | + ]) |
| 28 | + done |
| 29 | + done |
| 30 | +
|
| 31 | + if test "x$git_cv_socklen_t_equiv" = x; then |
| 32 | + AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) |
| 33 | + fi |
| 34 | + ]) |
| 35 | + AC_MSG_RESULT($git_cv_socklen_t_equiv) |
| 36 | + AC_DEFINE_UNQUOTED(socklen_t, $git_cv_socklen_t_equiv, |
| 37 | + [type to use in place of socklen_t if not defined])], |
| 38 | + [#include <sys/types.h> |
| 39 | +#include <sys/socket.h>]) |
| 40 | +]) |
0 commit comments