Subject: [PATCH] Fix Tru64 socklen_t compile issue with direct_tcpip.c

[PATCH] Fix Tru64 socklen_t compile issue with direct_tcpip.c

From: Dave McCaldon <davem_at_intersystems.com>
Date: Fri, 5 Feb 2010 16:04:16 -0500

I spoke too soon -- my test build of libssh2-1.2.3 (with my previous patch) in fact failed in direct_tcpip.c on Tru64 (DECunix) with:

cxx -DHAVE_CONFIG_H -I../include -I../example -I/home/davem/work/openssl-0.9.8g/include -DLIBSSH2DEBUG -g -c direct_tcpip.c
cc: Error: direct_tcpip.c, line 48: In this declaration, "socklen_t" must specify a type. (badparsedecl)
    socklen_t sinlen;
----^
cc: Error: direct_tcpip.c, line 166: In this statement, "sinlen" is not declared. (undeclared)
    sinlen=sizeof(sin);
----^

Looking into this, in /usr/include/sys/socket.h, Tru64 only defines socklen_t under the following conditions:

/*
 * This data type is needed for both UNIX98 and POSIX support.
 */
#if (defined (_XOPEN_SOURCE) && (_XOPEN_SOURCE>=500)) || \
    defined(_POSIX_PII_SOCKET) || defined(__VMS)
typedef unsigned long socklen_t; /* 64-bits */
#endif

It's not as simple as just adding a typedef for socklen_t as other socket functions (such as accept()) are defined as taking an int for socklen_t if _POSIX_PII_SOCKET is not defined.

Since socklen_t is the more portable approach, I felt it best to properly fix this for Tru64 and thus I have updated configure.ac to add -D_POSIX_PII_SOCKET to CFLAGS for Tru64 (DECunix) platform(s).

Thanks.

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-02-05