Skip to content

Commit e88a135

Browse files
Gary V. Vaughangitster
authored andcommitted
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>
1 parent 5a857c7 commit e88a135

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ all::
88
# Define SANE_TOOL_PATH to a colon-separated list of paths to prepend
99
# to PATH if your tools in /usr/bin are broken.
1010
#
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+
#
1114
# Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
1215
# or vsnprintf() return -1 instead of number of characters which would
1316
# have been written to the final string if enough space had been available.
@@ -1087,6 +1090,10 @@ else
10871090
BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
10881091
endif
10891092

1093+
ifneq (,$(SOCKLEN_T))
1094+
BASIC_CFLAGS += -Dsocklen_t=$(SOCKLEN_T)
1095+
endif
1096+
10901097
ifeq ($(uname_S),Darwin)
10911098
ifndef NO_FINK
10921099
ifeq ($(shell test -d /sw/lib && echo y),y)

aclocal.m4

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ NO_INET_PTON=@NO_INET_PTON@
5858
NO_ICONV=@NO_ICONV@
5959
OLD_ICONV=@OLD_ICONV@
6060
NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@
61+
SOCKLEN_T=@SOCKLEN_T@
6162
FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@
6263
SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@
6364
NO_PTHREADS=@NO_PTHREADS@

configure.ac

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,12 @@ AC_SUBST(OLD_ICONV)
633633
## Checks for typedefs, structures, and compiler characteristics.
634634
AC_MSG_NOTICE([CHECKS for typedefs, structures, and compiler characteristics])
635635
#
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+
636642
# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
637643
AC_CHECK_MEMBER(struct dirent.d_ino,
638644
[NO_D_INO_IN_DIRENT=],

0 commit comments

Comments
 (0)