Commit 54c99af1 by Michael Koch Committed by Michael Koch

2003-03-20 Michael Koch <konqueror@gmx.de>

	* gnu/java/nio/FileChannelImpl.java
	(address): Removed.
	(map_address): New member variable.
	(length): Make it package private.
	(fd): Make it package private.
	(buf): Make it package private.
	(file_obj): Make it package private.
	(FileChannelImpl): New constructor.
	(nio_mmap_file): Use RawData instead of long.
	(nio_munmap_file): Use RawData instead of long.
	(nio_msync): Use RawData instead of long.
	(implCloseChannel): New implementation using map_address.
	(read): Reformated.
	(map): Implemented.
	(create_direct_mapped_buffer): Implemented, use RawData, throws
	IOException.
	(force): Use map_address instead of address.
	* gnu/java/nio/MappedByteFileBuffer.java
	(address): Removed.
	(map_address): New member variable.
	(MappedByteFileBuffer): Use map_address instead of address, reformated.
	(several methods): Use map_address instead of address, replaced long
	with RawData where appropriate.
	* gnu/java/nio/natFileChannelImpl.cc
	(nio_mmap_file): Replaced long with RawData.
	(nio_munmap_file): Replaced long with RawData.
	(nio_msync): Replaced long with RawData.
	* gnu/java/nio/natMappedByteFileBuffer.cc
	(several methods): Replaced long with RawData where appropriate.

From-SVN: r64612
parent 111a007d
2003-03-20 Michael Koch <konqueror@gmx.de> 2003-03-20 Michael Koch <konqueror@gmx.de>
* gnu/java/nio/FileChannelImpl.java
(address): Removed.
(map_address): New member variable.
(length): Make it package private.
(fd): Make it package private.
(buf): Make it package private.
(file_obj): Make it package private.
(FileChannelImpl): New constructor.
(nio_mmap_file): Use RawData instead of long.
(nio_munmap_file): Use RawData instead of long.
(nio_msync): Use RawData instead of long.
(implCloseChannel): New implementation using map_address.
(read): Reformated.
(map): Implemented.
(create_direct_mapped_buffer): Implemented, use RawData, throws
IOException.
(force): Use map_address instead of address.
* gnu/java/nio/MappedByteFileBuffer.java
(address): Removed.
(map_address): New member variable.
(MappedByteFileBuffer): Use map_address instead of address, reformated.
(several methods): Use map_address instead of address, replaced long
with RawData where appropriate.
* gnu/java/nio/natFileChannelImpl.cc
(nio_mmap_file): Replaced long with RawData.
(nio_munmap_file): Replaced long with RawData.
(nio_msync): Replaced long with RawData.
* gnu/java/nio/natMappedByteFileBuffer.cc
(several methods): Replaced long with RawData where appropriate.
2003-03-20 Michael Koch <konqueror@gmx.de>
* java/net/InetAddress.java, * java/net/InetAddress.java,
java/net/JarURLConnection.java, java/net/JarURLConnection.java,
java/net/PlainDatagramSocketImpl.java, java/net/PlainDatagramSocketImpl.java,
......
...@@ -52,6 +52,7 @@ import java.nio.channels.NonReadableChannelException; ...@@ -52,6 +52,7 @@ import java.nio.channels.NonReadableChannelException;
import java.nio.channels.NonWritableChannelException; import java.nio.channels.NonWritableChannelException;
import java.nio.channels.ReadableByteChannel; import java.nio.channels.ReadableByteChannel;
import java.nio.channels.WritableByteChannel; import java.nio.channels.WritableByteChannel;
import gnu.gcj.RawData;
/** /**
* This file is not user visible ! * This file is not user visible !
...@@ -63,11 +64,14 @@ import java.nio.channels.WritableByteChannel; ...@@ -63,11 +64,14 @@ import java.nio.channels.WritableByteChannel;
public class FileChannelImpl extends FileChannel public class FileChannelImpl extends FileChannel
{ {
public long address; // GCJ LOCAL: This variable stores a pointer to the memory
public int length; // where the file is mapped.
public FileDescriptor fd; RawData map_address;
public MappedByteBuffer buf;
public Object file_obj; // just to keep it live... int length;
FileDescriptor fd;
MappedByteBuffer buf;
Object file_obj; // just to keep it live...
public FileChannelImpl (FileDescriptor fd, boolean write, Object obj) public FileChannelImpl (FileDescriptor fd, boolean write, Object obj)
{ {
...@@ -80,24 +84,27 @@ public class FileChannelImpl extends FileChannel ...@@ -80,24 +84,27 @@ public class FileChannelImpl extends FileChannel
this.file_obj = obj; this.file_obj = obj;
} }
public FileChannelImpl ()
{
this (new FileDescriptor (-1), true, null);
}
private native long implPosition (); private native long implPosition ();
private native FileChannel implPosition (long newPosition); private native FileChannel implPosition (long newPosition);
private native FileChannel implTruncate (long size); private native FileChannel implTruncate (long size);
private native long nio_mmap_file (long pos, long size, int mode); private native RawData nio_mmap_file (long pos, long size, int mode);
private native void nio_unmmap_file (long address, int size); private native void nio_unmmap_file (RawData map_address, int size);
private native void nio_msync (long address, int length); private native void nio_msync (RawData map_address, int length);
public native long size () throws IOException; public native long size () throws IOException;
protected void implCloseChannel() throws IOException protected void implCloseChannel() throws IOException
{ {
// FIXME if (map_address != null)
if (address != 0)
{ {
//nio_unmmap_file (fd, address, (int) length); nio_unmmap_file (map_address, (int) length);
address = 0; map_address = null;
} }
if (file_obj instanceof RandomAccessFile) if (file_obj instanceof RandomAccessFile)
...@@ -126,9 +133,9 @@ public class FileChannelImpl extends FileChannel ...@@ -126,9 +133,9 @@ public class FileChannelImpl extends FileChannel
throw new EOFException("file not mapped"); throw new EOFException("file not mapped");
} }
for (int i=0; i<s; i++) for (int i = 0; i < s; i++)
{ {
dst.put( buf.get() ); dst.put (buf.get());
} }
return s; return s;
...@@ -154,9 +161,9 @@ public class FileChannelImpl extends FileChannel ...@@ -154,9 +161,9 @@ public class FileChannelImpl extends FileChannel
long result = 0; long result = 0;
for (int i = offset; i < offset + length; i++) for (int i = offset; i < offset + length; i++)
{ {
result += write (dsts[i]); result += write (dsts [i]);
} }
return result; return result;
} }
...@@ -218,23 +225,22 @@ public class FileChannelImpl extends FileChannel ...@@ -218,23 +225,22 @@ public class FileChannelImpl extends FileChannel
|| size > Integer.MAX_VALUE) || size > Integer.MAX_VALUE)
throw new IllegalArgumentException (); throw new IllegalArgumentException ();
// int cmode = mode.m; int cmode = mode.m;
// address = nio_mmap_file (fd, position, size, cmode); map_address = nio_mmap_file (position, size, cmode);
// length = size; length = (int) size;
// buf = new MappedByteFileBuffer (this); buf = new MappedByteFileBuffer (this);
// return buf; return buf;
return null;
} }
static MappedByteBuffer create_direct_mapped_buffer (long address, static MappedByteBuffer create_direct_mapped_buffer (RawData map_address,
long length) long length)
throws IOException
{ {
// FileChannelImpl ch = new FileChannelImpl (-1, null); FileChannelImpl ch = new FileChannelImpl ();
// ch.address = address; ch.map_address = map_address;
// ch.length = (int) length; ch.length = (int) length;
// ch.buf = new MappedByteFileBuffer (ch); ch.buf = new MappedByteFileBuffer (ch);
// return ch.buf; return ch.buf;
return null;
} }
public long write (ByteBuffer[] srcs) public long write (ByteBuffer[] srcs)
...@@ -253,7 +259,7 @@ public class FileChannelImpl extends FileChannel ...@@ -253,7 +259,7 @@ public class FileChannelImpl extends FileChannel
// FIXME: What to do with metaData ? // FIXME: What to do with metaData ?
nio_msync (address, length); nio_msync (map_address, length);
} }
public long transferTo (long position, long count, WritableByteChannel target) public long transferTo (long position, long count, WritableByteChannel target)
......
...@@ -24,6 +24,7 @@ details. */ ...@@ -24,6 +24,7 @@ details. */
#include <fcntl.h> #include <fcntl.h>
#endif #endif
#include <gnu/gcj/RawData.h>
#include <gnu/java/nio/FileChannelImpl.h> #include <gnu/java/nio/FileChannelImpl.h>
#include <java/io/FileDescriptor.h> #include <java/io/FileDescriptor.h>
#include <java/io/IOException.h> #include <java/io/IOException.h>
...@@ -55,20 +56,20 @@ gnu::java::nio::FileChannelImpl::implTruncate (jlong size) ...@@ -55,20 +56,20 @@ gnu::java::nio::FileChannelImpl::implTruncate (jlong size)
return this; return this;
} }
jlong gnu::gcj::RawData*
gnu::java::nio::FileChannelImpl::nio_mmap_file (jlong, jlong, jint) gnu::java::nio::FileChannelImpl::nio_mmap_file (jlong pos, jlong size, jint /*mode*/)
{ {
throw new ::java::io::IOException (JvNewStringUTF ("mmap not implemented")); throw new ::java::io::IOException (JvNewStringUTF ("mmap not implemented"));
} }
void void
gnu::java::nio::FileChannelImpl::nio_unmmap_file (jlong, jint) gnu::java::nio::FileChannelImpl::nio_unmmap_file (gnu::gcj::RawData* map_address, jint size)
{ {
throw new ::java::io::IOException (JvNewStringUTF ("munmap not implemented")); throw new ::java::io::IOException (JvNewStringUTF ("munmap not implemented"));
} }
void void
gnu::java::nio::FileChannelImpl::nio_msync (jlong, jint) gnu::java::nio::FileChannelImpl::nio_msync (gnu::gcj::RawData* map_address, jint length)
{ {
throw new ::java::io::IOException (JvNewStringUTF ("msync not implemented")); throw new ::java::io::IOException (JvNewStringUTF ("msync not implemented"));
} }
...@@ -24,13 +24,14 @@ details. */ ...@@ -24,13 +24,14 @@ details. */
#include <fcntl.h> #include <fcntl.h>
#endif #endif
#include <gnu/gcj/RawData.h>
#include <gnu/java/nio/MappedByteFileBuffer.h> #include <gnu/java/nio/MappedByteFileBuffer.h>
#include <java/lang/Error.h> #include <java/lang/Error.h>
jbyte jbyte
gnu::java::nio::MappedByteFileBuffer::nio_read_Byte_file_channel gnu::java::nio::MappedByteFileBuffer::nio_read_Byte_file_channel
(gnu::java::nio::FileChannelImpl*, (gnu::java::nio::FileChannelImpl*,
jint, jint, jlong) jint, jint, gnu::gcj::RawData*)
{ {
throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented")); throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented"));
} }
...@@ -38,7 +39,7 @@ gnu::java::nio::MappedByteFileBuffer::nio_read_Byte_file_channel ...@@ -38,7 +39,7 @@ gnu::java::nio::MappedByteFileBuffer::nio_read_Byte_file_channel
jchar jchar
gnu::java::nio::MappedByteFileBuffer::nio_read_Char_file_channel gnu::java::nio::MappedByteFileBuffer::nio_read_Char_file_channel
(gnu::java::nio::FileChannelImpl*, (gnu::java::nio::FileChannelImpl*,
jint, jint, jlong) jint, jint, gnu::gcj::RawData*)
{ {
throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented")); throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented"));
} }
...@@ -46,7 +47,7 @@ gnu::java::nio::MappedByteFileBuffer::nio_read_Char_file_channel ...@@ -46,7 +47,7 @@ gnu::java::nio::MappedByteFileBuffer::nio_read_Char_file_channel
jdouble jdouble
gnu::java::nio::MappedByteFileBuffer::nio_read_Double_file_channel gnu::java::nio::MappedByteFileBuffer::nio_read_Double_file_channel
(gnu::java::nio::FileChannelImpl*, (gnu::java::nio::FileChannelImpl*,
jint, jint, jlong) jint, jint, gnu::gcj::RawData*)
{ {
throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented")); throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented"));
} }
...@@ -54,7 +55,7 @@ gnu::java::nio::MappedByteFileBuffer::nio_read_Double_file_channel ...@@ -54,7 +55,7 @@ gnu::java::nio::MappedByteFileBuffer::nio_read_Double_file_channel
jfloat jfloat
gnu::java::nio::MappedByteFileBuffer::nio_read_Float_file_channel gnu::java::nio::MappedByteFileBuffer::nio_read_Float_file_channel
(gnu::java::nio::FileChannelImpl*, (gnu::java::nio::FileChannelImpl*,
jint, jint, jlong) jint, jint, gnu::gcj::RawData*)
{ {
throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented")); throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented"));
} }
...@@ -62,7 +63,7 @@ gnu::java::nio::MappedByteFileBuffer::nio_read_Float_file_channel ...@@ -62,7 +63,7 @@ gnu::java::nio::MappedByteFileBuffer::nio_read_Float_file_channel
jint jint
gnu::java::nio::MappedByteFileBuffer::nio_read_Int_file_channel gnu::java::nio::MappedByteFileBuffer::nio_read_Int_file_channel
(gnu::java::nio::FileChannelImpl*, (gnu::java::nio::FileChannelImpl*,
jint, jint, jlong) jint, jint, gnu::gcj::RawData*)
{ {
throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented")); throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented"));
} }
...@@ -70,7 +71,7 @@ gnu::java::nio::MappedByteFileBuffer::nio_read_Int_file_channel ...@@ -70,7 +71,7 @@ gnu::java::nio::MappedByteFileBuffer::nio_read_Int_file_channel
jlong jlong
gnu::java::nio::MappedByteFileBuffer::nio_read_Long_file_channel gnu::java::nio::MappedByteFileBuffer::nio_read_Long_file_channel
(gnu::java::nio::FileChannelImpl*, (gnu::java::nio::FileChannelImpl*,
jint, jint, jlong) jint, jint, gnu::gcj::RawData*)
{ {
throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented")); throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented"));
} }
...@@ -78,7 +79,7 @@ gnu::java::nio::MappedByteFileBuffer::nio_read_Long_file_channel ...@@ -78,7 +79,7 @@ gnu::java::nio::MappedByteFileBuffer::nio_read_Long_file_channel
jshort jshort
gnu::java::nio::MappedByteFileBuffer::nio_read_Short_file_channel gnu::java::nio::MappedByteFileBuffer::nio_read_Short_file_channel
(gnu::java::nio::FileChannelImpl*, (gnu::java::nio::FileChannelImpl*,
jint, jint, jlong) jint, jint, gnu::gcj::RawData*)
{ {
throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented")); throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented"));
} }
...@@ -86,7 +87,8 @@ gnu::java::nio::MappedByteFileBuffer::nio_read_Short_file_channel ...@@ -86,7 +87,8 @@ gnu::java::nio::MappedByteFileBuffer::nio_read_Short_file_channel
void void
gnu::java::nio::MappedByteFileBuffer::nio_write_Byte_file_channel gnu::java::nio::MappedByteFileBuffer::nio_write_Byte_file_channel
(gnu::java::nio::FileChannelImpl*, (gnu::java::nio::FileChannelImpl*,
jint, jint, jbyte, jlong) jint, jint, jbyte,
gnu::gcj::RawData*)
{ {
throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented")); throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented"));
} }
...@@ -94,7 +96,8 @@ gnu::java::nio::MappedByteFileBuffer::nio_write_Byte_file_channel ...@@ -94,7 +96,8 @@ gnu::java::nio::MappedByteFileBuffer::nio_write_Byte_file_channel
void void
gnu::java::nio::MappedByteFileBuffer::nio_write_Char_file_channel gnu::java::nio::MappedByteFileBuffer::nio_write_Char_file_channel
(gnu::java::nio::FileChannelImpl*, (gnu::java::nio::FileChannelImpl*,
jint, jint, jchar, jlong) jint, jint, jchar,
gnu::gcj::RawData*)
{ {
throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented")); throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented"));
} }
...@@ -102,7 +105,8 @@ gnu::java::nio::MappedByteFileBuffer::nio_write_Char_file_channel ...@@ -102,7 +105,8 @@ gnu::java::nio::MappedByteFileBuffer::nio_write_Char_file_channel
void void
gnu::java::nio::MappedByteFileBuffer::nio_write_Double_file_channel gnu::java::nio::MappedByteFileBuffer::nio_write_Double_file_channel
(gnu::java::nio::FileChannelImpl*, (gnu::java::nio::FileChannelImpl*,
jint, jint, jdouble, jlong) jint, jint, jdouble,
gnu::gcj::RawData*)
{ {
throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented")); throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented"));
} }
...@@ -110,7 +114,8 @@ gnu::java::nio::MappedByteFileBuffer::nio_write_Double_file_channel ...@@ -110,7 +114,8 @@ gnu::java::nio::MappedByteFileBuffer::nio_write_Double_file_channel
void void
gnu::java::nio::MappedByteFileBuffer::nio_write_Float_file_channel gnu::java::nio::MappedByteFileBuffer::nio_write_Float_file_channel
(gnu::java::nio::FileChannelImpl*, (gnu::java::nio::FileChannelImpl*,
jint, jint, jfloat, jlong) jint, jint, jfloat,
gnu::gcj::RawData*)
{ {
throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented")); throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented"));
} }
...@@ -118,7 +123,8 @@ gnu::java::nio::MappedByteFileBuffer::nio_write_Float_file_channel ...@@ -118,7 +123,8 @@ gnu::java::nio::MappedByteFileBuffer::nio_write_Float_file_channel
void void
gnu::java::nio::MappedByteFileBuffer::nio_write_Int_file_channel gnu::java::nio::MappedByteFileBuffer::nio_write_Int_file_channel
(gnu::java::nio::FileChannelImpl*, (gnu::java::nio::FileChannelImpl*,
jint, jint, jint, jlong) jint, jint, jint,
gnu::gcj::RawData*)
{ {
throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented")); throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented"));
} }
...@@ -126,7 +132,8 @@ gnu::java::nio::MappedByteFileBuffer::nio_write_Int_file_channel ...@@ -126,7 +132,8 @@ gnu::java::nio::MappedByteFileBuffer::nio_write_Int_file_channel
void void
gnu::java::nio::MappedByteFileBuffer::nio_write_Long_file_channel gnu::java::nio::MappedByteFileBuffer::nio_write_Long_file_channel
(gnu::java::nio::FileChannelImpl*, (gnu::java::nio::FileChannelImpl*,
jint, jint, jlong, jlong) jint, jint, jlong,
gnu::gcj::RawData*)
{ {
throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented")); throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented"));
} }
...@@ -134,7 +141,8 @@ gnu::java::nio::MappedByteFileBuffer::nio_write_Long_file_channel ...@@ -134,7 +141,8 @@ gnu::java::nio::MappedByteFileBuffer::nio_write_Long_file_channel
void void
gnu::java::nio::MappedByteFileBuffer::nio_write_Short_file_channel gnu::java::nio::MappedByteFileBuffer::nio_write_Short_file_channel
(gnu::java::nio::FileChannelImpl*, (gnu::java::nio::FileChannelImpl*,
jint, jint, jshort, jlong) jint, jint, jshort,
gnu::gcj::RawData*)
{ {
throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented")); throw new ::java::lang::Error (_Jv_NewStringUTF ("not implemented"));
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment