aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2016-06-12 10:31:25 -0700
committerPaul Eggert2016-06-12 10:33:52 -0700
commitab182c624868fcc0ed97597db669911099d4bd28 (patch)
treee9daecdac6ee59ab21768ed529cfdf6890d96122 /src
parent37f8a470d068c7dbb77fa515f09a9153b59aad35 (diff)
downloademacs-ab182c624868fcc0ed97597db669911099d4bd28.tar.gz
emacs-ab182c624868fcc0ed97597db669911099d4bd28.zip
New macro GNUC_PREREQ for GCC version
* src/conf_post.h (GNUC_PREREQ): New macro. Change uses of __GNUC_MINOR__ and __GNUC_PATCHLEVEL__ to use this macro instead, for clarity and consistency. (PRINTF_ARCHETYPE): New macro. Define it to __gnu_printf__ only if glibc, since non-GNU platforms don’t necessarily support GNU printf formats. (ATTRIBUTE_FORMAT_PRINTF): Use it.
Diffstat (limited to 'src')
-rw-r--r--src/bytecode.c4
-rw-r--r--src/conf_post.h49
-rw-r--r--src/emacsgtkfixed.c2
-rw-r--r--src/frame.h2
-rw-r--r--src/gmalloc.c2
-rw-r--r--src/lisp.h7
-rw-r--r--src/process.c4
7 files changed, 37 insertions, 33 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index fb9f617b514..c9e4a25dfa6 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -637,7 +637,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
637 the table clearer. */ 637 the table clearer. */
638#define LABEL(OP) [OP] = &&insn_ ## OP 638#define LABEL(OP) [OP] = &&insn_ ## OP
639 639
640#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) 640#if GNUC_PREREQ (4, 6, 0)
641# pragma GCC diagnostic push 641# pragma GCC diagnostic push
642# pragma GCC diagnostic ignored "-Woverride-init" 642# pragma GCC diagnostic ignored "-Woverride-init"
643#elif defined __clang__ 643#elif defined __clang__
@@ -656,7 +656,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
656#undef DEFINE 656#undef DEFINE
657 }; 657 };
658 658
659#if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) || defined __clang__ 659#if GNUC_PREREQ (4, 6, 0) || defined __clang__
660# pragma GCC diagnostic pop 660# pragma GCC diagnostic pop
661#endif 661#endif
662 662
diff --git a/src/conf_post.h b/src/conf_post.h
index e21e73eb99f..4459caf3f99 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -34,6 +34,17 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
34 34
35#include <stdbool.h> 35#include <stdbool.h>
36 36
37/* GNUC_PREREQ (V, W, X) is true if this is GNU C version V.W.X or later.
38 It can be used in a preprocessor expression. */
39#ifndef __GNUC_MINOR__
40# define GNUC_PREREQ(v, w, x) false
41#elif ! defined __GNUC_PATCHLEVEL__
42# define GNUC_PREREQ(v, w, x) ((v) < __GNUC__ + ((w) <= __GNUC_MINOR__))
43#else
44# define GNUC_PREREQ(v, w, x) \
45 ((v) < __GNUC__ + ((w) <= __GNUC_MINOR__ + ((x) <= __GNUC_PATCHLEVEL__)))
46#endif
47
37/* The type of bool bitfields. Needed to compile Objective-C with 48/* The type of bool bitfields. Needed to compile Objective-C with
38 standard GCC. It was also needed to port to pre-C99 compilers, 49 standard GCC. It was also needed to port to pre-C99 compilers,
39 although we don't care about that any more. */ 50 although we don't care about that any more. */
@@ -55,13 +66,11 @@ typedef bool bool_bf;
55 on arguments like alloc_size that are handled in this simulation. */ 66 on arguments like alloc_size that are handled in this simulation. */
56#ifndef __has_attribute 67#ifndef __has_attribute
57# define __has_attribute(a) __has_attribute_##a 68# define __has_attribute(a) __has_attribute_##a
58# define __has_attribute_alloc_size (4 < __GNUC__ + (3 <= __GNUC_MINOR__)) 69# define __has_attribute_alloc_size GNUC_PREREQ (4, 3, 0)
59# define __has_attribute_cleanup (3 < __GNUC__ + (4 <= __GNUC_MINOR__)) 70# define __has_attribute_cleanup GNUC_PREREQ (3, 4, 0)
60# define __has_attribute_externally_visible \ 71# define __has_attribute_externally_visible GNUC_PREREQ (4, 1, 0)
61 (4 < __GNUC__ + (1 <= __GNUC_MINOR__))
62# define __has_attribute_no_address_safety_analysis false 72# define __has_attribute_no_address_safety_analysis false
63# define __has_attribute_no_sanitize_address \ 73# define __has_attribute_no_sanitize_address GNUC_PREREQ (4, 8, 0)
64 (4 < __GNUC__ + (8 <= __GNUC_MINOR__))
65#endif 74#endif
66 75
67/* Simulate __has_builtin on compilers that lack it. It is used only 76/* Simulate __has_builtin on compilers that lack it. It is used only
@@ -69,8 +78,7 @@ typedef bool bool_bf;
69 simulation. */ 78 simulation. */
70#ifndef __has_builtin 79#ifndef __has_builtin
71# define __has_builtin(a) __has_builtin_##a 80# define __has_builtin(a) __has_builtin_##a
72# define __has_builtin___builtin_assume_aligned \ 81# define __has_builtin___builtin_assume_aligned GNUC_PREREQ (4, 7, 0)
73 (4 < __GNUC__ + (7 <= __GNUC_MINOR__))
74#endif 82#endif
75 83
76/* Simulate __has_feature on compilers that lack it. It is used only 84/* Simulate __has_feature on compilers that lack it. It is used only
@@ -245,24 +253,21 @@ extern int emacs_setenv_TZ (char const *);
245#define EXTERNALLY_VISIBLE 253#define EXTERNALLY_VISIBLE
246#endif 254#endif
247 255
248#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7) 256#if GNUC_PREREQ (2, 7, 0)
249# define ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) 257# define ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec))
250#else 258#else
251# define ATTRIBUTE_FORMAT(spec) /* empty */ 259# define ATTRIBUTE_FORMAT(spec) /* empty */
252#endif 260#endif
253 261
254#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) 262#if GNUC_PREREQ (4, 4, 0) && defined __GLIBC_MINOR__
255# ifdef __MINGW32__ 263# define PRINTF_ARCHETYPE __gnu_printf__
256# define ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \ 264#elif GNUC_PREREQ (4, 4, 0) && defined __MINGW32__
257 ATTRIBUTE_FORMAT ((__ms_printf__, formatstring_parameter, first_argument)) 265# define PRINTF_ARCHETYPE __ms_printf__
258#else /* !__MINGW32__ */ 266#else
259# define ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \ 267# define PRINTF_ARCHETYPE __printf__
260 ATTRIBUTE_FORMAT ((__gnu_printf__, formatstring_parameter, first_argument)) 268#endif
261#endif /* !__MINGW32__ */ 269#define ATTRIBUTE_FORMAT_PRINTF(string_index, first_to_check) \
262#else /* __GNUC__ < 4.4 */ 270 ATTRIBUTE_FORMAT ((PRINTF_ARCHETYPE, string_index, first_to_check))
263# define ATTRIBUTE_FORMAT_PRINTF(formatstring_parameter, first_argument) \
264 ATTRIBUTE_FORMAT ((__printf__, formatstring_parameter, first_argument))
265#endif /* __GNUC__ < 4.4 */
266 271
267#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST 272#define ATTRIBUTE_CONST _GL_ATTRIBUTE_CONST
268#define ATTRIBUTE_UNUSED _GL_UNUSED 273#define ATTRIBUTE_UNUSED _GL_UNUSED
@@ -286,7 +291,7 @@ extern int emacs_setenv_TZ (char const *);
286 no_sanitize_address attribute. This bug is fixed in GCC 4.9.0 and 291 no_sanitize_address attribute. This bug is fixed in GCC 4.9.0 and
287 clang 3.4. */ 292 clang 3.4. */
288#if (! ADDRESS_SANITIZER \ 293#if (! ADDRESS_SANITIZER \
289 || ((4 < __GNUC__ + (9 <= __GNUC_MINOR__)) \ 294 || (GNUC_PREREQ (4, 9, 0) \
290 || 3 < __clang_major__ + (4 <= __clang_minor__))) 295 || 3 < __clang_major__ + (4 <= __clang_minor__)))
291# define ADDRESS_SANITIZER_WORKAROUND /* No workaround needed. */ 296# define ADDRESS_SANITIZER_WORKAROUND /* No workaround needed. */
292#else 297#else
diff --git a/src/emacsgtkfixed.c b/src/emacsgtkfixed.c
index ca0bbfbb866..c04adf28b36 100644
--- a/src/emacsgtkfixed.c
+++ b/src/emacsgtkfixed.c
@@ -27,7 +27,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
27#include "emacsgtkfixed.h" 27#include "emacsgtkfixed.h"
28 28
29/* Silence a bogus diagnostic; see GNOME bug 683906. */ 29/* Silence a bogus diagnostic; see GNOME bug 683906. */
30#if 4 < __GNUC__ + (7 <= __GNUC_MINOR__) && ! GLIB_CHECK_VERSION (2, 35, 7) 30#if GNUC_PREREQ (4, 7, 0) && ! GLIB_CHECK_VERSION (2, 35, 7)
31# pragma GCC diagnostic push 31# pragma GCC diagnostic push
32# pragma GCC diagnostic ignored "-Wunused-local-typedefs" 32# pragma GCC diagnostic ignored "-Wunused-local-typedefs"
33#endif 33#endif
diff --git a/src/frame.h b/src/frame.h
index 9de672c8635..7d64e00b422 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -1470,7 +1470,7 @@ INLINE_HEADER_END
1470/* Suppress -Wsuggest-attribute=const if there are no scroll bars. 1470/* Suppress -Wsuggest-attribute=const if there are no scroll bars.
1471 This is for functions like x_set_horizontal_scroll_bars that have 1471 This is for functions like x_set_horizontal_scroll_bars that have
1472 no effect in this case. */ 1472 no effect in this case. */
1473#if ! USE_HORIZONTAL_SCROLL_BARS && 4 < __GNUC__ + (6 <= __GNUC_MINOR__) 1473#if ! USE_HORIZONTAL_SCROLL_BARS && GNUC_PREREQ (4, 6, 0)
1474# pragma GCC diagnostic ignored "-Wsuggest-attribute=const" 1474# pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
1475#endif 1475#endif
1476 1476
diff --git a/src/gmalloc.c b/src/gmalloc.c
index d795c13f616..483d05c5c61 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -44,7 +44,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
44#endif 44#endif
45 45
46#ifdef HAVE_MALLOC_H 46#ifdef HAVE_MALLOC_H
47# if 4 < __GNUC__ + (2 <= __GNUC_MINOR__) 47# if GNUC_PREREQ (4, 2, 0)
48# pragma GCC diagnostic ignored "-Wdeprecated-declarations" 48# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
49# endif 49# endif
50# include <malloc.h> 50# include <malloc.h>
diff --git a/src/lisp.h b/src/lisp.h
index a0d0610a186..972ca335115 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4172,8 +4172,8 @@ extern void kill_buffer_processes (Lisp_Object);
4172extern int wait_reading_process_output (intmax_t, int, int, bool, Lisp_Object, 4172extern int wait_reading_process_output (intmax_t, int, int, bool, Lisp_Object,
4173 struct Lisp_Process *, int); 4173 struct Lisp_Process *, int);
4174/* Max value for the first argument of wait_reading_process_output. */ 4174/* Max value for the first argument of wait_reading_process_output. */
4175#if __GNUC__ == 3 || (__GNUC__ == 4 && __GNUC_MINOR__ <= 5) 4175#if GNUC_PREREQ (3, 0, 0) && ! GNUC_PREREQ (4, 6, 0)
4176/* Work around a bug in GCC 3.4.2, known to be fixed in GCC 4.6.3. 4176/* Work around a bug in GCC 3.4.2, known to be fixed in GCC 4.6.0.
4177 The bug merely causes a bogus warning, but the warning is annoying. */ 4177 The bug merely causes a bogus warning, but the warning is annoying. */
4178# define WAIT_READING_MAX min (TYPE_MAXIMUM (time_t), INTMAX_MAX) 4178# define WAIT_READING_MAX min (TYPE_MAXIMUM (time_t), INTMAX_MAX)
4179#else 4179#else
@@ -4546,8 +4546,7 @@ extern void *record_xmalloc (size_t) ATTRIBUTE_ALLOC_SIZE ((1));
4546 Build with CPPFLAGS='-DUSE_STACK_LISP_OBJECTS=0' to disable it. */ 4546 Build with CPPFLAGS='-DUSE_STACK_LISP_OBJECTS=0' to disable it. */
4547 4547
4548#if (!defined USE_STACK_LISP_OBJECTS \ 4548#if (!defined USE_STACK_LISP_OBJECTS \
4549 && defined __GNUC__ && !defined __clang__ \ 4549 && defined __GNUC__ && !defined __clang__ && ! GNUC_PREREQ (4, 3, 2))
4550 && !(4 < __GNUC__ + (3 < __GNUC_MINOR__ + (2 <= __GNUC_PATCHLEVEL__))))
4551 /* Work around GCC bugs 36584 and 35271, which were fixed in GCC 4.3.2. */ 4550 /* Work around GCC bugs 36584 and 35271, which were fixed in GCC 4.3.2. */
4552# define USE_STACK_LISP_OBJECTS false 4551# define USE_STACK_LISP_OBJECTS false
4553#endif 4552#endif
diff --git a/src/process.c b/src/process.c
index 4d287d8cc51..e669278f6e3 100644
--- a/src/process.c
+++ b/src/process.c
@@ -130,10 +130,10 @@ extern int sys_select (int, fd_set *, fd_set *, fd_set *,
130 struct timespec *, void *); 130 struct timespec *, void *);
131#endif 131#endif
132 132
133/* Work around GCC 4.7.0 bug with strict overflow checking; see 133/* Work around GCC 4.3.0 bug with strict overflow checking; see
134 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>. 134 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>.
135 This bug appears to be fixed in GCC 5.1, so don't work around it there. */ 135 This bug appears to be fixed in GCC 5.1, so don't work around it there. */
136#if __GNUC__ == 4 && __GNUC_MINOR__ >= 3 136#if GNUC_PREREQ (4, 3, 0) && ! GNUC_PREREQ (5, 1, 0)
137# pragma GCC diagnostic ignored "-Wstrict-overflow" 137# pragma GCC diagnostic ignored "-Wstrict-overflow"
138#endif 138#endif
139 139