Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys Add a new macro, __GNUC_PREREQ__(major, minor) which...
details: https://anonhg.NetBSD.org/src/rev/b4a7152aa784
branches: trunk
changeset: 485765:b4a7152aa784
user: thorpej <thorpej%NetBSD.org@localhost>
date: Fri May 05 00:19:04 2000 +0000
description:
Add a new macro, __GNUC_PREREQ__(major, minor) which tests to see if
the compiler is GCC and at least the version specified by <major,minor>,
and use it in a few appropriate places in this file.
diffstat:
sys/sys/cdefs.h | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
diffs (54 lines):
diff -r 4d437d20ab73 -r b4a7152aa784 sys/sys/cdefs.h
--- a/sys/sys/cdefs.h Thu May 04 21:56:47 2000 +0000
+++ b/sys/sys/cdefs.h Fri May 05 00:19:04 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cdefs.h,v 1.31 2000/02/03 02:20:13 cgd Exp $ */
+/* $NetBSD: cdefs.h,v 1.32 2000/05/05 00:19:04 thorpej Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -41,6 +41,25 @@
#ifndef _SYS_CDEFS_H_
#define _SYS_CDEFS_H_
+/*
+ * Macro to test if we're using a GNU C compiler of a specific vintage
+ * or later, for e.g. features that appeared in a particular version
+ * of GNU C. Usage:
+ *
+ * #if __GNUC_PREREQ__(major, minor)
+ * ...cool feature...
+ * #else
+ * ...delete feature...
+ * #endif
+ */
+#ifdef __GNUC__
+#define __GNUC_PREREQ__(x, y) \
+ ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \
+ (__GNUC__ > (x)))
+#else
+#define __GNUC_PREREQ__(x, y) 0
+#endif
+
#include <machine/cdefs.h>
#ifdef __ELF__
#include <sys/cdefs_elf.h>
@@ -122,7 +141,7 @@
* GCC2 provides __extension__ to suppress warnings for various GNU C
* language extensions under "-ansi -pedantic".
*/
-#if !defined(__GNUC__) || __GNUC__ < 2
+#if !__GNUC_PREREQ__(2, 0)
#define __extension__ /* delete __extension__ if non-gcc or gcc1 */
#endif
@@ -134,8 +153,7 @@
* these work for GNU C++ (modulo a slight glitch in the C++ grammar
* in the distribution version of 2.5.5).
*/
-#if !defined(__GNUC__) || __GNUC__ < 2 || \
- (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
+#if !__GNUC_PREREQ__(2, 5)
#define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
#define __dead __volatile
Home |
Main Index |
Thread Index |
Old Index