This is the mail archive of the java-patches@sourceware.cygnus.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

patch: gcc 2.96 compile fixes, file creation mode, ServerSocket bind cleanup


This patch addresses three issues:

1. Using the latest cvs gcc 2.96, exception.cc, boehm.cc, and
java/net/natPlainSocketImpl.cc each need explicit casts in order to
avoid compiler errors.

2. The mode of new files created by java.io.File is wrong (should be 644
not 755 - verified against the JDK). The mode of directories is correct
so removed the fixme comment.

3. Changes to use a dummy "0.0.0.0" InetAddress when binding a
ServerSocket or DatagramSocket. This brings libgcj's behaviour in line
with the JDK and cleans up the native code a bit. Fixes problems
reported by Lincoln Spiteri. I have NOT tested DatagramSocket but it
should be safe.

Changelog:

1999-08-02  Bryce McKinlay  <bryce@albatross.co.nz>

        * boehm.cc (_Jv_RegisterFinalizer): Cast `meth' to GC_PTR.
        * exception.cc (_Jv_Throw): Cast `_Jv_type_matcher' to
__eh_matcher.
        * java/io/natFile.cc (performMkdir): Remove FIXME.
        * java/io/natFileDescriptorPosix.cc (open): Use 0644 file mode.
        * java/net/DatagramSocket.java (DatagramSocket):
        * java/net/ServerSocket.java: Define ANY_IF.
        (ServerSocket (int,int)): Use ANY_IF instead of null to bind to
        all network interfaces.
        * java/net/DatagramSocket.java (DatagramSocket): ditto.
        * java/net/natPlainSocketImpl.cc (bind): Expect `0.0.0.0'
instead of
        null.
        (getOption): Cast `false' to __java_boolean.
        * java/net/natPlainDatagramSocketImpl (bind): Expect `0.0.0.0'
        instead of null.

I'll commit this tommorrow if there are no objections.

  [ bryce ]


Index: libjava/boehm.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/boehm.cc,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 boehm.cc
--- boehm.cc 1999/04/07 14:52:32 1.1.1.1
+++ boehm.cc 1999/08/02 04:15:08
@@ -260,7 +260,7 @@
 void
 _Jv_RegisterFinalizer (void *object, _Jv_FinalizerFunc *meth)
 {
-  GC_REGISTER_FINALIZER_NO_ORDER (object, call_finalizer, meth,
+  GC_REGISTER_FINALIZER_NO_ORDER (object, call_finalizer, (GC_PTR)meth,

       NULL, NULL);
 }

Index: libjava/exception.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/exception.cc,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 exception.cc
--- exception.cc 1999/04/07 14:52:32 1.1.1.1
+++ exception.cc 1999/08/02 04:15:08
@@ -147,7 +147,7 @@
       _Jv_eh_alloc ();
       ehinfo = *(__get_eh_info ());
     }
-  ehinfo->eh_info.match_function = _Jv_type_matcher;
+  ehinfo->eh_info.match_function = (__eh_matcher)_Jv_type_matcher;
   ehinfo->eh_info.language = EH_LANG_Java;
   ehinfo->eh_info.version = 1;
   ehinfo->value = value;
Index: libjava/java/io/natFile.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/io/natFile.cc,v
retrieving revision 1.2
diff -u -r1.2 natFile.cc
--- natFile.cc 1999/07/26 02:51:44 1.2
+++ natFile.cc 1999/08/02 04:15:09
@@ -227,7 +227,6 @@
   buf[total] = '\0';

 #ifdef HAVE_MKDIR
-  // FIXME: mode.
   return ::mkdir (buf, 0755) == 0;
 #else
   return false;
Index: libjava/java/io/natFileDescriptorPosix.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/io/natFileDescriptorPosix.cc,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 natFileDescriptorPosix.cc
--- natFileDescriptorPosix.cc 1999/04/07 14:52:36 1.1.1.1
+++ natFileDescriptorPosix.cc 1999/08/02 04:15:09
@@ -96,8 +96,7 @@
  flags |= O_TRUNC;
     }

-  // FIXME: mode?
-  int fd = ::open (buf, flags, 0755);
+  int fd = ::open (buf, flags, 0644);
   if (fd == -1)
     {
       char msg[MAXPATHLEN + 200];
Index: libjava/java/net/DatagramSocket.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/net/DatagramSocket.java,v
retrieving revision 1.4
diff -u -r1.4 DatagramSocket.java
--- DatagramSocket.java 1999/07/20 20:30:42 1.4
+++ DatagramSocket.java 1999/08/02 04:15:09
@@ -28,12 +28,12 @@

   public DatagramSocket() throws SocketException
   {
-    this(0, null);
+    this(0, ServerSocket.ANY_IF);
   }

   public DatagramSocket(int port) throws SocketException
   {
-    this(port, null);
+    this(port, ServerSocket.ANY_IF);
   }

   public DatagramSocket(int port, InetAddress laddr) throws
SocketException
Index: libjava/java/net/ServerSocket.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/net/ServerSocket.java,v
retrieving revision 1.5
diff -u -r1.5 ServerSocket.java
--- ServerSocket.java 1999/06/17 00:21:22 1.5
+++ ServerSocket.java 1999/08/02 04:15:09
@@ -25,6 +25,10 @@
   static SocketImplFactory factory;
   SocketImpl impl;

+  static final byte[] zeros = {0,0,0,0};
+  /* dummy InetAddress, used to bind socket to any (all) network
interfaces */
+  static final InetAddress ANY_IF = new InetAddress(zeros, null);
+
   public ServerSocket (int port)
     throws java.io.IOException
   {
@@ -34,7 +38,7 @@
   public ServerSocket (int port, int backlog)
     throws java.io.IOException
   {
-    this(port, backlog, null);
+    this(port, backlog, ANY_IF);
   }

   public ServerSocket (int port, int backlog, InetAddress bindAddr)
Index: libjava/java/net/natPlainDatagramSocketImpl.cc
===================================================================
RCS file:
/cvs/java/libgcj/libjava/java/net/natPlainDatagramSocketImpl.cc,v
retrieving revision 1.8
diff -u -r1.8 natPlainDatagramSocketImpl.cc
--- natPlainDatagramSocketImpl.cc 1999/08/01 23:39:53 1.8
+++ natPlainDatagramSocketImpl.cc 1999/08/02 04:15:09
@@ -101,16 +101,10 @@
   // FIXME: prob. need to do a setsockopt with SO_BROADCAST to allow
multicast.
   union SockAddr u;
   struct sockaddr *ptr = (struct sockaddr *) &u.address;
-  jbyte *bytes = NULL;
   // FIXME: Use getaddrinfo() to get actual protocol instead of
assuming ipv4.
-  int len = 4; // Initialize for INADDR_ANY in case host is NULL.
-
-  if (host != NULL)
-    {
-      jbyteArray haddress = host->address;
-      bytes = elements (haddress);
-      len = haddress->length;
-    }
+  jbyteArray haddress = host->address;
+  jbyte *bytes = elements (haddress);
+  int len = haddress->length;

   if (len == 4)
     {
Index: libjava/java/net/natPlainSocketImpl.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/net/natPlainSocketImpl.cc,v
retrieving revision 1.7
diff -u -r1.7 natPlainSocketImpl.cc
--- natPlainSocketImpl.cc 1999/08/01 23:39:53 1.7
+++ natPlainSocketImpl.cc 1999/08/02 04:15:10
@@ -71,17 +71,10 @@
 {
   union SockAddr u;
   struct sockaddr *ptr = (struct sockaddr *) &u.address;
-  jbyte *bytes = NULL;
-  // FIXME: Use getaddrinfo() to get actual protocol instead of
assuming ipv4.
-  int len = 4; // Initialize for INADDR_ANY in case host is NULL.
+  jbyteArray haddress = host->address;
+  jbyte *bytes = elements (haddress);
+  int len = haddress->length;

-  if (host != NULL)
-    {
-      jbyteArray haddress = host->address;
-      bytes = elements (haddress);
-      len = haddress->length;
-    }
-
   if (len == 4)
     {
       u.address.sin_family = AF_INET;
@@ -361,7 +354,7 @@
         if (l_val.l_onoff)
           return new java::lang::Integer (l_val.l_linger);
         else
-   return new java::lang::Boolean (false);
+   return new java::lang::Boolean ( (__java_boolean)false );
 #else
         JvThrow (new java::lang::InternalError (
           JvNewStringUTF ("SO_LINGER not supported")));




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]