Last change
on this file since 1850e89 was
ec11ea4,
checked in by zzz <zzz@…>, 16 years ago
|
- Convert native jcpuid code from C++ to C. This should alleviate build
problems experienced by some users.
|
-
Property mode set to
100644
|
File size:
763 bytes
|
Line | |
---|
1 | #include "jcpuid.h" |
---|
2 | |
---|
3 | //Executes the indicated subfunction of the CPUID operation |
---|
4 | JNIEXPORT jobject JNICALL Java_freenet_support_CPUInformation_CPUID_doCPUID |
---|
5 | (JNIEnv * env, jclass cls, jint iFunction) |
---|
6 | { |
---|
7 | int a,b,c,d; |
---|
8 | jclass clsResult = (*env)->FindClass(env, "freenet/support/CPUInformation/CPUID$CPUIDResult"); |
---|
9 | jmethodID constructor = (*env)->GetMethodID(env, clsResult,"<init>","(IIII)V" ); |
---|
10 | #ifdef _MSC_VER |
---|
11 | //Use MSVC assembler notation |
---|
12 | _asm |
---|
13 | { |
---|
14 | mov eax, iFunction |
---|
15 | cpuid |
---|
16 | mov a, eax |
---|
17 | mov b, ebx |
---|
18 | mov c, ecx |
---|
19 | mov d, edx |
---|
20 | } |
---|
21 | #else |
---|
22 | //Use GCC assembler notation |
---|
23 | asm |
---|
24 | ( |
---|
25 | "cpuid" |
---|
26 | : "=a" (a), |
---|
27 | "=b" (b), |
---|
28 | "=c"(c), |
---|
29 | "=d"(d) |
---|
30 | :"a"(iFunction) |
---|
31 | ); |
---|
32 | #endif |
---|
33 | return (*env)->NewObject(env, clsResult,constructor,a,b,c,d); |
---|
34 | } |
---|
35 | |
---|
Note: See
TracBrowser
for help on using the repository browser.