This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Unifying ansidecl.h/gansidecl.h for gcc to include libiberty.h [1/3]
- To: egcs-patches at cygnus dot com
- Subject: Unifying ansidecl.h/gansidecl.h for gcc to include libiberty.h [1/3]
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Tue, 3 Nov 1998 15:15:12 -0500 (EST)
This patch is another step in unifying libiberty and gcc. The
main goal is having gansidecl.h include ansidecl.h, which has a couple
of benefits:
1. It allows for a migration path towards using the PARAMS() macros
instead of the gcc PROTO() ones. This will eventually make gcc
consistent with the rest of the world using libiberty.
2. It allows gcc source code to include libiberty.h without worrying
about conflicts between ansidecl.h and gansidecl.h. (Libiberty.h
includes ansidecl.h so conflicts had to be resolved for this to work
in the gcc dir.) Including libiberty.h is useful for finding and
removing the duplicate cruft scattered in the source which currently
mimics libiberty's functionality. It also provides prototypes for the
main functions in the library.
The annoying part is that gansdecl.h/gcc currently switch on
__STDC__ when determining whether to use ANSI variable args and
libiberty switches on ANSI_PROTOTYPES. ANSI_PROTOTYPES is true under
slightly different circumstances than plain __STDC__, so all the gcc
source had to be immediately updated to switch on ANSI_PROTOTYPES in
VPROTO functions and a couple of other places.
I've included the interesting stuff here (note this crosses
directory ChangeLog boundaries.) And the __STDC__ -> ANSI_PROTOTYPES
changes in following postings. These patches depend on the
"gansidecl.h in {ht}config.h" patches sent in previously in:
http://www.cygnus.com/ml/egcs-patches/1998-Oct/0977.html
http://www.cygnus.com/ml/egcs-patches/1998-Nov/0023.html
http://www.cygnus.com/ml/egcs-patches/1998-Nov/0020.html
This is part 1/3, okay to install?
--Kaveh
Sun Nov 1 20:49:48 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* ansidecl.h: Wrap problematic macros with !IN_GCC.
* demangle.h: Never define PARAMS().
* splay-tree.h: Likewise.
diff -rup orig/egcs-CVS19981102/include/ansidecl.h egcs-CVS19981102/include/ansidecl.h
--- orig/egcs-CVS19981102/include/ansidecl.h Mon Nov 2 16:35:07 1998
+++ egcs-CVS19981102/include/ansidecl.h Tue Nov 3 13:49:19 1998
@@ -103,10 +103,12 @@ Foundation, Inc., 59 Temple Place - Suit
#define PTRCONST void *CONST
#define LONG_DOUBLE long double
+#ifndef IN_GCC
#define AND ,
#define NOARGS void
#define VOLATILE volatile
#define SIGNED signed
+#endif /* ! IN_GCC */
#define PARAMS(paramlist) paramlist
#define ANSI_PROTOTYPES 1
@@ -115,12 +117,14 @@ Foundation, Inc., 59 Temple Place - Suit
#define VA_START(va_list,var) va_start(va_list,var)
/* These are obsolete. Do not use. */
+#ifndef IN_GCC
#define CONST const
#define DOTS , ...
#define PROTO(type, name, arglist) type name arglist
#define EXFUN(name, proto) name proto
#define DEFUN(name, arglist, args) name(args)
#define DEFUN_VOID(name) name(void)
+#endif /* ! IN_GCC */
#else /* Not ANSI C. */
@@ -128,13 +132,16 @@ Foundation, Inc., 59 Temple Place - Suit
#define PTRCONST PTR
#define LONG_DOUBLE double
+#ifndef IN_GCC
#define AND ;
#define NOARGS
+#define VOLATILE
+#define SIGNED
+#endif /* !IN_GCC */
+
#ifndef const /* some systems define it in header files for non-ansi mode */
#define const
#endif
-#define VOLATILE
-#define SIGNED
#define PARAMS(paramlist) ()
@@ -142,12 +149,14 @@ Foundation, Inc., 59 Temple Place - Suit
#define VA_START(va_list,var) va_start(va_list)
/* These are obsolete. Do not use. */
+#ifndef IN_GCC
#define CONST
#define DOTS
#define PROTO(type, name, arglist) type name ()
#define EXFUN(name, proto) name()
#define DEFUN(name, arglist, args) name arglist args;
#define DEFUN_VOID(name) name()
+#endif /* ! IN_GCC */
#endif /* ANSI C. */
diff -rup orig/egcs-CVS19981102/include/demangle.h egcs-CVS19981102/include/demangle.h
--- orig/egcs-CVS19981102/include/demangle.h Tue Nov 3 13:51:40 1998
+++ egcs-CVS19981102/include/demangle.h Tue Nov 3 13:56:30 1998
@@ -20,11 +20,9 @@
#if !defined (DEMANGLE_H)
#define DEMANGLE_H
-#ifdef IN_GCC
-#define PARAMS(ARGS) PROTO(ARGS)
-#else /* ! IN_GCC */
+#ifndef IN_GCC
#include <ansidecl.h>
-#endif /* IN_GCC */
+#endif /* ! IN_GCC */
/* Options passed to cplus_demangle (in 2nd parameter). */
diff -rup orig/egcs-CVS19981102/include/splay-tree.h egcs-CVS19981102/include/splay-tree.h
--- orig/egcs-CVS19981102/include/splay-tree.h Tue Nov 3 13:51:40 1998
+++ egcs-CVS19981102/include/splay-tree.h Tue Nov 3 13:53:04 1998
@@ -33,11 +33,9 @@
extern "C" {
#endif /* __cplusplus */
-#ifdef IN_GCC
-#define PARAMS(ARGS) PROTO(ARGS)
-#else /* ! IN_GCC */
+#ifndef IN_GCC
#include <ansidecl.h>
-#endif /* IN_GCC */
+#endif /* ! IN_GCC */
/* Use typedefs for the key and data types to facilitate changing
these types, if necessary. These types should be sufficiently wide
Sun Nov 1 21:44:21 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gansidecl.h: Prepend a "G" to the macro wrapping this file
(to distinguish it from the macro wrapping ansidecl.h.)
Include libiberty's ansidecl.h. Remove all redundant definitions.
Define the PROTO() style macros in terms of the PARAMS() ones.
diff -rup orig/egcs-CVS19981102/gcc/gansidecl.h egcs-CVS19981102/gcc/gansidecl.h
--- orig/egcs-CVS19981102/gcc/gansidecl.h Mon Nov 2 16:30:37 1998
+++ egcs-CVS19981102/gcc/gansidecl.h Tue Nov 3 13:49:20 1998
@@ -22,29 +22,17 @@ Boston, MA 02111-1307, USA. */
in binutils and gdb releases.
??? Over time the two should be merged into one. */
-#ifndef ANSIDECL_H
-#define ANSIDECL_H
+#ifndef __GANSIDECL_H__
+#define __GANSIDECL_H__
-/* Add prototype support. */
-#ifndef PROTO
-#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
-#define PROTO(ARGS) ARGS
-#else
-#define PROTO(ARGS) ()
-#endif
-#endif
+#include "ansidecl.h"
-#ifndef VPROTO
-#ifdef __STDC__
-#define PVPROTO(ARGS) ARGS
-#define VPROTO(ARGS) ARGS
-#define VA_START(va_list,var) va_start(va_list,var)
-#else
-#define PVPROTO(ARGS) ()
-#define VPROTO(ARGS) (va_alist) va_dcl
-#define VA_START(va_list,var) va_start(va_list)
-#endif
-#endif
+/* Undef ansidecl.h's "obsolete" version. */
+#undef PROTO
+/* These macros are deprecated, use ansidecl.h's PARAMS style instead. */
+#define PROTO(ARGS) PARAMS(ARGS)
+#define VPROTO(ARGS) VPARAMS(ARGS)
+#define PVPROTO(ARGS) PARAMS(ARGS)
#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
# define __attribute__(x)
@@ -67,29 +55,10 @@ Boston, MA 02111-1307, USA. */
#define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
#endif /* ATTRIBUTE_PRINTF */
-#ifndef GENERIC_PTR
-#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
-#define GENERIC_PTR void *
-#else
-#define GENERIC_PTR char *
-#endif
-#endif
+#define GENERIC_PTR PTR
#ifndef NULL_PTR
-#define NULL_PTR ((GENERIC_PTR) 0)
+#define NULL_PTR ((PTR) 0)
#endif
-#ifdef __STDC__
-
-#define PTR void *
-
-#else
-
-#define PTR char *
-#ifndef const
-#define const
-#endif
-
-#endif /* ! __STDC__ */
-
-#endif /* ANSIDECL_H */
+#endif /* __GANSIDECL_H__ */
Sun Nov 1 21:44:21 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* Makefile.in (INCLUDES): Add "-I$(srcdir)/../../include".
diff -rup orig/egcs-CVS19981102/gcc/f/Makefile.in egcs-CVS19981102/gcc/f/Makefile.in
--- orig/egcs-CVS19981102/gcc/f/Makefile.in Mon Nov 2 16:31:18 1998
+++ egcs-CVS19981102/gcc/f/Makefile.in Tue Nov 3 13:49:20 1998
@@ -154,7 +154,7 @@ LIBS = $(SUBDIR_OBSTACK) $(SUBDIR_USE_AL
# Both . and srcdir are used, in that order,
# so that tm.h and config.h will be found in the compilation
# subdirectory rather than in the source directory.
-INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../config
+INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../config -I$(srcdir)/../../include
# Always use -I$(srcdir)/config when compiling.
.c.o: