diff --git a/generic/tclArithSeries.c b/generic/tclArithSeries.c index d05d07fd0f3..92cf611549a 100755 --- a/generic/tclArithSeries.c +++ b/generic/tclArithSeries.c @@ -193,7 +193,7 @@ ArithSeriesIndexDbl( if (index) { d += (index * dblRepPtr->step); } - + return ArithRound(d, dblRepPtr->precision); } @@ -334,7 +334,7 @@ ArithSeriesLenDbl( } /* distance */ end -= start; - /* + /* * To improve numerical stability use wide arithmetic instead of IEEE-754 * when distance and step do not exceed wide-integers. */ @@ -1086,7 +1086,7 @@ TclArithSeriesObjReverse( -dblRepPtr->step, arithSeriesRepPtr->len, dblRepPtr->precision); } else { ArithSeriesInt *intRepPtr = (ArithSeriesInt *)arithSeriesRepPtr; - resultObj = NewArithSeriesInt(ArithSeriesEndInt(intRepPtr), + resultObj = NewArithSeriesInt(ArithSeriesEndInt(intRepPtr), -intRepPtr->step, arithSeriesRepPtr->len); } } else { diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 622651af9fb..3b757bb72b5 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -68,7 +68,7 @@ * compatible with AddressSanitizer (ASan) use-after-return detection. */ -#if defined(_MSC_VER) && defined(HAVE_INTRIN_H) +#if defined(_MSC_VER) #include /* for _AddressOfReturnAddress() */ #endif @@ -85,7 +85,7 @@ TclGetCStackPtr(void) { #if defined( __GNUC__ ) || __has_builtin(__builtin_frame_address) return __builtin_frame_address(0); -#elif defined(_MSC_VER) && defined(HAVE_INTRIN_H) +#elif defined(_MSC_VER) return _AddressOfReturnAddress(); #else ptrdiff_t unused = 0; @@ -8068,11 +8068,11 @@ DoubleObjClass( *fpClsPtr = FP_NAN; return TCL_OK; case TCL_NUMBER_DOUBLE: - d = *((const double *) ptr); - break; + d = *((const double *) ptr); + break; case TCL_NUMBER_INT: - d = (double)*((const Tcl_WideInt *) ptr); - break; + d = (double)*((const Tcl_WideInt *) ptr); + break; default: if (Tcl_GetDoubleFromObj(interp, objPtr, &d) != TCL_OK) { return TCL_ERROR; @@ -8185,7 +8185,7 @@ ExprIsUnorderedFunc( ) { return TCL_ERROR; } - + dCls = ((dCls == FP_NAN) || (dCls2 == FP_NAN)) ? 1 : 0; Tcl_SetObjResult(interp, ((Interp *)interp)->execEnvPtr->constants[dCls]); return TCL_OK; diff --git a/generic/tclCmdIL.c b/generic/tclCmdIL.c index f194ff602ea..b3d5fe96805 100644 --- a/generic/tclCmdIL.c +++ b/generic/tclCmdIL.c @@ -3927,7 +3927,7 @@ Tcl_LsearchObjCmd( &sortInfo); Tcl_ListObjAppendElement(interp, listPtr, itemPtr); } else if (returnSubindices && (sortInfo.indexc == 0) && (groupSize > 1)) { - Tcl_BounceRefCount(itemPtr); + Tcl_BounceRefCount(itemPtr); itemPtr = listv[i + groupOffset]; Tcl_ListObjAppendElement(interp, listPtr, itemPtr); } else if (groupSize > 1) { diff --git a/generic/tclStubLib.c b/generic/tclStubLib.c index 1da7e0848f1..bc14820cd18 100644 --- a/generic/tclStubLib.c +++ b/generic/tclStubLib.c @@ -89,7 +89,7 @@ Tcl_InitStubs( char major[4], minor[4]; snprintf(major, sizeof(major), "%d", (exact & 0xFF00)>>8); snprintf(minor, sizeof(minor), "%d", (exact & 0xFF0000)>>16); - stubsPtr->tcl_AppendResult(interp, + stubsPtr->tcl_AppendResult(interp, "this extension is compiled for Tcl ", major, ".", minor, (char *)NULL); } else { iPtr->legacyResult = "interpreter uses an incompatible stubs mechanism"; diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index 6ad8f52533a..b59a091bd28 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -3847,7 +3847,7 @@ SerializeCentralDirectoryEntry( unsigned char *buf, /* Where to serialize to */ ZipEntry *z, /* The description of what to serialize. */ size_t nameLength, /* The length of the name. */ - long long dataStartOffset) /* The overall file offset of the start of the + long long dataStartOffset) /* The overall file offset of the start of the * data section of the file. */ { ZipWriteInt(start, end, buf + ZIP_CENTRAL_SIG_OFFS, diff --git a/win/configure b/win/configure index 801ff648117..10b63648e09 100755 --- a/win/configure +++ b/win/configure @@ -5361,50 +5361,44 @@ fi # See if the compiler supports cpuid header. -if test "${GCC}" = "yes" ; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for cpuid-header support in compiler" >&5 -printf %s "checking for cpuid-header support in compiler... " >&6; } -if test ${tcl_cv_cpuidhead+y} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for cpuid.h" >&5 +printf %s "checking for cpuid.h... " >&6; } +if test ${tcl_cv_cpuid_h+y} then : printf %s "(cached) " >&6 else case e in #( e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)))) - # include - #endif +#include int main (void) { - unsigned int regs; - __get_cpuid(0, ®s, ®s, ®s, ®s); + __get_cpuid(0, 0, 0, 0, 0); ; return 0; } _ACEOF -if ac_fn_c_try_link "$LINENO" +if ac_fn_c_try_compile "$LINENO" then : - tcl_cv_cpuidhead=yes + tcl_cv_cpuid_h=yes else case e in #( - e) tcl_cv_cpuidhead=no ;; + e) tcl_cv_cpuid_h=no ;; esac fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext - ;; +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + ;; esac fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cpuidhead" >&5 -printf "%s\n" "$tcl_cv_cpuidhead" >&6; } - if test "$tcl_cv_cpuidhead" = "yes"; then +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cpuid_h" >&5 +printf "%s\n" "$tcl_cv_cpuid_h" >&6; } +if test "$tcl_cv_cpuid_h" = "yes"; then printf "%s\n" "#define HAVE_CPUID_H 1" >>confdefs.h - fi fi # See if the header file is present diff --git a/win/configure.ac b/win/configure.ac index 630d204d8a2..b7ede2076f6 100644 --- a/win/configure.ac +++ b/win/configure.ac @@ -257,24 +257,19 @@ fi # See if the compiler supports cpuid header. -if test "${GCC}" = "yes" ; then - AC_CACHE_CHECK(for cpuid-header support in compiler, - tcl_cv_cpuidhead, - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - #if defined (__clang__) || ((__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)))) - # include - #endif - ]], [[ - unsigned int regs; - __get_cpuid(0, ®s, ®s, ®s, ®s); +AC_CACHE_CHECK(for cpuid.h, + tcl_cv_cpuid_h, +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +]], [[ + __get_cpuid(0, 0, 0, 0, 0); ]])], - [tcl_cv_cpuidhead=yes], - [tcl_cv_cpuidhead=no]) - ) - if test "$tcl_cv_cpuidhead" = "yes"; then + [tcl_cv_cpuid_h=yes], + [tcl_cv_cpuid_h=no]) +) +if test "$tcl_cv_cpuid_h" = "yes"; then AC_DEFINE(HAVE_CPUID_H, 1, - [Defined when the compilers supports cpuid header]) - fi + [Defined when cpuid.h exists]) fi # See if the header file is present diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index 12dfab9c3d8..3b7bbea3ae0 100644 --- a/win/tclWin32Dll.c +++ b/win/tclWin32Dll.c @@ -14,7 +14,7 @@ #include "tclWinInt.h" #if defined(HAVE_CPUID_H) # include -#elif defined(HAVE_INTRIN_H) +#elif defined(_MSC_VER) # include #endif @@ -445,134 +445,12 @@ TclWinCPUID( __get_cpuid(index, ®s[0], ®s[1], ®s[2], ®s[3]); status = TCL_OK; -#elif defined(HAVE_INTRIN_H) && defined(_WIN64) && defined(HAVE_CPUID) +#elif defined(_MSC_VER) && defined(_WIN64) && defined(HAVE_CPUID) __cpuid((int *)regsPtr, index); status = TCL_OK; -#elif defined(__GNUC__) && defined(HAVE_CPUID) -# if defined(_WIN64) - /* - * Execute the CPUID instruction with the given index, and store results - * off 'regPtr'. - */ - - __asm__ __volatile__( - /* - * Do the CPUID instruction, and save the results in the 'regsPtr' - * area. - */ - - "movl %[rptr], %%edi" "\n\t" - "movl %[index], %%eax" "\n\t" - "cpuid" "\n\t" - "movl %%eax, 0x0(%%edi)" "\n\t" - "movl %%ebx, 0x4(%%edi)" "\n\t" - "movl %%ecx, 0x8(%%edi)" "\n\t" - "movl %%edx, 0xC(%%edi)" "\n\t" - - : - /* No outputs */ - : - [index] "m" (index), - [rptr] "m" (regsPtr) - : - "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory"); - status = TCL_OK; - -# else - - TCLEXCEPTION_REGISTRATION registration; - - /* - * Execute the CPUID instruction with the given index, and store results - * off 'regPtr'. - */ - - __asm__ __volatile__( - /* - * Construct an TCLEXCEPTION_REGISTRATION to protect the CPUID - * instruction (early 486's don't have CPUID) - */ - - "leal %[registration], %%edx" "\n\t" - "movl %%fs:0, %%eax" "\n\t" - "movl %%eax, 0x0(%%edx)" "\n\t" /* link */ - "leal 1f, %%eax" "\n\t" - "movl %%eax, 0x4(%%edx)" "\n\t" /* handler */ - "movl %%ebp, 0x8(%%edx)" "\n\t" /* ebp */ - "movl %%esp, 0xC(%%edx)" "\n\t" /* esp */ - "movl %[error], 0x10(%%edx)" "\n\t" /* status */ - - /* - * Link the TCLEXCEPTION_REGISTRATION on the chain - */ - - "movl %%edx, %%fs:0" "\n\t" - - /* - * Do the CPUID instruction, and save the results in the 'regsPtr' - * area. - */ - - "movl %[rptr], %%edi" "\n\t" - "movl %[index], %%eax" "\n\t" - "cpuid" "\n\t" - "movl %%eax, 0x0(%%edi)" "\n\t" - "movl %%ebx, 0x4(%%edi)" "\n\t" - "movl %%ecx, 0x8(%%edi)" "\n\t" - "movl %%edx, 0xC(%%edi)" "\n\t" - - /* - * Come here on a normal exit. Recover the TCLEXCEPTION_REGISTRATION and - * store a TCL_OK status. - */ - - "movl %%fs:0, %%edx" "\n\t" - "movl %[ok], %%eax" "\n\t" - "movl %%eax, 0x10(%%edx)" "\n\t" - "jmp 2f" "\n" - - /* - * Come here on an exception. Get the TCLEXCEPTION_REGISTRATION that we - * previously put on the chain. - */ - - "1:" "\t" - "movl %%fs:0, %%edx" "\n\t" - "movl 0x8(%%edx), %%edx" "\n\t" - - /* - * Come here however we exited. Restore context from the - * TCLEXCEPTION_REGISTRATION in case the stack is unbalanced. - */ - - "2:" "\t" - "movl 0xC(%%edx), %%esp" "\n\t" - "movl 0x8(%%edx), %%ebp" "\n\t" - "movl 0x0(%%edx), %%eax" "\n\t" - "movl %%eax, %%fs:0" "\n\t" - - : - /* No outputs */ - : - [index] "m" (index), - [rptr] "m" (regsPtr), - [registration] "m" (registration), - [ok] "i" (TCL_OK), - [error] "i" (TCL_ERROR) - : - "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory"); - status = registration.status; - -# endif /* !_WIN64 */ -#elif defined(_MSC_VER) && defined(HAVE_CPUID) -# if defined(_WIN64) - - __cpuid(regsPtr, index); - status = TCL_OK; - -# elif defined (_M_IX86) +#elif defined (_M_IX86) /* * Define a structure in the stack frame to hold the registers. */ @@ -619,7 +497,6 @@ TclWinCPUID( /* do nothing */ } -# endif #else (void)index; (void)regsPtr; diff --git a/win/tclWinReg.c b/win/tclWinReg.c index ee0c2df309c..59de335d569 100644 --- a/win/tclWinReg.c +++ b/win/tclWinReg.c @@ -1208,7 +1208,7 @@ RecursiveDeleteKey( HKEY hKey; REGSAM saveMode = mode; static int checkExProc = 0; - typedef LONG (* regDeleteKeyExProc) (HKEY, LPCWSTR, REGSAM, DWORD); + typedef LONG (* regDeleteKeyExProc) (HKEY, LPCWSTR, REGSAM, DWORD); static regDeleteKeyExProc regDeleteKeyEx = (regDeleteKeyExProc) NULL; /* Really RegDeleteKeyExW() but that's not * available on all versions of Windows