Import Tcl-code 8.6.8
This commit is contained in:
@@ -840,17 +840,17 @@ install-libraries: libraries
|
||||
do \
|
||||
$(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)"/http1.0; \
|
||||
done;
|
||||
@echo "Installing package http 2.8.9 as a Tcl Module";
|
||||
@$(INSTALL_DATA) $(TOP_DIR)/library/http/http.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.6/http-2.8.9.tm;
|
||||
@echo "Installing package http 2.8.12 as a Tcl Module";
|
||||
@$(INSTALL_DATA) $(TOP_DIR)/library/http/http.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.6/http-2.8.12.tm;
|
||||
@echo "Installing package opt0.4 files to $(SCRIPT_INSTALL_DIR)/opt0.4/";
|
||||
@for i in $(TOP_DIR)/library/opt/*.tcl ; \
|
||||
do \
|
||||
$(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)"/opt0.4; \
|
||||
done;
|
||||
@echo "Installing package msgcat 1.6.0 as a Tcl Module";
|
||||
@$(INSTALL_DATA) $(TOP_DIR)/library/msgcat/msgcat.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/msgcat-1.6.0.tm;
|
||||
@echo "Installing package tcltest 2.4.0 as a Tcl Module";
|
||||
@$(INSTALL_DATA) $(TOP_DIR)/library/tcltest/tcltest.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/tcltest-2.4.0.tm;
|
||||
@echo "Installing package msgcat 1.6.1 as a Tcl Module";
|
||||
@$(INSTALL_DATA) $(TOP_DIR)/library/msgcat/msgcat.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/msgcat-1.6.1.tm;
|
||||
@echo "Installing package tcltest 2.4.1 as a Tcl Module";
|
||||
@$(INSTALL_DATA) $(TOP_DIR)/library/tcltest/tcltest.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/tcltest-2.4.1.tm;
|
||||
|
||||
@echo "Installing package platform 1.0.14 as a Tcl Module";
|
||||
@$(INSTALL_DATA) $(TOP_DIR)/library/platform/platform.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.4/platform-1.0.14.tm;
|
||||
@@ -2018,8 +2018,7 @@ dist: $(UNIX_DIR)/configure $(UNIX_DIR)/tclConfig.h.in $(UNIX_DIR)/tcl.pc.in $(M
|
||||
cp -p $(TOP_DIR)/win/*.[ch] $(TOP_DIR)/win/*.ico $(TOP_DIR)/win/*.rc \
|
||||
$(DISTDIR)/win
|
||||
cp -p $(TOP_DIR)/win/*.bat $(DISTDIR)/win
|
||||
cp -p $(TOP_DIR)/win/makefile.* $(DISTDIR)/win
|
||||
cp -p $(TOP_DIR)/win/rules.vc $(DISTDIR)/win
|
||||
cp -p $(TOP_DIR)/win/*.vc $(DISTDIR)/win
|
||||
cp -p $(TOP_DIR)/win/coffbase.txt $(DISTDIR)/win
|
||||
cp -p $(TOP_DIR)/win/tcl.hpj.in $(DISTDIR)/win
|
||||
cp -p $(TOP_DIR)/win/tcl.ds* $(DISTDIR)/win
|
||||
|
||||
71
unix/configure
vendored
Normal file → Executable file
71
unix/configure
vendored
Normal file → Executable file
@@ -1335,7 +1335,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
||||
TCL_VERSION=8.6
|
||||
TCL_MAJOR_VERSION=8
|
||||
TCL_MINOR_VERSION=6
|
||||
TCL_PATCH_LEVEL=".6"
|
||||
TCL_PATCH_LEVEL=".8"
|
||||
VERSION=${TCL_VERSION}
|
||||
|
||||
EXTRA_INSTALL_BINARIES=${EXTRA_INSTALL_BINARIES:-"@:"}
|
||||
@@ -6650,8 +6650,10 @@ fi
|
||||
PLAT_OBJS=""
|
||||
PLAT_SRCS=""
|
||||
LDAIX_SRC=""
|
||||
if test x"${SHLIB_VERSION}" = x; then
|
||||
SHLIB_VERSION="1.0"
|
||||
if test "x${SHLIB_VERSION}" = x; then
|
||||
SHLIB_VERSION=".1.0"
|
||||
else
|
||||
SHLIB_VERSION=".${SHLIB_VERSION}"
|
||||
fi
|
||||
|
||||
case $system in
|
||||
@@ -6929,9 +6931,9 @@ echo "$as_me: error: CYGWIN compile is only supported with --enable-threads" >&2
|
||||
fi
|
||||
do64bit_ok=yes
|
||||
if test "x${SHARED_BUILD}" = "x1"; then
|
||||
echo "running cd ${TCL_SRC_DIR}/win; ${CONFIG_SHELL-/bin/sh} ./configure $ac_configure_args"
|
||||
echo "running cd ../win; ${CONFIG_SHELL-/bin/sh} ./configure $ac_configure_args"
|
||||
# The eval makes quoting arguments work.
|
||||
if cd ${TCL_SRC_DIR}/win; eval ${CONFIG_SHELL-/bin/sh} ./configure $ac_configure_args; cd ../unix
|
||||
if cd ../win; eval ${CONFIG_SHELL-/bin/sh} ./configure $ac_configure_args; cd ../unix
|
||||
then :
|
||||
else
|
||||
{ echo "configure: error: configure failed for ../win" 1>&2; exit 1; }
|
||||
@@ -6952,7 +6954,7 @@ echo "$as_me: error: CYGWIN compile is only supported with --enable-threads" >&2
|
||||
LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
|
||||
SHLIB_CFLAGS="-fPIC"
|
||||
SHLIB_SUFFIX=".so"
|
||||
SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS}'
|
||||
SHLIB_LD='${CC} ${CFLAGS} ${LDFLAGS} -shared'
|
||||
DL_OBJS="tclLoadDl.o"
|
||||
DL_LIBS="-lroot"
|
||||
echo "$as_me:$LINENO: checking for inet_ntoa in -lnetwork" >&5
|
||||
@@ -7381,7 +7383,7 @@ fi
|
||||
# get rid of the warnings.
|
||||
#CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D__NO_STRING_INLINES -D__NO_MATH_INLINES"
|
||||
|
||||
SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS}'
|
||||
SHLIB_LD='${CC} ${CFLAGS} ${LDFLAGS} -shared'
|
||||
DL_OBJS="tclLoadDl.o"
|
||||
DL_LIBS="-ldl"
|
||||
LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
|
||||
@@ -7516,47 +7518,26 @@ fi
|
||||
OpenBSD-*)
|
||||
arch=`arch -s`
|
||||
case "$arch" in
|
||||
vax)
|
||||
# Equivalent using configure option --disable-load
|
||||
# Step 4 will set the necessary variables
|
||||
DL_OBJS=""
|
||||
SHLIB_LD_LIBS=""
|
||||
LDFLAGS=""
|
||||
alpha|sparc64)
|
||||
SHLIB_CFLAGS="-fPIC"
|
||||
;;
|
||||
*)
|
||||
case "$arch" in
|
||||
alpha|sparc|sparc64)
|
||||
SHLIB_CFLAGS="-fPIC"
|
||||
;;
|
||||
*)
|
||||
SHLIB_CFLAGS="-fpic"
|
||||
;;
|
||||
esac
|
||||
SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}'
|
||||
SHLIB_SUFFIX=".so"
|
||||
DL_OBJS="tclLoadDl.o"
|
||||
DL_LIBS=""
|
||||
if test $doRpath = yes; then
|
||||
SHLIB_CFLAGS="-fpic"
|
||||
;;
|
||||
esac
|
||||
SHLIB_LD='${CC} ${SHLIB_CFLAGS} -shared'
|
||||
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}'
|
||||
LDFLAGS="-Wl,-export-dynamic"
|
||||
;;
|
||||
esac
|
||||
case "$arch" in
|
||||
vax)
|
||||
CFLAGS_OPTIMIZE="-O1"
|
||||
;;
|
||||
sh)
|
||||
CFLAGS_OPTIMIZE="-O0"
|
||||
;;
|
||||
*)
|
||||
CFLAGS_OPTIMIZE="-O2"
|
||||
;;
|
||||
esac
|
||||
LD_SEARCH_FLAGS=${CC_SEARCH_FLAGS}
|
||||
SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so${SHLIB_VERSION}'
|
||||
LDFLAGS="-Wl,-export-dynamic"
|
||||
CFLAGS_OPTIMIZE="-O2"
|
||||
if test "${TCL_THREADS}" = "1"; then
|
||||
|
||||
# On OpenBSD: Compile with -pthread
|
||||
@@ -7573,7 +7554,7 @@ fi
|
||||
NetBSD-*)
|
||||
# NetBSD has ELF and can use 'cc -shared' to build shared libs
|
||||
SHLIB_CFLAGS="-fPIC"
|
||||
SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}'
|
||||
SHLIB_LD='${CC} ${SHLIB_CFLAGS} -shared'
|
||||
SHLIB_SUFFIX=".so"
|
||||
DL_OBJS="tclLoadDl.o"
|
||||
DL_LIBS=""
|
||||
@@ -8295,7 +8276,7 @@ fi
|
||||
# requires an extra version number at the end of .so file names.
|
||||
# So, the library has to have a name like libtcl75.so.1.0
|
||||
|
||||
SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}'
|
||||
SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so${SHLIB_VERSION}'
|
||||
UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
|
||||
TCL_LIB_VERSIONS_OK=nodots
|
||||
;;
|
||||
|
||||
2
unix/configure.in
Normal file → Executable file
2
unix/configure.in
Normal file → Executable file
@@ -25,7 +25,7 @@ m4_ifdef([SC_USE_CONFIG_HEADERS], [
|
||||
TCL_VERSION=8.6
|
||||
TCL_MAJOR_VERSION=8
|
||||
TCL_MINOR_VERSION=6
|
||||
TCL_PATCH_LEVEL=".6"
|
||||
TCL_PATCH_LEVEL=".8"
|
||||
VERSION=${TCL_VERSION}
|
||||
|
||||
EXTRA_INSTALL_BINARIES=${EXTRA_INSTALL_BINARIES:-"@:"}
|
||||
|
||||
0
unix/install-sh
Normal file → Executable file
0
unix/install-sh
Normal file → Executable file
0
unix/installManPage
Normal file → Executable file
0
unix/installManPage
Normal file → Executable file
0
unix/ldAix
Normal file → Executable file
0
unix/ldAix
Normal file → Executable file
70
unix/tcl.m4
70
unix/tcl.m4
@@ -91,8 +91,9 @@ AC_DEFUN([SC_PATH_TCLCONFIG], [
|
||||
for i in `ls -d ${libdir} 2>/dev/null` \
|
||||
`ls -d ${exec_prefix}/lib 2>/dev/null` \
|
||||
`ls -d ${prefix}/lib 2>/dev/null` \
|
||||
`ls -d /usr/local/lib 2>/dev/null` \
|
||||
`ls -d /usr/contrib/lib 2>/dev/null` \
|
||||
`ls -d /usr/local/lib 2>/dev/null` \
|
||||
`ls -d /usr/pkg/lib 2>/dev/null` \
|
||||
`ls -d /usr/lib 2>/dev/null` \
|
||||
`ls -d /usr/lib64 2>/dev/null` \
|
||||
; do
|
||||
@@ -611,7 +612,6 @@ AC_DEFUN([SC_ENABLE_FRAMEWORK], [
|
||||
# TCL_THREADS
|
||||
# _REENTRANT
|
||||
# _THREAD_SAFE
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
AC_DEFUN([SC_ENABLE_THREADS], [
|
||||
@@ -727,7 +727,6 @@ AC_DEFUN([SC_ENABLE_THREADS], [
|
||||
# Sets to $(LDFLAGS_OPTIMIZE) if false
|
||||
# DBGX Formerly used as debug library extension;
|
||||
# always blank now.
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
AC_DEFUN([SC_ENABLE_SYMBOLS], [
|
||||
@@ -977,7 +976,7 @@ AC_DEFUN([SC_CONFIG_SYSTEM], [
|
||||
# SHLIB_LD_LIBS - Dependent libraries for the linker to scan when
|
||||
# creating shared libraries. This symbol typically
|
||||
# goes at the end of the "ld" commands that build
|
||||
# shared libraries. The value of the symbol is
|
||||
# shared libraries. The value of the symbol defaults to
|
||||
# "${LIBS}" if all of the dependent libraries should
|
||||
# be specified when creating a shared library. If
|
||||
# dependent libraries should not be specified (as on
|
||||
@@ -1107,7 +1106,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
|
||||
PLAT_OBJS=""
|
||||
PLAT_SRCS=""
|
||||
LDAIX_SRC=""
|
||||
AS_IF([test x"${SHLIB_VERSION}" = x], [SHLIB_VERSION="1.0"])
|
||||
AS_IF([test "x${SHLIB_VERSION}" = x],[SHLIB_VERSION=".1.0"],[SHLIB_VERSION=".${SHLIB_VERSION}"])
|
||||
case $system in
|
||||
AIX-*)
|
||||
AS_IF([test "${TCL_THREADS}" = "1" -a "$GCC" != "yes"], [
|
||||
@@ -1236,9 +1235,9 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
|
||||
fi
|
||||
do64bit_ok=yes
|
||||
if test "x${SHARED_BUILD}" = "x1"; then
|
||||
echo "running cd ${TCL_SRC_DIR}/win; ${CONFIG_SHELL-/bin/sh} ./configure $ac_configure_args"
|
||||
echo "running cd ../win; ${CONFIG_SHELL-/bin/sh} ./configure $ac_configure_args"
|
||||
# The eval makes quoting arguments work.
|
||||
if cd ${TCL_SRC_DIR}/win; eval ${CONFIG_SHELL-/bin/sh} ./configure $ac_configure_args; cd ../unix
|
||||
if cd ../win; eval ${CONFIG_SHELL-/bin/sh} ./configure $ac_configure_args; cd ../unix
|
||||
then :
|
||||
else
|
||||
{ echo "configure: error: configure failed for ../win" 1>&2; exit 1; }
|
||||
@@ -1259,7 +1258,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
|
||||
LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
|
||||
SHLIB_CFLAGS="-fPIC"
|
||||
SHLIB_SUFFIX=".so"
|
||||
SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS}'
|
||||
SHLIB_LD='${CC} ${CFLAGS} ${LDFLAGS} -shared'
|
||||
DL_OBJS="tclLoadDl.o"
|
||||
DL_LIBS="-lroot"
|
||||
AC_CHECK_LIB(network, inet_ntoa, [LIBS="$LIBS -lnetwork"])
|
||||
@@ -1403,7 +1402,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
|
||||
# get rid of the warnings.
|
||||
#CFLAGS_OPTIMIZE="${CFLAGS_OPTIMIZE} -D__NO_STRING_INLINES -D__NO_MATH_INLINES"
|
||||
|
||||
SHLIB_LD='${CC} -shared ${CFLAGS} ${LDFLAGS}'
|
||||
SHLIB_LD='${CC} ${CFLAGS} ${LDFLAGS} -shared'
|
||||
DL_OBJS="tclLoadDl.o"
|
||||
DL_LIBS="-ldl"
|
||||
LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
|
||||
@@ -1467,44 +1466,23 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
|
||||
OpenBSD-*)
|
||||
arch=`arch -s`
|
||||
case "$arch" in
|
||||
vax)
|
||||
# Equivalent using configure option --disable-load
|
||||
# Step 4 will set the necessary variables
|
||||
DL_OBJS=""
|
||||
SHLIB_LD_LIBS=""
|
||||
LDFLAGS=""
|
||||
alpha|sparc64)
|
||||
SHLIB_CFLAGS="-fPIC"
|
||||
;;
|
||||
*)
|
||||
case "$arch" in
|
||||
alpha|sparc|sparc64)
|
||||
SHLIB_CFLAGS="-fPIC"
|
||||
;;
|
||||
*)
|
||||
SHLIB_CFLAGS="-fpic"
|
||||
;;
|
||||
esac
|
||||
SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}'
|
||||
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}'
|
||||
LDFLAGS="-Wl,-export-dynamic"
|
||||
;;
|
||||
esac
|
||||
case "$arch" in
|
||||
vax)
|
||||
CFLAGS_OPTIMIZE="-O1"
|
||||
;;
|
||||
sh)
|
||||
CFLAGS_OPTIMIZE="-O0"
|
||||
;;
|
||||
*)
|
||||
CFLAGS_OPTIMIZE="-O2"
|
||||
SHLIB_CFLAGS="-fpic"
|
||||
;;
|
||||
esac
|
||||
SHLIB_LD='${CC} ${SHLIB_CFLAGS} -shared'
|
||||
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}'
|
||||
LDFLAGS="-Wl,-export-dynamic"
|
||||
CFLAGS_OPTIMIZE="-O2"
|
||||
AS_IF([test "${TCL_THREADS}" = "1"], [
|
||||
# On OpenBSD: Compile with -pthread
|
||||
# Don't link with -lpthread
|
||||
@@ -1518,7 +1496,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
|
||||
NetBSD-*)
|
||||
# NetBSD has ELF and can use 'cc -shared' to build shared libs
|
||||
SHLIB_CFLAGS="-fPIC"
|
||||
SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}'
|
||||
SHLIB_LD='${CC} ${SHLIB_CFLAGS} -shared'
|
||||
SHLIB_SUFFIX=".so"
|
||||
DL_OBJS="tclLoadDl.o"
|
||||
DL_LIBS=""
|
||||
@@ -1825,7 +1803,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
|
||||
# requires an extra version number at the end of .so file names.
|
||||
# So, the library has to have a name like libtcl75.so.1.0
|
||||
|
||||
SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so.${SHLIB_VERSION}'
|
||||
SHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.so${SHLIB_VERSION}'
|
||||
UNSHARED_LIB_SUFFIX='${TCL_TRIM_DOTS}.a'
|
||||
TCL_LIB_VERSIONS_OK=nodots
|
||||
;;
|
||||
@@ -2706,7 +2684,7 @@ AC_DEFUN([SC_TCL_CFG_ENCODING], [
|
||||
# advancedTest - the advanced test to run if the function is present
|
||||
#
|
||||
# Results:
|
||||
# Might cause compatability versions of the function to be used.
|
||||
# Might cause compatibility versions of the function to be used.
|
||||
# Might affect the following vars:
|
||||
# USE_COMPAT (implicit)
|
||||
#
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
Name: tcl
|
||||
Summary: Tcl scripting language development environment
|
||||
Version: 8.6.6
|
||||
Version: 8.6.8
|
||||
Release: 2
|
||||
License: BSD
|
||||
Group: Development/Languages
|
||||
|
||||
@@ -81,7 +81,7 @@ TCL_DL_LIBS='@DL_LIBS@'
|
||||
# an executable tclsh or tcltest binary.
|
||||
TCL_LD_FLAGS='@LDFLAGS@'
|
||||
|
||||
# Flags to pass to ld, such as "-R /usr/local/tcl/lib", that tell the
|
||||
# Flags to pass to cc/ld, such as "-R /usr/local/tcl/lib", that tell the
|
||||
# run-time dynamic linker where to look for shared libraries such as
|
||||
# libtcl.so. Used when linking applications. Only works if there
|
||||
# is a variable "LIB_RUNTIME_DIR" defined in the Makefile.
|
||||
|
||||
@@ -48,7 +48,9 @@
|
||||
#endif /* TCL_DYLD_USE_DLFCN */
|
||||
|
||||
#if TCL_DYLD_USE_NSMODULE || defined(TCL_LOAD_FROM_MEMORY)
|
||||
#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
#include <mach-o/dyld.h>
|
||||
#include <mach-o/fat.h>
|
||||
#include <mach-o/swap.h>
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
#ifdef HAVE_LANGINFO
|
||||
# include <langinfo.h>
|
||||
# ifdef __APPLE__
|
||||
# if defined(HAVE_WEAK_IMPORT) && MAC_OS_X_VERSION_MIN_REQUIRED < 1030
|
||||
# if defined(HAVE_WEAK_IMPORT) && MAC_OS_X_VERSION_MIN_REQUIRED < 1030
|
||||
/* Support for weakly importing nl_langinfo on Darwin. */
|
||||
# define WEAK_IMPORT_NL_LANGINFO
|
||||
extern char *nl_langinfo(nl_item) WEAK_IMPORT_ATTRIBUTE;
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#include <sys/resource.h>
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
DLLIMPORT extern __stdcall unsigned char GetVersionExW(void *);
|
||||
DLLIMPORT extern __stdcall void *LoadLibraryW(const void *);
|
||||
DLLIMPORT extern __stdcall void *GetModuleHandleW(const void *);
|
||||
DLLIMPORT extern __stdcall void FreeLibrary(void *);
|
||||
DLLIMPORT extern __stdcall void *GetProcAddress(void *, const char *);
|
||||
DLLIMPORT extern __stdcall void GetSystemInfo(void *);
|
||||
@@ -45,12 +45,12 @@ static const char *const platforms[NUMPLATFORMS] = {
|
||||
};
|
||||
|
||||
#define NUMPROCESSORS 11
|
||||
static const char *const processors[NUMPROCESSORS] = {
|
||||
static const char *const processors[NUMPROCESSORS] = {
|
||||
"intel", "mips", "alpha", "ppc", "shx", "arm", "ia64", "alpha64", "msil",
|
||||
"amd64", "ia32_on_win64"
|
||||
};
|
||||
|
||||
typedef struct _SYSTEM_INFO {
|
||||
typedef struct {
|
||||
union {
|
||||
DWORD dwOemId;
|
||||
struct {
|
||||
@@ -69,7 +69,7 @@ typedef struct _SYSTEM_INFO {
|
||||
int wProcessorRevision;
|
||||
} SYSTEM_INFO;
|
||||
|
||||
typedef struct _OSVERSIONINFOW {
|
||||
typedef struct {
|
||||
DWORD dwOSVersionInfoSize;
|
||||
DWORD dwMajorVersion;
|
||||
DWORD dwMinorVersion;
|
||||
@@ -744,6 +744,43 @@ Tcl_GetEncodingNameFromEnvironment(
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#if defined(HAVE_COREFOUNDATION) && MAC_OS_X_VERSION_MAX_ALLOWED > 1020
|
||||
/*
|
||||
* Helper because whether CFLocaleCopyCurrent and CFLocaleGetIdentifier are
|
||||
* strongly or weakly bound varies by version of OSX, triggering warnings.
|
||||
*/
|
||||
|
||||
static inline void
|
||||
InitMacLocaleInfoVar(
|
||||
CFLocaleRef (*localeCopyCurrent)(void),
|
||||
CFStringRef (*localeGetIdentifier)(CFLocaleRef),
|
||||
Tcl_Interp *interp)
|
||||
{
|
||||
CFLocaleRef localeRef;
|
||||
CFStringRef locale;
|
||||
char loc[256];
|
||||
|
||||
if (localeCopyCurrent == NULL || localeGetIdentifier == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
localeRef = localeCopyCurrent();
|
||||
if (!localeRef) {
|
||||
return;
|
||||
}
|
||||
|
||||
locale = localeGetIdentifier(localeRef);
|
||||
if (locale && CFStringGetCString(locale, loc, 256,
|
||||
kCFStringEncodingUTF8)) {
|
||||
if (!Tcl_CreateNamespace(interp, "::tcl::mac", NULL, NULL)) {
|
||||
Tcl_ResetResult(interp);
|
||||
}
|
||||
Tcl_SetVar(interp, "::tcl::mac::locale", loc, TCL_GLOBAL_ONLY);
|
||||
}
|
||||
CFRelease(localeRef);
|
||||
}
|
||||
#endif /*defined(HAVE_COREFOUNDATION) && MAC_OS_X_VERSION_MAX_ALLOWED > 1020*/
|
||||
|
||||
void
|
||||
TclpSetVariables(
|
||||
Tcl_Interp *interp)
|
||||
@@ -762,29 +799,12 @@ TclpSetVariables(
|
||||
#ifdef HAVE_COREFOUNDATION
|
||||
char tclLibPath[MAXPATHLEN + 1];
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED > 1020
|
||||
/*
|
||||
* Set msgcat fallback locale to current CFLocale identifier.
|
||||
*/
|
||||
|
||||
CFLocaleRef localeRef;
|
||||
|
||||
if (CFLocaleCopyCurrent != NULL && CFLocaleGetIdentifier != NULL &&
|
||||
(localeRef = CFLocaleCopyCurrent())) {
|
||||
CFStringRef locale = CFLocaleGetIdentifier(localeRef);
|
||||
|
||||
if (locale) {
|
||||
char loc[256];
|
||||
|
||||
if (CFStringGetCString(locale, loc, 256, kCFStringEncodingUTF8)) {
|
||||
if (!Tcl_CreateNamespace(interp, "::tcl::mac", NULL, NULL)) {
|
||||
Tcl_ResetResult(interp);
|
||||
}
|
||||
Tcl_SetVar(interp, "::tcl::mac::locale", loc, TCL_GLOBAL_ONLY);
|
||||
}
|
||||
}
|
||||
CFRelease(localeRef);
|
||||
}
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED > 1020
|
||||
InitMacLocaleInfoVar(CFLocaleCopyCurrent, CFLocaleGetIdentifier, interp);
|
||||
#endif /* MAC_OS_X_VERSION_MAX_ALLOWED > 1020 */
|
||||
|
||||
if (MacOSXGetLibraryPath(interp, MAXPATHLEN, tclLibPath) == TCL_OK) {
|
||||
@@ -865,16 +885,13 @@ TclpSetVariables(
|
||||
#ifdef __CYGWIN__
|
||||
unameOK = 1;
|
||||
if (!osInfoInitialized) {
|
||||
HANDLE handle = LoadLibraryW(L"NTDLL");
|
||||
HANDLE handle = GetModuleHandleW(L"NTDLL");
|
||||
int(__stdcall *getversion)(void *) =
|
||||
(int(__stdcall *)(void *))GetProcAddress(handle, "RtlGetVersion");
|
||||
osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
|
||||
if (!getversion || getversion(&osInfo)) {
|
||||
GetVersionExW(&osInfo);
|
||||
}
|
||||
if (handle) {
|
||||
FreeLibrary(handle);
|
||||
}
|
||||
osInfoInitialized = 1;
|
||||
}
|
||||
|
||||
@@ -1032,7 +1049,6 @@ TclpFindVariable(
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
|
||||
@@ -152,8 +152,8 @@ static int triggerPipe = -1;
|
||||
* The notifierMutex locks access to all of the global notifier state.
|
||||
*/
|
||||
|
||||
pthread_mutex_t notifierInitMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
pthread_mutex_t notifierMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_mutex_t notifierInitMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_mutex_t notifierMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
/*
|
||||
* The following static indicates if the notifier thread is running.
|
||||
*
|
||||
|
||||
@@ -125,11 +125,11 @@ typedef off_t Tcl_SeekOffset;
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#if TIME_WITH_SYS_TIME
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
#if HAVE_SYS_TIME_H
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
#else
|
||||
# include <time.h>
|
||||
@@ -138,11 +138,11 @@ typedef off_t Tcl_SeekOffset;
|
||||
#ifndef NO_SYS_WAIT_H
|
||||
# include <sys/wait.h>
|
||||
#endif
|
||||
#if HAVE_INTTYPES_H
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
#include <limits.h>
|
||||
#if HAVE_STDINT_H
|
||||
#ifdef HAVE_STDINT_H
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#define SET_BITS(var, bits) ((var) |= (bits))
|
||||
#define CLEAR_BITS(var, bits) ((var) &= ~(bits))
|
||||
#define GOT_BITS(var, bits) (((var) & (bits)) != 0)
|
||||
|
||||
/* "sock" + a pointer in hex + \0 */
|
||||
#define SOCK_CHAN_LENGTH (4 + sizeof(void *) * 2 + 1)
|
||||
@@ -117,8 +118,7 @@ struct TcpState {
|
||||
* Static routines for this file:
|
||||
*/
|
||||
|
||||
static int TcpConnect(Tcl_Interp *interp,
|
||||
TcpState *state);
|
||||
static int TcpConnect(Tcl_Interp *interp, TcpState *state);
|
||||
static void TcpAccept(ClientData data, int mask);
|
||||
static int TcpBlockModeProc(ClientData data, int mode);
|
||||
static int TcpCloseProc(ClientData instanceData,
|
||||
@@ -173,21 +173,24 @@ static ProcessGlobalValue hostName =
|
||||
|
||||
#if 0
|
||||
/* printf debugging */
|
||||
void printaddrinfo(struct addrinfo *addrlist, char *prefix)
|
||||
void
|
||||
printaddrinfo(
|
||||
struct addrinfo *addrlist,
|
||||
char *prefix)
|
||||
{
|
||||
char host[NI_MAXHOST], port[NI_MAXSERV];
|
||||
struct addrinfo *ai;
|
||||
|
||||
for (ai = addrlist; ai != NULL; ai = ai->ai_next) {
|
||||
getnameinfo(ai->ai_addr, ai->ai_addrlen,
|
||||
host, sizeof(host),
|
||||
port, sizeof(port),
|
||||
NI_NUMERICHOST|NI_NUMERICSERV);
|
||||
host, sizeof(host), port, sizeof(port),
|
||||
NI_NUMERICHOST|NI_NUMERICSERV);
|
||||
fprintf(stderr,"%s: %s:%s\n", prefix, host, port);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*
|
||||
* InitializeHostName --
|
||||
*
|
||||
@@ -197,7 +200,7 @@ void printaddrinfo(struct addrinfo *addrlist, char *prefix)
|
||||
* Results:
|
||||
* None.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void
|
||||
@@ -271,12 +274,12 @@ InitializeHostName(
|
||||
|
||||
*encodingPtr = Tcl_GetEncoding(NULL, NULL);
|
||||
*lengthPtr = strlen(native);
|
||||
*valuePtr = ckalloc((*lengthPtr) + 1);
|
||||
memcpy(*valuePtr, native, (size_t)(*lengthPtr)+1);
|
||||
*valuePtr = ckalloc(*lengthPtr + 1);
|
||||
memcpy(*valuePtr, native, (size_t)(*lengthPtr) + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*
|
||||
* Tcl_GetHostName --
|
||||
*
|
||||
@@ -290,7 +293,7 @@ InitializeHostName(
|
||||
* Side effects:
|
||||
* Caches the name to return for future calls.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
const char *
|
||||
@@ -300,7 +303,7 @@ Tcl_GetHostName(void)
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*
|
||||
* TclpHasSockets --
|
||||
*
|
||||
@@ -312,7 +315,7 @@ Tcl_GetHostName(void)
|
||||
* Side effects:
|
||||
* None.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
int
|
||||
@@ -323,7 +326,7 @@ TclpHasSockets(
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*
|
||||
* TclpFinalizeSockets --
|
||||
*
|
||||
@@ -335,7 +338,7 @@ TclpHasSockets(
|
||||
* Side effects:
|
||||
* None.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
void
|
||||
@@ -345,7 +348,7 @@ TclpFinalizeSockets(void)
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*
|
||||
* TcpBlockModeProc --
|
||||
*
|
||||
@@ -358,7 +361,7 @@ TclpFinalizeSockets(void)
|
||||
* Side effects:
|
||||
* Sets the device into blocking or nonblocking mode.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
@@ -376,7 +379,7 @@ TcpBlockModeProc(
|
||||
} else {
|
||||
SET_BITS(statePtr->flags, TCP_NONBLOCKING);
|
||||
}
|
||||
if (statePtr->flags & TCP_ASYNC_CONNECT) {
|
||||
if (GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT)) {
|
||||
statePtr->cachedBlocking = mode;
|
||||
return 0;
|
||||
}
|
||||
@@ -387,33 +390,32 @@ TcpBlockModeProc(
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*
|
||||
* WaitForConnect --
|
||||
*
|
||||
* Check the state of an async connect process. If a connection
|
||||
* attempt terminated, process it, which may finalize it or may
|
||||
* start the next attempt. If a connect error occures, it is saved
|
||||
* in statePtr->connectError to be reported by 'fconfigure -error'.
|
||||
* Check the state of an async connect process. If a connection attempt
|
||||
* terminated, process it, which may finalize it or may start the next
|
||||
* attempt. If a connect error occures, it is saved in
|
||||
* statePtr->connectError to be reported by 'fconfigure -error'.
|
||||
*
|
||||
* There are two modes of operation, defined by errorCodePtr:
|
||||
* * non-NULL: Called by explicite read/write command. block if
|
||||
* * non-NULL: Called by explicite read/write command. Blocks if the
|
||||
* socket is blocking.
|
||||
* May return two error codes:
|
||||
* * EWOULDBLOCK: if connect is still in progress
|
||||
* * ENOTCONN: if connect failed. This would be the error
|
||||
* message of a rect or sendto syscall so this is
|
||||
* emulated here.
|
||||
* * NULL: Called by a backround operation. Do not block and
|
||||
* don't return any error code.
|
||||
* * ENOTCONN: if connect failed. This would be the error message
|
||||
* of a rect or sendto syscall so this is emulated here.
|
||||
* * NULL: Called by a backround operation. Do not block and do not
|
||||
* return any error code.
|
||||
*
|
||||
* Results:
|
||||
* 0 if the connection has completed, -1 if still in progress
|
||||
* or there is an error.
|
||||
* 0 if the connection has completed, -1 if still in progress or there is
|
||||
* an error.
|
||||
*
|
||||
* Side effects:
|
||||
* Processes socket events off the system queue.
|
||||
* May process asynchroneous connect.
|
||||
* Processes socket events off the system queue. May process
|
||||
* asynchroneous connects.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
@@ -426,11 +428,11 @@ WaitForConnect(
|
||||
int timeout;
|
||||
|
||||
/*
|
||||
* Check if an async connect failed already and error reporting is demanded,
|
||||
* return the error ENOTCONN
|
||||
* Check if an async connect failed already and error reporting is
|
||||
* demanded, return the error ENOTCONN
|
||||
*/
|
||||
|
||||
if (errorCodePtr != NULL && (statePtr->flags & TCP_ASYNC_FAILED)) {
|
||||
if (errorCodePtr != NULL && GOT_BITS(statePtr->flags, TCP_ASYNC_FAILED)) {
|
||||
*errorCodePtr = ENOTCONN;
|
||||
return -1;
|
||||
}
|
||||
@@ -439,26 +441,29 @@ WaitForConnect(
|
||||
* Check if an async connect is running. If not return ok
|
||||
*/
|
||||
|
||||
if (!(statePtr->flags & TCP_ASYNC_PENDING)) {
|
||||
if (!GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (errorCodePtr == NULL || (statePtr->flags & TCP_NONBLOCKING)) {
|
||||
if (errorCodePtr == NULL || GOT_BITS(statePtr->flags, TCP_NONBLOCKING)) {
|
||||
timeout = 0;
|
||||
} else {
|
||||
timeout = -1;
|
||||
}
|
||||
do {
|
||||
if (TclUnixWaitForFile(statePtr->fds.fd,
|
||||
TCL_WRITABLE | TCL_EXCEPTION, timeout) != 0) {
|
||||
TCL_WRITABLE | TCL_EXCEPTION, timeout) != 0) {
|
||||
TcpConnect(NULL, statePtr);
|
||||
}
|
||||
/* Do this only once in the nonblocking case and repeat it until the
|
||||
* socket is final when blocking */
|
||||
} while (timeout == -1 && statePtr->flags & TCP_ASYNC_CONNECT);
|
||||
|
||||
/*
|
||||
* Do this only once in the nonblocking case and repeat it until the
|
||||
* socket is final when blocking.
|
||||
*/
|
||||
} while (timeout == -1 && GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT));
|
||||
|
||||
if (errorCodePtr != NULL) {
|
||||
if (statePtr->flags & TCP_ASYNC_PENDING) {
|
||||
if (GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) {
|
||||
*errorCodePtr = EAGAIN;
|
||||
return -1;
|
||||
} else if (statePtr->connectError != 0) {
|
||||
@@ -615,7 +620,8 @@ TcpCloseProc(
|
||||
fds = statePtr->fds.next;
|
||||
while (fds != NULL) {
|
||||
TcpFdList *next = fds->next;
|
||||
ckfree(fds);
|
||||
|
||||
ckfree(fds);
|
||||
fds = next;
|
||||
}
|
||||
if (statePtr->addrlist != NULL) {
|
||||
@@ -685,10 +691,9 @@ TcpClose2Proc(
|
||||
*
|
||||
* TcpHostPortList --
|
||||
*
|
||||
* This function is called by the -gethostname and -getpeername
|
||||
* switches of TcpGetOptionProc() to add three list elements
|
||||
* with the textual representation of the given address to the
|
||||
* given DString.
|
||||
* This function is called by the -gethostname and -getpeername switches
|
||||
* of TcpGetOptionProc() to add three list elements with the textual
|
||||
* representation of the given address to the given DString.
|
||||
*
|
||||
* Results:
|
||||
* None.
|
||||
@@ -698,6 +703,37 @@ TcpClose2Proc(
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef NEED_FAKE_RFC2553
|
||||
#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
|
||||
#endif
|
||||
static inline int
|
||||
IPv6AddressNeedsNumericRendering(
|
||||
struct in6_addr addr)
|
||||
{
|
||||
if (IN6_ARE_ADDR_EQUAL(&addr, &in6addr_any)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* The IN6_IS_ADDR_V4MAPPED macro has a problem with aliasing warnings on
|
||||
* at least some versions of OSX.
|
||||
*/
|
||||
|
||||
if (!IN6_IS_ADDR_V4MAPPED(&addr)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (addr.s6_addr[12] == 0 && addr.s6_addr[13] == 0
|
||||
&& addr.s6_addr[14] == 0 && addr.s6_addr[15] == 0);
|
||||
}
|
||||
#if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 5))))
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#endif /* NEED_FAKE_RFC2553 */
|
||||
|
||||
static void
|
||||
TcpHostPortList(
|
||||
Tcl_Interp *interp,
|
||||
@@ -709,40 +745,47 @@ TcpHostPortList(
|
||||
char host[NI_MAXHOST], nhost[NI_MAXHOST], nport[NI_MAXSERV];
|
||||
int flags = 0;
|
||||
|
||||
getnameinfo(&addr.sa, salen,
|
||||
nhost, sizeof(nhost), nport, sizeof(nport),
|
||||
NI_NUMERICHOST | NI_NUMERICSERV);
|
||||
getnameinfo(&addr.sa, salen, nhost, sizeof(nhost), nport, sizeof(nport),
|
||||
NI_NUMERICHOST | NI_NUMERICSERV);
|
||||
Tcl_DStringAppendElement(dsPtr, nhost);
|
||||
|
||||
/*
|
||||
* We don't want to resolve INADDR_ANY and sin6addr_any; they
|
||||
* can sometimes cause problems (and never have a name).
|
||||
* We don't want to resolve INADDR_ANY and sin6addr_any; they can
|
||||
* sometimes cause problems (and never have a name).
|
||||
*/
|
||||
|
||||
if (addr.sa.sa_family == AF_INET) {
|
||||
if (addr.sa4.sin_addr.s_addr == INADDR_ANY) {
|
||||
flags |= NI_NUMERICHOST;
|
||||
}
|
||||
#ifndef NEED_FAKE_RFC2553
|
||||
} else if (addr.sa.sa_family == AF_INET6) {
|
||||
if ((IN6_ARE_ADDR_EQUAL(&addr.sa6.sin6_addr,
|
||||
&in6addr_any))
|
||||
|| (IN6_IS_ADDR_V4MAPPED(&addr.sa6.sin6_addr) &&
|
||||
addr.sa6.sin6_addr.s6_addr[12] == 0 &&
|
||||
addr.sa6.sin6_addr.s6_addr[13] == 0 &&
|
||||
addr.sa6.sin6_addr.s6_addr[14] == 0 &&
|
||||
addr.sa6.sin6_addr.s6_addr[15] == 0)) {
|
||||
if (IPv6AddressNeedsNumericRendering(addr.sa6.sin6_addr)) {
|
||||
flags |= NI_NUMERICHOST;
|
||||
}
|
||||
#endif /* NEED_FAKE_RFC2553 */
|
||||
}
|
||||
/* Check if reverse DNS has been switched off globally */
|
||||
if (interp != NULL && Tcl_GetVar(interp, SUPPRESS_RDNS_VAR, 0) != NULL) {
|
||||
|
||||
/*
|
||||
* Check if reverse DNS has been switched off globally.
|
||||
*/
|
||||
|
||||
if (interp != NULL &&
|
||||
Tcl_GetVar2(interp, SUPPRESS_RDNS_VAR, NULL, 0) != NULL) {
|
||||
flags |= NI_NUMERICHOST;
|
||||
}
|
||||
if (getnameinfo(&addr.sa, salen, host, sizeof(host), NULL, 0, flags) == 0) {
|
||||
/* Reverse mapping worked */
|
||||
if (getnameinfo(&addr.sa, salen, host, sizeof(host), NULL, 0,
|
||||
flags) == 0) {
|
||||
/*
|
||||
* Reverse mapping worked.
|
||||
*/
|
||||
|
||||
Tcl_DStringAppendElement(dsPtr, host);
|
||||
} else {
|
||||
/* Reverse mappong failed - use the numeric rep once more */
|
||||
/*
|
||||
* Reverse mapping failed - use the numeric rep once more.
|
||||
*/
|
||||
|
||||
Tcl_DStringAppendElement(dsPtr, nhost);
|
||||
}
|
||||
Tcl_DStringAppendElement(dsPtr, nport);
|
||||
@@ -792,16 +835,20 @@ TcpGetOptionProc(
|
||||
(strncmp(optionName, "-error", len) == 0)) {
|
||||
socklen_t optlen = sizeof(int);
|
||||
|
||||
if (statePtr->flags & TCP_ASYNC_CONNECT) {
|
||||
/* Suppress errors as long as we are not done */
|
||||
if (GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT)) {
|
||||
/*
|
||||
* Suppress errors as long as we are not done.
|
||||
*/
|
||||
|
||||
errno = 0;
|
||||
} else if (statePtr->connectError != 0) {
|
||||
errno = statePtr->connectError;
|
||||
statePtr->connectError = 0;
|
||||
} else {
|
||||
int err;
|
||||
getsockopt(statePtr->fds.fd, SOL_SOCKET, SO_ERROR,
|
||||
(char *) &err, &optlen);
|
||||
|
||||
getsockopt(statePtr->fds.fd, SOL_SOCKET, SO_ERROR, (char *) &err,
|
||||
&optlen);
|
||||
errno = err;
|
||||
}
|
||||
if (errno != 0) {
|
||||
@@ -812,9 +859,8 @@ TcpGetOptionProc(
|
||||
|
||||
if ((len > 1) && (optionName[1] == 'c') &&
|
||||
(strncmp(optionName, "-connecting", len) == 0)) {
|
||||
|
||||
Tcl_DStringAppend(dsPtr,
|
||||
(statePtr->flags & TCP_ASYNC_CONNECT) ? "1" : "0", -1);
|
||||
GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT) ? "1" : "0", -1);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
@@ -823,10 +869,11 @@ TcpGetOptionProc(
|
||||
address peername;
|
||||
socklen_t size = sizeof(peername);
|
||||
|
||||
if ( (statePtr->flags & TCP_ASYNC_CONNECT) ) {
|
||||
if (GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT)) {
|
||||
/*
|
||||
* In async connect output an empty string
|
||||
*/
|
||||
|
||||
if (len == 0) {
|
||||
Tcl_DStringAppendElement(dsPtr, "-peername");
|
||||
Tcl_DStringAppendElement(dsPtr, "");
|
||||
@@ -837,6 +884,7 @@ TcpGetOptionProc(
|
||||
/*
|
||||
* Peername fetch succeeded - output list
|
||||
*/
|
||||
|
||||
if (len == 0) {
|
||||
Tcl_DStringAppendElement(dsPtr, "-peername");
|
||||
Tcl_DStringStartSublist(dsPtr);
|
||||
@@ -876,11 +924,12 @@ TcpGetOptionProc(
|
||||
Tcl_DStringAppendElement(dsPtr, "-sockname");
|
||||
Tcl_DStringStartSublist(dsPtr);
|
||||
}
|
||||
if ( (statePtr->flags & TCP_ASYNC_CONNECT) ) {
|
||||
if (GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT)) {
|
||||
/*
|
||||
* In async connect output an empty string
|
||||
*/
|
||||
found = 1;
|
||||
|
||||
found = 1;
|
||||
} else {
|
||||
for (fds = &statePtr->fds; fds != NULL; fds = fds->next) {
|
||||
size = sizeof(sockname);
|
||||
@@ -905,14 +954,15 @@ TcpGetOptionProc(
|
||||
}
|
||||
|
||||
if (len > 0) {
|
||||
return Tcl_BadChannelOption(interp, optionName, "connecting peername sockname");
|
||||
return Tcl_BadChannelOption(interp, optionName,
|
||||
"connecting peername sockname");
|
||||
}
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*
|
||||
* TcpWatchProc --
|
||||
*
|
||||
@@ -925,7 +975,7 @@ TcpGetOptionProc(
|
||||
* Sets up the notifier so that a future event on the channel will be
|
||||
* seen by Tcl.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void
|
||||
@@ -938,17 +988,17 @@ WrapNotify(
|
||||
|
||||
if (newmask == 0) {
|
||||
/*
|
||||
* There was no overlap between the states the channel is
|
||||
* interested in notifications for, and the states that are
|
||||
* reported present on the file descriptor by select(). The
|
||||
* only way that can happen is when the channel is interested
|
||||
* in a writable condition, and only a readable state is reported
|
||||
* present (see TcpWatchProc() below). In that case, signal back
|
||||
* to the caller the writable state, which is really an error
|
||||
* condition. As an extra check on that assumption, check for
|
||||
* a non-zero value of errno before reporting an artificial
|
||||
* There was no overlap between the states the channel is interested
|
||||
* in notifications for, and the states that are reported present on
|
||||
* the file descriptor by select(). The only way that can happen is
|
||||
* when the channel is interested in a writable condition, and only a
|
||||
* readable state is reported present (see TcpWatchProc() below). In
|
||||
* that case, signal back to the caller the writable state, which is
|
||||
* really an error condition. As an extra check on that assumption,
|
||||
* check for a non-zero value of errno before reporting an artificial
|
||||
* writable state.
|
||||
*/
|
||||
|
||||
if (errno == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -972,33 +1022,36 @@ TcpWatchProc(
|
||||
* be readable or writable at the Tcl level. This keeps Tcl scripts
|
||||
* from interfering with the -accept behavior (bug #3394732).
|
||||
*/
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (statePtr->flags & TCP_ASYNC_PENDING) {
|
||||
/* Async sockets use a FileHandler internally while connecting, so we
|
||||
* need to cache this request until the connection has succeeded. */
|
||||
if (GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING)) {
|
||||
/*
|
||||
* Async sockets use a FileHandler internally while connecting, so we
|
||||
* need to cache this request until the connection has succeeded.
|
||||
*/
|
||||
|
||||
statePtr->filehandlers = mask;
|
||||
} else if (mask) {
|
||||
|
||||
/*
|
||||
* Whether it is a bug or feature or otherwise, it is a fact
|
||||
* of life that on at least some Linux kernels select() fails
|
||||
* to report that a socket file descriptor is writable when
|
||||
* the other end of the socket is closed. This is in contrast
|
||||
* to the guarantees Tcl makes that its channels become
|
||||
* writable and fire writable events on an error conditon.
|
||||
* This has caused a leak of file descriptors in a state of
|
||||
* Whether it is a bug or feature or otherwise, it is a fact of life
|
||||
* that on at least some Linux kernels select() fails to report that a
|
||||
* socket file descriptor is writable when the other end of the socket
|
||||
* is closed. This is in contrast to the guarantees Tcl makes that
|
||||
* its channels become writable and fire writable events on an error
|
||||
* conditon. This has caused a leak of file descriptors in a state of
|
||||
* background flushing. See Tcl ticket 1758a0b603.
|
||||
*
|
||||
* As a workaround, when our caller indicates an interest in
|
||||
* writable notifications, we must tell the notifier built
|
||||
* around select() that we are interested in the readable state
|
||||
* of the file descriptor as well, as that is the only reliable
|
||||
* means to get notified of error conditions. Then it is the
|
||||
* task of WrapNotify() above to untangle the meaning of these
|
||||
* channel states and report the chan events as best it can.
|
||||
* We save a copy of the mask passed in to assist with that.
|
||||
* As a workaround, when our caller indicates an interest in writable
|
||||
* notifications, we must tell the notifier built around select() that
|
||||
* we are interested in the readable state of the file descriptor as
|
||||
* well, as that is the only reliable means to get notified of error
|
||||
* conditions. Then it is the task of WrapNotify() above to untangle
|
||||
* the meaning of these channel states and report the chan events as
|
||||
* best it can. We save a copy of the mask passed in to assist with
|
||||
* that.
|
||||
*/
|
||||
|
||||
statePtr->interest = mask;
|
||||
@@ -1010,7 +1063,7 @@ TcpWatchProc(
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*
|
||||
* TcpGetHandleProc --
|
||||
*
|
||||
@@ -1024,7 +1077,7 @@ TcpWatchProc(
|
||||
* Side effects:
|
||||
* None.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ARGSUSED */
|
||||
@@ -1041,16 +1094,17 @@ TcpGetHandleProc(
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*
|
||||
* TcpAsyncCallback --
|
||||
*
|
||||
* Called by the event handler that TcpConnect sets up
|
||||
* internally for [socket -async] to get notified when the
|
||||
* asyncronous connection attempt has succeeded or failed.
|
||||
* Called by the event handler that TcpConnect sets up internally for
|
||||
* [socket -async] to get notified when the asyncronous connection
|
||||
* attempt has succeeded or failed.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static void
|
||||
TcpAsyncCallback(
|
||||
ClientData clientData, /* The socket state. */
|
||||
@@ -1062,7 +1116,7 @@ TcpAsyncCallback(
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*
|
||||
* TcpConnect --
|
||||
*
|
||||
@@ -1088,7 +1142,7 @@ TcpAsyncCallback(
|
||||
* return and the loops resume as if they had never been interrupted.
|
||||
* For syncronously connecting sockets, the loops work the usual way.
|
||||
*
|
||||
*----------------------------------------------------------------------
|
||||
* ----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
static int
|
||||
@@ -1097,9 +1151,9 @@ TcpConnect(
|
||||
TcpState *statePtr)
|
||||
{
|
||||
socklen_t optlen;
|
||||
int async_callback = statePtr->flags & TCP_ASYNC_PENDING;
|
||||
int ret = -1, error = errno;
|
||||
int async = statePtr->flags & TCP_ASYNC_CONNECT;
|
||||
int async_callback = GOT_BITS(statePtr->flags, TCP_ASYNC_PENDING);
|
||||
int ret = -1, error = EHOSTUNREACH;
|
||||
int async = GOT_BITS(statePtr->flags, TCP_ASYNC_CONNECT);
|
||||
|
||||
if (async_callback) {
|
||||
goto reenter;
|
||||
@@ -1107,8 +1161,8 @@ TcpConnect(
|
||||
|
||||
for (statePtr->addr = statePtr->addrlist; statePtr->addr != NULL;
|
||||
statePtr->addr = statePtr->addr->ai_next) {
|
||||
|
||||
for (statePtr->myaddr = statePtr->myaddrlist; statePtr->myaddr != NULL;
|
||||
for (statePtr->myaddr = statePtr->myaddrlist;
|
||||
statePtr->myaddr != NULL;
|
||||
statePtr->myaddr = statePtr->myaddr->ai_next) {
|
||||
int reuseaddr = 1;
|
||||
|
||||
@@ -1132,7 +1186,8 @@ TcpConnect(
|
||||
errno = 0;
|
||||
}
|
||||
|
||||
statePtr->fds.fd = socket(statePtr->addr->ai_family, SOCK_STREAM, 0);
|
||||
statePtr->fds.fd = socket(statePtr->addr->ai_family, SOCK_STREAM,
|
||||
0);
|
||||
if (statePtr->fds.fd < 0) {
|
||||
continue;
|
||||
}
|
||||
@@ -1151,14 +1206,18 @@ TcpConnect(
|
||||
TclSockMinimumBuffers(INT2PTR(statePtr->fds.fd), SOCKET_BUFSIZE);
|
||||
|
||||
if (async) {
|
||||
ret = TclUnixSetBlockingMode(statePtr->fds.fd,TCL_MODE_NONBLOCKING);
|
||||
ret = TclUnixSetBlockingMode(statePtr->fds.fd,
|
||||
TCL_MODE_NONBLOCKING);
|
||||
if (ret < 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* Gotta reset the error variable here, before we use it for the
|
||||
* first time in this iteration. */
|
||||
/*
|
||||
* Must reset the error variable here, before we use it for the
|
||||
* first time in this iteration.
|
||||
*/
|
||||
|
||||
error = 0;
|
||||
|
||||
(void) setsockopt(statePtr->fds.fd, SOL_SOCKET, SO_REUSEADDR,
|
||||
@@ -1179,10 +1238,13 @@ TcpConnect(
|
||||
|
||||
ret = connect(statePtr->fds.fd, statePtr->addr->ai_addr,
|
||||
statePtr->addr->ai_addrlen);
|
||||
if (ret < 0) error = errno;
|
||||
if (ret < 0) {
|
||||
error = errno;
|
||||
}
|
||||
if (ret < 0 && errno == EINPROGRESS) {
|
||||
Tcl_CreateFileHandler(statePtr->fds.fd,
|
||||
TCL_WRITABLE|TCL_EXCEPTION, TcpAsyncCallback, statePtr);
|
||||
TCL_WRITABLE | TCL_EXCEPTION, TcpAsyncCallback,
|
||||
statePtr);
|
||||
errno = EWOULDBLOCK;
|
||||
SET_BITS(statePtr->flags, TCP_ASYNC_PENDING);
|
||||
return TCL_OK;
|
||||
@@ -1210,7 +1272,7 @@ TcpConnect(
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
out:
|
||||
statePtr->connectError = error;
|
||||
CLEAR_BITS(statePtr->flags, TCP_ASYNC_CONNECT);
|
||||
if (async_callback) {
|
||||
@@ -1308,6 +1370,7 @@ Tcl_OpenTcpClient(
|
||||
/*
|
||||
* Allocate a new TcpState for this socket.
|
||||
*/
|
||||
|
||||
statePtr = ckalloc(sizeof(TcpState));
|
||||
memset(statePtr, 0, sizeof(TcpState));
|
||||
statePtr->flags = async ? TCP_ASYNC_CONNECT : 0;
|
||||
@@ -1319,6 +1382,7 @@ Tcl_OpenTcpClient(
|
||||
/*
|
||||
* Create a new client socket and wrap it in a channel.
|
||||
*/
|
||||
|
||||
if (TcpConnect(interp, statePtr) != TCL_OK) {
|
||||
TcpCloseProc(statePtr, NULL);
|
||||
return NULL;
|
||||
@@ -1326,8 +1390,8 @@ Tcl_OpenTcpClient(
|
||||
|
||||
sprintf(channelName, SOCK_TEMPLATE, (long) statePtr);
|
||||
|
||||
statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName, statePtr,
|
||||
(TCL_READABLE | TCL_WRITABLE));
|
||||
statePtr->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
|
||||
statePtr, TCL_READABLE | TCL_WRITABLE);
|
||||
if (Tcl_SetChannelOption(interp, statePtr->channel, "-translation",
|
||||
"auto crlf") == TCL_ERROR) {
|
||||
Tcl_Close(NULL, statePtr->channel);
|
||||
@@ -1356,7 +1420,8 @@ Tcl_Channel
|
||||
Tcl_MakeTcpClientChannel(
|
||||
ClientData sock) /* The socket to wrap up into a channel. */
|
||||
{
|
||||
return (Tcl_Channel) TclpMakeTcpClientChannelMode(sock, (TCL_READABLE | TCL_WRITABLE));
|
||||
return (Tcl_Channel) TclpMakeTcpClientChannelMode(sock,
|
||||
TCL_READABLE | TCL_WRITABLE);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1495,7 +1560,10 @@ Tcl_OpenTcpServer(
|
||||
}
|
||||
|
||||
#ifdef IPV6_V6ONLY
|
||||
/* Missing on: Solaris 2.8 */
|
||||
/*
|
||||
* Missing on: Solaris 2.8
|
||||
*/
|
||||
|
||||
if (addrPtr->ai_family == AF_INET6) {
|
||||
int v6only = 1;
|
||||
|
||||
@@ -1641,7 +1709,7 @@ TcpAccept(
|
||||
|
||||
sprintf(channelName, SOCK_TEMPLATE, (long) newSockState);
|
||||
newSockState->channel = Tcl_CreateChannel(&tcpChannelType, channelName,
|
||||
newSockState, (TCL_READABLE | TCL_WRITABLE));
|
||||
newSockState, TCL_READABLE | TCL_WRITABLE);
|
||||
|
||||
Tcl_SetChannelOption(NULL, newSockState->channel, "-translation",
|
||||
"auto crlf");
|
||||
|
||||
@@ -722,7 +722,8 @@ TclpFreeAllocCache(
|
||||
{
|
||||
if (ptr != NULL) {
|
||||
/*
|
||||
* Called by the pthread lib when a thread exits
|
||||
* Called by TclFinalizeThreadAllocThread() during the thread
|
||||
* finalization initiated from Tcl_FinalizeThread()
|
||||
*/
|
||||
|
||||
TclFreeAllocCache(ptr);
|
||||
@@ -730,7 +731,7 @@ TclpFreeAllocCache(
|
||||
|
||||
} else if (initialized) {
|
||||
/*
|
||||
* Called by us in TclFinalizeThreadAlloc() during the library
|
||||
* Called by TclFinalizeThreadAlloc() during the process
|
||||
* finalization initiated from Tcl_Finalize()
|
||||
*/
|
||||
|
||||
@@ -745,7 +746,7 @@ TclpGetAllocCache(void)
|
||||
if (!initialized) {
|
||||
pthread_mutex_lock(allocLockPtr);
|
||||
if (!initialized) {
|
||||
pthread_key_create(&key, TclpFreeAllocCache);
|
||||
pthread_key_create(&key, NULL);
|
||||
initialized = 1;
|
||||
}
|
||||
pthread_mutex_unlock(allocLockPtr);
|
||||
|
||||
@@ -158,7 +158,7 @@ TclpGetWideClicks(void)
|
||||
Tcl_Time time;
|
||||
|
||||
tclGetTimeProcPtr(&time, tclTimeClientData);
|
||||
now = (Tcl_WideInt) (time.sec*1000000 + time.usec);
|
||||
now = ((Tcl_WideInt)time.sec)*1000000 + time.usec;
|
||||
} else {
|
||||
#ifdef MAC_OSX_TCL
|
||||
now = (Tcl_WideInt) (mach_absolute_time() & INT64_MAX);
|
||||
|
||||
@@ -16,4 +16,4 @@ TCLOO_STUB_LIB_SPEC=""
|
||||
TCLOO_INCLUDE_SPEC=""
|
||||
TCLOO_PRIVATE_INCLUDE_SPEC=""
|
||||
TCLOO_CFLAGS=""
|
||||
TCLOO_VERSION=1.0.4
|
||||
TCLOO_VERSION=1.1.0
|
||||
|
||||
Reference in New Issue
Block a user