change sigar pointer field from int to long.

on tru64 size(void*) == 8 which does not fit into sizeof(int) == 4
This commit is contained in:
Doug MacEachern 2004-09-06 17:43:37 +00:00
parent ac0db4ceb6
commit 5f3deb8927
2 changed files with 6 additions and 11 deletions

View File

@ -130,8 +130,8 @@ static jni_sigar_t *sigar_get_pointer(JNIEnv *env, jobject obj) {
cls = JENV->GetObjectClass(env, obj);
pointer_field = JENV->GetFieldID(env, cls, "sigarWrapper", "I");
jsigar = (jni_sigar_t *) JENV->GetIntField(env, obj, pointer_field);
pointer_field = JENV->GetFieldID(env, cls, "sigarWrapper", "J");
jsigar = (jni_sigar_t *) JENV->GetLongField(env, obj, pointer_field);
if (!jsigar) {
sigar_throw_exception(env, "sigar has been closed");
@ -149,15 +149,10 @@ static jni_sigar_t *sigar_get_pointer(JNIEnv *env, jobject obj) {
static void sigar_set_pointer(JNIEnv *env, jobject obj, const void *ptr) {
jfieldID pointer_field;
int pointer_int;
jclass cls;
jclass cls = JENV->GetObjectClass(env, obj);
cls = JENV->GetObjectClass(env, obj);
pointer_field = JENV->GetFieldID(env, cls, "sigarWrapper", "I");
pointer_int = (int)ptr;
JENV->SetIntField(env, obj, pointer_field, pointer_int);
pointer_field = JENV->GetFieldID(env, cls, "sigarWrapper", "J");
JENV->SetLongField(env, obj, pointer_field, (jlong)ptr);
}
JNIEXPORT jstring SIGAR_JNI(Sigar_formatSize)

View File

@ -33,7 +33,7 @@ public class Sigar implements SigarProxy {
private static SigarLoader loader = new SigarLoader(Sigar.class);
private FileSystemMap mounts = null;
int sigarWrapper = 0; //holds the sigar_t *
long sigarWrapper = 0; //holds the sigar_t *
// lastCpu is used to calculate the cpuPerc;
private Cpu lastCpu;