From c96fff9fc1d126e5cc439f2f5ea79f3714f46f07 Mon Sep 17 00:00:00 2001 From: sebres Date: Sat, 28 Dec 2024 13:58:53 +0000 Subject: [PATCH 1/2] amend to [98006f00ac471be5]: fixes MSVC build (values of FP_* are compiler/implementation specific, e. g. for MSVC FP_NORMAL is equal -1) --- generic/tclBasic.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/generic/tclBasic.c b/generic/tclBasic.c index c06aac85ae6..a3fe901ae6b 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -8719,32 +8719,34 @@ ClassifyDouble( #endif /* !fpclassify */ } -#define FP_CLS_ERROR -1 static inline int DoubleObjClass( Tcl_Interp *interp, - Tcl_Obj *objPtr) /* Object with double to get its class. */ + Tcl_Obj *objPtr, /* Object with double to get its class. */ + int *fpClsPtr) /* FP class retrieved for double in object. */ { double d; void *ptr; int type; if (Tcl_GetNumberFromObj(interp, objPtr, &ptr, &type) != TCL_OK) { - return FP_CLS_ERROR; + return TCL_ERROR; } switch (type) { case TCL_NUMBER_NAN: - return FP_NAN; + *fpClsPtr = FP_NAN; + return TCL_OK; case TCL_NUMBER_DOUBLE: d = *((const double *) ptr); break; default: if (Tcl_GetDoubleFromObj(interp, objPtr, &d) != TCL_OK) { - return FP_CLS_ERROR; + return TCL_ERROR; } break; } - return ClassifyDouble(d); + *fpClsPtr = ClassifyDouble(d); + return TCL_OK; } static inline int DoubleObjIsClass( @@ -8761,8 +8763,7 @@ DoubleObjIsClass( return TCL_ERROR; } - dCls = DoubleObjClass(interp, objv[1]); - if (dCls == FP_CLS_ERROR) { + if (DoubleObjClass(interp, objv[1], &dCls) != TCL_OK) { return TCL_ERROR; } dCls = ( @@ -8844,9 +8845,10 @@ ExprIsUnorderedFunc( return TCL_ERROR; } - dCls = DoubleObjClass(interp, objv[1]); - dCls2 = DoubleObjClass(interp, objv[2]); - if (dCls == FP_CLS_ERROR || dCls2 == FP_CLS_ERROR) { + if ( + DoubleObjClass(interp, objv[1], &dCls) != TCL_OK || + DoubleObjClass(interp, objv[2], &dCls2) != TCL_OK + ) { return TCL_ERROR; } From 477921f598c4b28d43faafe2bd478d358fc9051c Mon Sep 17 00:00:00 2001 From: sebres Date: Sat, 28 Dec 2024 14:00:58 +0000 Subject: [PATCH 2/2] small speed-up for FP classification of int (simple cast wide to double) --- generic/tclBasic.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/generic/tclBasic.c b/generic/tclBasic.c index a3fe901ae6b..b8bd6ca7352 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -8739,6 +8739,9 @@ DoubleObjClass( case TCL_NUMBER_DOUBLE: d = *((const double *) ptr); break; + case TCL_NUMBER_INT: + d = (double)*((const Tcl_WideInt *) ptr); + break; default: if (Tcl_GetDoubleFromObj(interp, objPtr, &d) != TCL_OK) { return TCL_ERROR;