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
|
|
31 ATTRIBUTE_MALLOC, ATTRIBUTE_CONST, ATTRIBUTE_PURE, UNUSED_ARG
|
|
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
|
|
42 #define min(a,b) (((a) <= (b)) ? (a) : (b))
|
|
43 #endif
|
|
44 #ifndef max
|
|
45 #define max(a,b) (((a) > (b)) ? (a) : (b))
|
|
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
|
|
62 #define VOLATILE_IF_NOT_CPP
|
|
63 #else
|
|
64 #define VOLATILE_IF_NOT_CPP volatile
|
|
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
|
1744
|
78 /* Macro simplification for non-GNU compilers and older gccs that did not
|
|
79 define all of these symbols */
|
1743
|
80 #ifndef __GNUC__
|
|
81 #define __GNUC__ 0
|
1744
|
82 #endif
|
|
83 #ifndef __GNUC_MINOR__
|
1743
|
84 #define __GNUC_MINOR__ 0
|
1744
|
85 #endif
|
|
86 #ifndef __GNUC_PATCHLEVEL__
|
1743
|
87 #define __GNUC_PATCHLEVEL__ 0
|
1744
|
88 #endif
|
1743
|
89
|
|
90 /* Simplify testing for specific GCC versions. This also works for non-GCC
|
|
91 compilers, where GCC_VERSION is zero. */
|
|
92 #ifndef NEED_GCC
|
|
93 #define NEED_GCC(major,minor,patch) (major * 1000000 + minor * 1000 + patch)
|
|
94 #endif /* NEED_GCC */
|
|
95 #ifndef GCC_VERSION
|
|
96 #define GCC_VERSION NEED_GCC (__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
|
|
97 #endif /* GCC_VERSION */
|
|
98
|
|
99 /* GCC < 2.6.0 could only declare one attribute per function. In that case,
|
|
100 we define DOESNT_RETURN in preference to PRINTF_ARGS, which is only used
|
|
101 for checking args against the string spec. */
|
|
102 #ifndef PRINTF_ARGS
|
|
103 # if (GCC_VERSION >= NEED_GCC (2, 6, 0))
|
|
104 # define PRINTF_ARGS(string_index,first_to_check) \
|
|
105 __attribute__ ((format (printf, string_index, first_to_check)))
|
|
106 # else
|
|
107 # define PRINTF_ARGS(string_index,first_to_check)
|
|
108 # endif /* GNUC */
|
|
109 #endif
|
|
110
|
|
111 #ifndef DOESNT_RETURN
|
|
112 # if (GCC_VERSION > NEED_GCC (0, 0, 0))
|
|
113 # if (GCC_VERSION >= NEED_GCC (2, 5, 0))
|
|
114 # if (GCC_VERSION < NEED_GCC (3, 0, 0))
|
|
115 /* GCC 3.2 -O3 issues complaints in Fcommand_loop_1 about no return
|
|
116 statement if we have this definition */
|
|
117 # define RETURN_NOT_REACHED(value) DO_NOTHING
|
|
118 # endif
|
|
119 # define DOESNT_RETURN void
|
|
120 # define DECLARE_DOESNT_RETURN(decl) void decl __attribute__ ((noreturn))
|
|
121 # else /* GCC_VERSION < NEED_GCC (2, 5, 0) */
|
|
122 # define DOESNT_RETURN void volatile
|
|
123 # define DECLARE_DOESNT_RETURN(decl) void volatile decl
|
|
124 # endif /* GCC_VERSION >= NEED_GCC (2, 5, 0) */
|
|
125 # else /* not gcc */
|
|
126 # define DOESNT_RETURN void
|
|
127 # define DECLARE_DOESNT_RETURN(decl) void decl
|
|
128 # endif /* GCC_VERSION > NEED_GCC (0, 0, 0) */
|
|
129 #endif /* DOESNT_RETURN */
|
|
130
|
|
131 /* Another try to fix SunPro C compiler warnings */
|
|
132 /* "end-of-loop code not reached" */
|
|
133 /* "statement not reached */
|
|
134 #if defined __SUNPRO_C || defined __USLC__
|
|
135 #define RETURN_SANS_WARNINGS if (1) return
|
|
136 #define RETURN_NOT_REACHED(value) DO_NOTHING
|
|
137 #endif
|
|
138
|
|
139 /* More ways to shut up compiler. This works in Fcommand_loop_1(),
|
|
140 where there's an infinite loop in a function returning a Lisp object.
|
|
141 */
|
|
142 #if defined (_MSC_VER) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || \
|
|
143 (defined (DEC_ALPHA) && defined (OSF1))
|
|
144 #define DO_NOTHING_DISABLING_NO_RETURN_WARNINGS if (0) return Qnil
|
|
145 #else
|
|
146 #define DO_NOTHING_DISABLING_NO_RETURN_WARNINGS DO_NOTHING
|
|
147 #endif
|
|
148
|
|
149 #ifndef RETURN_NOT_REACHED
|
|
150 #define RETURN_NOT_REACHED(value) return (value)
|
|
151 #endif
|
|
152
|
|
153 #ifndef RETURN_SANS_WARNINGS
|
|
154 #define RETURN_SANS_WARNINGS return
|
|
155 #endif
|
|
156
|
|
157 #ifndef DO_NOTHING
|
|
158 #define DO_NOTHING do {} while (0)
|
|
159 #endif
|
|
160
|
|
161 #ifndef DECLARE_NOTHING
|
|
162 #define DECLARE_NOTHING struct nosuchstruct
|
|
163 #endif
|
|
164
|
|
165 #ifndef ATTRIBUTE_MALLOC
|
|
166 # if (GCC_VERSION >= NEED_GCC (2, 96, 0))
|
|
167 # define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
|
|
168 # else
|
|
169 # define ATTRIBUTE_MALLOC
|
|
170 # endif /* GCC_VERSION >= NEED_GCC (2, 96, 0) */
|
|
171 #endif /* ATTRIBUTE_MALLOC */
|
|
172
|
|
173 #ifndef ATTRIBUTE_PURE
|
|
174 # if (GCC_VERSION >= NEED_GCC (2, 96, 0))
|
|
175 # define ATTRIBUTE_PURE __attribute__ ((pure))
|
|
176 # else
|
|
177 # define ATTRIBUTE_PURE
|
|
178 # endif /* GCC_VERSION >= NEED_GCC (2, 96, 0) */
|
|
179 #endif /* ATTRIBUTE_PURE */
|
|
180
|
|
181 #ifndef ATTRIBUTE_CONST
|
|
182 # if (GCC_VERSION >= NEED_GCC (2, 5, 0))
|
|
183 # define ATTRIBUTE_CONST __attribute__ ((const))
|
|
184 # define CONST_FUNC
|
|
185 # else
|
|
186 # define ATTRIBUTE_CONST
|
|
187 # define CONST_FUNC const
|
|
188 # endif /* GCC_VERSION >= NEED_GCC (2, 5, 0) */
|
|
189 #endif /* ATTRIBUTE_CONST */
|
|
190
|
|
191 /* Unused declarations; g++ doesn't support this. */
|
|
192 #ifndef UNUSED_ARG
|
|
193 # if defined(__GNUC__) && !defined(__cplusplus)
|
|
194 # define UNUSED_ARG __attribute__ ((unused))
|
|
195 # else
|
|
196 # define UNUSED_ARG
|
|
197 # endif
|
|
198 #endif /* ATTRIBUTE_UNUSED */
|
|
199
|
|
200 #ifdef DEBUG_XEMACS
|
|
201 #define REGISTER
|
|
202 #define register
|
|
203 #else
|
|
204 #define REGISTER register
|
|
205 #endif
|
|
206
|
|
207 #if defined(HAVE_MS_WINDOWS) && defined(HAVE_SHLIB)
|
|
208 # ifdef EMACS_MODULE
|
|
209 # define MODULE_API __declspec(dllimport)
|
|
210 # else
|
|
211 # define MODULE_API __declspec(dllexport)
|
|
212 # endif
|
|
213 #else
|
|
214 # define MODULE_API
|
|
215 #endif
|
|
216
|
|
217 #endif /* INCLUDED_compiler_h */
|