I've been looking rather belatedly at this patch... it's simple,
but the type name ACCEPT_TYPE_ARG3 is a bit ugly to use in .c
source files instead of socklen_t.
What's the "nice" way to do this? It's an internal type dependent
on compiler switches (-D_XOPEN_SOURCE_EXTENDED on HP-UX), so I
don't think it is wise to expose it in lber_types.h. It depends
on <sys/socket.h> anyway. If not... just use ACCEPT_TYPE_ARG3 or
maybe AC_SOCKLEN_T directly in .c files? #define AC_SOCKLEN_T in
portable.h and typedef ac_socklen_t as it in sys/socket.h? Cheat
and #define ber_socklen_t in portable.h?
Also the patch is incomplete, we need to use this type (or some
configured type) in getpeername(), getsockopt() and recvfrom()
too. I _hope_ they all use the same type or at least a type with
the same size on all these platforms...
Googling around a bit, the mess with socklen_t and accept()
prototypes seems amazing. I'm not sure I dare commit a patch
which fails if it doesn't figure out the right type. At least not
to RE23 - I'll commit a patch there which just guesses socklen_t
or int if it can't figure out the right prototype. We can try one
which fails in that case in HEAD and see if anyone complain.
If we are going to be as paranoid as some other code out there,
it'd be something like this (and even more if we want to try until
succeeding in HEAD) - that's 12 compiles instead of the 5 in the
submitted patch. Quite a lot...
dnl socklen_t-like type in accept(), default socklen_t or int:
dnl - The OS might define socklen_t without using it. POSIX moved from
dnl int to size_t to socklen_t, hoping to stay at a 32-bit type, and
dnl HP-UX has selectors for what to use.
dnl - On Solaris 2.8 the prototype has void *len, but the default is OK.
AC_MSG_CHECKING([for socklen_t-like type in accept()])
AC_CACHE_VAL(ol_cv_type_lber_socklen_t, [
set socklen_t int unsigned "unsigned long" long size_t
test "$ac_cv_type_socklen_t" = yes || shift
ol_cv_type_lber_socklen_t=$1 guessing="guessing "
for lentype in "$@" ; do for addrtype in "struct sockaddr" void ; do
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$ac_includes_default
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
extern int accept(int s, $addrtype *ap, $lentype *lp);
], [
$lentype len;
accept(0, (struct sockaddr *) 0, &len);
])], [ol_cv_type_lber_socklen_t=$lentype guessing= ; break 2])
done ; done])
AC_MSG_RESULT([$guessing$ol_cv_type_lber_socklen_t])
AC_DEFINE_UNQUOTED(LBER_SOCKLEN_T, $ol_cv_type_lber_socklen_t,
[define to socklen_t-like type in accept()])
--
Regards,
Hallvard