summaryrefslogtreecommitdiffstats
path: root/generic/tclTest.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-05-03 12:31:19 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-05-03 12:31:19 (GMT)
commitb9ecc426358d3737357f0460caee4eae5be61a3a (patch)
tree1af98744597d706e888e17d56f9a96c61450f14d /generic/tclTest.c
parent0d066cf5f9286f6ecb836a4c131cdd3d70b76734 (diff)
parentf2d051b8afa1a1d9acf943607988e4c911ed2d3c (diff)
downloadtcl-b9ecc426358d3737357f0460caee4eae5be61a3a.zip
tcl-b9ecc426358d3737357f0460caee4eae5be61a3a.tar.gz
tcl-b9ecc426358d3737357f0460caee4eae5be61a3a.tar.bz2
Move cpuid testcase from win-specific to generic tests
Diffstat (limited to 'generic/tclTest.c')
-rw-r--r--generic/tclTest.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/generic/tclTest.c b/generic/tclTest.c
index 57c17e3..4a9f85f 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -444,6 +444,9 @@ static int TestNumUtfCharsCmd(ClientData clientData,
static int TestHashSystemHashCmd(ClientData clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const objv[]);
+static int TestcpuidCmd (ClientData dummy,
+ Tcl_Interp* interp, int objc,
+ Tcl_Obj *CONST objv[]);
static Tcl_Filesystem testReportingFilesystem = {
"reporting",
@@ -707,6 +710,8 @@ Tcltest_Init(
(ClientData) NULL, NULL);
Tcl_CreateCommand(interp, "testexitmainloop", TestexitmainloopCmd,
(ClientData) NULL, NULL);
+ Tcl_CreateObjCommand(interp, "testcpuid", TestcpuidCmd,
+ (ClientData) 0, NULL);
t3ArgTypes[0] = TCL_EITHER;
t3ArgTypes[1] = TCL_EITHER;
Tcl_CreateMathFunc(interp, "T3", 2, t3ArgTypes, TestMathFunc2,
@@ -7103,6 +7108,60 @@ TestNumUtfCharsCmd(
}
return TCL_OK;
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TestcpuidCmd --
+ *
+ * Retrieves CPU ID information.
+ *
+ * Usage:
+ * testwincpuid <eax>
+ *
+ * Parameters:
+ * eax - The value to pass in the EAX register to a CPUID instruction.
+ *
+ * Results:
+ * Returns a four-element list containing the values from the EAX, EBX,
+ * ECX and EDX registers returned from the CPUID instruction.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+TestcpuidCmd(
+ ClientData dummy,
+ Tcl_Interp* interp, /* Tcl interpreter */
+ int objc, /* Parameter count */
+ Tcl_Obj *const * objv) /* Parameter vector */
+{
+ int status, index, i;
+ unsigned int regs[4];
+ Tcl_Obj *regsObjs[4];
+
+ if (objc != 2) {
+ Tcl_WrongNumArgs(interp, 1, objv, "eax");
+ return TCL_ERROR;
+ }
+ if (Tcl_GetIntFromObj(interp, objv[1], &index) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ status = TclWinCPUID((unsigned) index, regs);
+ if (status != TCL_OK) {
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj("operation not available", -1));
+ return status;
+ }
+ for (i=0 ; i<4 ; ++i) {
+ regsObjs[i] = Tcl_NewIntObj((int) regs[i]);
+ }
+ Tcl_SetObjResult(interp, Tcl_NewListObj(4, regsObjs));
+ return TCL_OK;
+}
/*
* Used to do basic checks of the TCL_HASH_KEY_SYSTEM_HASH flag