tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Optionally make compat socklen_t default to int in bootstrap?
Maybe something like this?
I didn't get the result define quoting/value correct, but otherwise
it seems to do what I intended.
Martin
Index: configure.ac
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/libnbcompat/files/configure.ac,v
retrieving revision 1.86
diff -u -r1.86 configure.ac
--- configure.ac 1 Sep 2015 23:17:51 -0000 1.86
+++ configure.ac 1 May 2016 10:41:13 -0000
@@ -345,6 +345,44 @@
AC_LIBOBJ(getaddrinfo)
fi
+dnl If we do not have socklen_t, figure out what to substitute for it
+old_CFLAGS="$CFLAGS"
+if test "x$ac_cv_type_socklen_t" = xno; then
+ AC_MSG_CHECKING(whether compiler understands -Wall -Werror)
+ CFLAGS="$CFLAGS -Wall -Werror"
+ AC_TRY_COMPILE([],[], [
+
+ AC_MSG_RESULT(yes)
+ AC_MSG_CHECKING(for type to use instead of socklen_t)
+ socklen_t_found="no"
+ socklen_surrogate=""
+ AC_DEFUN(AC_TRY_SOCKLEN, [
+ AC_TRY_COMPILE([#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#include <sys/socket.h>
+], [
+ $1 l;
+ getsockname(0, 0, &l);
+], [ socklen_t_found=yes ], [ socklen_t_found=no ])
+ if test "x[$]socklen_t_found" = "xyes"; then
+ socklen_surrogate="$1"
+ fi
+ ])
+ AC_TRY_SOCKLEN(int)
+ if test $socklen_t_found = "no"; then
+ AC_TRY_SOCKLEN(size_t)
+ if test $socklen_t_found = "no"; then
+ AC_TRY_SOCKLEN(unsigned int)
+ fi
+ fi
+ ], [ AC_MSG_RESULT(no) ])
+fi
+AC_DEFINE(SOCKLEN_SURROGATE, socklen_surrogate,
+ [Type to use as surrogate for socklen_t])
+AC_MSG_RESULT($socklen_surrogate)
+CFLAGS="$old_CFLAGS"
+
need_findenv=no
AC_CHECK_FUNCS([getenv setenv unsetenv], [:], [need_findenv=yes])
if test $need_findenv = yes; then
Home |
Main Index |
Thread Index |
Old Index