X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=include%2Flibfirm%2Fadt%2Fobstack.h;h=973db8412d23343be2fd425f677ae2008dedacdb;hb=95439e41faebfaeca2bf517718932e47dd8aaa7c;hp=206fe55050b4ea73d5266773961ebea587fb5e23;hpb=049e7746fb729a28e90e69f02899c76c7b98b275;p=libfirm diff --git a/include/libfirm/adt/obstack.h b/include/libfirm/adt/obstack.h index 206fe5505..973db8412 100644 --- a/include/libfirm/adt/obstack.h +++ b/include/libfirm/adt/obstack.h @@ -106,10 +106,8 @@ Summary: #ifndef _OBSTACK_H #define _OBSTACK_H 1 -#ifdef __cplusplus -extern "C" { -#endif - +#include "../begin.h" + /* We need the type of a pointer subtraction. If __PTRDIFF_TYPE__ is defined, as with GNU C, use that; that way we don't pollute the namespace with 's symbols. Otherwise, include @@ -140,6 +138,7 @@ extern "C" { P, A) #include +#include struct _obstack_chunk /* Lives at front of each chunk. */ { @@ -150,7 +149,7 @@ struct _obstack_chunk /* Lives at front of each chunk. */ struct obstack /* control current object in current chunk */ { - long chunk_size; /* preferred size to allocate chunks in */ + PTR_INT_TYPE chunk_size; /* preferred size to allocate chunks in */ struct _obstack_chunk *chunk; /* address of current struct obstack_chunk */ char *object_base; /* address of object we are building */ char *next_free; /* where to add next char to current object */ @@ -164,7 +163,7 @@ struct obstack /* control current object in current chunk */ /* These prototypes vary based on `use_extra_arg', and we use casts to the prototypeless function type in all assignments, but having prototypes here quiets -Wstrict-prototypes. */ - struct _obstack_chunk *(*chunkfun) (void *, long); + struct _obstack_chunk *(*chunkfun) (void *, PTR_INT_TYPE); void (*freefun) (void *, struct _obstack_chunk *); void *extra_arg; /* first arg for chunk alloc/dealloc funcs */ unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */ @@ -179,13 +178,13 @@ struct obstack /* control current object in current chunk */ /* Declare the external functions we use; they are in obstack.c. */ -extern void _obstack_newchunk (struct obstack *, int); +extern void _obstack_newchunk (struct obstack *, PTR_INT_TYPE); extern int _obstack_begin (struct obstack *, int, int, - void *(*) (long), void (*) (void *)); + void *(*) (PTR_INT_TYPE), void (*) (void *)); extern int _obstack_begin_1 (struct obstack *, int, int, - void *(*) (void *, long), + void *(*) (void *, PTR_INT_TYPE), void (*) (void *, void *), void *); -extern int _obstack_memory_used (struct obstack *); +extern PTR_INT_TYPE _obstack_memory_used (struct obstack *); void obstack_free (struct obstack *obstack, void *block); @@ -220,26 +219,26 @@ extern int obstack_exit_failure; /* To prevent prototype warnings provide complete argument list. */ #define obstack_init(h) \ _obstack_begin ((h), 0, 0, \ - (void *(*) (long)) obstack_chunk_alloc, \ + (void *(*) (PTR_INT_TYPE)) obstack_chunk_alloc, \ (void (*) (void *)) obstack_chunk_free) #define obstack_begin(h, size) \ _obstack_begin ((h), (size), 0, \ - (void *(*) (long)) obstack_chunk_alloc, \ + (void *(*) (PTR_INT_TYPE)) obstack_chunk_alloc, \ (void (*) (void *)) obstack_chunk_free) #define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \ _obstack_begin ((h), (size), (alignment), \ - (void *(*) (long)) (chunkfun), \ + (void *(*) (PTR_INT_TYPE)) (chunkfun), \ (void (*) (void *)) (freefun)) #define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \ _obstack_begin_1 ((h), (size), (alignment), \ - (void *(*) (void *, long)) (chunkfun), \ + (void *(*) (void *, PTR_INT_TYPE)) (chunkfun), \ (void (*) (void *, void *)) (freefun), (arg)) #define obstack_chunkfun(h, newchunkfun) \ - ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun)) + ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, PTR_INT_TYPE)) (newchunkfun)) #define obstack_freefun(h, newfreefun) \ ((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun)) @@ -496,14 +495,20 @@ __extension__ \ ( (h)->temp.tempint = (char *) (obj) - (char *) (h)->chunk, \ ((((h)->temp.tempint > 0 \ && (h)->temp.tempint < (h)->chunk_limit - (char *) (h)->chunk)) \ - ? (int) ((h)->next_free = (h)->object_base \ + ? (PTR_INT_TYPE) ((h)->next_free = (h)->object_base \ = (h)->temp.tempint + (char *) (h)->chunk) \ : (((obstack_free) ((h), (h)->temp.tempint + (char *) (h)->chunk), 0), 0))) #endif /* not __GNUC__ or not __STDC__ */ -#ifdef __cplusplus -} /* C++ */ -#endif +/** prints formated string (printf-style format) to an obstack. + * This is done by "growing" the obstack with the obstack_*grow* + * functions. Note: Does NOT append a null-byte. */ +int obstack_printf(struct obstack *obst, const char *fmt, ...) + FIRM_NOTHROW FIRM_PRINTF(2, 3); +int obstack_vprintf(struct obstack *obst, const char *fmt, va_list ap) + FIRM_NOTHROW FIRM_PRINTF(2, 0); + +#include "../end.h" -#endif /* obstack.h */ +#endif