Skip to content

Commit

Permalink
Simplification for [d58e315172]
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Jan 7, 2025
2 parents 380ef99 + a0a8e2f commit 1235d67
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 175 deletions.
6 changes: 3 additions & 3 deletions generic/tclArithSeries.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ ArithSeriesIndexDbl(
if (index) {
d += (index * dblRepPtr->step);
}

return ArithRound(d, dblRepPtr->precision);
}

Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions generic/tclBasic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion generic/tclCmdIL.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion generic/tclStubLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion generic/tclZipfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
32 changes: 13 additions & 19 deletions win/configure
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cpuid.h>
#endif
#include <cpuid.h>
int
main (void)
{
unsigned int regs;
__get_cpuid(0, &regs, &regs, &regs, &regs);
__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
Expand Down
27 changes: 11 additions & 16 deletions win/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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 <cpuid.h>
#endif
]], [[
unsigned int regs;
__get_cpuid(0, &regs, &regs, &regs, &regs);
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
Expand Down
129 changes: 3 additions & 126 deletions win/tclWin32Dll.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -445,134 +445,12 @@ TclWinCPUID(
__get_cpuid(index, &regs[0], &regs[1], &regs[2], &regs[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.
*/
Expand Down Expand Up @@ -619,7 +497,6 @@ TclWinCPUID(
/* do nothing */
}

# endif
#else
(void)index;
(void)regsPtr;
Expand Down
2 changes: 1 addition & 1 deletion win/tclWinReg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1235d67

Please sign in to comment.