summaryrefslogtreecommitdiff
blob: e4c84b58ffee2619dd3ffa98059e0c4ae12b39cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Backported from:

From ec11ea4ca73646a790f20adf8ded2e48dedd96e5 Mon Sep 17 00:00:00 2001
From: scintilla <scintilla>
Date: Sun, 19 Dec 2004 06:25:27 +0000
Subject: [PATCH] * Convert native jcpuid code from C++ to C. This should
 alleviate build   problems experienced by some users.

--- /dev/null
+++ b/jcpuid/src/jcpuid.c
@@ -0,0 +1,35 @@
+#include "jcpuid.h"
+
+//Executes the indicated subfunction of the CPUID operation
+JNIEXPORT jobject JNICALL Java_freenet_support_CPUInformation_CPUID_doCPUID
+  (JNIEnv * env, jclass cls, jint iFunction)
+{
+	int a,b,c,d;
+	jclass clsResult = (*env)->FindClass(env, "freenet/support/CPUInformation/CPUID$CPUIDResult");
+	jmethodID constructor = (*env)->GetMethodID(env, clsResult,"<init>","(IIII)V" );
+	#ifdef _MSC_VER
+		//Use MSVC assembler notation
+		_asm 
+		{
+			mov eax, iFunction
+			cpuid
+			mov a, eax
+			mov b, ebx
+			mov c, ecx
+			mov d, edx
+		}
+	#else
+		//Use GCC assembler notation
+		asm 
+		(
+			"cpuid"
+			: "=a" (a),
+			  "=b" (b),
+			  "=c"(c),
+			  "=d"(d)
+			:"a"(iFunction)
+		);
+	#endif
+	return (*env)->NewObject(env, clsResult,constructor,a,b,c,d);
+}
+