diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | generic/tclIOSock.c | 2 | ||||
-rw-r--r-- | generic/tclStubInit.c | 6 | ||||
-rw-r--r-- | generic/tclTest.c | 59 | ||||
-rw-r--r-- | tests/platform.test | 10 | ||||
-rwxr-xr-x | unix/configure | 2 | ||||
-rw-r--r-- | unix/configure.in | 2 | ||||
-rw-r--r-- | unix/tclUnixCompat.c | 2 | ||||
-rw-r--r-- | unix/tclUnixFile.c | 8 | ||||
-rw-r--r-- | unix/tclUnixPort.h | 23 | ||||
-rw-r--r-- | win/tclWinTest.c | 80 |
11 files changed, 90 insertions, 107 deletions
@@ -3,6 +3,9 @@ * generic/configure.in: Better detection and implementation for cpuid * generic/configure: instruction on Intel-derived processors, both * generic/tclUnixCompat.c: 32-bit and 64-bit. + * generic/tclTest.c: Move cpuid testcase from win-specific to generic + * win/tclWinTest.c: tests, as it should work on all Intel-related + * tests/platform.test: platforms now 2012-04-30 Alexandre Ferrieux <ferrieux@users.sourceforge.net> diff --git a/generic/tclIOSock.c b/generic/tclIOSock.c index 7b7b647..538ca1d 100644 --- a/generic/tclIOSock.c +++ b/generic/tclIOSock.c @@ -87,7 +87,7 @@ TclSockGetPort( *---------------------------------------------------------------------- */ -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(__CYGWIN__) # define SOCKET size_t #endif diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c index 3483074..8864a56 100644 --- a/generic/tclStubInit.c +++ b/generic/tclStubInit.c @@ -54,12 +54,6 @@ static int TclSockMinimumBuffersOld(int sock, int size) #endif #ifdef __CYGWIN__ - -/* Trick, so we don't have to include <windows.h> here, which - * - b.t.w. - lacks this function anyway */ -#define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 0x00000004 -int __stdcall GetModuleHandleExW(unsigned int, const char *, void *); - #define TclWinGetPlatformId winGetPlatformId #define Tcl_WinUtfToTChar winUtfToTChar #define Tcl_WinTCharToUtf winTCharToUtf diff --git a/generic/tclTest.c b/generic/tclTest.c index 7631dee..b4c5bb9 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -419,6 +419,9 @@ static int TestNRELevels(ClientData clientData, static int TestInterpResolverCmd(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 const Tcl_Filesystem testReportingFilesystem = { "reporting", @@ -676,6 +679,8 @@ Tcltest_Init( NULL, NULL); Tcl_CreateCommand(interp, "testexitmainloop", TestexitmainloopCmd, 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, @@ -6648,6 +6653,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 diff --git a/tests/platform.test b/tests/platform.test index 8cb8dcd..92ca7ab 100644 --- a/tests/platform.test +++ b/tests/platform.test @@ -14,7 +14,7 @@ if {[lsearch [namespace children] ::tcltest] == -1} { namespace import -force ::tcltest::* } -testConstraint testWinCPUID [llength [info commands testwincpuid]] +testConstraint testCPUID [llength [info commands testcpuid]] test platform-1.1 {TclpSetVariables: tcl_platform} { interp create i @@ -36,12 +36,12 @@ test platform-2.1 {tcl_platform(wordSize) indicates size of native word} { list [expr {$result < 0}] [expr {$result ^ int($result - 1)}] } {1 -1} -# On Windows, test that the CPU ID works +# On Windows/UNIX, test that the CPU ID works -test platform-3.1 {CPU ID on Windows } \ - -constraints testWinCPUID \ +test platform-3.1 {CPU ID on Windows/UNIX} \ + -constraints testCPUID \ -body { - set cpudata [testwincpuid 0] + set cpudata [testcpuid 0] binary format iii \ [lindex $cpudata 1] \ [lindex $cpudata 3] \ diff --git a/unix/configure b/unix/configure index f763eeb..8f25c08 100755 --- a/unix/configure +++ b/unix/configure @@ -19366,7 +19366,7 @@ main () "mov %%ebx, %%esi \n\t" "mov %%edi, %%ebx \n\t" : "=a"(regsPtr[0]), "=S"(regsPtr[1]), "=c"(regsPtr[2]), "=d"(regsPtr[3]) - : "a"(index)); + : "a"(index) : "edi"); ; return 0; diff --git a/unix/configure.in b/unix/configure.in index ad82ee0..066a84f 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -761,7 +761,7 @@ AC_CACHE_CHECK([whether the cpuid instruction is usable], tcl_cv_cpuid, [ "mov %%ebx, %%esi \n\t" "mov %%edi, %%ebx \n\t" : "=a"(regsPtr[0]), "=S"(regsPtr[1]), "=c"(regsPtr[2]), "=d"(regsPtr[3]) - : "a"(index)); + : "a"(index) : "edi"); ], tcl_cv_cpuid=yes, tcl_cv_cpuid=no)]) if test $tcl_cv_cpuid = yes; then AC_DEFINE(HAVE_CPUID, 1, [Is the cpuid instruction usable?]) diff --git a/unix/tclUnixCompat.c b/unix/tclUnixCompat.c index 792d6da..3818121 100644 --- a/unix/tclUnixCompat.c +++ b/unix/tclUnixCompat.c @@ -996,7 +996,7 @@ TclWinCPUID( "mov %%ebx, %%esi \n\t" /* save what cpuid just put in %ebx */ "mov %%edi, %%ebx \n\t" /* restore the old %ebx */ : "=a"(regsPtr[0]), "=S"(regsPtr[1]), "=c"(regsPtr[2]), "=d"(regsPtr[3]) - : "a"(index)); + : "a"(index) : "edi"); status = TCL_OK; #endif return status; diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c index a4426b7..1c456a0 100644 --- a/unix/tclUnixFile.c +++ b/unix/tclUnixFile.c @@ -44,14 +44,6 @@ TclpFindExecutable( int length; char buf[PATH_MAX * TCL_UTF_MAX + 1]; char name[PATH_MAX * TCL_UTF_MAX + 1]; - - /* Make some symbols available without including <windows.h> */ -# define CP_UTF8 65001 - DLLIMPORT extern int cygwin_conv_to_full_posix_path(const char *, char *); - DLLIMPORT extern __stdcall int GetModuleFileNameW(void *, const char *, int); - DLLIMPORT extern __stdcall int WideCharToMultiByte(int, int, const char *, int, - const char *, int, const char *, const char *); - GetModuleFileNameW(NULL, name, PATH_MAX); WideCharToMultiByte(CP_UTF8, 0, name, -1, buf, PATH_MAX, NULL, NULL); cygwin_conv_to_full_posix_path(buf, name); diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h index 5bb61a2..fac9f75 100644 --- a/unix/tclUnixPort.h +++ b/unix/tclUnixPort.h @@ -79,12 +79,27 @@ typedef off_t Tcl_SeekOffset; #endif #ifdef __CYGWIN__ -# define WSAEWOULDBLOCK 10035 -# define HINSTANCE void * -# define HANDLE void * + + /* Make some symbols available without including <windows.h> */ # define DWORD unsigned int +# define CP_UTF8 65001 +# define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 0x00000004 +# define HANDLE void * +# define HINSTANCE void * # define SOCKET unsigned int -# typedef char TCHAR; +# define WSAEWOULDBLOCK 10035 + typedef char TCHAR; + typedef unsigned short WCHAR; + DLLIMPORT extern __stdcall int GetModuleHandleExW(unsigned int, const char *, void *); + DLLIMPORT extern __stdcall int GetModuleFileNameW(void *, const char *, int); + DLLIMPORT extern __stdcall int WideCharToMultiByte(int, int, const char *, int, + const char *, int, const char *, const char *); + DLLIMPORT extern __stdcall int MultiByteToWideChar(int, int, const char *, int, + WCHAR *, int); + DLLIMPORT extern __stdcall void OutputDebugStringW(const WCHAR *); + DLLIMPORT extern __stdcall int IsDebuggerPresent(); + + DLLIMPORT extern int cygwin_conv_to_full_posix_path(const char *, char *); # define USE_PUTENV 1 # define USE_PUTENV_FOR_UNSET 1 /* On Cygwin, the environment is imported from the Cygwin DLL. */ diff --git a/win/tclWinTest.c b/win/tclWinTest.c index 392e830..136c4db 100644 --- a/win/tclWinTest.c +++ b/win/tclWinTest.c @@ -42,8 +42,6 @@ static int TestwinclockCmd(ClientData dummy, Tcl_Interp* interp, static int TestwinsleepCmd(ClientData dummy, Tcl_Interp* interp, int objc, Tcl_Obj *const objv[]); static Tcl_ObjCmdProc TestExceptionCmd; -static int TestwincpuidCmd(ClientData dummy, Tcl_Interp* interp, - int objc, Tcl_Obj *const objv[]); static int TestplatformChmod(const char *nativePath, int pmode); static int TestchmodCmd(ClientData dummy, Tcl_Interp *interp, int argc, const char **argv); @@ -78,7 +76,6 @@ TclplatformtestInit( Tcl_CreateObjCommand(interp, "testvolumetype", TestvolumetypeCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "testwinclock", TestwinclockCmd, NULL, NULL); - Tcl_CreateObjCommand(interp, "testwincpuid", TestwincpuidCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "testwinsleep", TestwinsleepCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "testexcept", TestExceptionCmd, NULL, NULL); return TCL_OK; @@ -294,83 +291,6 @@ TestwinclockCmd( return TCL_OK; } -/* - *---------------------------------------------------------------------- - * - * TestwincpuidCmd -- - * - * 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 -TestwincpuidCmd( - 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; -} - -/* - *---------------------------------------------------------------------- - * - * TestwinsleepCmd -- - * - * Causes this process to wait for the given number of milliseconds by - * means of a direct call to Sleep. - * - * Usage: - * testwinsleep <n> - * - * Parameters: - * n - the number of milliseconds to sleep - * - * Results: - * None. - * - * Side effects: - * Sleeps for the requisite number of milliseconds. - * - *---------------------------------------------------------------------- - */ - static int TestwinsleepCmd( ClientData clientData, /* Unused */ |