summaryrefslogtreecommitdiff
path: root/libjava/gnu/java/nio/channels/natFileChannelEcos.cc
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /libjava/gnu/java/nio/channels/natFileChannelEcos.cc
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'libjava/gnu/java/nio/channels/natFileChannelEcos.cc')
-rw-r--r--libjava/gnu/java/nio/channels/natFileChannelEcos.cc192
1 files changed, 192 insertions, 0 deletions
diff --git a/libjava/gnu/java/nio/channels/natFileChannelEcos.cc b/libjava/gnu/java/nio/channels/natFileChannelEcos.cc
new file mode 100644
index 000000000..78575e7e6
--- /dev/null
+++ b/libjava/gnu/java/nio/channels/natFileChannelEcos.cc
@@ -0,0 +1,192 @@
+// natFileDescriptor.cc - Native part of FileDescriptor class.
+
+/* Copyright (C) 1998, 1999, 2001, 2002 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#include <config.h>
+
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/param.h>
+
+#include <gcj/cni.h>
+#include <jvm.h>
+#include <java/io/FileDescriptor.h>
+#include <java/io/SyncFailedException.h>
+#include <java/io/IOException.h>
+#include <java/io/EOFException.h>
+#include <java/lang/ArrayIndexOutOfBoundsException.h>
+#include <java/lang/NullPointerException.h>
+#include <java/lang/String.h>
+#include <java/io/FileNotFoundException.h>
+#include <gnu/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 gnu::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;
+
+extern "C" void diag_write_char (char c);
+
+static void
+diag_write (char *data, int len)
+{
+ while (len > 0)
+ {
+ diag_write_char (*data++);
+ len--;
+ }
+}
+
+#define NO_FSYNC_MESSAGE "sync unsupported"
+
+void
+FileChannelImpl::init(void)
+{
+ in = new FileChannelImpl((jint) 0, FileChannelImpl::READ);
+ out = new FileChannelImpl((jint) 1, FileChannelImpl::WRITE);
+ err = new FileChannelImpl((jint) 2, FileChannelImpl::WRITE);
+}
+
+#if 0
+jboolean
+FileChannelImpl::valid (void)
+{
+ return true;
+}
+
+void
+FileChannelImpl::sync (void)
+{
+ // Some files don't support fsync. We don't bother reporting these
+ // as errors.
+#ifdef HAVE_FSYNC
+#else
+ throw new SyncFailedException (JvNewStringLatin1 (NO_FSYNC_MESSAGE));
+#endif
+}
+#endif
+
+jint
+FileChannelImpl::open (jstring, jint)
+{
+ return fd;
+}
+
+void
+FileChannelImpl::write (jint)
+{
+ char d = (char) b;
+ ::diag_write (&d, 1);
+}
+
+void
+FileChannelImpl::write (jbyteArray b, jint offset, jint len)
+{
+ if (! b)
+ throw new NullPointerException;
+ if (offset < 0 || len < 0 || offset + len > JvGetArrayLength (b))
+ throw new ArrayIndexOutOfBoundsException;
+ char *bytes = (char *)elements (b) + offset;
+ ::diag_write (bytes, len);
+}
+
+void
+FileChannelImpl::implCloseChannel (void)
+{
+}
+
+void
+FileChannelImpl::implTruncate (jlong)
+{
+}
+
+void
+FileChannelImpl::seek (jlong)
+{
+}
+
+jlong
+FileChannelImpl::size (void)
+{
+ return 0;
+}
+
+jlong
+FileChannelImpl::implPosition (void)
+{
+ return 0;
+}
+
+jint
+FileChannelImpl::read (void)
+{
+ return 0;
+}
+
+jint
+FileChannelImpl::read (jbyteArray buffer, jint offset, jint count)
+{
+ return 0;
+}
+
+jint
+FileChannelImpl::available (void)
+{
+ return 0;
+}
+
+jboolean
+FileChannelImpl::lock (jlong, jlong, jboolean, jboolean)
+{
+ throw new IOException (JvNewStringLatin1
+ ("gnu.java.nio.FileChannelImpl.lock() not implemented"));
+}
+
+void
+FileChannelImpl::unlock (jlong, jlong)
+{
+ throw new IOException (JvNewStringLatin1
+ ("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
+MappedByteBufferImpl::isLoadedImpl ()
+{
+ return true;
+}
+
+void
+MappedByteBufferImpl::forceImpl ()
+{
+}