@matheusbsbs / matheus-bagliano / commits / e88a135bc5
Fork 0

Some platforms lack socklen_t type

Some platforms do not have a socklen_t type declaration. Signed-off-by: Gary V. Vaughan <gary@thewrittenword.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Gary V. Vaughan committed May 14, 2010 at 09:31 UTC e88a135bc55a974ea04576ccc014c5e2bdc4b892
4 files changed +54
Makefile
+7
@@ -8,6 +8,9 @@ all::
8 # Define SANE_TOOL_PATH to a colon-separated list of paths to prepend
9 # to PATH if your tools in /usr/bin are broken.
10 #
11 +# Define SOCKLEN_T to a suitable type (such as 'size_t') if your
12 +# system headers do not define a socklen_t type.
13 +#
14 # Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
15 # or vsnprintf() return -1 instead of number of characters which would
16 # have been written to the final string if enough space had been available.
@@ -1087,6 +1090,10 @@ else
1090 BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
1091 endif
1092
1093 +ifneq (,$(SOCKLEN_T))
1094 + BASIC_CFLAGS += -Dsocklen_t=$(SOCKLEN_T)
1095 +endif
1096 +
1097 ifeq ($(uname_S),Darwin)
1098 ifndef NO_FINK
1099 ifeq ($(shell test -d /sw/lib && echo y),y)
aclocal.m4 new
+40
@@ -0,0 +1,40 @@
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 +])
config.mak.in
+1
@@ -58,6 +58,7 @@ NO_INET_PTON=@NO_INET_PTON@
58 NO_ICONV=@NO_ICONV@
59 OLD_ICONV=@OLD_ICONV@
60 NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@
61 +SOCKLEN_T=@SOCKLEN_T@
62 FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@
63 SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@
64 NO_PTHREADS=@NO_PTHREADS@
configure.ac
+6
@@ -633,6 +633,12 @@ AC_SUBST(OLD_ICONV)
633 ## Checks for typedefs, structures, and compiler characteristics.
634 AC_MSG_NOTICE([CHECKS for typedefs, structures, and compiler characteristics])
635 #
636 +TYPE_SOCKLEN_T
637 +case $ac_cv_type_socklen_t in
638 + yes) ;;
639 + *) AC_SUBST([SOCKLEN_T], [$git_cv_socklen_t_equiv]) ;;
640 +esac
641 +
642 # Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
643 AC_CHECK_MEMBER(struct dirent.d_ino,
644 [NO_D_INO_IN_DIRENT=],