need to make pointer size adjustment from int to long at compile time only where needed.
This commit is contained in:
parent
5f3deb8927
commit
c4b58c19bc
|
@ -130,8 +130,13 @@ static jni_sigar_t *sigar_get_pointer(JNIEnv *env, jobject obj) {
|
||||||
|
|
||||||
cls = JENV->GetObjectClass(env, obj);
|
cls = JENV->GetObjectClass(env, obj);
|
||||||
|
|
||||||
pointer_field = JENV->GetFieldID(env, cls, "sigarWrapper", "J");
|
#ifdef SIGAR_POINTER_LONG
|
||||||
|
pointer_field = JENV->GetFieldID(env, cls, "longSigarWrapper", "J");
|
||||||
jsigar = (jni_sigar_t *) JENV->GetLongField(env, obj, pointer_field);
|
jsigar = (jni_sigar_t *) JENV->GetLongField(env, obj, pointer_field);
|
||||||
|
#else
|
||||||
|
pointer_field = JENV->GetFieldID(env, cls, "sigarWrapper", "I");
|
||||||
|
jsigar = (jni_sigar_t *) JENV->GetIntField(env, obj, pointer_field);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!jsigar) {
|
if (!jsigar) {
|
||||||
sigar_throw_exception(env, "sigar has been closed");
|
sigar_throw_exception(env, "sigar has been closed");
|
||||||
|
@ -151,8 +156,13 @@ static void sigar_set_pointer(JNIEnv *env, jobject obj, const void *ptr) {
|
||||||
jfieldID pointer_field;
|
jfieldID pointer_field;
|
||||||
jclass cls = JENV->GetObjectClass(env, obj);
|
jclass cls = JENV->GetObjectClass(env, obj);
|
||||||
|
|
||||||
pointer_field = JENV->GetFieldID(env, cls, "sigarWrapper", "J");
|
#ifdef SIGAR_POINTER_LONG
|
||||||
|
pointer_field = JENV->GetFieldID(env, cls, "longSigarWrapper", "J");
|
||||||
JENV->SetLongField(env, obj, pointer_field, (jlong)ptr);
|
JENV->SetLongField(env, obj, pointer_field, (jlong)ptr);
|
||||||
|
#else
|
||||||
|
pointer_field = JENV->GetFieldID(env, cls, "sigarWrapper", "I");
|
||||||
|
JENV->SetIntField(env, obj, pointer_field, (int)ptr);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring SIGAR_JNI(Sigar_formatSize)
|
JNIEXPORT jstring SIGAR_JNI(Sigar_formatSize)
|
||||||
|
|
|
@ -33,7 +33,8 @@ public class Sigar implements SigarProxy {
|
||||||
private static SigarLoader loader = new SigarLoader(Sigar.class);
|
private static SigarLoader loader = new SigarLoader(Sigar.class);
|
||||||
private FileSystemMap mounts = null;
|
private FileSystemMap mounts = null;
|
||||||
|
|
||||||
long sigarWrapper = 0; //holds the sigar_t *
|
int sigarWrapper = 0; //holds the sigar_t *
|
||||||
|
long longSigarWrapper = 0; //same, but where sizeof(void*) > sizeof(int)
|
||||||
|
|
||||||
// lastCpu is used to calculate the cpuPerc;
|
// lastCpu is used to calculate the cpuPerc;
|
||||||
private Cpu lastCpu;
|
private Cpu lastCpu;
|
||||||
|
|
Loading…
Reference in New Issue