comparison lib/obstack.h @ 17791:bfa82dd4206c

obstack: fix macro return values * lib/obstack.h (obstack_next_free): Return void *. (obstack_1grow_fast, obstack_blank_fast): Return void. For __GNUC__ macros: (obstack_1grow, obstack_blank): Remove now unnecessary (void) 0. For !__GNUC__ macros: (obstack_make_room, obstack_grow, obstack_grow0) (obstack_ptr_grow_fast, obstack_int_grow_fast): Return void.
author Alan Modra <amodra@gmail.com>
date Mon, 03 Nov 2014 17:32:27 -0800
parents 4fbd46593c56
children 7497a1d1d497
comparison
equal deleted inserted replaced
17790:1313252b8540 17791:bfa82dd4206c
217 217
218 #define obstack_chunk_size(h) ((h)->chunk_size) 218 #define obstack_chunk_size(h) ((h)->chunk_size)
219 219
220 /* Pointer to next byte not yet allocated in current chunk. */ 220 /* Pointer to next byte not yet allocated in current chunk. */
221 221
222 #define obstack_next_free(h) ((h)->next_free) 222 #define obstack_next_free(h) ((void *) (h)->next_free)
223 223
224 /* Mask specifying low bits that should be clear in address of an object. */ 224 /* Mask specifying low bits that should be clear in address of an object. */
225 225
226 #define obstack_alignment_mask(h) ((h)->alignment_mask) 226 #define obstack_alignment_mask(h) ((h)->alignment_mask)
227 227
250 ((h)->chunkfun = (struct _obstack_chunk *(*)(void *, size_t))(newchunkfun)) 250 ((h)->chunkfun = (struct _obstack_chunk *(*)(void *, size_t))(newchunkfun))
251 251
252 #define obstack_freefun(h, newfreefun) \ 252 #define obstack_freefun(h, newfreefun) \
253 ((h)->freefun = (void (*)(void *, struct _obstack_chunk *))(newfreefun)) 253 ((h)->freefun = (void (*)(void *, struct _obstack_chunk *))(newfreefun))
254 254
255 #define obstack_1grow_fast(h, achar) (*((h)->next_free)++ = (achar)) 255 #define obstack_1grow_fast(h, achar) ((void) (*((h)->next_free)++ = (achar)))
256 256
257 #define obstack_blank_fast(h, n) ((h)->next_free += (n)) 257 #define obstack_blank_fast(h, n) ((void) ((h)->next_free += (n)))
258 258
259 #define obstack_memory_used(h) _obstack_memory_used (h) 259 #define obstack_memory_used(h) _obstack_memory_used (h)
260 260
261 #if defined __GNUC__ 261 #if defined __GNUC__
262 # if !defined __GNUC_MINOR__ || __GNUC__ * 1000 + __GNUC_MINOR__ < 2008 262 # if !defined __GNUC_MINOR__ || __GNUC__ * 1000 + __GNUC_MINOR__ < 2008
320 # define obstack_1grow(OBSTACK, datum) \ 320 # define obstack_1grow(OBSTACK, datum) \
321 __extension__ \ 321 __extension__ \
322 ({ struct obstack *__o = (OBSTACK); \ 322 ({ struct obstack *__o = (OBSTACK); \
323 if (obstack_room (__o) < 1) \ 323 if (obstack_room (__o) < 1) \
324 _obstack_newchunk (__o, 1); \ 324 _obstack_newchunk (__o, 1); \
325 obstack_1grow_fast (__o, datum); \ 325 obstack_1grow_fast (__o, datum); })
326 (void) 0; })
327 326
328 /* These assume that the obstack alignment is good enough for pointers 327 /* These assume that the obstack alignment is good enough for pointers
329 or ints, and that the data added so far to the current object 328 or ints, and that the data added so far to the current object
330 shares that much alignment. */ 329 shares that much alignment. */
331 330
363 __extension__ \ 362 __extension__ \
364 ({ struct obstack *__o = (OBSTACK); \ 363 ({ struct obstack *__o = (OBSTACK); \
365 _OBSTACK_SIZE_T __len = (length); \ 364 _OBSTACK_SIZE_T __len = (length); \
366 if (obstack_room (__o) < __len) \ 365 if (obstack_room (__o) < __len) \
367 _obstack_newchunk (__o, __len); \ 366 _obstack_newchunk (__o, __len); \
368 obstack_blank_fast (__o, __len); \ 367 obstack_blank_fast (__o, __len); })
369 (void) 0; })
370 368
371 # define obstack_alloc(OBSTACK, length) \ 369 # define obstack_alloc(OBSTACK, length) \
372 __extension__ \ 370 __extension__ \
373 ({ struct obstack *__h = (OBSTACK); \ 371 ({ struct obstack *__h = (OBSTACK); \
374 obstack_blank (__h, (length)); \ 372 obstack_blank (__h, (length)); \
433 but some compilers won't accept it. */ 431 but some compilers won't accept it. */
434 432
435 # define obstack_make_room(h, length) \ 433 # define obstack_make_room(h, length) \
436 ((h)->temp.i = (length), \ 434 ((h)->temp.i = (length), \
437 ((obstack_room (h) < (h)->temp.i) \ 435 ((obstack_room (h) < (h)->temp.i) \
438 ? (_obstack_newchunk ((h), (h)->temp.i), 0) : 0)) 436 ? (_obstack_newchunk (h, (h)->temp.i), 0) : 0), \
437 (void) 0)
439 438
440 # define obstack_grow(h, where, length) \ 439 # define obstack_grow(h, where, length) \
441 ((h)->temp.i = (length), \ 440 ((h)->temp.i = (length), \
442 ((obstack_room (h) < (h)->temp.i) \ 441 ((obstack_room (h) < (h)->temp.i) \
443 ? (_obstack_newchunk ((h), (h)->temp.i), 0) : 0), \ 442 ? (_obstack_newchunk ((h), (h)->temp.i), 0) : 0), \
444 memcpy ((h)->next_free, where, (h)->temp.i), \ 443 memcpy ((h)->next_free, where, (h)->temp.i), \
445 (h)->next_free += (h)->temp.i) 444 (h)->next_free += (h)->temp.i, \
445 (void) 0)
446 446
447 # define obstack_grow0(h, where, length) \ 447 # define obstack_grow0(h, where, length) \
448 ((h)->temp.i = (length), \ 448 ((h)->temp.i = (length), \
449 ((obstack_room (h) < (h)->temp.i + 1) \ 449 ((obstack_room (h) < (h)->temp.i + 1) \
450 ? (_obstack_newchunk ((h), (h)->temp.i + 1), 0) : 0), \ 450 ? (_obstack_newchunk ((h), (h)->temp.i + 1), 0) : 0), \
451 memcpy ((h)->next_free, where, (h)->temp.i), \ 451 memcpy ((h)->next_free, where, (h)->temp.i), \
452 (h)->next_free += (h)->temp.i, \ 452 (h)->next_free += (h)->temp.i, \
453 *((h)->next_free)++ = 0) 453 *((h)->next_free)++ = 0, \
454 (void) 0)
454 455
455 # define obstack_1grow(h, datum) \ 456 # define obstack_1grow(h, datum) \
456 (((obstack_room (h) < 1) \ 457 (((obstack_room (h) < 1) \
457 ? (_obstack_newchunk ((h), 1), 0) : 0), \ 458 ? (_obstack_newchunk ((h), 1), 0) : 0), \
458 obstack_1grow_fast (h, datum)) 459 obstack_1grow_fast (h, datum))
466 (((obstack_room (h) < sizeof (int)) \ 467 (((obstack_room (h) < sizeof (int)) \
467 ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \ 468 ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0), \
468 obstack_int_grow_fast (h, datum)) 469 obstack_int_grow_fast (h, datum))
469 470
470 # define obstack_ptr_grow_fast(h, aptr) \ 471 # define obstack_ptr_grow_fast(h, aptr) \
471 (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr)) 472 (((const void **) ((h)->next_free += sizeof (void *)))[-1] = (aptr), \
473 (void) 0)
472 474
473 # define obstack_int_grow_fast(h, aint) \ 475 # define obstack_int_grow_fast(h, aint) \
474 (((int *) ((h)->next_free += sizeof (int)))[-1] = (aint)) 476 (((int *) ((h)->next_free += sizeof (int)))[-1] = (aint), \
477 (void) 0)
475 478
476 # define obstack_blank(h, length) \ 479 # define obstack_blank(h, length) \
477 ((h)->temp.i = (length), \ 480 ((h)->temp.i = (length), \
478 ((obstack_room (h) < (h)->temp.i) \ 481 ((obstack_room (h) < (h)->temp.i) \
479 ? (_obstack_newchunk ((h), (h)->temp.i), 0) : 0), \ 482 ? (_obstack_newchunk ((h), (h)->temp.i), 0) : 0), \