diff options
author | DJ Delorie <dj@redhat.com> | 2004-07-24 18:04:39 +0000 |
---|---|---|
committer | DJ Delorie <dj@redhat.com> | 2004-07-24 18:04:39 +0000 |
commit | d5b4094f381410813c8eaceae0d71f9c11394bf4 (patch) | |
tree | a04cf7c56d4f10dc36881f638f94a35c6999d5e3 /include | |
parent | b4632131601c0c375c1c571b5671fca4176979ae (diff) | |
download | gdb-d5b4094f381410813c8eaceae0d71f9c11394bf4.zip gdb-d5b4094f381410813c8eaceae0d71f9c11394bf4.tar.gz gdb-d5b4094f381410813c8eaceae0d71f9c11394bf4.tar.bz2 |
merge from gcc
Diffstat (limited to 'include')
-rw-r--r-- | include/ChangeLog | 4 | ||||
-rw-r--r-- | include/ansidecl.h | 8 | ||||
-rw-r--r-- | include/libiberty.h | 31 |
3 files changed, 43 insertions, 0 deletions
diff --git a/include/ChangeLog b/include/ChangeLog index 6adbc67..2c53400 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +2004-07-24 Bernardo Innocenti <bernie@develer.com> + + * ansidecl.h (ARG_UNUSED): New Macro. + 2004-07-23 H.J. Lu <hongjiu.lu@intel.com> * bin-bugs.h (REPORT_BUGS_TO): Set to diff --git a/include/ansidecl.h b/include/ansidecl.h index 4b3eae9..ccf0b27 100644 --- a/include/ansidecl.h +++ b/include/ansidecl.h @@ -264,6 +264,14 @@ So instead we use the macro below and test it against specific values. */ #define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) #endif /* ATTRIBUTE_UNUSED */ +/* Before GCC 3.4, the C++ frontend couldn't parse attributes placed after the + identifier name. */ +#if ! defined(__cplusplus) || (GCC_VERSION >= 3004) +# define ARG_UNUSED(NAME) NAME ATTRIBUTE_UNUSED +#else /* !__cplusplus || GNUC >= 3.4 */ +# define ARG_UNUSED(NAME) NAME +#endif /* !__cplusplus || GNUC >= 3.4 */ + #ifndef ATTRIBUTE_NORETURN #define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) #endif /* ATTRIBUTE_NORETURN */ diff --git a/include/libiberty.h b/include/libiberty.h index 5c10153..68eeeae 100644 --- a/include/libiberty.h +++ b/include/libiberty.h @@ -250,6 +250,37 @@ extern PTR xmemdup PARAMS ((const PTR, size_t, size_t)) ATTRIBUTE_MALLOC; extern double physmem_total PARAMS ((void)); extern double physmem_available PARAMS ((void)); + +/* These macros provide a K&R/C89/C++-friendly way of allocating structures + with nice encapsulation. The XDELETE*() macros are technically + superfluous, but provided here for symmetry. Using them consistently + makes it easier to update client code to use different allocators such + as new/delete and new[]/delete[]. */ + +/* Scalar allocators. */ + +#define XNEW(T) ((T *) xmalloc (sizeof (T))) +#define XCNEW(T) ((T *) xcalloc (1, sizeof (T))) +#define XDELETE(P) free ((P)) + +/* Array allocators. */ + +#define XNEWVEC(T, N) ((T *) xmalloc (sizeof (T) * (N))) +#define XCNEWVEC(T, N) ((T *) xcalloc ((N), sizeof (T))) +#define XRESIZEVEC(T, P, N) ((T *) xrealloc ((P), sizeof (T) * (N))) +#define XDELETEVEC(P) free ((P)) + +/* Allocators for variable-sized structures and raw buffers. */ + +#define XNEWVAR(T, S) ((T *) xmalloc ((S))) +#define XCNEWVAR(T, S) ((T *) xcalloc (1, (S))) +#define XRESIZEVAR(T, P, S) ((T *) xrealloc ((P), (S))) + +/* Type-safe obstack allocator. */ + +#define XOBNEW(O, T) ((T *) obstack_alloc ((O), sizeof (T))) + + /* hex character manipulation routines */ #define _hex_array_size 256 |