summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5a857c7)
raw | patch | inline | side by side (parent: 5a857c7)
author | Gary V. Vaughan <git@mlists.thewrittenword.com> | |
Fri, 14 May 2010 09:31:42 +0000 (09:31 +0000) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 1 Jun 2010 00:36:27 +0000 (17:36 -0700) |
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>
Signed-off-by: Gary V. Vaughan <gary@thewrittenword.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile | patch | blob | history | |
aclocal.m4 | [new file with mode: 0644] | patch | blob |
config.mak.in | patch | blob | history | |
configure.ac | patch | blob | history |
diff --git a/Makefile b/Makefile
index c7e757720378afa484d4969308607dd097db84d7..f3717f1e452ea75dc91fab96538d251f9a4b097a 100644 (file)
--- a/Makefile
+++ b/Makefile
# Define SANE_TOOL_PATH to a colon-separated list of paths to prepend
# to PATH if your tools in /usr/bin are broken.
#
+# Define SOCKLEN_T to a suitable type (such as 'size_t') if your
+# system headers do not define a socklen_t type.
+#
# Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf()
# or vsnprintf() return -1 instead of number of characters which would
# have been written to the final string if enough space had been available.
BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d'
endif
+ifneq (,$(SOCKLEN_T))
+ BASIC_CFLAGS += -Dsocklen_t=$(SOCKLEN_T)
+endif
+
ifeq ($(uname_S),Darwin)
ifndef NO_FINK
ifeq ($(shell test -d /sw/lib && echo y),y)
diff --git a/aclocal.m4 b/aclocal.m4
--- /dev/null
+++ b/aclocal.m4
@@ -0,0 +1,40 @@
+dnl Check for socklen_t: historically on BSD it is an int, and in
+dnl POSIX 1g it is a type of its own, but some platforms use different
+dnl types for the argument to getsockopt, getpeername, etc. So we
+dnl have to test to find something that will work.
+AC_DEFUN([TYPE_SOCKLEN_T],
+[
+ AC_CHECK_TYPE([socklen_t], ,[
+ AC_MSG_CHECKING([for socklen_t equivalent])
+ AC_CACHE_VAL([git_cv_socklen_t_equiv],
+ [
+ # Systems have either "struct sockaddr *" or
+ # "void *" as the second argument to getpeername
+ git_cv_socklen_t_equiv=
+ for arg2 in "struct sockaddr" void; do
+ for t in int size_t unsigned long "unsigned long"; do
+ AC_TRY_COMPILE([
+ #include <sys/types.h>
+ #include <sys/socket.h>
+
+ int getpeername (int, $arg2 *, $t *);
+ ],[
+ $t len;
+ getpeername(0,0,&len);
+ ],[
+ git_cv_socklen_t_equiv="$t"
+ break 2
+ ])
+ done
+ done
+
+ if test "x$git_cv_socklen_t_equiv" = x; then
+ AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
+ fi
+ ])
+ AC_MSG_RESULT($git_cv_socklen_t_equiv)
+ AC_DEFINE_UNQUOTED(socklen_t, $git_cv_socklen_t_equiv,
+ [type to use in place of socklen_t if not defined])],
+ [#include <sys/types.h>
+#include <sys/socket.h>])
+])
diff --git a/config.mak.in b/config.mak.in
index 8667ac5b55382ec9ba52077ee043c86b350b5268..ed0f8f57de1ef1b973bf3f9be40150e9048354e0 100644 (file)
--- a/config.mak.in
+++ b/config.mak.in
NO_ICONV=@NO_ICONV@
OLD_ICONV=@OLD_ICONV@
NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@
+SOCKLEN_T=@SOCKLEN_T@
FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@
SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@
NO_PTHREADS=@NO_PTHREADS@
diff --git a/configure.ac b/configure.ac
index b97ee6dbb9e4ff95527bd079fb935f3f13a05b1b..df831c35d46bba556084aa0861800b83536409a1 100644 (file)
--- a/configure.ac
+++ b/configure.ac
## Checks for typedefs, structures, and compiler characteristics.
AC_MSG_NOTICE([CHECKS for typedefs, structures, and compiler characteristics])
#
+TYPE_SOCKLEN_T
+case $ac_cv_type_socklen_t in
+ yes) ;;
+ *) AC_SUBST([SOCKLEN_T], [$git_cv_socklen_t_equiv]) ;;
+esac
+
# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
AC_CHECK_MEMBER(struct dirent.d_ino,
[NO_D_INO_IN_DIRENT=],