summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c
diff options
context:
space:
mode:
authordoko <doko@138bc75d-0d04-0410-961f-82ee72b054a4>2007-08-04 10:53:49 +0000
committerdoko <doko@138bc75d-0d04-0410-961f-82ee72b054a4>2007-08-04 10:53:49 +0000
commitbfd03af53013b43663c88995c6d5943815e8d75b (patch)
tree871b70a606d87369d5aa9d6f621baedc13b49eba /libjava/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c
parentbefb0bace8afefe156fe5718f9d1f202d28560c7 (diff)
downloadppe42-gcc-bfd03af53013b43663c88995c6d5943815e8d75b.tar.gz
ppe42-gcc-bfd03af53013b43663c88995c6d5943815e8d75b.zip
libjava/
2007-08-04 Matthias Klose <doko@ubuntu.com> Import GNU Classpath (libgcj-import-20070727). * Regenerate class and header files. * Regenerate auto* files. * include/jvm.h: * jni-libjvm.cc (Jv_JNI_InvokeFunctions): Rename type. * jni.cc (_Jv_JNIFunctions, _Jv_JNI_InvokeFunctions): Likewise. * jni.cc (_Jv_JNI_CallAnyMethodA, _Jv_JNI_CallAnyVoidMethodA, _Jv_JNI_CallMethodA, _Jv_JNI_CallVoidMethodA, _Jv_JNI_CallStaticMethodA, _Jv_JNI_CallStaticVoidMethodA, _Jv_JNI_NewObjectA, _Jv_JNI_SetPrimitiveArrayRegion): Constify jvalue parameter. * java/lang/reflect/natMethod.cc (_Jv_CallAnyMethodA): Likewise. * java/lang/VMFloat.java (toString, parseFloat): New. * gnu/awt/xlib/XToolkit.java (setAlwaysOnTop, isModalityTypeSupported, isModalExclusionTypeSupported): New (stub only). * gnu/awt/xlib/XCanvasPeer.java (requestFocus): Likewise. * gnu/awt/xlib/XFramePeer.java (updateMinimumSize, updateIconImages, updateFocusableWindowState, setModalBlocked, getBoundsPrivate, setAlwaysOnTop): Likewise. * gnu/awt/xlib/XFontPeer.java (canDisplay): Update signature. * scripts/makemake.tcl: Ignore gnu/javax/sound/sampled/gstreamer, ignore javax.sound.sampled.spi.MixerProvider, ignore .in files. * HACKING: Mention --enable-gstreamer-peer, removal of generated files. libjava/classpath/ 2007-08-04 Matthias Klose <doko@ubuntu.com> * java/util/EnumMap.java (clone): Add cast. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127204 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c')
-rw-r--r--libjava/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c78
1 files changed, 76 insertions, 2 deletions
diff --git a/libjava/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c b/libjava/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c
index c8df841a1d6..a5bbd71262c 100644
--- a/libjava/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c
+++ b/libjava/classpath/native/jni/java-nio/gnu_java_nio_VMChannel.c
@@ -771,6 +771,10 @@ Java_gnu_java_nio_VMChannel_receive (JNIEnv *env,
if (JCL_init_buffer (env, &buf, dst) == -1)
JCL_ThrowException (env, IO_EXCEPTION, "loading buffer failed");
+#ifndef HAVE_MSG_WAITALL
+#define MSG_WAITALL 0
+#endif
+
ret = cpnio_recvfrom (fd, &(buf.ptr[buf.position + buf.offset]),
buf.limit - buf.position, MSG_WAITALL,
sockaddr, &slen);
@@ -1582,14 +1586,84 @@ Java_gnu_java_nio_VMChannel_available (JNIEnv *env,
jclass c __attribute__((unused)),
jint fd)
{
+#if defined (FIONREAD)
+
jint avail = 0;
+#if defined(ENOTTY) && defined(HAVE_FSTAT)
+ struct stat statBuffer;
+ off_t n;
+#endif
+
/* NIODBG("fd: %d", fd); */
if (ioctl (fd, FIONREAD, &avail) == -1)
- JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ {
+#if defined(ENOTTY) && defined(HAVE_FSTAT)
+ if (errno == ENOTTY)
+ {
+ if ((fstat (fd, &statBuffer) == 0) && S_ISREG (statBuffer.st_mode))
+ {
+ n = lseek (fd, 0, SEEK_CUR);
+ if (n != -1)
+ {
+ avail = statBuffer.st_size - n;
+ return avail;
+ }
+ }
+ }
+#endif
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+ }
/* NIODBG("avail: %d", avail); */
return avail;
+
+#elif defined(HAVE_FSTAT)
+
+ jint avail = 0;
+
+ struct stat statBuffer;
+ off_t n;
+
+ if ((fstat (fd, &statBuffer) == 0) && S_ISREG (statBuffer.st_mode))
+ {
+ n = lseek (fd, 0, SEEK_CUR);
+ if (n != -1)
+ {
+ avail = statBuffer.st_size - n;
+ return avail;
+ }
+ }
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+
+#elif defined(HAVE_SELECT)
+
+ jint avail = 0;
+ fd_set filedescriptset;
+ struct timeval tv;
+
+ FD_ZERO (&filedescriptset);
+ FD_SET (fd,&filedescriptset);
+ memset (&tv, 0, sizeof(tv));
+
+ switch (select (fd+1, &filedescriptset, NULL, NULL, &tv))
+ {
+ case -1:
+ break;
+ case 0:
+ avail = 0;
+ return avail;
+ default:
+ avail = 1;
+ return avail;
+ }
+ JCL_ThrowException (env, IO_EXCEPTION, strerror (errno));
+
+#else
+
+ JCL_ThrowException (env, IO_EXCEPTION, "No native method for available");
+
+#endif
}
@@ -1627,7 +1701,7 @@ Java_gnu_java_nio_VMChannel_open (JNIEnv *env,
nmode = (nmode
| ((nmode == O_RDWR || nmode == O_WRONLY) ? O_CREAT : 0)
| ((mode & CPNIO_APPEND) ? O_APPEND :
- ((nmode == O_RDWR || nmode == O_WRONLY) ? O_TRUNC : 0))
+ ((nmode == O_WRONLY) ? O_TRUNC : 0))
| ((mode & CPNIO_EXCL) ? O_EXCL : 0)
| ((mode & CPNIO_SYNC) ? O_SYNC : 0));
OpenPOWER on IntegriCloud