commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting FIONREAD for checking available bytes on (non-file) channel


From: Mark Wielaard
Subject: Getting FIONREAD for checking available bytes on (non-file) channel
Date: Fri, 23 Apr 2004 01:07:08 +0200

Hi,

I want to make the following change to target_generic_file.h which
defines TARGET_NATIVE_FILE_AVAILABLE. The original tested for
HAVE_FIONREAD, but I couldn't find a good way to test for this. So I
took the approach that libgcj also uses.

2004-04-22  Mark Wielaard  <address@hidden>

        * configure.ac (AC_CHECK_HEADERS): Check for sys/filio.h.
        * native/target/generic/target_generic_file.h
        (TARGET_NATIVE_FILE_AVAILABLE): First include headers if they exist,
        then check for FIONREAD.

Without this change you will get exceptions when calling available on
non-file streams like System.in for example:

java.io.IOException: No such file or directory
   at gnu.java.nio.channels.FileChannelImpl.available (Native Method)

If someone knows a better way to get this functionality please let me
know. If nobody objects I will commit this this weekend.

Cheers,

Mark
Index: configure.ac
===================================================================
RCS file: /cvsroot/classpath/classpath/configure.ac,v
retrieving revision 1.20
diff -u -r1.20 configure.ac
--- configure.ac        21 Apr 2004 15:53:37 -0000      1.20
+++ configure.ac        22 Apr 2004 22:58:14 -0000
@@ -97,7 +97,13 @@
 
 if test "x${COMPILE_JNI}" = xyes; then
   AC_HEADER_STDC
-  AC_CHECK_HEADERS(unistd.h sys/types.h sys/config.h sys/ioctl.h asm/ioctls.h 
inttypes.h stdint.h utime.h sys/utime.h)
+
+  dnl We check for sys/filio.h because Solaris 2.5 defines FIONREAD there.
+  dnl On that system, sys/ioctl.h will not include sys/filio.h unless
+  dnl BSD_COMP is defined; just including sys/filio.h is simpler.
+  AC_CHECK_HEADERS(unistd.h sys/types.h sys/config.h sys/ioctl.h asm/ioctls.h)
+  AC_CHECK_HEADERS(inttypes.h stdint.h utime.h sys/utime.h sys/filio.h)
+
   AC_EGREP_HEADER(uint32_t, stdint.h, AC_DEFINE(HAVE_INT32_DEFINED, 1, [Define 
to 1 if you have uint32_t]))
   AC_EGREP_HEADER(uint32_t, inttypes.h, AC_DEFINE(HAVE_INT32_DEFINED, 1, 
[Define to 1 if you have uint32_t]))
   AC_EGREP_HEADER(u_int32_t, sys/types.h, AC_DEFINE(HAVE_BSD_INT32_DEFINED, 1, 
[Define to 1 if you have BSD u_int32_t]))
Index: native/target/generic/target_generic_file.h
===================================================================
RCS file: 
/cvsroot/classpath/classpath/native/target/generic/target_generic_file.h,v
retrieving revision 1.16
diff -u -r1.16 target_generic_file.h
--- native/target/generic/target_generic_file.h 9 Apr 2004 14:04:50 -0000       
1.16
+++ native/target/generic/target_generic_file.h 22 Apr 2004 22:58:14 -0000
@@ -413,14 +413,14 @@
 \***********************************************************************/
 
 #ifndef TARGET_NATIVE_FILE_AVAILABLE
-  #if   defined(HAVE_FIONREAD)
-    #ifdef HAVE_SYS_IOCTL
-      #define BSD_COMP /* Get FIONREAD on Solaris2 */
-      #include <sys/ioctl.h>
-    #endif
-    #ifdef HAVE_SYS_FILIO /* Get FIONREAD on Solaris 2.5 */
-      #include <sys/filio.h>
-    #endif
+  #ifdef HAVE_SYS_IOCTL_H
+    #define BSD_COMP /* Get FIONREAD on Solaris2 */
+    #include <sys/ioctl.h>
+  #endif
+  #ifdef HAVE_SYS_FILIO_H /* Get FIONREAD on Solaris 2.5 */
+    #include <sys/filio.h>
+  #endif
+  #if defined (FIONREAD)
     #define TARGET_NATIVE_FILE_AVAILABLE(filedescriptor,length,result) \
       do { \
         ssize_t __n; \

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]