diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2025-01-08 08:36:24 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2025-01-08 08:36:24 (GMT) |
| commit | 89d6a3c475ee7d737c93b44db8a6bf151eb44e1e (patch) | |
| tree | 8dbcad88b9f73b4f3bf03decf3a07ac5d43bcb09 | |
| parent | 3de5fedc12ca776c782e63c096e0dc550ef5add9 (diff) | |
| download | tcl-89d6a3c475ee7d737c93b44db8a6bf151eb44e1e.zip tcl-89d6a3c475ee7d737c93b44db8a6bf151eb44e1e.tar.gz tcl-89d6a3c475ee7d737c93b44db8a6bf151eb44e1e.tar.bz2 | |
(cherry-pick): Simplification for [d58e315172]
| -rw-r--r-- | generic/tclBasic.c | 14 | ||||
| -rwxr-xr-x | win/configure | 32 | ||||
| -rw-r--r-- | win/configure.ac | 27 | ||||
| -rw-r--r-- | win/tclWin32Dll.c | 129 | ||||
| -rw-r--r-- | win/tclWinConsole.c | 2 | ||||
| -rw-r--r-- | win/tclWinPipe.c | 14 | ||||
| -rw-r--r-- | win/tclWinPort.h | 2 | ||||
| -rw-r--r-- | win/tclWinReg.c | 14 | ||||
| -rw-r--r-- | win/tclWinSerial.c | 2 | ||||
| -rw-r--r-- | win/tclWinSock.c | 4 | ||||
| -rw-r--r-- | win/tclWinTime.c | 22 |
11 files changed, 66 insertions, 196 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c index be7896a..4f91e99 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 <intrin.h> /* 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; @@ -8737,11 +8737,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; @@ -8854,7 +8854,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/win/configure b/win/configure index b5c9ffe..abe2c89 100755 --- a/win/configure +++ b/win/configure @@ -5391,50 +5391,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 <cpuid.h> - #endif +#include <cpuid.h> 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 <wspiapi.h> header file is present diff --git a/win/configure.ac b/win/configure.ac index ad0db6f..62e282c 100644 --- a/win/configure.ac +++ b/win/configure.ac @@ -272,24 +272,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 <cpuid.h> - #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 <cpuid.h> +]], [[ + __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 <wspiapi.h> header file is present diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c index aa420bb..feb44a9 100644 --- a/win/tclWin32Dll.c +++ b/win/tclWin32Dll.c @@ -14,7 +14,7 @@ #include "tclWinInt.h" #if defined(HAVE_CPUID_H) # include <cpuid.h> -#elif defined(HAVE_INTRIN_H) +#elif defined(_MSC_VER) # include <intrin.h> #endif @@ -515,134 +515,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. */ @@ -689,7 +567,6 @@ TclWinCPUID( /* do nothing */ } -# endif #else (void)index; (void)regsPtr; diff --git a/win/tclWinConsole.c b/win/tclWinConsole.c index 71d1f79..dad65f1 100644 --- a/win/tclWinConsole.c +++ b/win/tclWinConsole.c @@ -176,7 +176,7 @@ typedef struct ConsoleHandleInfo { * is queued and dropped on receipt. */ typedef struct ConsoleChannelInfo { - HANDLE handle; /* Console handle */ + HANDLE handle; /* Console handle */ Tcl_ThreadId threadId; /* Id of owning thread */ struct ConsoleChannelInfo *nextWatchingChannelPtr; /* Pointer to next channel watching events. */ diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index 19199de..1c8d9ee 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -1458,7 +1458,7 @@ QuoteCmdLineBackslash( Tcl_DStringAppend(dsPtr, start, (int) (current - start)); } } else { - if (bspos > start) { /* part before first backslash */ + if (bspos > start) { /* part before first backslash */ Tcl_DStringAppend(dsPtr, start, (int) (bspos - start)); } while (bspos++ < current) { /* each backslash twice */ @@ -1501,7 +1501,7 @@ QuoteCmdLinePart( TclDStringAppendLiteral(dsPtr, "\""); /* opening escape quote-char */ do { - *bspos = NULL; + *bspos = NULL; special++; if (*special == '\\') { /* @@ -1806,7 +1806,7 @@ TclpCreateCommandChannel( SetThreadPriority(infoPtr->readThread, THREAD_PRIORITY_HIGHEST); infoPtr->validMask |= TCL_READABLE; } else { - infoPtr->readTI = NULL; + infoPtr->readTI = NULL; infoPtr->readThread = 0; } if (writeFile != NULL) { @@ -1821,8 +1821,8 @@ TclpCreateCommandChannel( SetThreadPriority(infoPtr->writeThread, THREAD_PRIORITY_HIGHEST); infoPtr->validMask |= TCL_WRITABLE; } else { - infoPtr->writeTI = NULL; - infoPtr->writeThread = 0; + infoPtr->writeTI = NULL; + infoPtr->writeThread = 0; } /* @@ -3398,10 +3398,10 @@ TclPipeThreadWaitForSignal( if (state != PTI_STATE_STOP) { *pipeTIPtr = NULL; } else { - pipeTI->evWakeUp = NULL; + pipeTI->evWakeUp = NULL; } if (wakeEvent) { - SetEvent(wakeEvent); + SetEvent(wakeEvent); } return 0; } diff --git a/win/tclWinPort.h b/win/tclWinPort.h index ccb2acc..511dbe5 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -114,7 +114,7 @@ typedef DWORD_PTR * PDWORD_PTR; */ #ifndef ENOTEMPTY -# define ENOTEMPTY 41 /* Directory not empty */ +# define ENOTEMPTY 41 /* Directory not empty */ #endif #ifndef EREMOTE # define EREMOTE 66 /* The object is remote */ diff --git a/win/tclWinReg.c b/win/tclWinReg.c index 1034392..59de335 100644 --- a/win/tclWinReg.c +++ b/win/tclWinReg.c @@ -1208,7 +1208,11 @@ RecursiveDeleteKey( HKEY hKey; REGSAM saveMode = mode; static int checkExProc = 0; - static LONG (* regDeleteKeyExProc) (HKEY, LPCWSTR, REGSAM, DWORD) = (LONG (*) (HKEY, LPCWSTR, REGSAM, DWORD)) NULL; + typedef LONG (* regDeleteKeyExProc) (HKEY, LPCWSTR, REGSAM, DWORD); + static regDeleteKeyExProc regDeleteKeyEx = (regDeleteKeyExProc) NULL; + /* Really RegDeleteKeyExW() but that's not + * available on all versions of Windows + * supported by Tcl. */ /* * Do not allow NULL or empty key name. @@ -1248,11 +1252,11 @@ RecursiveDeleteKey( checkExProc = 1; handle = GetModuleHandleW(L"ADVAPI32"); - regDeleteKeyExProc = (LONG (*) (HKEY, LPCWSTR, REGSAM, DWORD)) - (void *)GetProcAddress(handle, "RegDeleteKeyExW"); + regDeleteKeyEx = (regDeleteKeyExProc) (void *) + GetProcAddress(handle, "RegDeleteKeyExW"); } - if (mode && regDeleteKeyExProc) { - result = regDeleteKeyExProc(startKey, keyName, mode, 0); + if (mode && regDeleteKeyEx) { + result = regDeleteKeyEx(startKey, keyName, mode, 0); } else { result = RegDeleteKeyW(startKey, keyName); } diff --git a/win/tclWinSerial.c b/win/tclWinSerial.c index 635e978..2bd4c83 100644 --- a/win/tclWinSerial.c +++ b/win/tclWinSerial.c @@ -621,7 +621,7 @@ SerialCloseProc( serialPtr->validMask &= ~TCL_READABLE; if (serialPtr->writeThread) { - TclPipeThreadStop(&serialPtr->writeTI, serialPtr->writeThread); + TclPipeThreadStop(&serialPtr->writeTI, serialPtr->writeThread); CloseHandle(serialPtr->osWrite.hEvent); CloseHandle(serialPtr->evWritable); diff --git a/win/tclWinSock.c b/win/tclWinSock.c index f783b1b..58d742e 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -621,8 +621,8 @@ TcpBlockModeProc( * 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 diff --git a/win/tclWinTime.c b/win/tclWinTime.c index 1f1f948..7aca496 100644 --- a/win/tclWinTime.c +++ b/win/tclWinTime.c @@ -60,7 +60,7 @@ typedef struct { HANDLE readyEvent; /* System event used to trigger the requesting * thread when the clock calibration procedure * is initialized for the first time. */ - HANDLE exitEvent; /* Event to signal out of an exit handler to + HANDLE exitEvent; /* Event to signal out of an exit handler to * tell the calibration loop to terminate. */ LARGE_INTEGER nominalFreq; /* Nominal frequency of the system performance * counter, that is, the value returned from @@ -138,7 +138,7 @@ static struct tm * ComputeGMT(const time_t *tp); #endif /* TCL_NO_DEPRECATED */ static void StopCalibration(void *clientData); static DWORD WINAPI CalibrationThread(LPVOID arg); -static void UpdateTimeEachSecond(void); +static void UpdateTimeEachSecond(void); static void ResetCounterSamples(unsigned long long fileTime, long long perfCounter, long long perfFreq); static long long AccumulateSample(long long perfCounter, @@ -306,7 +306,7 @@ TclpGetWideClicks(void) wideClick.microsecsScale = 1; return TclpGetMicroseconds(); } else { - return TclpGetMicroseconds(); + return TclpGetMicroseconds(); } } @@ -320,7 +320,7 @@ TclpGetWideClicks(void) * and back. * * Results: - * 1 click in microseconds as double. + * 1 click in microseconds as double. * * Side effects: * None. @@ -332,7 +332,7 @@ double TclpWideClickInMicrosec(void) { if (!wideClick.initialized) { - (void) TclpGetWideClicks(); /* initialize */ + (void)TclpGetWideClicks(); /* initialize */ } return wideClick.microsecsScale; } @@ -1118,7 +1118,7 @@ UpdateTimeEachSecond(void) if (curFileTime.QuadPart > lastFileTime.QuadPart && curFileTime.QuadPart < lastFileTime.QuadPart + (timeInfo.calibrationInterv * 10000000)) { - /* + /* * Look again in next one second. */ @@ -1188,13 +1188,13 @@ UpdateTimeEachSecond(void) tdiff = vt0 - curFileTime.QuadPart; if (tdiff > 10000000 || tdiff < -10000000) { - /* + /* * Jump to current system time, use curent estimated frequency. */ - vt0 = curFileTime.QuadPart; + vt0 = curFileTime.QuadPart; } else { - /* + /* * Calculate new frequency and estimate drift to the next second. */ @@ -1262,11 +1262,11 @@ UpdateTimeEachSecond(void) vt1 = vt0 - curFileTime.QuadPart; if (vt1 > 10000000 || vt1 < -10000000) { - /* + /* * Larger jump resp. shift relative new file-time. */ - vt0 = curFileTime.QuadPart; + vt0 = curFileTime.QuadPart; } } } |
