bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: __GNUC_PREREQ


From: Eric Blake
Subject: Re: __GNUC_PREREQ
Date: Thu, 28 Jan 2010 06:55:02 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666

According to Jim Meyering on 1/28/2010 6:45 AM:
>>> It looks like several other files have a sane definition, such as fts_.h.
>> For that matter, would it make sense to have a gnulib module that
>> guarantees that __GNUC_PREREQ is defined in <config.h>, and then convert
>> various other modules to use it rather than open-coding their __GNUC__
>> version checks?  On the other hand, modules like string (lib/string.in.h)
>> still have to open-code their checks, since the point of replacement
>> headers is that they can be installed without <config.h>.
> 
> Good idea.
> I do see some value in factoring out the duplication (there are
> currently 4, and we need a 5th), even if we have to leave a copy
> or two open-coded for string.h.

For now, I'm just committing this to fix compilation, but when I get more
time, I'll try and do the factorization of creating a gnuc-prereq module.

$ git grep '__GNUC__ [<=>]' lib

shows that at least these files could benefit:

alloca.c
argp-fmtstream.h
argp.h
c-stack.c
count-one-bits.h
eealloc.h
error.h
fnmatch.c
fts_.h
gettext.h
gl_anytreehash_list1.h
gl_list.h
gl_oset.h
glob-libc.h
glob.c
hash.h
intprops.h
inttostr.h
isnand-nolibm.h
isnanf-nolibm.h
isnanl-nolibm.h
md4.c
md5.h
obstack.c
obstack.h
openat.h
pagealign_alloc.h
poll.c
regex_internal.h
safe-alloc.h
scandir.c
sigpipe-die.h
strptime.c
strtol.c
uniname/uninames.h
vasnprintf.h
xalloc.h
xmemdup0.h
xprintf.h
xsize.h
xstrtol.h
xvasprintf.h

-- 
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
From e296359d39962cfd1f8b15877ada83d95878fdd7 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 28 Jan 2010 06:46:05 -0700
Subject: [PATCH] regex: fix build failure

* lib/regex_internal.h (__GNUC_PREREQ): Define for non-glibc
platforms.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog            |    6 ++++++
 lib/regex_internal.h |    9 +++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c3cb300..3843078 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-01-28  Eric Blake  <address@hidden>
+
+       regex: fix build failure
+       * lib/regex_internal.h (__GNUC_PREREQ): Define for non-glibc
+       platforms.
+
 2010-01-28  Jim Meyering  <address@hidden>

        regex: do not ignore memory allocation failure
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index 704d1cc..e1b4c61 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -851,6 +851,15 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
 }
 #endif /* RE_ENABLE_I18N */

+#ifndef __GNUC_PREREQ
+# if defined __GNUC__ && defined __GNUC_MINOR__
+#  define __GNUC_PREREQ(maj, min) \
+         ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+# else
+#  define __GNUC_PREREQ(maj, min) 0
+# endif
+#endif
+
 #if __GNUC_PREREQ (3,4)
 # undef __attribute_warn_unused_result__
 # define __attribute_warn_unused_result__ \
-- 
1.6.4.2

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]