commit-classpath
[Top][All Lists]
Advanced

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

Re: gtk-peer compile fixes for gcc-2.95


From: Mark Wielaard
Subject: Re: gtk-peer compile fixes for gcc-2.95
Date: Fri, 09 Apr 2004 16:02:50 +0200

Hi,

On Wed, 2004-04-07 at 22:25, Mark Wielaard wrote:
> On Mon, 2004-04-05 at 19:43, Tom Tromey wrote:
> > >>>>> "Mark" == Mark Wielaard <address@hidden> writes:
> > 
> > Mark> The attached patch does that and enables -Wall for GNU Classpath.
> > 
> > Nice.  I skimmed it and it generally looks fine to me.
> > 
> > Mark> It fixes all issues found when compiling with -std=c89. Lots in the 
> > gtk
> > Mark> peers I am afraid. So please yell and scream if this is to intrusive. 
> > It
> > Mark> would be good if the gtk-peer stuff in libgcj was also compiled with
> > Mark> this flag.
> > 
> > I think it is a requirement, not just nice to have.  Otherwise we're
> > going to end up reintroducing code that isn't C89.
> > 
> > Here's an untested patch for the GUI branch.
> > 
> > from  Tom Tromey  <address@hidden>
> > 
> >     * Makefile.am (WARNINGS): Added -std=c89.
> 
> Thanks for that.
> 
> Here is the gtk+ peer part of my patch.
> I'll commit this to classpath now.
> Could someone commit it to libgcj mainline and/or gui?
> (I only have a 3.4 branch checkout on my development machine at the
> moment.)
> 
> I want to test the other part of my patch first more carefully before
> committing to classpath and enabling -std=c89

OK I tested some more and here is what I came up with:
-ansi -std=c89 -pedantic -Wall -Wno-long-long -D_POSIX_SOURCE
-D_BSD_SOURCE
This gives us ISO C90 pedantic ansi, but with longlong (jlong) support
and modern POSIX and BSD C library functions/prototypes (we actually
need fsync and ftruncate for example which aren't in ISO C 90 so the
glibc headers wouldn't define it with the above two defines).

I have even gone through the complete source to make sure we can clean
it up so much to enable even -Werror. But when discussion some of the
changes on irc people pointed out that some of the "fixes" actually only
made the warnings go away and not the real problem gcc was warning about
(especially with the "dereferencing type-punned pointer will break
strict-aliasing rules" warnings).

So here is just the minimal safe patch (mostly just wat Tom already
reviewed) to enable the above without -Werror. With all the language
lawyering going on I didn't dare to make changes that might infuriate
some C purist :) I'll study the warnings that are now generated by
default some more and suggest fixes, but others are more then welcome to
do the same!

If someone could enable the above flags also for libgcj and/or add at
least the native/gtk-peer parts to libgcj (mainline/gui-branch) that
would be nice.

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

      * configure.ac: Set AM_CFLAGS to ISO C90 pedantic ansi, but with
      longlong (jlong) support and modern POSIX and BSD C library
      funtions/prototypes.
      * native/fdlibm/Makefile.am: Cancel out project wide AM_CFLAGS.
      * native/fdlibm/mprec.h: Remove C++ comments.
      * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c: Turn C++
      comments into C comments.
      * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c:
      Likewise.
      * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c:
      Likewise.
      * native/jni/java-io/FileDescriptor.c: Likewise.
      * native/jni/java-io/java_io_File.c: Likewise.
      * native/jni/java-io/javaio.c: Remove unused fprintf calls.
      * native/jni/java-net/javanet.c: Turn C++ comments into C comments.
      * native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c:
      Likewise.
      * native/target/generic/target_generic_file.h: Likewise.
      * native/target/generic/target_generic_network.h: Likewise.

Cheers,

Mark


Index: configure.ac
===================================================================
RCS file: /cvsroot/classpath/classpath/configure.ac,v
retrieving revision 1.14
diff -u -r1.14 configure.ac
--- configure.ac        8 Apr 2004 20:04:12 -0000       1.14
+++ configure.ac        9 Apr 2004 13:46:37 -0000
@@ -118,12 +118,16 @@
   dnl We want to avoid -O2 at the moment, gcc 2.96 from Red Hat 7
   dnl cannot compile some native functions (gcc errors) with this
   dnl flag.
-  CFLAGS="-g" 
+  CFLAGS="-g"
 
   dnl We want warnings, lots of warnings :-)
+  AM_CFLAGS=
   if test "x${GCC}" = xyes; then
-    JAPHAR_GREP_CFLAGS(-Wall, [ CFLAGS="$CFLAGS -Wall" ])
+    dnl We want ISO C90 pedantic ansi, but with longlong (jlong) support
+    dnl and modern POSIX and BSD C library funtions/prototypes.
+    AM_CFLAGS='-ansi -std=c89 -pedantic -Wall -Wno-long-long -D_POSIX_SOURCE 
-D_BSD_SOURCE'
   fi
+  AC_SUBST(AM_CFLAGS)
 
   dnl Check for AWT related gthread/gtk/libart_lgpl
   if test "x${COMPILE_GTK_PEER}" = xyes; then
Index: native/fdlibm/Makefile.am
===================================================================
RCS file: /cvsroot/classpath/classpath/native/fdlibm/Makefile.am,v
retrieving revision 1.2
diff -u -r1.2 Makefile.am
--- native/fdlibm/Makefile.am   7 Feb 2002 14:18:45 -0000       1.2
+++ native/fdlibm/Makefile.am   9 Apr 2004 13:46:37 -0000
@@ -15,7 +15,6 @@
                        e_sqrt.c \
                        fdlibm.h \
                        ieeefp.h \
-                       java-assert.h \
                        k_cos.c \
                        k_rem_pio2.c \
                        k_sin.c \
@@ -46,6 +45,10 @@
                        w_sqrt.c 
 
 libfdlibm_la_LDFLAGS = -module -version-info @LIBVERSION@ 
+
+# We just want the standard flags for fdlibm since it is an upstream lib
+# and our normal -ansi -pedantic -Wall -Werror breaks this lib.
+AM_CFLAGS = 
 
 INCLUDES =  @EXTRA_INCLUDES@ \
             -I$(top_builddir)/include 
Index: native/fdlibm/mprec.h
===================================================================
RCS file: /cvsroot/classpath/classpath/native/fdlibm/mprec.h,v
retrieving revision 1.3
diff -u -r1.3 mprec.h
--- native/fdlibm/mprec.h       29 Mar 2004 07:07:26 -0000      1.3
+++ native/fdlibm/mprec.h       9 Apr 2004 13:46:37 -0000
@@ -32,10 +32,6 @@
 #include <config.h>
 #include "ieeefp.h"
 
-// #include <math.h>
-// #include <float.h>
-// #include <errno.h>
-
 #if defined HAVE_STDINT_H
 #include <stdint.h>
 #elif defined HAVE_INTTYPES_H
@@ -61,7 +57,7 @@
 #endif
 
 #if !defined HAVE_BSD_INT32_DEFINED && !defined HAVE_INT32_DEFINED
-// FIXME -- this could have problems with systems that don't define SI to be 4
+/* FIXME this could have problems with systems that don't define SI to be 4 */
 typedef int int32_t __attribute__((mode(SI)));
 
 /* This is a blatant hack: on Solaris 2.5, pthread.h defines uint32_t
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c
===================================================================
RCS file: 
/cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c,v
retrieving revision 1.8
diff -u -r1.8 gnu_java_awt_peer_gtk_GtkMenuPeer.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c     8 Apr 2004 
21:56:00 -0000       1.8
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMenuPeer.c     9 Apr 2004 
13:46:37 -0000
@@ -1,5 +1,5 @@
 /* gtkmenupeer.c -- Native implementation of GtkMenuPeer
-   Copyright (C) 1999 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -46,8 +46,8 @@
   GtkAccelGroup *accel;
 
   accel = gtk_menu_get_accel_group (GTK_MENU (menu_item->submenu));
-  // FIXME: _gtk_accel_group_attach is a GTK-private function, so
-  // we'll need a different approach here:
+  /* FIXME: _gtk_accel_group_attach is a GTK-private function, so
+     we'll need a different approach here: */
 #if 0
   _gtk_accel_group_attach (accel, 
     G_OBJECT (gtk_widget_get_toplevel (GTK_WIDGET(menu_item))));
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c
===================================================================
RCS file: 
/cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c,v
retrieving revision 1.7
diff -u -r1.7 gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c        8 Apr 
2004 21:56:01 -0000       1.7
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkPopupMenuPeer.c        9 Apr 
2004 13:46:37 -0000
@@ -1,5 +1,5 @@
 /* gtkpopupmenupeer.c -- Native implementation of GtkPopupMenuPeer
-   Copyright (C) 1999 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -91,8 +91,8 @@
   gdk_threads_enter ();
   menu = GTK_MENU (GTK_MENU_ITEM (ptr1)->submenu);
   gtk_menu_set_accel_group (menu, gtk_accel_group_new ());
-  // FIXME: _gtk_accel_group_attach is a GTK-private function, so
-  // we'll need a different approach here:
+  /* FIXME: _gtk_accel_group_attach is a GTK-private function, so
+     we'll need a different approach here: */
 #if 0
   _gtk_accel_group_attach (gtk_menu_get_accel_group (menu),
                           G_OBJECT (gtk_widget_get_toplevel (ptr2)));
Index: native/jni/java-io/FileDescriptor.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/java-io/FileDescriptor.c,v
retrieving revision 1.17
diff -u -r1.17 FileDescriptor.c
--- native/jni/java-io/FileDescriptor.c 29 Mar 2004 07:07:27 -0000      1.17
+++ native/jni/java-io/FileDescriptor.c 9 Apr 2004 13:46:37 -0000
@@ -1,5 +1,5 @@
 /* FileDescriptor.c - Native methods for java.io.FileDescriptor class
-   Copyright (C) 1998,2003 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -65,19 +65,19 @@
 
 #include "java_io_FileDescriptor.h"
 
-// FIXME: This can't be right.  Need converter macros
+/* FIXME: This can't be right.  Need converter macros */
 #define CONVERT_JLONG_TO_INT(x) TARGET_NATIVE_MATH_INT_INT64_TO_INT32(x)
 #define CONVERT_INT_TO_JLONG(x) TARGET_NATIVE_MATH_INT_INT32_TO_INT64(x)
 
-// FIXME: This can't be right.  Need converter macros
+/* FIXME: This can't be right.  Need converter macros */
 #define CONVERT_JLONG_TO_OFF_T(x) TARGET_NATIVE_MATH_INT_INT64_TO_INT32(x)
 #define CONVERT_OFF_T_TO_JLONG(x) TARGET_NATIVE_MATH_INT_INT32_TO_INT64(x)
 
-// FIXME: This can't be right.  Need converter macros
+/* FIXME: This can't be right.  Need converter macros */
 #define CONVERT_JINT_TO_INT(x) ((int)(x & 0xFFFFFFFF))
 #define CONVERT_INT_TO_JINT(x) ((int)(x & 0xFFFFFFFF))
 
-// FIXME: This can't be right.  Need converter macros
+/* FIXME: This can't be right.  Need converter macros */
 #define CONVERT_SSIZE_T_TO_JINT(x) ((jint)(x & 0xFFFFFFFF))
 #define CONVERT_JINT_TO_SSIZE_T(x) (x)
 
@@ -420,7 +420,7 @@
       return(0);
     }
 
-// FIXME NYI ??? why only jint and not jlong?
+/* FIXME NYI ??? why only jint and not jlong? */
   return(TARGET_NATIVE_MATH_INT_INT64_TO_INT32(bytes_available));
 }
 
Index: native/jni/java-io/java_io_File.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/java-io/java_io_File.c,v
retrieving revision 1.12
diff -u -r1.12 java_io_File.c
--- native/jni/java-io/java_io_File.c   29 Mar 2004 07:07:27 -0000      1.12
+++ native/jni/java-io/java_io_File.c   9 Apr 2004 13:46:37 -0000
@@ -1,5 +1,5 @@
 /* File.c - Native methods for java.io.File class
-   Copyright (C) 1998 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -81,7 +81,7 @@
   TARGET_NATIVE_FILE_OPEN_CREATE(filename,fd,result);
   if (result != TARGET_NATIVE_OK)
     {
-//??? NYI
+      /* XXX ??? NYI */
       if (errno != EEXIST)
         JCL_ThrowException(env,
                            "java/io/IOException",
Index: native/jni/java-io/javaio.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/java-io/javaio.c,v
retrieving revision 1.11
diff -u -r1.11 javaio.c
--- native/jni/java-io/javaio.c 29 Mar 2004 07:07:27 -0000      1.11
+++ native/jni/java-io/javaio.c 9 Apr 2004 13:46:37 -0000
@@ -1,5 +1,5 @@
 /* javaio.c - Common java.io native functions
-   Copyright (C) 1998, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2002, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -64,7 +64,6 @@
   int        fd;
   int        result;
 
-// fprintf(stderr,"call %s (line %d):\n",__FUNCTION__,__LINE__);
   filename = JCL_jstring_to_cstring(env, name); 
   if (filename == NULL)
     return(-1);
@@ -101,7 +100,6 @@
   int        fd;
   int        result;
 
-// fprintf(stderr,"call %s (line %d):\n",__FUNCTION__,__LINE__);
   filename = JCL_jstring_to_cstring(env, name); 
   if (filename == NULL)
     return(-1);
@@ -163,7 +161,6 @@
   jlong current_offset, new_offset;
   int   result;
 
-// fprintf(stderr,"call %s (line %d):\n",__FUNCTION__,__LINE__);
   
TARGET_NATIVE_FILE_SEEK_CURRENT(fd,TARGET_NATIVE_MATH_INT_INT64_CONST_0,current_offset,result);
   if (result != TARGET_NATIVE_OK)
     JCL_ThrowException(env,
@@ -195,7 +192,6 @@
   jlong length;
   int   result;
 
-// fprintf(stderr,"call %s (line %d):\n",__FUNCTION__,__LINE__);
   TARGET_NATIVE_FILE_SIZE(fd,length,result);
   if (result != TARGET_NATIVE_OK)
     {
@@ -229,7 +225,6 @@
   assert(offset>=0);
   assert(len>=0);
 
-// fprintf(stderr,"call %s (line %d):\n",__FUNCTION__,__LINE__);
   if (len == 0)
     return 0; /* Nothing todo, and GetByteArrayElements() seems undefined. */
 
@@ -258,7 +253,6 @@
   assert(offset>=0);
   assert(len>=0);
 
-// fprintf(stderr,"call %s (line %d):\n",__FUNCTION__,__LINE__);
   if ((fd==0) || (fd==1) || (fd==2))
   {
     if (len == 0)
Index: native/jni/java-net/javanet.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/java-net/javanet.c,v
retrieving revision 1.15
diff -u -r1.15 javanet.c
--- native/jni/java-net/javanet.c       29 Mar 2004 07:07:39 -0000      1.15
+++ native/jni/java-net/javanet.c       9 Apr 2004 13:46:38 -0000
@@ -1,5 +1,5 @@
 /* javanet.c - Common internal functions for the java.net package
-   Copyright (C) 1998, 2002 Free Software Foundation, Inc.
+   Copyright (C) 1998, 2002, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -681,7 +681,7 @@
     }
   DBG("_javanet_bind(): Past native_fd lookup\n");
 
-// NYI ???
+  /* XXX NYI ??? */
   _javanet_set_option (env, this, SOCKOPT_SO_REUSEADDR, 
                       _javanet_create_boolean (env, JNI_TRUE));
 
@@ -1099,7 +1099,8 @@
 
         TARGET_NATIVE_NETWORK_SOCKET_SET_OPTION_SO_TIMEOUT(fd,optval,result);
 #endif
-       result = TARGET_NATIVE_OK;  // ignore errors and do not throw an 
exception
+       /* ignore errors and do not throw an exception. */
+       result = TARGET_NATIVE_OK;
         break;
 
       case SOCKOPT_SO_SNDBUF:
Index: native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c
===================================================================
RCS file: 
/cvsroot/classpath/classpath/native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c,v
retrieving revision 1.1
diff -u -r1.1 gnu_java_nio_channels_FileChannelImpl.c
--- native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c 8 Apr 2004 
20:04:13 -0000       1.1
+++ native/jni/java-nio/gnu_java_nio_channels_FileChannelImpl.c 9 Apr 2004 
13:46:38 -0000
@@ -74,19 +74,19 @@
 
 #define IO_EXCEPTION "java/io/IOException"
 
-// FIXME: This can't be right.  Need converter macros
+/* FIXME: This can't be right.  Need converter macros. */
 #define CONVERT_JLONG_TO_INT(x) TARGET_NATIVE_MATH_INT_INT64_TO_INT32(x)
 #define CONVERT_INT_TO_JLONG(x) TARGET_NATIVE_MATH_INT_INT32_TO_INT64(x)
 
-// FIXME: This can't be right.  Need converter macros
+/* FIXME: This can't be right.  Need converter macros. */
 #define CONVERT_JLONG_TO_OFF_T(x) TARGET_NATIVE_MATH_INT_INT64_TO_INT32(x)
 #define CONVERT_OFF_T_TO_JLONG(x) TARGET_NATIVE_MATH_INT_INT32_TO_INT64(x)
 
-// FIXME: This can't be right.  Need converter macros
+/* FIXME: This can't be right.  Need converter macros */
 #define CONVERT_JINT_TO_INT(x) ((int)(x & 0xFFFFFFFF))
 #define CONVERT_INT_TO_JINT(x) ((int)(x & 0xFFFFFFFF))
 
-// FIXME: This can't be right.  Need converter macros
+/* FIXME: This can't be right.  Need converter macros. */
 #define CONVERT_SSIZE_T_TO_JINT(x) ((jint)(x & 0xFFFFFFFF))
 #define CONVERT_JINT_TO_SSIZE_T(x) (x)
 
@@ -253,7 +253,7 @@
       return 0;
     }
 
-  // FIXME NYI ??? why only jint and not jlong?
+  /* FIXME NYI ??? why only jint and not jlong? */
   return TARGET_NATIVE_MATH_INT_INT64_TO_INT32(bytes_available);
 }
 
Index: native/target/generic/target_generic_file.h
===================================================================
RCS file: 
/cvsroot/classpath/classpath/native/target/generic/target_generic_file.h,v
retrieving revision 1.15
diff -u -r1.15 target_generic_file.h
--- native/target/generic/target_generic_file.h 29 Mar 2004 07:07:40 -0000      
1.15
+++ native/target/generic/target_generic_file.h 9 Apr 2004 13:46:38 -0000
@@ -1,5 +1,5 @@
-/* generic_math_int64.h - Native methods for 64bit math operations
-   Copyright (C) 1998 Free Software Foundation, Inc.
+/* target_generic_file - Native methods for file operations
+   Copyright (C) 1998, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -795,7 +795,7 @@
 * Notes      : -
 \***********************************************************************/
 
-//??? name als buffer?
+/* XXX ??? name als buffer? */
 #ifndef TARGET_NATIVE_FILE_READ_DIR
   #include <sys/types.h>
   #include <dirent.h>
Index: native/target/generic/target_generic_network.h
===================================================================
RCS file: 
/cvsroot/classpath/classpath/native/target/generic/target_generic_network.h,v
retrieving revision 1.10
diff -u -r1.10 target_generic_network.h
--- native/target/generic/target_generic_network.h      29 Mar 2004 07:07:40 
-0000      1.10
+++ native/target/generic/target_generic_network.h      9 Apr 2004 13:46:38 
-0000
@@ -1,5 +1,5 @@
-/* generic_math_int64.h - Native methods for 64bit math operations
-   Copyright (C) 1998 Free Software Foundation, Inc.
+/* target_generic_network.h - Native methods for network operations.
+   Copyright (C) 1998, 2004 Free Software Foundation, Inc.
 
 This file is part of GNU Classpath.
 
@@ -143,7 +143,7 @@
 * Notes      : -
 \***********************************************************************/
 
-//NYI??? reentrant?
+/* XXX NYI??? reentrant? */
 #ifndef TARGET_NATIVE_NETWORK_GET_HOSTNAME_BY_ADDRESS
   #include <netdb.h>
   #define 
TARGET_NATIVE_NETWORK_GET_HOSTNAME_BY_ADDRESS(address,name,maxNameLen,result) \
@@ -181,7 +181,7 @@
 * Notes      : -
 \***********************************************************************/
 
-//NYI??? reentrant?
+/* XXX NYI??? reentrant? */
 #ifndef TARGET_NATIVE_NETWORK_GET_HOSTNAME_BY_NAME
   #include <netdb.h>
   #define 
TARGET_NATIVE_NETWORK_GET_HOSTNAME_BY_NAME(name,addresses,maxAddressSize,addressCount,result)
 \
@@ -317,7 +317,7 @@
 * Notes      : -
 \***********************************************************************/
 
-//??? address in network byte order?
+/* XXX ??? address in network byte order? */
 #ifndef TARGET_NATIVE_NETWORK_SOCKET_BIND
   #include <sys/types.h>
   #include <sys/socket.h>
@@ -347,7 +347,7 @@
 * Notes      : -
 \***********************************************************************/
 
-//??? address in network byte order?
+/* XXX ??? address in network byte order? */
 #ifndef TARGET_NATIVE_NETWORK_SOCKET_LISTEN
   #include <sys/socket.h>
   #define 
TARGET_NATIVE_NETWORK_SOCKET_LISTEN(socketDescriptor,maxQueueLength,result) \
@@ -367,7 +367,7 @@
 * Notes      : -
 \***********************************************************************/
 
-//??? address in network byte order?
+/* XXX ??? address in network byte order? */
 #ifndef TARGET_NATIVE_NETWORK_SOCKET_ACCEPT
   #include <sys/types.h>
   #include <sys/socket.h>

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


reply via email to

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