This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: PATCH to optimize two Channels methods
- From: Michael Koch <konqueror at gmx dot de>
- To: Richard Earnshaw <rearnsha at arm dot com>
- Cc: Per Bothner <per at bothner dot com>, java-patches at gcc dot gnu dot org
- Date: Tue, 9 Mar 2004 23:38:56 +0100
- Subject: Re: PATCH to optimize two Channels methods
- References: <200403091927.i29JRVk05900@pc960.cambridge.arm.com>
Am Dienstag, 9. März 2004 20:27 schrieb Richard Earnshaw:
> > > Am Dienstag, 9. März 2004 13:35 schrieb Richard.Earnshaw@arm.com:
> > > > > Am Dienstag, 9. März 2004 13:09 schrieb Richard Earnshaw:
> > > > > > > Am Dienstag, 9. März 2004 12:59 schrieb Richard Earnshaw:
> > > > > > > > konqueror@gmx.de said:
> > > > > > > > > Another iteration of the patch as I forgot the
> > > > > > > > > include files.
> > > > > > > >
> > > > > > > > nope, still not there yet, I guess there's yet another
> > > > > > > > header file missing
> > > > > > >
> > > > > > > no, I did one type and forgot to delete something. Try
> > > > > > > the attached please. Sorry to need to bother you so much
> > > > > > > today.
> > > > > >
> > > > > > A bit better, but still not quite there yet...
> > > > >
> > > > > hmm, hopefully much better now ...
> > > >
> > > > Nope:
> > >
> > > More stuff fixed now. Thats hopefully it. I have to leave for two
> > > hours or so. So next iteration would take some time.
> >
> > Nearly there :-)
> >
> > gnu/java/nio/channels/natFileChannelImpl.cc: In member function
> > `void gnu::java::nio::channels::FileChannelImpl::seek(jlong)':
> > gnu/java/nio/channels/natFileChannelImpl.cc:121: error:
> > return-statement with a value, in function returning 'void'
> >
> >
> > Fortunately I can fix that one myself :-)
> >
> > R.
>
> After fixing the above, I can build now build libjava. Yipee!
>
> Unfortunately I get major regressions in the test suite. They all
> seem to be related to this problem:
>
> /work/rearnsha/gnu/egcs/arm-elf/./libjava/.libs/libgcj.a(natFileChann
>elImpl .o)(.
> text+0x20): In function `diag_write':
> gnu/java/nio/channels/natFileChannelImpl.cc:41: undefined reference
> to `diag_wri
> te_char'
One more chance ....
Michael
Index: gnu/java/nio/channels/natFileChannelEcos.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/nio/channels/natFileChannelEcos.cc,v
retrieving revision 1.1
diff -u -b -B -r1.1 natFileChannelEcos.cc
--- gnu/java/nio/channels/natFileChannelEcos.cc 29 Feb 2004 19:09:27 -0000 1.1
+++ gnu/java/nio/channels/natFileChannelEcos.cc 9 Mar 2004 22:38:56 -0000
@@ -26,37 +26,39 @@
#include <java/lang/NullPointerException.h>
#include <java/lang/String.h>
#include <java/io/FileNotFoundException.h>
-
-extern "C" void diag_write_char (char c);
-
-static void
-diag_write (char *data, int len)
-{
- while (len > 0)
- {
- diag_write_char (*data++);
- len--;
- }
-}
+#include <java/nio/MappedByteBufferImpl.h>
+#include <java/nio/channels/FileChannel.h>
+#include <java/nio/channels/FileLock.h>
+#include <gnu/java/nio/channels/FileChannelImpl.h>
+
+using gnu::gcj::RawData;
+using java::io::IOException;
+using java::nio::MappedByteBufferImpl;
+using java::io::InterruptedIOException;
+using java::io::FileNotFoundException;
+using java::lang::ArrayIndexOutOfBoundsException;
+using java::lang::NullPointerException;
+using gnu::java::nio::channels::FileChannelImpl;
#define NO_FSYNC_MESSAGE "sync unsupported"
void
-java::io::FileDescriptor::init(void)
+FileChannelImpl::init(void)
{
- in = new java::io::FileDescriptor(0);
- out = new java::io::FileDescriptor(1);
- err = new java::io::FileDescriptor(2);
+ in = new FileChannelImpl((jint) 0, FileChannelImpl::READ);
+ out = new FileChannelImpl((jint) 1, FileChannelImpl::WRITE);
+ err = new FileChannelImpl((jint) 2, FileChannelImpl::WRITE);
}
+#if 0
jboolean
-java::io::FileDescriptor::valid (void)
+FileChannelImpl::valid (void)
{
return true;
}
void
-java::io::FileDescriptor::sync (void)
+FileChannelImpl::sync (void)
{
// Some files don't support fsync. We don't bother reporting these
// as errors.
@@ -65,95 +67,114 @@
throw new SyncFailedException (JvNewStringLatin1 (NO_FSYNC_MESSAGE));
#endif
}
+#endif
jint
-java::io::FileDescriptor::open (jstring path, jint jflags)
+FileChannelImpl::open (jstring path, jint jflags)
{
return fd;
}
void
-java::io::FileDescriptor::write (jint b)
+FileChannelImpl::write (jint b)
{
char d = (char) b;
::diag_write (&d, 1);
}
void
-java::io::FileDescriptor::write (jbyteArray b, jint offset, jint len)
+FileChannelImpl::write (jbyteArray b, jint offset, jint len)
{
if (! b)
- throw new java::lang::NullPointerException;
+ throw new NullPointerException;
if (offset < 0 || len < 0 || offset + len > JvGetArrayLength (b))
- throw new java::lang::ArrayIndexOutOfBoundsException;
+ throw new ArrayIndexOutOfBoundsException;
char *bytes = (char *)elements (b) + offset;
::diag_write (bytes, len);
}
void
-java::io::FileDescriptor::close (void)
+FileChannelImpl::implCloseChannel (void)
{
}
void
-java::io::FileDescriptor::setLength (long)
+FileChannelImpl::implTruncate (jlong)
{
}
-jint
-java::io::FileDescriptor::seek (jlong pos, jint whence, jboolean)
+void
+FileChannelImpl::seek (jlong)
{
- JvAssert (whence == SET || whence == CUR);
- return 0;
}
jlong
-java::io::FileDescriptor::getLength (void)
+FileChannelImpl::size (void)
{
return 0;
}
jlong
-java::io::FileDescriptor::getFilePointer (void)
+FileChannelImpl::implPosition (void)
{
return 0;
}
jint
-java::io::FileDescriptor::read (void)
+FileChannelImpl::read (void)
{
return 0;
}
jint
-java::io::FileDescriptor::read (jbyteArray buffer, jint offset, jint count)
+FileChannelImpl::read (jbyteArray buffer, jint offset, jint count)
{
return 0;
}
jint
-java::io::FileDescriptor::available (void)
+FileChannelImpl::available (void)
{
return 0;
}
+jboolean
+FileChannelImpl::lock (jlong, jlong, jboolean, jboolean)
+{
+ throw new IOException (JvNewStringLatin1
+ ("gnu.java.nio.FileChannelImpl.lock() not implemented"));
+}
+
void
-java::io::FileDescriptor::lock (jlong pos, jint len, jboolean shared)
+FileChannelImpl::unlock (jlong, jlong)
{
throw new IOException (JvNewStringLatin1
- ("java.io.FileDescriptor.lock() not implemented"));
+ ("gnu.java.nio.channels.FileChannelImpl.unlock() not implemented"));
+}
+
+java::nio::MappedByteBuffer *
+FileChannelImpl::mapImpl (jchar, jlong, jint)
+{
+ return NULL;
+}
+
+void
+MappedByteBufferImpl::unmapImpl ()
+{
+}
+
+void
+MappedByteBufferImpl::loadImpl ()
+{
}
jboolean
-java::io::FileDescriptor::tryLock (jlong pos, jint len, jboolean shared)
+MappedByteBufferImpl::isLoadedImpl ()
{
- throw new IOException (JvNewStringLatin1
- ("java.io.FileDescriptor.tryLock() not implemented"));
+ return true;
}
void
-java::io::FileDescriptor::unlock (jlong pos, jint len)
+MappedByteBufferImpl::forceImpl ()
{
- throw new IOException (JvNewStringLatin1
- ("java.io.FileDescriptor.unlock() not implemented"));
}