[kaffe] CVS kaffe (robilad): resynced nio native code with GNU Classpath

Kaffe CVS cvs-commits at kaffe.org
Mon Aug 21 15:13:29 PDT 2006


PatchSet 7390 
Date: 2006/08/21 22:04:49
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
resynced nio native code with GNU Classpath

2006-08-21  Dalibor Topic  <robilad at kaffe.org>

        * libraries/clib/nio/gnu_java_nio_channels_FileChannelImpl.c,
        libraries/clib/nio/gnu_java_nio_charset_iconv_IconvDecoder.c,
        libraries/clib/nio/gnu_java_nio_charset_iconv_IconvEncoder.c,
        libraries/clib/nio/java_nio_VMDirectByteBuffer.c,

        Resynced with GNU Classpath:

        2006-01-09  Mark Wielaard  <mark at klomp.org>

        * native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c
        (mapImpl): Add PROT_WRITE when mode == 'c' (MAP_PRIVATE). Make sure
        there is enough space to mmap().

        2006-01-10  Roman Kennke  <kennke at aicas.com>

        * native/jni/java-nio/java_nio_VMDirectByteBuffer.c
        (get): Release the array with the correct pointer.
        (put): Release the array with the correct pointer. Copy the array
        around _before_ releasing it.

Members: 
	ChangeLog:1.4892->1.4893 
	libraries/clib/nio/gnu_java_nio_channels_FileChannelImpl.c:1.5->1.6 
	libraries/clib/nio/gnu_java_nio_charset_iconv_IconvDecoder.c:1.7->1.8 
	libraries/clib/nio/gnu_java_nio_charset_iconv_IconvEncoder.c:1.6->1.7 
	libraries/clib/nio/java_nio_VMDirectByteBuffer.c:1.12->1.13 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4892 kaffe/ChangeLog:1.4893
--- kaffe/ChangeLog:1.4892	Sun Aug 20 22:27:29 2006
+++ kaffe/ChangeLog	Mon Aug 21 22:04:49 2006
@@ -1,3 +1,25 @@
+2006-08-21  Dalibor Topic  <robilad at kaffe.org>
+
+	* libraries/clib/nio/gnu_java_nio_channels_FileChannelImpl.c,
+	libraries/clib/nio/gnu_java_nio_charset_iconv_IconvDecoder.c,
+	libraries/clib/nio/gnu_java_nio_charset_iconv_IconvEncoder.c,
+	libraries/clib/nio/java_nio_VMDirectByteBuffer.c,
+
+	Resynced with GNU Classpath:
+
+	2006-01-09  Mark Wielaard  <mark at klomp.org>
+
+        * native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c
+        (mapImpl): Add PROT_WRITE when mode == 'c' (MAP_PRIVATE). Make sure
+        there is enough space to mmap().
+
+	2006-01-10  Roman Kennke  <kennke at aicas.com>
+
+        * native/jni/java-nio/java_nio_VMDirectByteBuffer.c
+        (get): Release the array with the correct pointer.
+        (put): Release the array with the correct pointer. Copy the array
+        around _before_ releasing it.
+
 2006-08-20  Dalibor Topic  <robilad at kaffe.org>
 
 	* configure.ac: Substitute GLIBJ_ZIP for location of glibj.zip.
Index: kaffe/libraries/clib/nio/gnu_java_nio_channels_FileChannelImpl.c
diff -u kaffe/libraries/clib/nio/gnu_java_nio_channels_FileChannelImpl.c:1.5 kaffe/libraries/clib/nio/gnu_java_nio_channels_FileChannelImpl.c:1.6
--- kaffe/libraries/clib/nio/gnu_java_nio_channels_FileChannelImpl.c:1.5	Thu Jan  5 01:33:10 2006
+++ kaffe/libraries/clib/nio/gnu_java_nio_channels_FileChannelImpl.c	Mon Aug 21 22:04:52 2006
@@ -1,5 +1,5 @@
 /* gnu_java_nio_channels_FileChannelImpl.c -
-   Copyright (C) 2003, 2004, 2005  Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -384,7 +384,7 @@
 {
   int native_fd;
   jlong file_size;
-  ssize_t bytes_written;
+  int bytes_written;
   jlong save_offset, new_offset;
   char data;
   int result;
@@ -538,11 +538,27 @@
       return NULL;
     }
 
+  fd = get_native_fd (env, obj);
+
   prot = PROT_READ;
-  if (mode == '+')
-    prot |= PROT_WRITE;
+  if (mode == '+' || mode == 'c')
+    {
+      /* When writing we need to make sure the file is big enough,
+         otherwise the result of mmap is undefined. */
+      jlong filesize;
+      filesize = Java_gnu_java_nio_channels_FileChannelImpl_size(env, obj);
+      if (filesize == -1)
+	return NULL;
+      if (position + size > filesize)
+	if (ftruncate(fd, position + size) == -1)
+	  {
+	    JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+	    return NULL;
+	  }
+      prot |= PROT_WRITE;
+    }
+
   flags = (mode == 'c' ? MAP_PRIVATE : MAP_SHARED);
-  fd = get_native_fd (env, obj);
   p = mmap (NULL, (size_t) ALIGN_UP (size, pagesize), prot, flags,
 	    fd, ALIGN_DOWN (position, pagesize));
   if (p == MAP_FAILED)
Index: kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvDecoder.c
diff -u kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvDecoder.c:1.7 kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvDecoder.c:1.8
--- kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvDecoder.c:1.7	Fri Oct 21 16:03:22 2005
+++ kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvDecoder.c	Mon Aug 21 22:04:52 2006
@@ -123,8 +123,8 @@
   size_t lenIn = (size_t) remIn;
   size_t lenOut = (size_t) remOut * 2;
 
-  inputcopy = input = (*env)->GetByteArrayElements (env, inArr, NULL);
-  outputcopy = output = (*env)->GetCharArrayElements (env, outArr, NULL);
+  inputcopy = input = (*env)->GetByteArrayElements (env, inArr, 0);
+  outputcopy = output = (*env)->GetCharArrayElements (env, outArr, 0);
 
   input += posIn;
   output += posOut;
Index: kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvEncoder.c
diff -u kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvEncoder.c:1.6 kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvEncoder.c:1.7
--- kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvEncoder.c:1.6	Mon Aug  8 02:52:15 2005
+++ kaffe/libraries/clib/nio/gnu_java_nio_charset_iconv_IconvEncoder.c	Mon Aug 21 22:04:52 2006
@@ -123,8 +123,8 @@
   size_t lenIn = (size_t) remIn * 2;
   size_t lenOut = (size_t) remOut;
 
-  inputcopy = input = (*env)->GetCharArrayElements (env, inArr, NULL);
-  outputcopy = output = (*env)->GetByteArrayElements (env, outArr, NULL);
+  inputcopy = input = (*env)->GetCharArrayElements (env, inArr, 0);
+  outputcopy = output = (*env)->GetByteArrayElements (env, outArr, 0);
 
   input += posIn;
   output += posOut;
Index: kaffe/libraries/clib/nio/java_nio_VMDirectByteBuffer.c
diff -u kaffe/libraries/clib/nio/java_nio_VMDirectByteBuffer.c:1.12 kaffe/libraries/clib/nio/java_nio_VMDirectByteBuffer.c:1.13
--- kaffe/libraries/clib/nio/java_nio_VMDirectByteBuffer.c:1.12	Mon Aug  8 02:52:15 2005
+++ kaffe/libraries/clib/nio/java_nio_VMDirectByteBuffer.c	Mon Aug 21 22:04:52 2006
@@ -60,6 +60,8 @@
       return 0;
     }
 
+  memset (buffer, 0, capacity);
+
   return JCL_NewRawDataObject (env, buffer);
 }
 
@@ -93,8 +95,8 @@
    jobject address, jint index, jbyteArray dst, jint dst_offset, jint dst_len)
 {
   jbyte *src = (jbyte *) JCL_GetRawData (env, address) + index;
-  jbyte *_dst = (*env)->GetByteArrayElements (env, dst, NULL) + dst_offset;
-  memcpy (_dst, src, dst_len);
+  jbyte *_dst = (*env)->GetByteArrayElements (env, dst, NULL);
+  memcpy (_dst + dst_offset, src, dst_len);
   (*env)->ReleaseByteArrayElements (env, dst, _dst, 0);
 }
 
@@ -103,10 +105,10 @@
   (JNIEnv *env, jclass clazz __attribute__ ((__unused__)),
    jobject address, jint index, jbyteArray src, jint src_offset, jint src_len)
 {
-  jbyte *_src = (*env)->GetByteArrayElements (env, src, NULL) + src_offset;
-  jbyte *dst = (jbyte *)JCL_GetRawData (env, address) + index;
+  jbyte *_src = (*env)->GetByteArrayElements (env, src, NULL);
+  jbyte *dst = (jbyte *)JCL_GetRawData (env, address);
+  memcpy (dst + index, _src + src_offset, src_len);
   (*env)->ReleaseByteArrayElements (env, src, _src, 0);
-  memcpy (dst, _src, src_len);
 }
 
 JNIEXPORT void JNICALL




More information about the kaffe mailing list