diff options
Diffstat (limited to 'unix')
-rwxr-xr-x | unix/configure | 51 | ||||
-rw-r--r-- | unix/tcl.m4 | 47 | ||||
-rw-r--r-- | unix/tclUnixSock.c | 38 |
3 files changed, 91 insertions, 45 deletions
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. |