Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys Add an __UNVOLATILE() macro. It should be used with...
details: https://anonhg.NetBSD.org/src/rev/f3eae6475b54
branches: trunk
changeset: 581548:f3eae6475b54
user: he <he%NetBSD.org@localhost>
date: Thu Jun 02 14:31:38 2005 +0000
description:
Add an __UNVOLATILE() macro. It should be used with caution, but
it is required to use this whenever you want to pass a pointer to
volatile data e.g. to memset(). This allows us to still compile
files doing such things with -Wcast-qual and get the rest of the
code checked under that option.
Based on suggestions from tron and christos.
diffstat:
sys/sys/cdefs.h | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diffs (25 lines):
diff -r 3f49afdb6038 -r f3eae6475b54 sys/sys/cdefs.h
--- a/sys/sys/cdefs.h Thu Jun 02 14:29:02 2005 +0000
+++ b/sys/sys/cdefs.h Thu Jun 02 14:31:38 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cdefs.h,v 1.58 2004/12/11 05:59:00 christos Exp $ */
+/* $NetBSD: cdefs.h,v 1.59 2005/06/02 14:31:38 he Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -147,6 +147,15 @@
#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a))
/*
+ * The following macro is used to remove the volatile cast-away warnings
+ * from gcc -Wcast-qual; as above it should be used with caution
+ * because it can hide valid errors or warnings. Valid uses include
+ * making it possible to pass a volatile pointer to memset().
+ * For the same reasons as above, we use unsigned long and not intptr_t.
+ */
+#define __UNVOLATILE(a) ((void *)(unsigned long)(volatile void *)(a))
+
+/*
* GCC2 provides __extension__ to suppress warnings for various GNU C
* language extensions under "-ansi -pedantic".
*/
Home |
Main Index |
Thread Index |
Old Index