From patchwork Sat Jul 26 05:57:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 2188 Received: (qmail 15299 invoked by alias); 26 Jul 2014 05:57:35 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 15174 invoked by uid 89); 26 Jul 2014 05:57:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS, UNWANTED_LANGUAGE_BODY autolearn=ham version=3.3.2 X-HELO: mail-pa0-f47.google.com X-Received: by 10.67.30.130 with SMTP id ke2mr23799911pad.44.1406354250646; Fri, 25 Jul 2014 22:57:30 -0700 (PDT) From: Alan Modra To: bug-gnulib@gnu.org, libc-alpha@sourceware.org Cc: Alan Modra Subject: [PATCH 5/5] obstack usability Date: Sat, 26 Jul 2014 15:27:12 +0930 Message-Id: <1406354233-7664-6-git-send-email-amodra@gmail.com> In-Reply-To: <1406354233-7664-1-git-send-email-amodra@gmail.com> References: <1406354233-7664-1-git-send-email-amodra@gmail.com> When using obstack.h/c in other projects it isn't very nice that gnulib headers like exitfail.h and gettext.h need to be present. Far worse is a dependency on gnulib's version of stdlib.h for __attribute_pure__ and _Noreturn. This only works if a project is willing to import rather a lot of gnulib configury magic, because gnulib's stdlib.h must be modified at configure time. * lib/obstack.h (__attribute_pure__): Don't use _GL_ATTRIBUTE_PURE. * lib/obstack.c (obstack_exit_failure): Don't include exitfail.h. (_): Include libintl.h when HAVE_LIBINTL_H and ENABLE_NLS. Don't include gettext.h. (_Noreturn): Define. --- lib/obstack.c | 29 +++++++++++++++++++++++------ lib/obstack.h | 6 +++++- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/lib/obstack.c b/lib/obstack.c index 1ac0e5d..4101581 100644 --- a/lib/obstack.c +++ b/lib/obstack.c @@ -312,17 +312,34 @@ libc_hidden_def (_obstack2_newchunk) # 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 +# 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__ && 201112 <= __STDC_VERSION__)) +# if ((defined __GNUC__ \ + && (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__))) \ + || (defined __SUNPRO_C && 0x5110 <= __SUNPRO_C)) +# define _Noreturn __attribute__ ((__noreturn__)) +# elif defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn +# endif # endif # ifdef _LIBC diff --git a/lib/obstack.h b/lib/obstack.h index 19a8eb2..b79d4cb 100644 --- a/lib/obstack.h +++ b/lib/obstack.h @@ -188,7 +188,11 @@ #include #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