diff options
author | amodra <amodra@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-11-09 04:28:21 +0000 |
---|---|---|
committer | amodra <amodra@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-11-09 04:28:21 +0000 |
commit | d843131446fa32915ceb12049d3606062307a8fe (patch) | |
tree | 682bf1ffda298891ad7163b4f5f8b0e4aadb0a24 /libiberty/obstack.c | |
parent | 1ed1385ecb1c11d6915adac74afa2ff7da8be5d1 (diff) |
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/
* obstack.h (__attribute_pure__): Expand _GL_ATTRIBUTE_PURE.
libiberty/
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229988 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libiberty/obstack.c')
-rw-r--r-- | libiberty/obstack.c | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/libiberty/obstack.c b/libiberty/obstack.c index 3b99dfadef6..9f34da1164b 100644 --- a/libiberty/obstack.c +++ b/libiberty/obstack.c @@ -51,9 +51,14 @@ /* If GCC, or if an oddball (testing?) host that #defines __alignof__, use the already-supplied __alignof__. Otherwise, this must be Gnulib (as glibc assumes GCC); defer to Gnulib's alignof_type. */ -# if !defined __GNUC__ && !defined __alignof__ -# include <alignof.h> -# define __alignof__(type) alignof_type (type) +# if !defined __GNUC__ && !defined __IBM__ALIGNOF__ && !defined __alignof__ +# if defined __cplusplus +template <class type> struct alignof_helper { char __slot1; type __slot2; }; +# define __alignof__(type) offsetof (alignof_helper<type>, __slot2) +# else +# define __alignof__(type) \ + offsetof (struct { char __slot1; type __slot2; }, __slot2) +# endif # endif # include <stdlib.h> # include <stdint.h> @@ -309,17 +314,34 @@ _obstack_memory_used (struct obstack *h) # ifdef _LIBC int obstack_exit_failure = EXIT_FAILURE; # else -# include "exitfail.h" -# define obstack_exit_failure exit_failure +# ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +# endif +# define obstack_exit_failure EXIT_FAILURE # endif -# ifdef _LIBC +# if defined _LIBC || (HAVE_LIBINTL_H && ENABLE_NLS) # include <libintl.h> +# ifndef _ +# define _(msgid) gettext (msgid) +# endif # else -# include "gettext.h" +# ifndef _ +# define _(msgid) (msgid) +# endif # endif -# ifndef _ -# define _(msgid) gettext (msgid) + +# if !(defined _Noreturn \ + || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112)) +# if ((defined __GNUC__ \ + && (__GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))) \ + || (defined __SUNPRO_C && __SUNPRO_C >= 0x5110)) +# define _Noreturn __attribute__ ((__noreturn__)) +# elif defined _MSC_VER && _MSC_VER >= 1200 +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn +# endif # endif # ifdef _LIBC |