From d429b03d85eee5652a8a3a1c093489a55cf9458d Mon Sep 17 00:00:00 2001 From: behlendo Date: Thu, 27 Mar 2008 22:06:59 +0000 Subject: [PATCH] - Thinko fix to the SPL module interface - Enhanse the VERIFY() support to output the values which failed to compare as expected before crashing. This make debugging much much much easier. git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@55 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c --- include/sys/sunddi.h | 2 +- include/sys/sysmacros.h | 25 ++++++++++++++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/include/sys/sunddi.h b/include/sys/sunddi.h index 888b844518b3..59f98061a18f 100644 --- a/include/sys/sunddi.h +++ b/include/sys/sunddi.h @@ -161,7 +161,7 @@ static __inline__ void ddi_prop_remove_all(dev_info_t *dip) { } static __inline__ major_t ddi_driver_major(dev_info_t *di) { - return getminor(di->di_dev); + return getmajor(di->di_dev); } static __inline__ int diff --git a/include/sys/sysmacros.h b/include/sys/sysmacros.h index 83e421b6a33a..a64950d10aa0 100644 --- a/include/sys/sysmacros.h +++ b/include/sys/sysmacros.h @@ -76,20 +76,23 @@ extern "C" { #define ASSERT(x) BUG_ON(!(x)) #define VERIFY(x) ASSERT(x) -#define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE) do { \ - const TYPE __left = (TYPE)(LEFT); \ - const TYPE __right = (TYPE)(RIGHT); \ - if (!(__left OP __right)) \ - BUG(); \ +#define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE, FMT, CAST) do { \ + const TYPE __left = (TYPE)(LEFT); \ + const TYPE __right = (TYPE)(RIGHT); \ + if (!(__left OP __right)) { \ + printk("Failed VERIFY3(" FMT " " #OP " " FMT ")\n", \ + CAST __left, CAST __right); \ + BUG(); \ + } \ } while (0) -#define VERIFY3S(x, y, z) VERIFY3_IMPL(x, y, z, int64_t) -#define VERIFY3U(x, y, z) VERIFY3_IMPL(x, y, z, uint64_t) -#define VERIFY3P(x, y, z) VERIFY3_IMPL(x, y, z, uintptr_t) +#define VERIFY3S(x, y, z) VERIFY3_IMPL(x, y, z, int64_t, "%ld", (long)) +#define VERIFY3U(x, y, z) VERIFY3_IMPL(x, y, z, uint64_t, "%lu", (unsigned long)) +#define VERIFY3P(x, y, z) VERIFY3_IMPL(x, y, z, uintptr_t, "%p", (void *)) -#define ASSERT3S(x, y, z) VERIFY3S(x, y, z) -#define ASSERT3U(x, y, z) VERIFY3U(x, y, z) -#define ASSERT3P(x, y, z) VERIFY3P(x, y, z) +#define ASSERT3S(x, y, z) VERIFY3S(x, y, z) +#define ASSERT3U(x, y, z) VERIFY3U(x, y, z) +#define ASSERT3P(x, y, z) VERIFY3P(x, y, z) /* Dtrace probes do not exist in the linux kernel */