comparison lib-src/ellcc.c @ 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 13aa577c1dd2
children 9fc738581a9d
comparison
equal deleted inserted replaced
1505:ac5cd070b858 1506:4d97756f2fbe
76 #define EMODULES_GATHER_VERSION 76 #define EMODULES_GATHER_VERSION
77 #define EXEC_GROW_SIZE 4 77 #define EXEC_GROW_SIZE 4
78 78
79 #include <emodules.h> 79 #include <emodules.h>
80 #include <ellcc.h> /* Generated files must be included using <...> */ 80 #include <ellcc.h> /* Generated files must be included using <...> */
81
82 #ifndef ATTRIBUTE_MALLOC
83 # if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__==2 && __GNUC_MINOR__>=96))
84 # define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
85 # else
86 # define ATTRIBUTE_MALLOC
87 # endif /* GCC version >= 2.96 */
88 #endif /* ATTRIBUTE_MALLOC */
89
90 #ifdef __GNUC_
91 # define ATTRIBUTE_FATAL __attribute__ ((noreturn, format (printf, 1, 2)))
92 #else
93 # define ATTRIBUTE_FATAL
94 #endif /* __GNUC__ */
95
96 #if defined(__GNUC__) && (__GNUC__ >= 2 || (__GNUC__==2 && __GNUC_MINOR__>=5))
97 # define ATTRIBUTE_CONST __attribute__ ((const))
98 #else
99 # define ATTRIBUTE_CONST
100 #endif
101
81 102
82 #ifndef HAVE_SHLIB 103 #ifndef HAVE_SHLIB
83 int 104 int
84 main (int argc, char *argv[]) 105 main (int argc, char *argv[])
85 { 106 {
140 */ 161 */
141 162
142 enum mode { ELLCC_COMPILE_MODE, ELLCC_LINK_MODE, ELLCC_INIT_MODE }; 163 enum mode { ELLCC_COMPILE_MODE, ELLCC_LINK_MODE, ELLCC_INIT_MODE };
143 164
144 #ifdef DEBUG 165 #ifdef DEBUG
145 static const char *ellcc_mode_name (enum mode ellcc_mode) 166 static const char *ellcc_mode_name (enum mode ellcc_mode) ATTRIBUTE_CONST;
146 #if defined(__GNUC__) && __GNUC__ >= 2 && __GNUC_MINOR__ >= 5
147 __attribute__ ((const))
148 #endif
149 ;
150 167
151 static const char * 168 static const char *
152 ellcc_mode_name (enum mode ellcc_mode) 169 ellcc_mode_name (enum mode ellcc_mode)
153 { 170 {
154 switch (ellcc_mode) 171 switch (ellcc_mode)
166 183
167 /* 184 /*
168 * Function Prototypes 185 * Function Prototypes
169 */ 186 */
170 187
171 static void *xmalloc (size_t size) 188 static void *xmalloc (size_t size) ATTRIBUTE_MALLOC;
172 #ifdef __GNUC__ 189 static void *xrealloc (void *ptr, size_t size) ATTRIBUTE_MALLOC;
173 __attribute__ ((malloc)) 190 static char *xstrdup (char *) ATTRIBUTE_MALLOC;
174 #endif 191 static void fatal (char *, ...) ATTRIBUTE_FATAL;
175 ;
176
177 static void *xrealloc (void *ptr, size_t size)
178 #ifdef __GNUC__
179 __attribute__ ((malloc))
180 #endif
181 ;
182
183 static char *xstrdup (char *)
184 #ifdef __GNUC__
185 __attribute__ ((malloc))
186 #endif
187 ;
188
189 static void fatal (char *, ...)
190 #ifdef __GNUC__
191 __attribute__ ((noreturn, format (printf, 1, 2)))
192 #endif
193 ;
194
195 static char ** add_string (char **, char *); 192 static char ** add_string (char **, char *);
196 static char ** add_to_argv (char **, const char *); 193 static char ** add_to_argv (char **, const char *);
197 static char ** do_compile_mode (void); 194 static char ** do_compile_mode (void);
198 static char ** do_link_mode (void); 195 static char ** do_link_mode (void);
199 static char ** do_init_mode (void); 196 static char ** do_init_mode (void);