From a535608cfd95c419d02f9956a4361a81095eaad3 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Thu, 11 Sep 2008 00:35:49 +0000 Subject: [PATCH] Improve code flow for KASSERT and KKASSERT using __predict_false(). Fix a bug in KKASSERT related to the use of an else clause after the KKASSERT. --- sys/sys/systm.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sys/sys/systm.h b/sys/sys/systm.h index f9501fb1df..1c27ef2785 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -37,7 +37,7 @@ * * @(#)systm.h 8.7 (Berkeley) 3/29/95 * $FreeBSD: src/sys/sys/systm.h,v 1.111.2.18 2002/12/17 18:04:02 sam Exp $ - * $DragonFly: src/sys/sys/systm.h,v 1.80 2008/07/23 17:22:33 dillon Exp $ + * $DragonFly: src/sys/sys/systm.h,v 1.81 2008/09/11 00:35:49 dillon Exp $ */ #ifndef _SYS_SYSTM_H_ @@ -103,8 +103,11 @@ extern int nfs_diskless_valid; /* NFS diskless params were obtained */ extern vm_paddr_t Maxmem; /* Highest physical memory address in system */ #ifdef INVARIANTS /* The option is always available */ -#define KASSERT(exp,msg) do { if (!(exp)) panic msg; } while (0) -#define KKASSERT(exp) if (!(exp)) panic("assertion: %s in %s", #exp, __func__) +#define KASSERT(exp,msg) do { if (__predict_false(!(exp))) \ + panic msg; } while (0) +#define KKASSERT(exp) do { if (__predict_false(!(exp))) \ + panic("assertion: %s in %s", \ + #exp, __func__); } while (0) #else #define KASSERT(exp,msg) #define KKASSERT(exp) -- 2.11.4.GIT