From 6638ab2cc75d41465a5191828f2c9acbab86af6b Mon Sep 17 00:00:00 2001 From: mdejong Date: Mon, 13 Jan 2003 01:27:50 +0000 Subject: * win/configure: Regen. * win/configure.in: Check for typedefs like LPFN_ACCEPT in winsock2.h and define HAVE_NO_LPFN_DECLS if not found. * win/tclWinSock.c: Define LPFN_* typedefs if HAVE_NO_LPFN_DECLS is defined. This fixes the build under Mingw and Cygwin, it was broken by the changes made on 2002-11-26. --- ChangeLog | 10 ++++++ win/configure | 95 +++++++++++++++++++++++++++++++++++++++++--------------- win/configure.in | 25 ++++++++++++++- win/tclWinSock.c | 60 ++++++++++++++++++++++++++++++++++- 4 files changed, 163 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index e586bc8..355644b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2003-01-12 Mo DeJong + + * win/configure: Regen. + * win/configure.in: Check for typedefs like LPFN_ACCEPT + in winsock2.h and define HAVE_NO_LPFN_DECLS if not found. + * win/tclWinSock.c: Define LPFN_* typedefs if + HAVE_NO_LPFN_DECLS is defined. This fixes the build + under Mingw and Cygwin, it was broken by the changes + made on 2002-11-26. + 2003-01-10 Vince Darley * generic/tclIOUtil.c: diff --git a/win/configure b/win/configure index bcb69ce..fc5a72a 100755 --- a/win/configure +++ b/win/configure @@ -1075,18 +1075,63 @@ EOF fi + +# Check to see if the winsock2.h include file provided contains +# typedefs like LPFN_ACCEPT and friends. +# +echo $ac_n "checking for LPFN_ACCEPT support in winsock2.h""... $ac_c" 1>&6 +echo "configure:1084: checking for LPFN_ACCEPT support in winsock2.h" >&5 +if eval "test \"`echo '$''{'tcl_cv_lpfn_decls'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#undef WIN32_LEAN_AND_MEAN +#include + +int main() { + + LPFN_ACCEPT accept; + +; return 0; } +EOF +if { (eval echo configure:1103: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + tcl_cv_lpfn_decls=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + tcl_cv_lpfn_decls=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$tcl_cv_lpfn_decls" 1>&6 +if test "$tcl_cv_lpfn_decls" = "no" ; then + cat >> confdefs.h <<\EOF +#define HAVE_NO_LPFN_DECLS 1 +EOF + +fi + #-------------------------------------------------------------------- # Determines the correct binary file extension (.o, .obj, .exe etc.) #-------------------------------------------------------------------- echo $ac_n "checking for object suffix""... $ac_c" 1>&6 -echo "configure:1084: checking for object suffix" >&5 +echo "configure:1129: checking for object suffix" >&5 if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else rm -f conftest* echo 'int i = 1;' > conftest.$ac_ext -if { (eval echo configure:1090: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1135: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then for ac_file in conftest.*; do case $ac_file in *.c) ;; @@ -1104,19 +1149,19 @@ OBJEXT=$ac_cv_objext ac_objext=$ac_cv_objext echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:1108: checking for mingw32 environment" >&5 +echo "configure:1153: checking for mingw32 environment" >&5 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1165: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -1135,7 +1180,7 @@ test "$ac_cv_mingw32" = yes && MINGW32=yes echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:1139: checking for executable suffix" >&5 +echo "configure:1184: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1145,7 +1190,7 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:1149: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:1194: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.o | *.obj) ;; @@ -1172,7 +1217,7 @@ ac_exeext=$EXEEXT echo $ac_n "checking for building with threads""... $ac_c" 1>&6 -echo "configure:1176: checking for building with threads" >&5 +echo "configure:1221: checking for building with threads" >&5 # Check whether --enable-threads or --disable-threads was given. if test "${enable_threads+set}" = set; then enableval="$enable_threads" @@ -1209,7 +1254,7 @@ EOF echo $ac_n "checking how to build libraries""... $ac_c" 1>&6 -echo "configure:1213: checking how to build libraries" >&5 +echo "configure:1258: checking how to build libraries" >&5 # Check whether --enable-shared or --disable-shared was given. if test "${enable_shared+set}" = set; then enableval="$enable_shared" @@ -1250,7 +1295,7 @@ EOF # Step 0: Enable 64 bit support? echo $ac_n "checking if 64bit support is requested""... $ac_c" 1>&6 -echo "configure:1254: checking if 64bit support is requested" >&5 +echo "configure:1299: checking if 64bit support is requested" >&5 # Check whether --enable-64bit or --disable-64bit was given. if test "${enable_64bit+set}" = set; then enableval="$enable_64bit" @@ -1267,7 +1312,7 @@ fi # Extract the first word of "cygpath", so it can be a program name with args. set dummy cygpath; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1271: checking for $ac_word" >&5 +echo "configure:1316: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CYGPATH'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1309,9 +1354,9 @@ fi echo "END" >> $conftest echo $ac_n "checking for Windows native path bug in windres""... $ac_c" 1>&6 -echo "configure:1313: checking for Windows native path bug in windres" >&5 +echo "configure:1358: checking for Windows native path bug in windres" >&5 cyg_conftest=`$CYGPATH $conftest` - if { ac_try='$RC -o conftest.res.o $cyg_conftest'; { (eval echo configure:1315: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } ; then + if { ac_try='$RC -o conftest.res.o $cyg_conftest'; { (eval echo configure:1360: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } ; then echo "$ac_t""no" 1>&6 else echo "$ac_t""yes" 1>&6 @@ -1330,7 +1375,7 @@ echo "configure:1313: checking for Windows native path bug in windres" >&5 # set various compiler flags depending on whether we are using gcc or cl echo $ac_n "checking compiler flags""... $ac_c" 1>&6 -echo "configure:1334: checking compiler flags" >&5 +echo "configure:1379: checking compiler flags" >&5 if test "${GCC}" = "yes" ; then if test "$do64bit" = "yes" ; then echo "configure: warning: "64bit mode not supported with GCC on Windows"" 1>&2 @@ -1543,7 +1588,7 @@ echo "configure:1334: checking compiler flags" >&5 echo $ac_n "checking for build with symbols""... $ac_c" 1>&6 -echo "configure:1547: checking for build with symbols" >&5 +echo "configure:1592: checking for build with symbols" >&5 # Check whether --enable-symbols or --disable-symbols was given. if test "${enable_symbols+set}" = set; then enableval="$enable_symbols" @@ -1603,7 +1648,7 @@ TCL_DBGX=${DBGX} #-------------------------------------------------------------------- echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1607: checking how to run the C preprocessor" >&5 +echo "configure:1652: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1618,13 +1663,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1628: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1673: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1635,13 +1680,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1645: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1690: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1652,13 +1697,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1662: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1707: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1684,17 +1729,17 @@ echo "$ac_t""$CPP" 1>&6 ac_safe=`echo "errno.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for errno.h""... $ac_c" 1>&6 -echo "configure:1688: checking for errno.h" >&5 +echo "configure:1733: checking for errno.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1698: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1743: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* diff --git a/win/configure.in b/win/configure.in index d580a63..9dfaebe 100644 --- a/win/configure.in +++ b/win/configure.in @@ -3,7 +3,7 @@ # generate the file "configure", which is run during Tcl installation # to configure the system for the local environment. # -# RCS: @(#) $Id: configure.in,v 1.60 2002/12/13 17:46:01 dgp Exp $ +# RCS: @(#) $Id: configure.in,v 1.61 2003/01/13 01:27:51 mdejong Exp $ AC_INIT(../generic/tcl.h) AC_PREREQ(2.13) @@ -146,6 +146,29 @@ if test "$tcl_cv_eh_disposition" = "no" ; then [Defined when cygwin/mingw does not support EXCEPTION DISPOSITION]) fi + +# Check to see if the winsock2.h include file provided contains +# typedefs like LPFN_ACCEPT and friends. +# +AC_CACHE_CHECK(for LPFN_ACCEPT support in winsock2.h, + tcl_cv_lpfn_decls, +AC_TRY_COMPILE([ +#define WIN32_LEAN_AND_MEAN +#include +#undef WIN32_LEAN_AND_MEAN +#include +], +[ + LPFN_ACCEPT accept; +], + tcl_cv_lpfn_decls=yes, + tcl_cv_lpfn_decls=no) +) +if test "$tcl_cv_lpfn_decls" = "no" ; then + AC_DEFINE(HAVE_NO_LPFN_DECLS, 1, + [Defined when cygwin/mingw does not support LPFN_ACCEPT and friends.]) +fi + #-------------------------------------------------------------------- # Determines the correct binary file extension (.o, .obj, .exe etc.) #-------------------------------------------------------------------- diff --git a/win/tclWinSock.c b/win/tclWinSock.c index 03900b8..ddd5aec 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinSock.c,v 1.34 2002/12/08 15:31:59 davygrvy Exp $ + * RCS: @(#) $Id: tclWinSock.c,v 1.35 2003/01/13 01:27:51 mdejong Exp $ */ #include "tclWinInt.h" @@ -35,6 +35,64 @@ static char hostname[255]; /* This buffer should be big enough for TCL_DECLARE_MUTEX(socketMutex) + +/* + * Mingw and Cygwin may not have LPFN_* typedefs. + */ + +#ifdef HAVE_NO_LPFN_DECLS + typedef SOCKET (PASCAL FAR *LPFN_ACCEPT)(SOCKET s, + struct sockaddr FAR * addr, int FAR * addrlen); + typedef int (PASCAL FAR *LPFN_BIND)(SOCKET s, + const struct sockaddr FAR *addr, int namelen); + typedef int (PASCAL FAR *LPFN_CLOSESOCKET)(SOCKET s); + typedef int (PASCAL FAR *LPFN_CONNECT)(SOCKET s, + const struct sockaddr FAR *name, int namelen); + typedef struct hostent FAR * (PASCAL FAR *LPFN_GETHOSTBYADDR) + (const char FAR *addr, int addrlen, int addrtype); + typedef struct hostent FAR * (PASCAL FAR *LPFN_GETHOSTBYNAME) + (const char FAR * name); + typedef int (PASCAL FAR *LPFN_GETHOSTNAME)(char FAR * name, + int namelen); + typedef int (PASCAL FAR *LPFN_GETPEERNAME)(SOCKET sock, + struct sockaddr FAR *name, int FAR *namelen); + typedef struct servent FAR * (PASCAL FAR *LPFN_GETSERVBYNAME) + (const char FAR * name, const char FAR * proto); + typedef int (PASCAL FAR *LPFN_GETSOCKNAME)(SOCKET sock, + struct sockaddr FAR *name, int FAR *namelen); + typedef int (PASCAL FAR *LPFN_GETSOCKOPT)(SOCKET s, int level, + int optname, char FAR * optval, int FAR *optlen); + typedef u_short (PASCAL FAR *LPFN_HTONS)(u_short hostshort); + typedef unsigned long (PASCAL FAR *LPFN_INET_ADDR) + (const char FAR * cp); + typedef char FAR * (PASCAL FAR *LPFN_INET_NTOA) + (struct in_addr in); + typedef int (PASCAL FAR *LPFN_IOCTLSOCKET)(SOCKET s, + long cmd, u_long FAR *argp); + typedef int (PASCAL FAR *LPFN_LISTEN)(SOCKET s, int backlog); + typedef u_short (PASCAL FAR *LPFN_NTOHS)(u_short netshort); + typedef int (PASCAL FAR *LPFN_RECV)(SOCKET s, char FAR * buf, + int len, int flags); + typedef int (PASCAL FAR *LPFN_SELECT)(int nfds, + fd_set FAR * readfds, fd_set FAR * writefds, + fd_set FAR * exceptfds, + const struct timeval FAR * timeout); + typedef int (PASCAL FAR *LPFN_SEND)(SOCKET s, + const char FAR * buf, int len, int flags); + typedef int (PASCAL FAR *LPFN_SETSOCKOPT)(SOCKET s, + int level, int optname, const char FAR * optval, + int optlen); + typedef SOCKET (PASCAL FAR *LPFN_SOCKET)(int af, + int type, int protocol); + typedef int (PASCAL FAR *LPFN_WSAASYNCSELECT)(SOCKET s, + HWND hWnd, u_int wMsg, long lEvent); + typedef int (PASCAL FAR *LPFN_WSACLEANUP)(void); + typedef int (PASCAL FAR *LPFN_WSAGETLASTERROR)(void); + typedef int (PASCAL FAR *LPFN_WSASTARTUP)(WORD wVersionRequired, + LPWSADATA lpWSAData); +#endif + + /* * The following structure contains pointers to all of the WinSock API * entry points used by Tcl. It is initialized by InitSockets. Since -- cgit v0.12