[kaffe] CVS kaffe (robilad): Resynced with gnu classpath: nio direct byte buffer fixes
Kaffe CVS
cvs-commits at kaffe.org
Thu Feb 10 15:30:52 PST 2005
PatchSet 5518
Date: 2005/02/10 23:23:28
Author: robilad
Branch: HEAD
Tag: (none)
Log:
Resynced with gnu classpath: nio direct byte buffer fixes
2005-02-10 Dalibor Topic <robilad at kaffe.org>
Resynced with GNU Classpath.
2005-02-08 Michael Koch <konqueror at gmx.de>
* native/jni/java-nio/java_nio_VMDirectByteBuffer.c
(NIOGetPointer): Handle case of pointer size != 32 bit.
(NIOGetRawData): Likewise.
(Java_java_nio_VMDirectByteBuffer_init): Likewise.
Fixed asking for primitive type 'long'.
Members:
ChangeLog:1.3562->1.3563
libraries/clib/nio/java_nio_VMDirectByteBuffer.c:1.3->1.4
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3562 kaffe/ChangeLog:1.3563
--- kaffe/ChangeLog:1.3562 Thu Feb 10 23:11:11 2005
+++ kaffe/ChangeLog Thu Feb 10 23:23:28 2005
@@ -2,6 +2,18 @@
Resynced with GNU Classpath.
+ 2005-02-08 Michael Koch <konqueror at gmx.de>
+
+ * native/jni/java-nio/java_nio_VMDirectByteBuffer.c
+ (NIOGetPointer): Handle case of pointer size != 32 bit.
+ (NIOGetRawData): Likewise.
+ (Java_java_nio_VMDirectByteBuffer_init): Likewise.
+ Fixed asking for primitive type 'long'.
+
+2005-02-10 Dalibor Topic <robilad at kaffe.org>
+
+ Resynced with GNU Classpath.
+
2005-02-07 Mark Wielaard <mark at klomp.org>
* java/util/ResourceBundle.java (getObject): Clarify
Index: kaffe/libraries/clib/nio/java_nio_VMDirectByteBuffer.c
diff -u kaffe/libraries/clib/nio/java_nio_VMDirectByteBuffer.c:1.3 kaffe/libraries/clib/nio/java_nio_VMDirectByteBuffer.c:1.4
--- kaffe/libraries/clib/nio/java_nio_VMDirectByteBuffer.c:1.3 Mon Dec 20 03:40:04 2004
+++ kaffe/libraries/clib/nio/java_nio_VMDirectByteBuffer.c Thu Feb 10 23:23:32 2005
@@ -1,5 +1,5 @@
/* java_nio_VMDirectByteBuffer.c - Native methods for VMDirectByteBuffer
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -7,7 +7,7 @@
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-
+
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -55,14 +55,27 @@
static void *
NIOGetPointer (JNIEnv *env, jobject rawdata)
{
+#if SIZEOF_VOID_P == 4
return (void *) (*env)->GetIntField (env, rawdata, fieldNativePointer);
+#elif SIZEOF_VOID_P == 8
+ return (void *) (*env)->GetLongField (env, rawdata, fieldNativePointer);
+#else
+#error unsupported pointer size
+#endif
}
static jobject
NIOGetRawData (JNIEnv *env, void *pointer)
{
+#if SIZEOF_VOID_P == 4
+ return (*env)->NewObject (env, classRawData, methodRawDataInit,
+ (jint) pointer);
+#elif SIZEOF_VOID_P == 8
return (*env)->NewObject (env, classRawData, methodRawDataInit,
- (jint) pointer);
+ (jlong) pointer);
+#else
+#error unsupported pointer size
+#endif
}
JNIEXPORT void JNICALL
@@ -74,52 +87,54 @@
if (classRawData == NULL)
{
JCL_ThrowException(env, "java/lang/InternalError",
- "unable to find internal class");
+ "unable to find internal class");
return;
}
methodRawDataInit = (*env)->GetMethodID (env, classRawData,
- "<init>", "(I)V");
+ "<init>", "(I)V");
if (methodRawDataInit == NULL)
{
JCL_ThrowException(env, "java/lang/InternalError",
- "unable to find internal constructor");
+ "unable to find internal constructor");
return;
}
-
+
fieldNativePointer = (*env)->GetFieldID (env, classRawData, "data", "I");
if (fieldNativePointer == NULL)
{
JCL_ThrowException(env, "java/lang/InternalError",
- "unable to find internal field");
+ "unable to find internal field");
return;
}
-#else /* SIZEOF_VOID_P != 4 */
+#elif SIZEOF_VOID_P == 8
classRawData = (*env)->FindClass (env, "gnu/classpath/RawData64");
if (classRawData == NULL)
{
JCL_ThrowException(env, "java/lang/InternalError",
- "unable to find internal class");
+ "unable to find internal class");
return;
}
methodRawDataInit = (*env)->GetMethodID (env, classRawData,
- "<init>", "(L)V");
+ "<init>", "(J)V");
if (methodRawDataInit == NULL)
{
JCL_ThrowException(env, "java/lang/InternalError",
- "unable to find internal constructor");
+ "unable to find internal constructor");
return;
}
-
- fieldNativePointer = (*env)->GetFieldID (env, classRawData, "data", "L");
+
+ fieldNativePointer = (*env)->GetFieldID (env, classRawData, "data", "J");
if (fieldNativePointer == NULL)
{
JCL_ThrowException(env, "java/lang/InternalError",
- "unable to find internal field");
+ "unable to find internal field");
return;
}
-#endif /* SIZEOF_VOID_P != 4 */
+#else
+#error unsupported pointer size
+#endif
}
JNIEXPORT jobject JNICALL
@@ -127,16 +142,16 @@
(JNIEnv *env, jclass clazz __attribute__ ((__unused__)), jint capacity)
{
void *buffer;
-
+
buffer = malloc (capacity);
if (buffer == NULL)
{
JCL_ThrowException (env, "java/lang/OutOfMemoryError",
- "unable to allocate memory for direct byte buffer");
- return NULL;
+ "unable to allocate memory for direct byte buffer");
+ return 0;
}
-
+
return NIOGetRawData (env, buffer);
}
More information about the kaffe
mailing list