From 56f33205c9ed776c3c909e07d52e94610a675740 Mon Sep 17 00:00:00 2001 From: Jonathan Adams Date: Tue, 12 Jan 2010 17:06:34 -0800 Subject: 4517853 debug.h should include macros to assert implication and equivalence 6915090 struct memlist should have ml_ member prefixes --- usr/src/uts/common/sys/debug.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'usr/src/uts/common/sys/debug.h') diff --git a/usr/src/uts/common/sys/debug.h b/usr/src/uts/common/sys/debug.h index 7c12ecab01..4de39d255e 100644 --- a/usr/src/uts/common/sys/debug.h +++ b/usr/src/uts/common/sys/debug.h @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -73,6 +73,25 @@ extern int assfail(); #define ASSERT32(x) ASSERT(x) #endif +/* + * IMPLY and EQUIV are assertions of the form: + * + * if (a) then (b) + * and + * if (a) then (b) *AND* if (b) then (a) + */ +#if DEBUG +#define IMPLY(A, B) \ + ((void)(((!(A)) || (B)) || \ + assfail("(" #A ") implies (" #B ")", __FILE__, __LINE__))) +#define EQUIV(A, B) \ + ((void)((!!(A) == !!(B)) || \ + assfail("(" #A ") is equivalent to (" #B ")", __FILE__, __LINE__))) +#else +#define IMPLY(A, B) ((void)0) +#define EQUIV(A, B) ((void)0) +#endif + /* * ASSERT3() behaves like ASSERT() except that it is an explicit conditional, * and prints out the values of the left and right hand expressions as part of -- cgit v1.2.3