1743
|
1 /* Compiler-specific definitions for XEmacs.
|
|
2 Copyright (C) 1998-1999, 2003 Free Software Foundation, Inc.
|
|
3 Copyright (C) 1994 Richard Mlynarik.
|
|
4
|
|
5 This file is part of XEmacs.
|
|
6
|
|
7 XEmacs is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
11
|
|
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* Synched up with: not in FSF. */
|
|
23
|
|
24 /* Authorship:
|
|
25
|
|
26 NOT_REACHED, DOESNT_RETURN, PRINTF_ARGS by Richard Mlynarik, c. 1994.
|
|
27 RETURN_SANS_WARNING by Martin buchholz, 1998 or 1999.
|
|
28 Many changes and improvements by Jerry James, 2003.
|
|
29 Split out of lisp.h, reorganized, and modernized.
|
|
30 {BEGIN,END}_C_DECLS, NEED_GCC, GCC_VERSION
|
2286
|
31 ATTRIBUTE_MALLOC, ATTRIBUTE_CONST, ATTRIBUTE_PURE, UNUSED
|
1743
|
32 */
|
|
33
|
|
34 #ifndef INCLUDED_compiler_h
|
|
35 #define INCLUDED_compiler_h
|
|
36
|
|
37 /* Define min() and max(). (Some compilers put them in strange places that
|
|
38 won't be referenced by include files used by XEmacs, such as 'macros.h'
|
|
39 under Solaris.) */
|
|
40
|
|
41 #ifndef min
|
1748
|
42 # define min(a,b) (((a) <= (b)) ? (a) : (b))
|
1743
|
43 #endif
|
|
44 #ifndef max
|
1748
|
45 # define max(a,b) (((a) > (b)) ? (a) : (b))
|
1743
|
46 #endif
|
|
47
|
|
48 /* Regular C complains about possible clobbering of local vars NOT declared
|
|
49 as volatile if there's a longjmp() in a function. C++ complains if such
|
|
50 vars ARE volatile; or more correctly, sans volatile no problem even when
|
|
51 you longjmp, avec volatile you get unfixable compile errors like
|
|
52
|
|
53 /src/xemacs/lilfix/src/process-unix.c: In function `void
|
|
54 unix_send_process(Lisp_Object, lstream*)':
|
|
55 /src/xemacs/lilfix/src/process-unix.c:1577: no matching function for call to `
|
|
56 Lisp_Object::Lisp_Object(volatile Lisp_Object&)'
|
|
57 /src/xemacs/lilfix/src/lisp-union.h:32: candidates are:
|
|
58 Lisp_Object::Lisp_Object(const Lisp_Object&)
|
|
59 */
|
|
60
|
|
61 #ifdef __cplusplus
|
1748
|
62 # define VOLATILE_IF_NOT_CPP
|
1743
|
63 #else
|
1748
|
64 # define VOLATILE_IF_NOT_CPP volatile
|
1743
|
65 #endif
|
|
66
|
|
67 /* Avoid indentation problems when XEmacs sees the curly braces */
|
|
68 #ifndef BEGIN_C_DECLS
|
|
69 # ifdef __cplusplus
|
|
70 # define BEGIN_C_DECLS extern "C" {
|
|
71 # define END_C_DECLS }
|
|
72 # else
|
|
73 # define BEGIN_C_DECLS
|
|
74 # define END_C_DECLS
|
|
75 # endif
|
|
76 #endif
|
|
77
|
1748
|
78 /* Guard against older gccs that did not define all of these symbols */
|
|
79 #ifdef __GNUC__
|
|
80 # ifndef __GNUC_MINOR__
|
|
81 # define __GNUC_MINOR__ 0
|
|
82 # endif
|
|
83 # ifndef __GNUC_PATCHLEVEL__
|
|
84 # define __GNUC_PATCHLEVEL__ 0
|
|
85 # endif
|
|
86 #endif /* __GNUC__ */
|
1743
|
87
|
1748
|
88 /* Simplify testing for specific GCC versions. For non-GNU compilers,
|
|
89 GCC_VERSION evaluates to zero. */
|
1743
|
90 #ifndef NEED_GCC
|
1748
|
91 # define NEED_GCC(major,minor,patch) (major * 1000000 + minor * 1000 + patch)
|
1743
|
92 #endif /* NEED_GCC */
|
|
93 #ifndef GCC_VERSION
|
1748
|
94 # ifdef __GNUC__
|
|
95 # define GCC_VERSION NEED_GCC (__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
|
|
96 # else
|
|
97 # define GCC_VERSION 0
|
|
98 # endif /* __GNUC__ */
|
1743
|
99 #endif /* GCC_VERSION */
|
|
100
|
|
101 /* GCC < 2.6.0 could only declare one attribute per function. In that case,
|
|
102 we define DOESNT_RETURN in preference to PRINTF_ARGS, which is only used
|
|
103 for checking args against the string spec. */
|
|
104 #ifndef PRINTF_ARGS
|
|
105 # if (GCC_VERSION >= NEED_GCC (2, 6, 0))
|
|
106 # define PRINTF_ARGS(string_index,first_to_check) \
|
|
107 __attribute__ ((format (printf, string_index, first_to_check)))
|
|
108 # else
|
|
109 # define PRINTF_ARGS(string_index,first_to_check)
|
|
110 # endif /* GNUC */
|
|
111 #endif
|
|
112
|
2268
|
113 #ifndef DOESNT_RETURN_TYPE
|
1743
|
114 # if (GCC_VERSION > NEED_GCC (0, 0, 0))
|
|
115 # if (GCC_VERSION >= NEED_GCC (2, 5, 0))
|
2270
|
116 # ifndef __INTEL_COMPILER
|
|
117 # define RETURN_NOT_REACHED(value) DO_NOTHING
|
|
118 # endif
|
2268
|
119 # define DOESNT_RETURN_TYPE(rettype) rettype
|
|
120 # define DECLARE_DOESNT_RETURN_TYPE(rettype,decl) rettype decl \
|
|
121 __attribute__ ((noreturn))
|
1743
|
122 # else /* GCC_VERSION < NEED_GCC (2, 5, 0) */
|
2268
|
123 # define DOESNT_RETURN_TYPE(rettype) rettype volatile
|
|
124 # define DECLARE_DOESNT_RETURN_TYPE(rettype,decl) rettype volatile decl
|
1743
|
125 # endif /* GCC_VERSION >= NEED_GCC (2, 5, 0) */
|
|
126 # else /* not gcc */
|
2268
|
127 # define DOESNT_RETURN_TYPE(rettype) rettype
|
|
128 # define DECLARE_DOESNT_RETURN_TYPE(rettype,decl) rettype decl
|
1743
|
129 # endif /* GCC_VERSION > NEED_GCC (0, 0, 0) */
|
2268
|
130 #endif /* DOESNT_RETURN_TYPE */
|
|
131 #ifndef DOESNT_RETURN
|
|
132 # define DOESNT_RETURN DOESNT_RETURN_TYPE (void)
|
|
133 # define DECLARE_DOESNT_RETURN(decl) DECLARE_DOESNT_RETURN_TYPE (void, decl)
|
1743
|
134 #endif /* DOESNT_RETURN */
|
|
135
|
|
136 /* Another try to fix SunPro C compiler warnings */
|
|
137 /* "end-of-loop code not reached" */
|
|
138 /* "statement not reached */
|
|
139 #if defined __SUNPRO_C || defined __USLC__
|
1748
|
140 # define RETURN_SANS_WARNINGS if (1) return
|
|
141 # define RETURN_NOT_REACHED(value) DO_NOTHING
|
1743
|
142 #endif
|
|
143
|
|
144 /* More ways to shut up compiler. This works in Fcommand_loop_1(),
|
|
145 where there's an infinite loop in a function returning a Lisp object.
|
|
146 */
|
|
147 #if defined (_MSC_VER) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || \
|
|
148 (defined (DEC_ALPHA) && defined (OSF1))
|
1748
|
149 # define DO_NOTHING_DISABLING_NO_RETURN_WARNINGS if (0) return Qnil
|
1743
|
150 #else
|
1748
|
151 # define DO_NOTHING_DISABLING_NO_RETURN_WARNINGS DO_NOTHING
|
1743
|
152 #endif
|
|
153
|
|
154 #ifndef RETURN_NOT_REACHED
|
1748
|
155 # define RETURN_NOT_REACHED(value) return (value)
|
1743
|
156 #endif
|
|
157
|
|
158 #ifndef RETURN_SANS_WARNINGS
|
1748
|
159 # define RETURN_SANS_WARNINGS return
|
1743
|
160 #endif
|
|
161
|
|
162 #ifndef DO_NOTHING
|
1748
|
163 # define DO_NOTHING do {} while (0)
|
1743
|
164 #endif
|
|
165
|
|
166 #ifndef DECLARE_NOTHING
|
1748
|
167 # define DECLARE_NOTHING struct nosuchstruct
|
1743
|
168 #endif
|
|
169
|
|
170 #ifndef ATTRIBUTE_MALLOC
|
|
171 # if (GCC_VERSION >= NEED_GCC (2, 96, 0))
|
|
172 # define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
|
|
173 # else
|
|
174 # define ATTRIBUTE_MALLOC
|
|
175 # endif /* GCC_VERSION >= NEED_GCC (2, 96, 0) */
|
|
176 #endif /* ATTRIBUTE_MALLOC */
|
|
177
|
|
178 #ifndef ATTRIBUTE_PURE
|
|
179 # if (GCC_VERSION >= NEED_GCC (2, 96, 0))
|
|
180 # define ATTRIBUTE_PURE __attribute__ ((pure))
|
|
181 # else
|
|
182 # define ATTRIBUTE_PURE
|
|
183 # endif /* GCC_VERSION >= NEED_GCC (2, 96, 0) */
|
|
184 #endif /* ATTRIBUTE_PURE */
|
|
185
|
|
186 #ifndef ATTRIBUTE_CONST
|
|
187 # if (GCC_VERSION >= NEED_GCC (2, 5, 0))
|
|
188 # define ATTRIBUTE_CONST __attribute__ ((const))
|
|
189 # define CONST_FUNC
|
|
190 # else
|
|
191 # define ATTRIBUTE_CONST
|
|
192 # define CONST_FUNC const
|
|
193 # endif /* GCC_VERSION >= NEED_GCC (2, 5, 0) */
|
|
194 #endif /* ATTRIBUTE_CONST */
|
|
195
|
2286
|
196 /* Unused declarations; g++ and icc do not support this. */
|
1743
|
197 #ifndef UNUSED_ARG
|
2286
|
198 # define UNUSED_ARG(decl) unused_##decl
|
|
199 #endif
|
|
200 #ifndef UNUSED
|
|
201 # if defined(__GNUC__) && !defined(__cplusplus) && !defined(__INTEL_COMPILER)
|
|
202 # define ATTRIBUTE_UNUSED __attribute__ ((unused))
|
1743
|
203 # else
|
2286
|
204 # define ATTRIBUTE_UNUSED
|
1743
|
205 # endif
|
2286
|
206 # define UNUSED(decl) UNUSED_ARG (decl) ATTRIBUTE_UNUSED
|
|
207 #endif /* UNUSED */
|
1743
|
208
|
|
209 #ifdef DEBUG_XEMACS
|
1748
|
210 # define REGISTER
|
|
211 # define register
|
1743
|
212 #else
|
1748
|
213 # define REGISTER register
|
1743
|
214 #endif
|
|
215
|
|
216 #if defined(HAVE_MS_WINDOWS) && defined(HAVE_SHLIB)
|
|
217 # ifdef EMACS_MODULE
|
|
218 # define MODULE_API __declspec(dllimport)
|
|
219 # else
|
|
220 # define MODULE_API __declspec(dllexport)
|
|
221 # endif
|
|
222 #else
|
|
223 # define MODULE_API
|
|
224 #endif
|
|
225
|
|
226 #endif /* INCLUDED_compiler_h */
|