changeset 1506:4d97756f2fbe

[xemacs-hg @ 2003-05-29 17:02:31 by james] Fix the use of GCC function attributes in ellcc.c
author james
date Thu, 29 May 2003 17:02:31 +0000
parents ac5cd070b858
children c9df76171cd2
files lib-src/ChangeLog lib-src/ellcc.c
diffstat 2 files changed, 30 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/ChangeLog	Wed May 28 21:52:26 2003 +0000
+++ b/lib-src/ChangeLog	Thu May 29 17:02:31 2003 +0000
@@ -1,3 +1,7 @@
+2003-05-29  Jerry James  <james@xemacs.org>
+
+	* ellcc.c: Rationalize and repair use of GCC function attributes.
+
 2003-05-10  Steve Youngs  <youngs@xemacs.org>
 
 	* XEmacs 21.5.13 "cauliflower" is released.
--- a/lib-src/ellcc.c	Wed May 28 21:52:26 2003 +0000
+++ b/lib-src/ellcc.c	Thu May 29 17:02:31 2003 +0000
@@ -79,6 +79,27 @@
 #include <emodules.h>
 #include <ellcc.h> /* Generated files must be included using <...> */
 
+#ifndef ATTRIBUTE_MALLOC
+# if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__==2 && __GNUC_MINOR__>=96))
+#  define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+# else
+#  define ATTRIBUTE_MALLOC
+# endif /* GCC version >= 2.96 */
+#endif /* ATTRIBUTE_MALLOC */
+
+#ifdef __GNUC_
+# define ATTRIBUTE_FATAL __attribute__ ((noreturn, format (printf, 1, 2)))
+#else
+# define ATTRIBUTE_FATAL
+#endif /* __GNUC__ */
+
+#if defined(__GNUC__) && (__GNUC__ >= 2 || (__GNUC__==2 && __GNUC_MINOR__>=5))
+# define ATTRIBUTE_CONST __attribute__ ((const))
+#else
+# define ATTRIBUTE_CONST
+#endif
+
+
 #ifndef HAVE_SHLIB
 int
 main (int argc, char *argv[])
@@ -142,11 +163,7 @@
 enum mode { ELLCC_COMPILE_MODE, ELLCC_LINK_MODE, ELLCC_INIT_MODE };
 
 #ifdef DEBUG
-static const char *ellcc_mode_name (enum mode ellcc_mode)
-#if defined(__GNUC__) && __GNUC__ >= 2 && __GNUC_MINOR__ >= 5
-     __attribute__ ((const))
-#endif
-     ;
+static const char *ellcc_mode_name (enum mode ellcc_mode) ATTRIBUTE_CONST;
 
 static const char *
 ellcc_mode_name (enum mode ellcc_mode)
@@ -168,30 +185,10 @@
  * Function Prototypes
  */
 
-static void *xmalloc (size_t size)
-#ifdef __GNUC__
-     __attribute__ ((malloc))
-#endif
-     ;
-
-static void *xrealloc (void *ptr, size_t size)
-#ifdef __GNUC__
-     __attribute__ ((malloc))
-#endif
-     ;
-
-static char *xstrdup (char *)
-#ifdef __GNUC__
-     __attribute__ ((malloc))
-#endif
-     ;
-
-static void fatal (char *, ...)
-#ifdef __GNUC__
-     __attribute__ ((noreturn, format (printf, 1, 2)))
-#endif
-     ;
-
+static void *xmalloc (size_t size) ATTRIBUTE_MALLOC;
+static void *xrealloc (void *ptr, size_t size) ATTRIBUTE_MALLOC;
+static char *xstrdup (char *) ATTRIBUTE_MALLOC;
+static void fatal (char *, ...) ATTRIBUTE_FATAL;
 static char ** add_string (char **, char *);
 static char ** add_to_argv (char **, const char *);
 static char ** do_compile_mode (void);