diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2010-04-30 20:09:36 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2010-04-30 20:09:36 +0000 |
commit | b7df20ae5e79ff938a2f57f6f53d14145e8c783a (patch) | |
tree | b9d21e83569111a3324f7dbbaed2164d8599034e | |
parent | a99a5d1a5c782b5ab02f111cdc35000f3df4b3e2 (diff) |
Add __unused and __used macros that expand to appropriate __attribute__
expressions depending on the GCC version in use. Use __unused to supress
warnings from GCC's -Wunused options, and use __used to prevent code from
being optimized away. From NetBSD.
ok tedu@, marco@
-rw-r--r-- | sys/sys/cdefs.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index 81bf7ab694f..d4f6a4cc655 100644 --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cdefs.h,v 1.28 2009/01/14 21:26:48 guenther Exp $ */ +/* $OpenBSD: cdefs.h,v 1.29 2010/04/30 20:09:35 kettenis Exp $ */ /* $NetBSD: cdefs.h,v 1.16 1996/04/03 20:46:39 christos Exp $ */ /* @@ -129,6 +129,18 @@ #define __pure __attribute__((__const__)) #endif +#if __GNUC_PREREQ__(2, 7) +#define __unused __attribute__((__unused__)) +#else +#define __unused /* delete */ +#endif + +#if __GNUC_PREREQ__(3, 1) +#define __used __attribute__((__used__)) +#else +#define __used __unused /* suppress -Wunused warnings */ +#endif + /* * GNU C version 2.96 adds explicit branch prediction so that * the CPU back-end can hint the processor and also so that |