WIN-28: fix POSIX file descriptor numbering assumptions

Adam Megacz patches@lists.megacz.com
Mon Feb 25 09:56:00 GMT 2002


ok to commit?

  - a

2002-02-25  Adam Megacz  <adam@xwt.org>

        * java/io/FileDescriptor.java: We now use getFD**().
        * java/io/natFileDescriptorWin32.cc (getFDin, getFDout,
        getFDerr): Added these.
        * java/io/natFileDescriptorPosix.cc (getFDin, getFDout,
        getFDerr): Added these.
        * java/io/natFileDescriptorEcos.cc (getFDin, getFDout,
        getFDerr): Added these.

Index: java/io/FileDescriptor.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/FileDescriptor.java,v
retrieving revision 1.8
diff -u -r1.8 FileDescriptor.java
--- FileDescriptor.java	2001/08/31 22:31:40	1.8
+++ FileDescriptor.java	2002/02/25 17:37:10
@@ -24,13 +24,17 @@
 // if need be.
 public final class FileDescriptor
 {
-  public static final FileDescriptor in = new FileDescriptor (0);
-  public static final FileDescriptor out = new FileDescriptor (1);
-  public static final FileDescriptor err = new FileDescriptor (2);
 
+  public static final FileDescriptor in = new FileDescriptor(getFDin());
+  public static final FileDescriptor out = new FileDescriptor(getFDout());
+  public static final FileDescriptor err = new FileDescriptor(getFDerr());
+
+  private static native int getFDin();
+  private static native int getFDout();
+  private static native int getFDerr();
+
   public native void sync () throws SyncFailedException;
   public native boolean valid ();
-
 
   // These are mode values for open().
   static final int READ   = 1;
Index: java/io/natFileDescriptorEcos.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/natFileDescriptorEcos.cc,v
retrieving revision 1.6
diff -u -r1.6 natFileDescriptorEcos.cc
--- natFileDescriptorEcos.cc	2001/08/02 23:46:39	1.6
+++ natFileDescriptorEcos.cc	2002/02/25 17:37:10
@@ -41,6 +41,24 @@
 
 #define NO_FSYNC_MESSAGE "sync unsupported"
 
+jint
+java::io::FileDescriptor::getFDin(void)
+{
+  return 0;
+}
+
+jint
+java::io::FileDescriptor::getFDout(void)
+{
+  return 1;
+}
+
+jint
+java::io::FileDescriptor::getFDerr(void)
+{
+  return 2;
+}
+
 jboolean
 java::io::FileDescriptor::valid (void)
 {
Index: java/io/natFileDescriptorPosix.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/natFileDescriptorPosix.cc,v
retrieving revision 1.16
diff -u -r1.16 natFileDescriptorPosix.cc
--- natFileDescriptorPosix.cc	2001/09/21 04:23:31	1.16
+++ natFileDescriptorPosix.cc	2002/02/25 17:37:10
@@ -45,6 +45,24 @@
 
 #define NO_FSYNC_MESSAGE "sync unsupported"
 
+jint
+java::io::FileDescriptor::getFDin(void)
+{
+  return 0;
+}
+
+jint
+java::io::FileDescriptor::getFDout(void)
+{
+  return 1;
+}
+
+jint
+java::io::FileDescriptor::getFDerr(void)
+{
+  return 2;
+}
+
 jboolean
 java::io::FileDescriptor::valid (void)
 {
Index: java/io/natFileDescriptorWin32.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/natFileDescriptorWin32.cc,v
retrieving revision 1.5
diff -u -r1.5 natFileDescriptorWin32.cc
--- natFileDescriptorWin32.cc	2002/02/12 02:17:21	1.5
+++ natFileDescriptorWin32.cc	2002/02/25 17:37:10
@@ -32,6 +32,24 @@
 #include <java/lang/Thread.h>
 #include <java/io/FileNotFoundException.h>
 
+jint
+java::io::FileDescriptor::getFDin(void)
+{
+  return (jint)(GetStdHandle (STD_INPUT_HANDLE));
+}
+
+jint
+java::io::FileDescriptor::getFDout(void)
+{
+  return (jint)(GetStdHandle (STD_OUTPUT_HANDLE));
+}
+
+jint
+java::io::FileDescriptor::getFDerr(void)
+{
+  return (jint)(GetStdHandle (STD_ERROR_HANDLE));
+}
+
 static char *
 winerr (void)
 {



More information about the Java mailing list