Modify obstack.[hc] to avoid having to include other gnulib files
authorAlan Modra <amodra@gmail.com>
Mon, 9 Nov 2015 04:43:51 +0000 (15:13 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 9 Nov 2015 04:48:35 +0000 (15:18 +1030)
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.

include/ChangeLog
include/obstack.h
libiberty/ChangeLog
libiberty/obstack.c
libiberty/obstacks.texi

index e8b5a6e3b86083b6394f54e1aaf7e0b2fd1ffc54..01a25def7a41def4c60bc18013a55295acea59f2 100644 (file)
@@ -1,3 +1,8 @@
+2015-11-09  Alan Modra  <amodra@gmail.com>
+
+       PR gdb/17133
+       * obstack.h (__attribute_pure__): Expand _GL_ATTRIBUTE_PURE.
+
 2015-11-09  Alan Modra  <amodra@gmail.com>
 
        PR gdb/17133
index 0ff33098443053aefb98518ca367d1f217f069ec..0d13c72d056c82cc2e03c4a6d32bfaa63f0ecaf3 100644 (file)
                 P, A)
 
 #ifndef __attribute_pure__
-# define __attribute_pure__ _GL_ATTRIBUTE_PURE
+# if defined __GNUC_MINOR__ && __GNUC__ * 1000 + __GNUC_MINOR__ >= 2096
+#  define __attribute_pure__ __attribute__ ((__pure__))
+# else
+#  define __attribute_pure__
+# endif
 #endif
 
 #ifdef __cplusplus
index f241135e8b37e3042b94986a2461022324fe2efb..05b60d876f90db67ca9463ee09227c0266559421 100644 (file)
@@ -1,3 +1,13 @@
+2015-11-09  Alan Modra  <amodra@gmail.com>
+
+       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.
+
 2015-11-09  Alan Modra  <amodra@gmail.com>
 
        PR gdb/17133
index 3b99dfadef67012940d72f454a1a38727751f064..9f34da1164bd4a6a3331c01eb66b9c9522b48226 100644 (file)
 /* 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
index 1bfc878e7778176a9eaa10e2b9f14f3dded24eaf..b2d2403210bb7de78344ebeb8d8b55e40e31d61d 100644 (file)
@@ -93,7 +93,7 @@ them are freed.  These macros should appear before any use of obstacks
 in the source file.
 
 Usually these are defined to use @code{malloc} via the intermediary
-@code{xmalloc} (@pxref{Unconstrained Allocation}).  This is done with
+@code{xmalloc} (@pxref{Unconstrained Allocation, , , libc, The GNU C Library Reference Manual}).  This is done with
 the following pair of macro definitions:
 
 @smallexample
@@ -172,8 +172,8 @@ The value of this variable is a pointer to a function that
 @code{obstack} uses when @code{obstack_chunk_alloc} fails to allocate
 memory.  The default action is to print a message and abort.
 You should supply a function that either calls @code{exit}
-(@pxref{Program Termination}) or @code{longjmp} (@pxref{Non-Local
-Exits}) and doesn't return.
+(@pxref{Program Termination, , , libc, The GNU C Library Reference Manual}) or @code{longjmp} (@pxref{Non-Local
+Exits, , , libc, The GNU C Library Reference Manual}) and doesn't return.
 
 @smallexample
 void my_obstack_alloc_failed (void)
@@ -253,7 +253,7 @@ obstack_savestring (char *addr, size_t size)
 
 @noindent
 Contrast this with the previous example of @code{savestring} using
-@code{malloc} (@pxref{Basic Allocation}).
+@code{malloc} (@pxref{Basic Allocation, , , libc, The GNU C Library Reference Manual}).
 
 @node Freeing Obstack Objects
 @subsubsection Freeing Objects in an Obstack
This page took 0.030246 seconds and 4 git commands to generate.