From 7c4049a13f83930bf6a57ef889abc9e49fa414ec Mon Sep 17 00:00:00 2001 From: Kevin B Kenny Date: Thu, 16 Dec 2010 01:42:18 +0000 Subject: merge --- ChangeLog | 33 ++++++++++++++++++++++++++++++ generic/tcl.h | 4 ++-- generic/tclPanic.c | 11 +++------- unix/configure | 51 ++++++++++++++++++++++++++++++++++------------ unix/tcl.m4 | 47 ++++++++++++++++++++++++++++++------------ unix/tclUnixSock.c | 38 +++++++++++++++++----------------- win/tclWinFile.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++---- win/tclWinSock.c | 10 ++++----- 8 files changed, 190 insertions(+), 64 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc2f494..1ab7f31 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,44 @@ 2010-12-15 Kevin B. Kenny + [dogeen-assembler-branch] + * tclAssembly.c: * assemble.test: Reworked beginCatch/endCatch handling to enforce the more severe (but more correct) restrictions on catch handling that appeared in the discussion of [Bug 3098302] and in tcl-core traffic beginning about 2010-10-29. +2010-12-14 Jan Nijtmans + + * generic/tclPanic.c: Restore abort() as it was before. + * win/tclWinFile.c: [Patch 3124554] use ExitProcess() here, like + in wish. + +2010-12-14 Jan Nijtmans + + * generic/tcl.h: [Bug 3137454]: Tcl CVS HEAD does not build on GCC 3 + +2010-12-14 Reinhard Max + + * win/tclWinSock.c (CreateSocket): Swap the loops over + * unix/tclUnixSock.c (CreateClientSocket): local and remote + addresses, so that the system's address preference for the remote + side decides which family gets tried first. Cleanup and clarify + some of the comments. + +2010-12-13 Jan Nijtmans + + * generic/tcl.h: [Bug 3135271] Link error due to hidden + * unix/tcl.m4: symbols (CentOS 4.2) + * unix/configure: (autoconf-2.59) + * win/tclWinFile.c: Undocumented feature, only meant to be + used by Tk_Main. See [Patch 3124554]: Move WishPanic from Tk to Tcl + +2010-12-12 Stuart Cassoff + + * unix/tcl.m4: Better building on OpenBSD. + * unix/configure: (autoconf-2.59) + 2010-12-10 Jan Nijtmans * generic/tcl.h: [Bug 3129448]: Possible over-allocation on diff --git a/generic/tcl.h b/generic/tcl.h index 27ed895..fd67dd4 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tcl.h,v 1.308.2.1 2010/12/11 18:39:28 kennykb Exp $ + * RCS: @(#) $Id: tcl.h,v 1.308.2.2 2010/12/16 01:42:18 kennykb Exp $ */ #ifndef _TCL @@ -190,7 +190,7 @@ extern "C" { # endif #else # define DLLIMPORT -# if defined(__GNUC__) && __GNUC__ > 3 +# if defined(__GNUC__) && !defined(NO_VIZ) && !defined(STATIC_BUILD) # define DLLEXPORT __attribute__ ((visibility("default"))) # else # define DLLEXPORT diff --git a/generic/tclPanic.c b/generic/tclPanic.c index 70d37a1..e8c1257 100644 --- a/generic/tclPanic.c +++ b/generic/tclPanic.c @@ -12,11 +12,10 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclPanic.c,v 1.14.4.1 2010/12/01 16:42:36 kennykb Exp $ + * RCS: @(#) $Id: tclPanic.c,v 1.14.4.2 2010/12/16 01:42:18 kennykb Exp $ */ #include "tclInt.h" -#undef Tcl_Panic /* * The panicProc variable contains a pointer to an application specific panic @@ -90,13 +89,9 @@ Tcl_PanicVA( arg8); fprintf(stderr, "\n"); fflush(stderr); -#ifdef _WIN32 - DebugBreak(); - ExitProcess(1); -#else - abort(); -#endif } + /* In case the users panic proc does not abort, we do it here */ + abort(); } /* diff --git a/unix/configure b/unix/configure index 04f77d4..5debd0a 100755 --- a/unix/configure +++ b/unix/configure @@ -6545,6 +6545,11 @@ echo "${ECHO_T}$tcl_cv_cc_visibility_hidden" >&6 else + +cat >>confdefs.h <<\_ACEOF +#define NO_VIZ +_ACEOF + hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -7718,20 +7723,40 @@ fi TCL_LIB_VERSIONS_OK=nodots ;; OpenBSD-*) - CFLAGS_OPTIMIZE='-O2' - SHLIB_CFLAGS="-fPIC" - SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}' - SHLIB_LD_LIBS='${LIBS}' - SHLIB_SUFFIX=".so" - DL_OBJS="tclLoadDl.o" - DL_LIBS="" - if test $doRpath = yes; then + arch=`arch -s` + case "$arch" in + m88k|vax) + # Equivalent using configure option --disable-load + # Step 4 will set the necessary variables + DL_OBJS="" + ;; + *) + SHLIB_CFLAGS="-fPIC" + SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}' + SHLIB_LD_LIBS='${LIBS}' + SHLIB_SUFFIX=".so" + DL_OBJS="tclLoadDl.o" + DL_LIBS="" + if test $doRpath = yes; then - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}' fi - LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} - SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}' + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}' + ;; + esac + case "$arch" in + m88k|vax) + CFLAGS_OPTIMIZE="-O1" + ;; + sh) + CFLAGS_OPTIMIZE="-O0" + ;; + *) + CFLAGS_OPTIMIZE="-O2" + ;; + esac echo "$as_me:$LINENO: checking for ELF" >&5 echo $ECHO_N "checking for ELF... $ECHO_C" >&6 if test "${tcl_cv_ld_elf+set}" = set; then @@ -7771,10 +7796,10 @@ fi if test "${TCL_THREADS}" = "1"; then - # OpenBSD builds and links with -pthread, never -lpthread. + # On OpenBSD: Compile with -pthread + # Don't link with -lpthread LIBS=`echo $LIBS | sed s/-lpthread//` CFLAGS="$CFLAGS -pthread" - SHLIB_CFLAGS="$SHLIB_CFLAGS -pthread" fi diff --git a/unix/tcl.m4 b/unix/tcl.m4 index 4d7fa71..c699535 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1056,6 +1056,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ AS_IF([test $tcl_cv_cc_visibility_hidden = yes], [ CFLAGS="$CFLAGS -fvisibility=hidden" ], [ + AC_DEFINE(NO_VIZ, [], [No visibility attribute]) hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -Werror" AC_TRY_LINK([ extern __attribute__((__visibility__("hidden"))) void f(void); @@ -1501,17 +1502,37 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ TCL_LIB_VERSIONS_OK=nodots ;; OpenBSD-*) - CFLAGS_OPTIMIZE='-O2' - SHLIB_CFLAGS="-fPIC" - SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}' - SHLIB_LD_LIBS='${LIBS}' - SHLIB_SUFFIX=".so" - DL_OBJS="tclLoadDl.o" - DL_LIBS="" - AS_IF([test $doRpath = yes], [ - CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}']) - LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} - SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}' + arch=`arch -s` + case "$arch" in + m88k|vax) + # Equivalent using configure option --disable-load + # Step 4 will set the necessary variables + DL_OBJS="" + ;; + *) + SHLIB_CFLAGS="-fPIC" + SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}' + SHLIB_LD_LIBS='${LIBS}' + SHLIB_SUFFIX=".so" + DL_OBJS="tclLoadDl.o" + DL_LIBS="" + AS_IF([test $doRpath = yes], [ + CC_SEARCH_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}']) + LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS} + SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}' + ;; + esac + case "$arch" in + m88k|vax) + CFLAGS_OPTIMIZE="-O1" + ;; + sh) + CFLAGS_OPTIMIZE="-O0" + ;; + *) + CFLAGS_OPTIMIZE="-O2" + ;; + esac AC_CACHE_CHECK([for ELF], tcl_cv_ld_elf, [ AC_EGREP_CPP(yes, [ #ifdef __ELF__ @@ -1522,10 +1543,10 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ LDFLAGS=-Wl,-export-dynamic ], [LDFLAGS=""]) AS_IF([test "${TCL_THREADS}" = "1"], [ - # OpenBSD builds and links with -pthread, never -lpthread. + # On OpenBSD: Compile with -pthread + # Don't link with -lpthread LIBS=`echo $LIBS | sed s/-lpthread//` CFLAGS="$CFLAGS -pthread" - SHLIB_CFLAGS="$SHLIB_CFLAGS -pthread" ]) # OpenBSD doesn't do version numbers with dots. UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a' diff --git a/unix/tclUnixSock.c b/unix/tclUnixSock.c index 6af51d1..21dd034 100644 --- a/unix/tclUnixSock.c +++ b/unix/tclUnixSock.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: tclUnixSock.c,v 1.26.2.4 2010/12/11 18:39:31 kennykb Exp $ + * RCS: @(#) $Id: tclUnixSock.c,v 1.26.2.5 2010/12/16 01:42:19 kennykb Exp $ */ #include "tclInt.h" @@ -862,9 +862,9 @@ static TcpState * CreateClientSocket( Tcl_Interp *interp, /* For error reporting; can be NULL. */ int port, /* Port number to open. */ - const char *host, /* Name of host on which to open port. NULL - * implies INADDR_ANY */ - const char *myaddr, /* Optional client-side address */ + const char *host, /* Name of host on which to open port. */ + const char *myaddr, /* Optional client-side address. + * NULL implies INADDR_ANY/in6addr_any */ int myport, /* Optional client-side port */ int async) /* If nonzero and creating a client socket, * attempt to do an async connect. Otherwise @@ -885,12 +885,12 @@ CreateClientSocket( goto error; } - for (myaddrPtr = myaddrlist; myaddrPtr != NULL; - myaddrPtr = myaddrPtr->ai_next) { - for (addrPtr = addrlist; addrPtr != NULL; - addrPtr = addrPtr->ai_next) { + for (addrPtr = addrlist; addrPtr != NULL; + addrPtr = addrPtr->ai_next) { + for (myaddrPtr = myaddrlist; myaddrPtr != NULL; + myaddrPtr = myaddrPtr->ai_next) { int reuseaddr; - + /* * No need to try combinations of local and remote addresses of * different families. @@ -900,14 +900,7 @@ CreateClientSocket( continue; } - /* - * Attempt to connect. The connect may fail at present with an - * EINPROGRESS but at a later time it will complete. The caller - * will set up a file handler on the socket if she is interested - * in being informed when the connect completes. - */ - - sock = socket(myaddrPtr->ai_family, SOCK_STREAM, 0); + sock = socket(addrPtr->ai_family, SOCK_STREAM, 0); if (sock < 0) { continue; } @@ -940,6 +933,13 @@ CreateClientSocket( goto looperror; } + /* + * Attempt to connect. The connect may fail at present with an + * EINPROGRESS but at a later time it will complete. The caller + * will set up a file handler on the socket if she is interested + * in being informed when the connect completes. + */ + status = connect(sock, addrPtr->ai_addr, addrPtr->ai_addrlen); if (status < 0 && errno == EINPROGRESS) { status = 0; @@ -1196,8 +1196,8 @@ Tcl_OpenTcpServer( (char *) &reuseaddr, sizeof(reuseaddr)); /* - * Make sure we use the same port when opening two server sockets for - * IPv4 and IPv6. + * Make sure we use the same port number when opening two server + * sockets for IPv4 and IPv6 on a random port. * * As sockaddr_in6 uses the same offset and size for the port member * as sockaddr_in, we can handle both through the IPv4 API. diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 1858756..0334ea6 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinFile.c,v 1.112.2.3 2010/12/01 16:42:38 kennykb Exp $ + * RCS: @(#) $Id: tclWinFile.c,v 1.112.2.4 2010/12/16 01:42:19 kennykb Exp $ */ #include "tclWinInt.h" @@ -784,6 +784,56 @@ NativeWriteReparse( } /* + *---------------------------------------------------------------------- + * + * WishPanic -- + * + * Display a message. + * + * Results: + * None. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +static void +PanicMessageBox( + const char *format, ...) +{ +#define TCL_MAX_WARN_LEN 1024 + va_list argList; + char buf[TCL_MAX_WARN_LEN * TCL_UTF_MAX]; + WCHAR msgString[TCL_MAX_WARN_LEN]; + + va_start(argList, format); + vsnprintf(buf, sizeof(buf), format, argList); + + msgString[TCL_MAX_WARN_LEN-1] = L'\0'; + MultiByteToWideChar(CP_UTF8, 0, buf, -1, msgString, TCL_MAX_WARN_LEN); + /* + * Truncate MessageBox string if it is too long to not overflow the screen + * and cause possible oversized window error. + */ + if (msgString[TCL_MAX_WARN_LEN-1] != L'\0') { + memcpy(msgString + (TCL_MAX_WARN_LEN - 5), L" ...", 5 * sizeof(WCHAR)); + } + MessageBeep(MB_ICONEXCLAMATION); + MessageBoxW(NULL, msgString, L"Fatal Error", + MB_ICONSTOP | MB_OK | MB_TASKMODAL | MB_SETFOREGROUND); + /* try to trigger the debugger */ +# ifdef __GNUC__ + __builtin_trap(); +# endif +# ifdef _MSC_VER + DebugBreak(); +# endif + ExitProcess(1); +} + +/* *--------------------------------------------------------------------------- * * TclpFindExecutable -- @@ -802,16 +852,18 @@ NativeWriteReparse( void TclpFindExecutable( - const char *argv0) /* The value of the application's argv[0] - * (native). */ + const char *argv0) /* If NULL, install PanicMessageBox, otherwise ignore */ { WCHAR wName[MAX_PATH]; char name[MAX_PATH * TCL_UTF_MAX]; /* * Under Windows we ignore argv0, and return the path for the file used to - * create this process. + * create this process. Only if it is NULL, install a new panic handler. */ + if (argv0 == NULL) { + Tcl_SetPanicProc(PanicMessageBox); + } #ifdef UNICODE GetModuleFileNameW(NULL, wName, MAX_PATH); diff --git a/win/tclWinSock.c b/win/tclWinSock.c index 19ebb82..ec2c4eb 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.74.2.5 2010/12/11 18:39:31 kennykb Exp $ + * RCS: @(#) $Id: tclWinSock.c,v 1.74.2.6 2010/12/16 01:42:19 kennykb Exp $ * * ----------------------------------------------------------------------- * @@ -1142,10 +1142,10 @@ CreateSocket( } } } else { - for (myaddrPtr = myaddrlist; myaddrPtr != NULL; - myaddrPtr = myaddrPtr->ai_next) { - for (addrPtr = addrlist; addrPtr != NULL; - addrPtr = addrPtr->ai_next) { + for (addrPtr = addrlist; addrPtr != NULL; + addrPtr = addrPtr->ai_next) { + for (myaddrPtr = myaddrlist; myaddrPtr != NULL; + myaddrPtr = myaddrPtr->ai_next) { /* * No need to try combinations of local and remote addresses * of different families. -- cgit v0.12