Index: configure ================================================================== --- configure +++ configure @@ -2684,12 +2684,13 @@ # check in a few common install locations if test x"${ac_cv_c_tclconfig}" = x ; then 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` \ `ls -d /usr/lib/tcl8.6 2>/dev/null` \ `ls -d /usr/lib/tcl8.5 2>/dev/null` \ ; do @@ -7882,43 +7883,27 @@ fi ;; OpenBSD-*) arch=`arch -s` case "$arch" in - vax) - SHLIB_SUFFIX="" - SHARED_LIB_SUFFIX="" - LDFLAGS="" - ;; - *) - case "$arch" in - alpha|sparc64) - SHLIB_CFLAGS="-fPIC" - ;; - *) - SHLIB_CFLAGS="-fpic" - ;; - esac - SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}' - SHLIB_SUFFIX=".so" - if test $doRpath = yes; then : - - 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" - ;; - *) - CFLAGS_OPTIMIZE="-O2" - ;; - esac + alpha|sparc64) + SHLIB_CFLAGS="-fPIC" + ;; + *) + SHLIB_CFLAGS="-fpic" + ;; + esac + SHLIB_LD='${CC} -shared ${SHLIB_CFLAGS}' + SHLIB_SUFFIX=".so" + if test $doRpath = yes; then : + + 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" + CFLAGS_OPTIMIZE="-O2" if test "${TCL_THREADS}" = "1"; then : # On OpenBSD: Compile with -pthread # Don't link with -lpthread LIBS=`echo $LIBS | sed s/-lpthread//` @@ -9196,10 +9181,53 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled $tcl_ok debugging" >&5 $as_echo "enabled $tcl_ok debugging" >&6; } fi fi + +#-------------------------------------------------------------------- +# INT2PTR / PTR2INT need to know about intptr_t. +# UINT2PTR / PTR2UINT need to know about uintptr_t. +#-------------------------------------------------------------------- + + + ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default" +if test "x$ac_cv_type_intptr_t" = xyes; then : + +$as_echo "#define HAVE_INTPTR_T 1" >>confdefs.h + +else + for ac_type in 'int' 'long int' 'long long int'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($ac_type))]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +cat >>confdefs.h <<_ACEOF +#define intptr_t $ac_type +_ACEOF + + ac_type= +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test -z "$ac_type" && break + done +fi + + +#AC_TYPE_UINTPTR_T #-------------------------------------------------------------------- # Everyone should be linking against the Tcl stub library. If you # can't for some reason, remove this definition. If you aren't using # stubs, you also need to modify the SHLIB_LD_LIBS setting below to Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -168,10 +168,18 @@ #-------------------------------------------------------------------- # Set the default compiler switches based on the --enable-symbols option. #-------------------------------------------------------------------- TEA_ENABLE_SYMBOLS + +#-------------------------------------------------------------------- +# INT2PTR / PTR2INT need to know about intptr_t. +# UINT2PTR / PTR2UINT need to know about uintptr_t. +#-------------------------------------------------------------------- + +AC_TYPE_INTPTR_T +#AC_TYPE_UINTPTR_T #-------------------------------------------------------------------- # Everyone should be linking against the Tcl stub library. If you # can't for some reason, remove this definition. If you aren't using # stubs, you also need to modify the SHLIB_LD_LIBS setting below to ADDED generic/intptr_t.h Index: generic/intptr_t.h ================================================================== --- /dev/null +++ generic/intptr_t.h @@ -0,0 +1,24 @@ +/* + * Macros used to cast between pointers and integers (e.g. when storing an int + * in ClientData), on 64-bit architectures they avoid gcc warning about "cast + * to/from pointer from/to integer of different size". + */ + +#if !defined(INT2PTR) && !defined(PTR2INT) +# if defined(HAVE_INTPTR_T) || defined(intptr_t) +# define INT2PTR(p) ((void *)(intptr_t)(p)) +# define PTR2INT(p) ((int)(intptr_t)(p)) +# else +# define INT2PTR(p) ((void *)(p)) +# define PTR2INT(p) ((int)(p)) +# endif +#endif +#if !defined(UINT2PTR) && !defined(PTR2UINT) +# if defined(HAVE_UINTPTR_T) || defined(uintptr_t) +# define UINT2PTR(p) ((void *)(uintptr_t)(p)) +# define PTR2UINT(p) ((unsigned int)(uintptr_t)(p)) +# else +# define UINT2PTR(p) ((void *)(p)) +# define PTR2UINT(p) ((unsigned int)(p)) +# endif +#endif Index: generic/odbcStubDefs.txt ================================================================== --- generic/odbcStubDefs.txt +++ generic/odbcStubDefs.txt @@ -10,11 +10,11 @@ # Accordingly, this file is in the public domain. # #----------------------------------------------------------------------------- * STUBSTRUCT: odbcStubs -* LIBRARY: odbc32 odbc libodbc32 libodbc +* LIBRARY: odbc32 odbc libodbc32 libodbc libiodbc * CONVENTION: SQL_API SQLRETURN SQLAllocHandle(SQLSMALLINT,SQLHANDLE,SQLHANDLE*); SQLRETURN SQLBindParameter(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLULEN,SQLSMALLINT,SQLPOINTER,SQLLEN,SQLLEN*); SQLRETURN SQLCloseCursor(SQLHSTMT); Index: generic/odbcStubInit.c ================================================================== --- generic/odbcStubInit.c +++ generic/odbcStubInit.c @@ -2,11 +2,11 @@ * odbcStubInit.c -- * * Stubs tables for the foreign ODBC libraries so that * Tcl extensions can use them without the linker's knowing about them. * - * @CREATED@ 2015-06-26 13:54:02Z by genExtStubs.tcl from ../generic/odbcStubDefs.txt + * @CREATED@ 2017-05-17 13:54:37Z by genExtStubs.tcl from ../generic/odbcStubDefs.txt * * Copyright (c) 2010 by Kevin B. Kenny. * * Please refer to the file, 'license.terms' for the conditions on * redistribution of this file and for a DISCLAIMER OF ALL WARRANTIES. @@ -29,16 +29,16 @@ * Names of the libraries that might contain the ODBC API */ static const char *const odbcStubLibNames[] = { /* @LIBNAMES@: DO NOT EDIT THESE NAMES */ - "odbc32", "odbc", "libodbc32", "libodbc", NULL + "odbc32", "odbc", "libodbc32", "libodbc", "libiodbc", NULL /* @END@ */ }; static const char *const odbcOptLibNames[] = { "odbccp", "odbccp32", "odbcinst", - "libodbccp", "libodbccp32", "libodbcinst", NULL + "libodbccp", "libodbccp32", "libodbcinst", "libiodbcinst", NULL }; /* * Names of the functions that we need from ODBC */ Index: generic/odbcStubs.h ================================================================== --- generic/odbcStubs.h +++ generic/odbcStubs.h @@ -1,21 +1,21 @@ /* *----------------------------------------------------------------------------- * - * ./generic/odbcStubs.h -- + * ../generic/odbcStubs.h -- * * Stubs for procedures in odbcStubDefs.txt * * Generated by genExtStubs.tcl: DO NOT EDIT - * 2015-06-26 13:54:02Z + * 2017-05-17 13:54:37Z * *----------------------------------------------------------------------------- */ typedef struct odbcStubDefs { - /* Functions from libraries: odbc32 odbc libodbc32 libodbc */ + /* Functions from libraries: odbc32 odbc libodbc32 libodbc libiodbc */ SQLRETURN (SQL_API*SQLAllocHandlePtr)(SQLSMALLINT,SQLHANDLE,SQLHANDLE*); SQLRETURN (SQL_API*SQLBindParameterPtr)(SQLHSTMT,SQLUSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLSMALLINT,SQLULEN,SQLSMALLINT,SQLPOINTER,SQLLEN,SQLLEN*); SQLRETURN (SQL_API*SQLCloseCursorPtr)(SQLHSTMT); SQLRETURN (SQL_API*SQLColumnsWPtr)(SQLHSTMT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT,SQLWCHAR*,SQLSMALLINT ,SQLWCHAR*,SQLSMALLINT ); Index: generic/tdbcodbc.c ================================================================== --- generic/tdbcodbc.c +++ generic/tdbcodbc.c @@ -29,10 +29,18 @@ #include #endif #include "fakesql.h" +/* + * PTR2INT/INT2PTR + */ +#if defined(HAVE_STDINT_H) && defined(HAVE_INTPTR_T) +# include +# include "intptr_t.h" +#endif + /* Static data contained in this file */ TCL_DECLARE_MUTEX(hEnvMutex); /* Mutex protecting the environment handle * and its reference count */ @@ -864,20 +872,22 @@ const char* sqlstate; /* SQL state */ Tcl_Obj* resultObj; /* Result string containing error message */ Tcl_Obj* codeObj; /* Error code object */ Tcl_Obj* lineObj; /* Object holding one diagnostic */ Tcl_DString bufferDS; /* Buffer for transferring messages */ + + SQLRETURN sqlreturn; resultObj = Tcl_NewObj(); codeObj = Tcl_NewStringObj("TDBC", -1); /* Loop through the diagnostics */ i = 1; - while (SQLGetDiagRecW(handleType, handle, i, state, &nativeError, - msg, SQL_MAX_MESSAGE_LENGTH, &msgLen) - != SQL_NO_DATA) { + while ((sqlreturn = SQLGetDiagRecW(handleType, handle, i, state, &nativeError, + msg, SQL_MAX_MESSAGE_LENGTH, &msgLen)) + != SQL_NO_DATA && sqlreturn >= 0) { /* Add the diagnostic to ::errorCode */ Tcl_DStringInit(&bufferDS); DStringAppendWChars(&bufferDS, state, 5); @@ -1322,13 +1332,13 @@ /* * Non-unique name - append a # and the number of times * we've seen it before. */ - count = (int) Tcl_GetHashValue(nameEntry); + count = PTR2INT(Tcl_GetHashValue(nameEntry)); ++count; - Tcl_SetHashValue(nameEntry, (ClientData) count); + Tcl_SetHashValue(nameEntry, /*(ClientData)*/ INT2PTR(count)); sprintf(numbuf, "#%d", count); Tcl_AppendToObj(colNameObj, numbuf, -1); } /* Add column name to the list of column names */ @@ -1685,11 +1695,11 @@ Tcl_AddErrorInfo(interp, "\n (retrieving ID of parent window)"); return status; } Tcl_ResetResult(interp); - *hParentWindowPtr = (HWND) w; + *hParentWindowPtr = (HWND) INT2PTR(w); *connectFlagsPtr = SQL_DRIVER_COMPLETE_REQUIRED; break; case COPTION_READONLY: /* read-only indicator */ @@ -2004,11 +2014,11 @@ Tcl_Interp* interp, /* Tcl interpreter */ Tcl_ObjectContext objectContext, /* Object context */ int objc, /* Parameter count */ Tcl_Obj *const objv[] /* Parameter vector */ ) { - SQLSMALLINT completionType = (SQLSMALLINT) (int) (clientData); + SQLSMALLINT completionType = (SQLSMALLINT) PTR2INT(clientData); Tcl_Object thisObject = Tcl_ObjectContextObject(objectContext); /* The current connection object */ ConnectionData* cdata = (ConnectionData*) Tcl_ObjectGetMetadata(thisObject, &connectionDataType); /* Instance data */ @@ -3957,11 +3967,11 @@ Tcl_ObjectContext context, /* Object context */ int objc, /* Parameter count */ Tcl_Obj *const objv[] /* Parameter vector */ ) { - int lists = (int) clientData; + int lists = PTR2INT(clientData); /* Flag == 1 if lists are to be returned, * 0 if dicts are to be returned */ Tcl_Object thisObject = Tcl_ObjectContextObject(context); /* The current result set object */ Index: tests/tdbcodbc.test ================================================================== --- tests/tdbcodbc.test +++ tests/tdbcodbc.test @@ -16,34 +16,34 @@ package require tdbc::odbc # Test setup. Figure out what sort of database we have. Default on Windows # is SQL Server Express, and on Unix is SQLite3 -if {![info exists env(TDBCODBC_TYPE)] || $env(TDBCODBC_TYPE) eq {default}} { +if {![info exists ::env(TDBCODBC_TEST_TYPE)] || $::env(TDBCODBC_TEST_TYPE) eq {default}} { set testdir [makeDirectory tdbctest] if {$tcl_platform(platform) eq {windows}} { - set env(TDBCODBC_TYPE) sqlserver + set ::env(TDBCODBC_TEST_TYPE) sqlserver } else { - set env(TDBCODBC_TYPE) sqlite + set ::env(TDBCODBC_TEST_TYPE) sqlite } } # Jet and SQL Server are Windows-only -if {$env(TDBCODBC_TYPE) in {jet sqlserver}} { +if {$::env(TDBCODBC_TEST_TYPE) in {jet sqlserver}} { if {$::tcl_platform(platform) ne {windows}} { - puts "$env(TDBCODBC_TYPE) testing is available on the\ + puts "$::env(TDBCODBC_TEST_TYPE) testing is available on the\ Windows platform only" removeDirectory tdbctest cleanupTests return } } # Configure the selected database -switch -exact -- $env(TDBCODBC_TYPE) { +switch -exact -- $::env(TDBCODBC_TEST_TYPE) { jet { # Begin by creating an empty .MDB file