comparison src/lisp.h @ 80:1ce6082ce73f r20-0b90

Import from CVS: tag r20-0b90
author cvs
date Mon, 13 Aug 2007 09:06:37 +0200
parents 54cc21c15cbb
children ac0620f6398e
comparison
equal deleted inserted replaced
79:5b0a5bbffab6 80:1ce6082ce73f
167 to a malloced array of TYPE objects (or possibly a NULL pointer, 167 to a malloced array of TYPE objects (or possibly a NULL pointer,
168 if SIZEVAR is 0), with the total size stored in SIZEVAR. This 168 if SIZEVAR is 0), with the total size stored in SIZEVAR. This
169 macro will realloc BASEVAR as necessary so that it can hold at 169 macro will realloc BASEVAR as necessary so that it can hold at
170 least NEEDED_SIZE objects. The reallocing is done by doubling, 170 least NEEDED_SIZE objects. The reallocing is done by doubling,
171 which ensures constant amortized time per element. */ 171 which ensures constant amortized time per element. */
172 #define DO_REALLOC(basevar, sizevar, needed_size, type) do \ 172 #define DO_REALLOC(basevar, sizevar, needed_size, type) do \
173 { \ 173 { \
174 /* Avoid side-effectualness. */ \ 174 /* Avoid side-effectualness. */ \
175 /* Dammit! Macros suffer from dynamic scope! */ \ 175 /* Dammit! Macros suffer from dynamic scope! */ \
176 /* We demand inline functions! */ \ 176 /* We demand inline functions! */ \
177 int do_realloc_needed_size = (needed_size); \ 177 int do_realloc_needed_size = (needed_size); \
178 int newsize = 0; \ 178 int newsize = 0; \
179 while ((sizevar) < (do_realloc_needed_size)) { \ 179 while ((sizevar) < (do_realloc_needed_size)) { \
180 newsize = 2*(sizevar); \ 180 newsize = 2*(sizevar); \
181 if (newsize < 32) \ 181 if (newsize < 32) \
182 newsize = 32; \ 182 newsize = 32; \
183 (sizevar) = newsize; \ 183 (sizevar) = newsize; \
184 } \ 184 } \
185 if (newsize) \ 185 if (newsize) \
186 (basevar) = (type *) xrealloc (basevar, \ 186 (basevar) = (type *) xrealloc (basevar, \
187 (newsize)*sizeof(type)); \ 187 (newsize)*sizeof(type)); \
188 } while (0) 188 } while (0)
189 189
190 #ifdef ERROR_CHECK_MALLOC 190 #ifdef ERROR_CHECK_MALLOC
191 #define xfree(lvalue) do \ 191 #define xfree(lvalue) do \
192 { \ 192 { \
193 void **ptr = (void **) &(lvalue); \ 193 void **ptr = (void **) &(lvalue); \
194 xfree_1 (*ptr); \ 194 xfree_1 (*ptr); \
195 *ptr = (void *) 0xDEADBEEF; \ 195 *ptr = (void *) 0xDEADBEEF; \
196 } while (0) 196 } while (0)
197 #else 197 #else
198 #define xfree_1 xfree 198 #define xfree_1 xfree
199 #endif 199 #endif
200 200
249 249
250 #define ALIGN_SIZE(len, unit) \ 250 #define ALIGN_SIZE(len, unit) \
251 ((((len) + (unit) - 1) / (unit)) * (unit)) 251 ((((len) + (unit) - 1) / (unit)) * (unit))
252 252
253 /* #### Yuck, this is kind of evil */ 253 /* #### Yuck, this is kind of evil */
254 #define ALIGN_PTR(ptr, unit) ((void *) ALIGN_SIZE ((long) (ptr), unit)) 254 #define ALIGN_PTR(ptr, unit) \
255 ((void *) ALIGN_SIZE ((long) (ptr), unit))
255 256
256 #ifdef QUANTIFY 257 #ifdef QUANTIFY
257 #include "quantify.h" 258 #include "quantify.h"
258 #define QUANTIFY_START_RECORDING quantify_start_recording_data () 259 #define QUANTIFY_START_RECORDING \
259 #define QUANTIFY_STOP_RECORDING quantify_stop_recording_data () 260 do { quantify_start_recording_data (); } while (0)
261 #define QUANTIFY_STOP_RECORDING \
262 do { quantify_stop_recording_data (); } while (0)
260 #else /* !QUANTIFY */ 263 #else /* !QUANTIFY */
261 #define QUANTIFY_START_RECORDING 264 #define QUANTIFY_START_RECORDING
262 #define QUANTIFY_STOP_RECORDING 265 #define QUANTIFY_STOP_RECORDING
263 #endif /* !QUANTIFY */ 266 #endif /* !QUANTIFY */
264 267