From 26318fe16192e8dc1241fc8f1a1f2b42d4b29d37 Mon Sep 17 00:00:00 2001 From: he Date: Thu, 2 Jun 2005 14:31:38 +0000 Subject: [PATCH] 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. --- sys/sys/cdefs.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index 7f64aa41f1b7..881b40051974 100644 --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -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 @@ -146,6 +146,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".