修訂 | e9f40d7d68ecc03c8c32ec0acd07c35359fdb4a3 (tree) |
---|---|
時間 | 2015-11-09 13:48:35 |
作者 | Alan Modra <amodra@gmai...> |
Commiter | Alan Modra |
Modify obstack.[hc] to avoid having to include other gnulib files
Using the standard gnulib obstack source requires importing quite a
lot of other files from gnulib, and requires build changes.
include/
PR gdb/17133
* obstack.h (attribute_pure): Expand _GL_ATTRIBUTE_PURE.
libiberty/
PR gdb/17133
* obstack.c (alignof): Expand alignof_type from alignof.h.
(obstack_exit_failure): Don't use exitfail.h.
(_): Include libintl.h when HAVE_LIBINTL_H and nls enabled.
Provide default. Don't include gettext.h.
(_Noreturn): Define.
* obstacks.texi: Adjust node references to external libc info files.
@@ -1,6 +1,11 @@ | ||
1 | 1 | 2015-11-09 Alan Modra <amodra@gmail.com> |
2 | 2 | |
3 | 3 | PR gdb/17133 |
4 | + * obstack.h (__attribute_pure__): Expand _GL_ATTRIBUTE_PURE. | |
5 | + | |
6 | +2015-11-09 Alan Modra <amodra@gmail.com> | |
7 | + | |
8 | + PR gdb/17133 | |
4 | 9 | * obstack.h: Import current gnulib file. |
5 | 10 | |
6 | 11 | 2015-10-22 H.J. Lu <hongjiu.lu@intel.com> |
@@ -142,7 +142,11 @@ | ||
142 | 142 | P, A) |
143 | 143 | |
144 | 144 | #ifndef __attribute_pure__ |
145 | -# define __attribute_pure__ _GL_ATTRIBUTE_PURE | |
145 | +# if defined __GNUC_MINOR__ && __GNUC__ * 1000 + __GNUC_MINOR__ >= 2096 | |
146 | +# define __attribute_pure__ __attribute__ ((__pure__)) | |
147 | +# else | |
148 | +# define __attribute_pure__ | |
149 | +# endif | |
146 | 150 | #endif |
147 | 151 | |
148 | 152 | #ifdef __cplusplus |
@@ -1,6 +1,16 @@ | ||
1 | 1 | 2015-11-09 Alan Modra <amodra@gmail.com> |
2 | 2 | |
3 | 3 | PR gdb/17133 |
4 | + * obstack.c (__alignof__): Expand alignof_type from alignof.h. | |
5 | + (obstack_exit_failure): Don't use exitfail.h. | |
6 | + (_): Include libintl.h when HAVE_LIBINTL_H and nls enabled. | |
7 | + Provide default. Don't include gettext.h. | |
8 | + (_Noreturn): Define. | |
9 | + * obstacks.texi: Adjust node references to external libc info files. | |
10 | + | |
11 | +2015-11-09 Alan Modra <amodra@gmail.com> | |
12 | + | |
13 | + PR gdb/17133 | |
4 | 14 | * obstack.c: Import current gnulib file. |
5 | 15 | * obstacks.texi: Updated doc, from glibc's manual/memory.texi. |
6 | 16 |
@@ -51,9 +51,14 @@ | ||
51 | 51 | /* If GCC, or if an oddball (testing?) host that #defines __alignof__, |
52 | 52 | use the already-supplied __alignof__. Otherwise, this must be Gnulib |
53 | 53 | (as glibc assumes GCC); defer to Gnulib's alignof_type. */ |
54 | -# if !defined __GNUC__ && !defined __alignof__ | |
55 | -# include <alignof.h> | |
56 | -# define __alignof__(type) alignof_type (type) | |
54 | +# if !defined __GNUC__ && !defined __IBM__ALIGNOF__ && !defined __alignof__ | |
55 | +# if defined __cplusplus | |
56 | +template <class type> struct alignof_helper { char __slot1; type __slot2; }; | |
57 | +# define __alignof__(type) offsetof (alignof_helper<type>, __slot2) | |
58 | +# else | |
59 | +# define __alignof__(type) \ | |
60 | + offsetof (struct { char __slot1; type __slot2; }, __slot2) | |
61 | +# endif | |
57 | 62 | # endif |
58 | 63 | # include <stdlib.h> |
59 | 64 | # include <stdint.h> |
@@ -309,17 +314,34 @@ _obstack_memory_used (struct obstack *h) | ||
309 | 314 | # ifdef _LIBC |
310 | 315 | int obstack_exit_failure = EXIT_FAILURE; |
311 | 316 | # else |
312 | -# include "exitfail.h" | |
313 | -# define obstack_exit_failure exit_failure | |
317 | +# ifndef EXIT_FAILURE | |
318 | +# define EXIT_FAILURE 1 | |
319 | +# endif | |
320 | +# define obstack_exit_failure EXIT_FAILURE | |
314 | 321 | # endif |
315 | 322 | |
316 | -# ifdef _LIBC | |
323 | +# if defined _LIBC || (HAVE_LIBINTL_H && ENABLE_NLS) | |
317 | 324 | # include <libintl.h> |
325 | +# ifndef _ | |
326 | +# define _(msgid) gettext (msgid) | |
327 | +# endif | |
318 | 328 | # else |
319 | -# include "gettext.h" | |
329 | +# ifndef _ | |
330 | +# define _(msgid) (msgid) | |
331 | +# endif | |
320 | 332 | # endif |
321 | -# ifndef _ | |
322 | -# define _(msgid) gettext (msgid) | |
333 | + | |
334 | +# if !(defined _Noreturn \ | |
335 | + || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112)) | |
336 | +# if ((defined __GNUC__ \ | |
337 | + && (__GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))) \ | |
338 | + || (defined __SUNPRO_C && __SUNPRO_C >= 0x5110)) | |
339 | +# define _Noreturn __attribute__ ((__noreturn__)) | |
340 | +# elif defined _MSC_VER && _MSC_VER >= 1200 | |
341 | +# define _Noreturn __declspec (noreturn) | |
342 | +# else | |
343 | +# define _Noreturn | |
344 | +# endif | |
323 | 345 | # endif |
324 | 346 | |
325 | 347 | # ifdef _LIBC |
@@ -93,7 +93,7 @@ them are freed. These macros should appear before any use of obstacks | ||
93 | 93 | in the source file. |
94 | 94 | |
95 | 95 | Usually these are defined to use @code{malloc} via the intermediary |
96 | -@code{xmalloc} (@pxref{Unconstrained Allocation}). This is done with | |
96 | +@code{xmalloc} (@pxref{Unconstrained Allocation, , , libc, The GNU C Library Reference Manual}). This is done with | |
97 | 97 | the following pair of macro definitions: |
98 | 98 | |
99 | 99 | @smallexample |
@@ -172,8 +172,8 @@ The value of this variable is a pointer to a function that | ||
172 | 172 | @code{obstack} uses when @code{obstack_chunk_alloc} fails to allocate |
173 | 173 | memory. The default action is to print a message and abort. |
174 | 174 | You should supply a function that either calls @code{exit} |
175 | -(@pxref{Program Termination}) or @code{longjmp} (@pxref{Non-Local | |
176 | -Exits}) and doesn't return. | |
175 | +(@pxref{Program Termination, , , libc, The GNU C Library Reference Manual}) or @code{longjmp} (@pxref{Non-Local | |
176 | +Exits, , , libc, The GNU C Library Reference Manual}) and doesn't return. | |
177 | 177 | |
178 | 178 | @smallexample |
179 | 179 | void my_obstack_alloc_failed (void) |
@@ -253,7 +253,7 @@ obstack_savestring (char *addr, size_t size) | ||
253 | 253 | |
254 | 254 | @noindent |
255 | 255 | Contrast this with the previous example of @code{savestring} using |
256 | -@code{malloc} (@pxref{Basic Allocation}). | |
256 | +@code{malloc} (@pxref{Basic Allocation, , , libc, The GNU C Library Reference Manual}). | |
257 | 257 | |
258 | 258 | @node Freeing Obstack Objects |
259 | 259 | @subsubsection Freeing Objects in an Obstack |