comparison src/lisp.h @ 454:d7a9135ec789 r21-2-42

Import from CVS: tag r21-2-42
author cvs
date Mon, 13 Aug 2007 11:40:54 +0200
parents 3d3049ae1304
children e7ef97881643
comparison
equal deleted inserted replaced
453:270b05afd845 454:d7a9135ec789
191 # define DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS(decl,str,idx) \ 191 # define DECLARE_DOESNT_RETURN_GCC_ATTRIBUTE_SYNTAX_SUCKS(decl,str,idx) \
192 extern void decl PRINTF_ARGS(str,idx) 192 extern void decl PRINTF_ARGS(str,idx)
193 # endif /* GNUC */ 193 # endif /* GNUC */
194 #endif 194 #endif
195 195
196 /* No type has a greater alignment requirement than max_align_t.
197 (except perhaps for types we don't use, like long double) */
198 typedef union
199 {
200 struct { long l; } l;
201 struct { void *p; } p;
202 struct { void (*f)(void); } f;
203 struct { double d; } d;
204 } max_align_t;
205
196 #ifndef ALIGNOF 206 #ifndef ALIGNOF
197 # if defined (__GNUC__) && (__GNUC__ >= 2) 207 # if defined (__GNUC__) && (__GNUC__ >= 2)
198 # define ALIGNOF(x) __alignof__ (x) 208 /* gcc has an extension that gives us exactly what we want. */
209 # define ALIGNOF(type) __alignof__ (type)
210 # elif ! defined (__cplusplus)
211 /* The following is mostly portable, except that:
212 - it doesn't work for inside out declarations like void (*) (void).
213 (so just call ALIGNOF with a typedef'ed name)
214 - it doesn't work with C++. The C++ committee has decided,
215 in its infinite wisdom, that:
216 "Types must be declared in declarations, not in expressions." */
217 # define ALIGNOF(type) offsetof (struct { char c; type member; }, member)
199 # else 218 # else
200 # define ALIGNOF(x) sizeof (x) 219 /* The following should be completely portable, but might give values
220 that are larger than necessary. But never larger than the maximum
221 possible alignment. */
222 # define ALIGNOF(type) \
223 ((sizeof (type) % sizeof (max_align_t)) == 0 ? \
224 sizeof (max_align_t) : \
225 (sizeof (type) % sizeof (max_align_t)))
201 # endif 226 # endif
202 #endif 227 #endif /* ALIGNOF */
203 228
204 #define ALIGN_SIZE(len, unit) \ 229 #define ALIGN_SIZE(len, unit) \
205 ((((len) + (unit) - 1) / (unit)) * (unit)) 230 ((((len) + (unit) - 1) / (unit)) * (unit))
206 231
207 /* #### Yuck, this is kind of evil */ 232 /* #### Yuck, this is kind of evil */
208 #define ALIGN_PTR(ptr, unit) \ 233 #define ALIGN_PTR(ptr, unit) \
209 ((void *) ALIGN_SIZE ((long) (ptr), unit)) 234 ((void *) ALIGN_SIZE ((size_t) (ptr), unit))
210 235
211 #ifndef DO_NOTHING 236 #ifndef DO_NOTHING
212 #define DO_NOTHING do {} while (0) 237 #define DO_NOTHING do {} while (0)
213 #endif 238 #endif
214 239