CPUID: Clear ECX register to ensure it will work with EAX=7

Tested on linux only
Add nativeJcpuidVersion()
Only call getCPUVendorID() once in getInfo()
Change all @since to 0.9.25 in hopes it will come true
Tab removal
Javadoc tweaks
This commit is contained in:
zzz
2015-12-16 15:02:03 +00:00
parent 1f4a266c22
commit 1e3e02d1f0
7 changed files with 75 additions and 43 deletions

View File

@@ -1,5 +1,27 @@
#include "jcpuid.h"
/*
* Versions:
*
* 1: Original version
*
* 2: (I2P 0.8.7)
* Add PIC-compatibility
*
* 3: (I2P 0.9.25)
* Added:
* nativeJcpuidVersion()
* Set ECX to 0 to support function 7
*
*/
#define JCPUID_VERSION 3
/* since version 3 */
JNIEXPORT jint JNICALL Java_net_i2p_util_NativeBigInteger_nativeJcpuidVersion
(JNIEnv* env, jclass cls) {
return (jint) JCPUID_VERSION;
}
/**
From: http://sam.zoy.org/blog/2007-04-13-shlib-with-non-pic-code-have-inline-assembly-and-pic-mix-well
@@ -52,6 +74,8 @@ JNIEXPORT jobject JNICALL Java_freenet_support_CPUInformation_CPUID_doCPUID
_asm
{
mov eax, iFunction
// When iFunction is 7, ECX must be 0, just set it all the time
mov ecx, 0
cpuid
mov a, eax
mov b, ebx
@@ -76,7 +100,8 @@ JNIEXPORT jobject JNICALL Java_freenet_support_CPUInformation_CPUID_doCPUID
/* 64 bit */
: "=a" (a), "=b" (b), "=c" (c), "=d" (d)
#endif
:"a"(iFunction)
/* When iFunction is 7, ECX must be 0, just set it all the time */
:"a"(iFunction), "c"(0)
: "cc"
);
#endif