assert.h revision 495aa273d2da4ac0ad6ad485abd752f29e5ccd1d
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @file
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * IPRT - Assertions.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/*
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Copyright (C) 2006-2007 Sun Microsystems, Inc.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * This file is part of VirtualBox Open Source Edition (OSE), as
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * available from http://www.virtualbox.org. This file is free software;
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * you can redistribute it and/or modify it under the terms of the GNU
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * General Public License (GPL) as published by the Free Software
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Foundation, in version 2 as it comes in the "COPYING" file of the
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * The contents of this file may alternatively be used under the terms
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * of the Common Development and Distribution License Version 1.0
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * VirtualBox OSE distribution, in which case the provisions of the
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * CDDL are applicable instead of those of the GPL.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * You may elect to license modified versions of this file under the
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * terms and conditions of either the GPL or the CDDL or both.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Clara, CA 95054 USA or visit http://www.sun.com if you need
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * additional information or have any questions.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifndef ___iprt_assert_h
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define ___iprt_assert_h
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#include <iprt/cdefs.h>
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#include <iprt/types.h>
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @defgroup grp_rt_assert Assert - Assertions
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @ingroup grp_rt
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assertions are generally used to check precoditions and other
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * assumptions. Sometimes it is also used to catch odd errors or errors
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * that one would like to inspect in the debugger. They should not be
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * used for errors that happen frequently.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * IPRT provides a host of assertion macros, so many that it can be a bit
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * overwhelming at first. Don't despair, there is a system (surprise).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * First there are four families of assertions:
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * - Assert - The normal strict build only assertions.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * - AssertLogRel - Calls LogRel() in non-strict builds, otherwise like Assert.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * - AssertRelease - Triggers in all builds.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * - AssertFatal - Triggers in all builds and cannot be continued.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Then there are variations wrt to argument list and behavior on failure:
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * - Msg - Custom RTStrPrintf-like message with the assertion message.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * - Return - Return the specific rc on failure.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * - ReturnVoid - Return (void) on failure.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * - Break - Break (out of switch/loop) on failure.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * - Stmt - Execute the specified statment(s) on failure.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * - RC - Assert RT_SUCCESS.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * - RCSuccess - Assert VINF_SUCCESS.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * In additions there is a very special familiy AssertCompile that can be
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * used for some limited compile checking. Like structure sizes and member
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * alignment. This family doesn't have the same variations.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remarks As you might've noticed, the macros doesn't follow the
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * coding guidelines wrt to macros supposedly being all uppercase
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * and underscored. For various reasons they don't, and it nobody
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * has complained yet. Wonder why... :-)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remarks Each project has its own specific guidelines on how to use
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * assertions, so the above is just trying to give you the general idea
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * from the IPRT point of view.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @{
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan__BEGIN_DECLS
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/**
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * The 1st part of an assert message.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param pszExpr Expression. Can be NULL.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param uLine Location line number.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param pszFile Location file name.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param pszFunction Location function name.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark This API exists in HC Ring-3 and GC.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki RajagopalanRTDECL(void) AssertMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction);
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/**
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * The 2nd (optional) part of an assert message.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param pszFormat Printf like format string.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param ... Arguments to that string.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark This API exists in HC Ring-3 and GC.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki RajagopalanRTDECL(void) AssertMsg2(const char *pszFormat, ...);
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/**
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Overridable function that decides whether assertions executes the breakpoint or not.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * The generic implementation will return true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @returns true if the breakpoint should be hit, false if it should be ignored.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark The RTDECL() makes this a bit difficult to override on windows. Sorry.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki RajagopalanRTDECL(bool) RTAssertDoBreakpoint(void);
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** The last assert message, 1st part. */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalanextern RTDATADECL(char) g_szRTAssertMsg1[1024];
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** The last assert message, 2nd part. */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalanextern RTDATADECL(char) g_szRTAssertMsg2[2048];
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan__END_DECLS
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertBreakpoint()
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assertion Breakpoint.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark In the gnu world we add a nop instruction after the int3 to
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * force gdb to remain at the int3 source line.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark The L4 kernel will try make sense of the breakpoint, thus the jmp.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# ifdef __GNUC__
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# ifndef __L4ENV__
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertBreakpoint() do { if (RTAssertDoBreakpoint()) { __asm__ __volatile__ ("int3\n\tnop"); } } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertBreakpoint() do { if (RTAssertDoBreakpoint()) { __asm__ __volatile__ ("int3; jmp 1f; 1:"); } } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# elif defined(_MSC_VER) || defined(DOXYGEN_RUNNING)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertBreakpoint() do { if (RTAssertDoBreakpoint()) { __debugbreak(); } } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# error "Unknown compiler"
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertBreakpoint() do { } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/**
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * RTASSERTTYPE is the type the AssertCompile() macro redefines.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * It has no other function and shouldn't be used.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Visual C++ uses this.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalantypedef int RTASSERTTYPE[1];
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/**
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * RTASSERTVAR is the type the AssertCompile() macro redefines.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * It has no other function and shouldn't be used.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * GCC uses this.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef __GNUC__
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan__BEGIN_DECLS
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalanextern int RTASSERTVAR[1];
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef __GNUC__
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan__END_DECLS
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertCompile
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Asserts that a compile-time expression is true. If it's not break the build.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef __GNUC__
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertCompile(expr) extern int RTASSERTVAR[1] __attribute__((unused)), RTASSERTVAR[(expr) ? 1 : 0] __attribute__((unused))
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertCompile(expr) typedef int RTASSERTTYPE[(expr) ? 1 : 0]
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertCompileSize
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Asserts a size at compile.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param type The type.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param size The expected type size.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertCompileSize(type, size) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertCompile(sizeof(type) == (size))
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertCompileSizeAlignment
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Asserts a size alignment at compile.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param type The type.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param align The size alignment to assert.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertCompileSizeAlignment(type, align) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertCompile(!(sizeof(type) & ((align) - 1)))
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertCompileMemberAlignment
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Asserts a member offset alignment at compile.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param type The type.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param member The member.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param align The member offset alignment to assert.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#if defined(__GNUC__) && defined(__cplusplus)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# if __GNUC__ >= 4
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertCompileMemberAlignment(type, member, align) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertCompile(!(__builtin_offsetof(type, member) & ((align) - 1)))
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertCompileMemberAlignment(type, member, align) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertCompile(!(RT_OFFSETOF(type, member) & ((align) - 1)))
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertCompileMemberAlignment(type, member, align) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertCompile(!(RT_OFFSETOF(type, member) & ((align) - 1)))
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertCompileMemberSize
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Asserts a member offset alignment at compile.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param type The type.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param member The member.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param size The member size to assert.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertCompileMemberSize(type, member, size) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertCompile(RT_SIZEOFMEMB(type, member) == (size))
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertCompileMemberSizeAlignment
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Asserts a member size alignment at compile.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param type The type.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param member The member.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param align The member size alignment to assert.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertCompileMemberSizeAlignment(type, member, align) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertCompile(!(RT_SIZEOFMEMB(type, member) & ((align) - 1)))
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def Assert
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true. If it's not hit breakpoint.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define Assert(expr) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define Assert(expr) do { } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReturn
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true and returns if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * In RT_STRICT mode it will hit a breakpoint before returning.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc What is to be presented to return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertReturn(expr, rc) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return (rc); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertReturn(expr, rc) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return (rc); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReturnVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true and returns if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * In RT_STRICT mode it will hit a breakpoint before returning.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertReturnVoid(expr) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertReturnVoid(expr) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertBreakStmt
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true and breaks if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * In RT_STRICT mode it will hit a breakpoint before doing break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param stmt Statement to execute before break in case of a failed assertion.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertBreakStmt(expr, stmt) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan stmt; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertBreakStmt(expr, stmt) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan stmt; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertBreakVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true and breaks if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * In RT_STRICT mode it will hit a breakpoint before returning.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @todo Rename to AssertBreak.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @todo broken, use if.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertBreakVoid(expr) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertBreakVoid(expr) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertMsg
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true. If it's not print message and hit breakpoint.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsg(expr, a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsg(expr, a) do { } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertMsgReturn
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true and returns if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * In RT_STRICT mode it will hit a breakpoint before returning.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc What is to be presented to return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsgReturn(expr, a, rc) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return (rc); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsgReturn(expr, a, rc) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return (rc); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertMsgReturnVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true and returns if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * In RT_STRICT mode it will hit a breakpoint before returning.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsgReturnVoid(expr, a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsgReturnVoid(expr, a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertMsgBreakStmt
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true and breaks if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * In RT_STRICT mode it will hit a breakpoint before doing break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param stmt Statement to execute before break in case of a failed assertion.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsgBreakStmt(expr, a, stmt) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan stmt; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsgBreakStmt(expr, a, stmt) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan stmt; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertMsgBreakVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true and breaks if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * In RT_STRICT mode it will hit a breakpoint before returning.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @todo Rename to AssertMsgBreak.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsgBreakVoid(expr, a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsgBreakVoid(expr, a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertFailed
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed hit breakpoint.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertFailed() \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertFailed() do { } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertFailedReturn
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc The rc to return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertFailedReturn(rc) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return (rc); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertFailedReturn(rc) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return (rc); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertFailedReturnVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, hit breakpoint (RT_STRICT mode only) and return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertFailedReturnVoid() \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertFailedReturnVoid() \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertFailedBreakStmt
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, hit breakpoint (RT_STRICT mode only), execute
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * the given statement and break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param stmt Statement to execute before break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertFailedBreakStmt(stmt) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (1) { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan stmt; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertFailedBreakStmt(stmt) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (1) { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan stmt; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertFailedBreakVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, hit breakpoint (RT_STRICT mode only) and break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @todo Rename to AssertFailedBreak.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertFailedBreakVoid() \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertFailedBreakVoid() \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertMsgFailed
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed print a message and a hit breakpoint.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsgFailed(a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsgFailed(a) do { } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertMsgFailedReturn
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc What is to be presented to return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsgFailedReturn(a, rc) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return (rc); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsgFailedReturn(a, rc) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return (rc); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertMsgFailedReturnVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsgFailedReturnVoid(a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsgFailedReturnVoid(a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertMsgFailedBreakStmt
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, hit breakpoint (RT_STRICT mode only), execute
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * the given statement and break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param stmt Statement to execute before break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsgFailedBreakStmt(a, stmt) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (1) { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan stmt; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsgFailedBreakStmt(a, stmt) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (1) { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan stmt; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertMsgFailedBreakVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, hit breakpoint with message (RT_STRICT mode only) and break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @todo Rename to AssertMsgFailedBreak.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @todo broken
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsgFailedBreakVoid(a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertMsgFailedBreakVoid(a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelBreakpoint()
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assertion LogRel Breakpoint.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * NOP in non-strict (release) builds, hardware breakpoint in strict builds,
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark In the gnu world we add a nop instruction after the int3 to
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * force gdb to remain at the int3 source line.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark The L4 kernel will try make sense of the breakpoint, thus the jmp.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# ifdef __GNUC__
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# ifndef __L4ENV__
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertLogRelBreakpoint() do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3\n\tnop"); } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertLogRelBreakpoint() do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3; jmp 1f; 1:"); } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# elif defined(_MSC_VER) || defined(DOXYGEN_RUNNING)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertLogRelBreakpoint() do { RTAssertDoBreakpoint(); __debugbreak(); } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# error "Unknown compiler"
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else /* !RT_STRICT */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertLogRelBreakpoint() do { } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif /* !RT_STRICT */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelMsg1
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * AssertMsg1 (strict builds) / LogRel wrapper (non-strict).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(pszExpr, iLine, pszFile, pszFunction)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertLogRelMsg1(pszExpr, iLine, pszFile, pszFunction) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan LogRel(("AssertLogRel %s(%d): %s\n",\
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan (pszFile), (iLine), (pszFile), (pszFunction), (pszExpr) ))
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelMsg2
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * AssertMsg2 (strict builds) / LogRel wrapper (non-strict).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef RT_STRICT
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertLogRelMsg2(a) AssertMsg2 a
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertLogRelMsg2(a) LogRel(a)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRel
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRel(expr) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelReturn
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true, return \a rc if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc What is to be presented to return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelReturn(expr, rc) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return (rc); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelReturnVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true, return void if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelReturnVoid(expr) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelBreak
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true, break if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelBreak(expr) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelBreakStmt
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true, execute \a stmt and break if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param stmt Statement to execute before break in case of a failed assertion.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelBreakStmt(expr, stmt) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan stmt; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelMsg
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelMsg(expr, a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg2(a); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelMsgReturn
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true, return \a rc if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc What is to be presented to return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelMsgReturn(expr, a, rc) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg2(a); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return (rc); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelMsgReturnVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true, return (void) if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelMsgReturnVoid(expr, a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg2(a); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelMsgBreak
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true, break if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelMsgBreak(expr, a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg2(a); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelMsgBreakStmt
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true, execute \a stmt and break if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param stmt Statement to execute before break in case of a failed assertion.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelMsgBreakStmt(expr, a, stmt) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg2(a); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan stmt; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelFailed
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelFailed() \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelFailedReturn
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc What is to be presented to return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelFailedReturn(rc) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return (rc); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelFailedReturnVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, hit a breakpoint and return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelFailedReturnVoid() \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelFailedBreak
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelFailedBreak() \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (1) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelFailedBreakStmt
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, execute \a stmt and break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param stmt Statement to execute before break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelFailedBreakStmt(stmt) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (1) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan stmt; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelMsgFailed
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelMsgFailed(a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg2(a); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelMsgFailedReturn
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, return \a rc.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc What is to be presented to return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelMsgFailedReturn(a, rc) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg2(a); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return (rc); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelMsgFailedReturnVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, return void.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelMsgFailedReturnVoid(a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg2(a); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelMsgFailedBreak
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelMsgFailedBreak(a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (1)\
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg2(a); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertLogRelMsgFailedBreakStmt
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, execute \a stmt and break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Strict builds will hit a breakpoint, non-strict will only do LogRel.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param stmt Statement to execute before break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertLogRelMsgFailedBreakStmt(a, stmt) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (1) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelMsg2(a); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertLogRelBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan stmt; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseBreakpoint()
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assertion Breakpoint.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark In the gnu world we add a nop instruction after the int3 to
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * force gdb to remain at the int3 source line.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark The L4 kernel will try make sense of the breakpoint, thus the jmp.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#ifdef __GNUC__
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# ifndef __L4ENV__
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertReleaseBreakpoint() do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3\n\tnop"); } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertReleaseBreakpoint() do { RTAssertDoBreakpoint(); __asm__ __volatile__ ("int3; jmp 1f; 1:"); } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#elif defined(_MSC_VER) || defined(DOXYGEN_RUNNING)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# define AssertReleaseBreakpoint() do { RTAssertDoBreakpoint(); __debugbreak(); } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#else
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan# error "Unknown compiler"
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#endif
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertRelease
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true. If it's not hit a breakpoint.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertRelease(expr) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseReturn
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true, hit a breakpoing and return if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc What is to be presented to return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseReturn(expr, rc) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return (rc); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseReturnVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true, hit a breakpoing and return if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseReturnVoid(expr) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseBreakStmt
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true, hit a breakpoing and break if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param stmt Statement to execute before break in case of a failed assertion.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseBreakStmt(expr, stmt) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan stmt; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseBreakVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true, hit a breakpoing and break if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @todo Rename to AssertReleaseBreak.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseBreakVoid(expr) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseMsg
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true, print the message and hit a breakpoint if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseMsg(expr, a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseMsgReturn
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc What is to be presented to return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseMsgReturn(expr, a, rc) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return (rc); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseMsgReturnVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true, print the message and hit a breakpoint and return if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseMsgReturnVoid(expr, a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseMsgBreakStmt
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true, print the message and hit a breakpoing and break if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param stmt Statement to execute before break in case of a failed assertion.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseMsgBreakStmt(expr, a, stmt) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan stmt; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseMsgBreakVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true, print the message and hit a breakpoint and break if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @todo Rename to AssertReleaseMsgBreak.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @todo broken
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseMsgBreakVoid(expr, a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseFailed
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, hit a breakpoint.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseFailed() \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseFailedReturn
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, hit a breakpoint and return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc What is to be presented to return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseFailedReturn(rc) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return (rc); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseFailedReturnVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, hit a breakpoint and return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseFailedReturnVoid() \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseFailedBreakStmt
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, hit a breakpoint and break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param stmt Statement to execute before break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseFailedBreakStmt(stmt) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (1) { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan stmt; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseFailedBreakVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, hit a breakpoint and break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @todo Rename to AssertReleaseFailedBreak.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @todo broken, should use 'if' instead of 'do'.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseFailedBreakVoid() \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseMsgFailed
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, print a message and hit a breakpoint.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseMsgFailed(a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseMsgFailedReturn
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, print a message, hit a breakpoint and return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc What is to be presented to return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseMsgFailedReturn(a, rc) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return (rc); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseMsgFailedReturnVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, print a message, hit a breakpoint and return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseMsgFailedReturnVoid(a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan return; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseMsgFailedBreakStmt
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, print a message, hit a breakpoint and break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param stmt Statement to execute before break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseMsgFailedBreakStmt(a, stmt) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (1) { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan stmt; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertReleaseMsgFailedBreakVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, print a message, hit a breakpoint and break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @todo Rename to AssertReleaseMsgFailedBreak.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @todo broken
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertReleaseMsgFailedBreakVoid(a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan break; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertFatal
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true. If it's not hit a breakpoint (for ever).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertFatal(expr) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan for (;;) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertFatalMsg
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Assert that an expression is true, print the message and hit a breakpoint (for ever) if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param expr Expression which should be true.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertFatalMsg(expr, a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (RT_UNLIKELY(!(expr))) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan for (;;) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertFatalFailed
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, hit a breakpoint (for ever).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertFatalFailed() \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan for (;;) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertFatalMsgFailed
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * An assertion failed, print a message and hit a breakpoint (for ever).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param a printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertFatalMsgFailed(a) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan for (;;) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan { \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg1((const char *)0, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertMsg2 a; \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan AssertReleaseBreakpoint(); \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertRC
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Asserts a iprt status code successful.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * On failure it will print info about the rc and hit a breakpoint.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc iprt status code.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark rc is references multiple times. In release mode is NOREF()'ed.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertRC(rc) AssertMsgRC(rc, ("%Vra\n", (rc)))
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertRCReturn
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc iprt status code.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rcRet What is to be presented to return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark rc is references multiple times. In release mode is NOREF()'ed.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertRCReturn(rc, rcRet) AssertMsgRCReturn(rc, ("%Vra\n", (rc)), rcRet)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertRCReturnVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and return if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc iprt status code.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark rc is references multiple times. In release mode is NOREF()'ed.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertRCReturnVoid(rc) AssertMsgRCReturnVoid(rc, ("%Vra\n", (rc)))
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertRCBreakStmt
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc iprt status code.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param stmt Statement to execute before break in case of a failed assertion.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark rc is references multiple times. In release mode is NOREF()'ed.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertRCBreakStmt(rc, stmt) AssertMsgRCBreakStmt(rc, ("%Vra\n", (rc)), stmt)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertRCBreakVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Asserts a iprt status code successful, bitch (RT_STRICT mode only) and break if it isn't.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc iprt status code.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark rc is references multiple times. In release mode is NOREF()'ed.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @todo Rename to AssertRCBreak.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertRCBreakVoid(rc) AssertMsgRCBreakVoid(rc, ("%Vra\n", (rc)))
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertMsgRC
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Asserts a iprt status code successful.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * It prints a custom message and hits a breakpoint on FAILURE.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc iprt status code.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param msg printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark rc is references multiple times. In release mode is NOREF()'ed.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertMsgRC(rc, msg) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { AssertMsg(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertMsgRCReturn
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Asserts a iprt status code successful and if it's not return the specified status code.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * If RT_STRICT is defined the message will be printed and a breakpoint hit before it returns
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc iprt status code.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param msg printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rcRet What is to be presented to return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark rc is references multiple times. In release mode is NOREF()'ed.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertMsgRCReturn(rc, msg, rcRet) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { AssertMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet); NOREF(rc); } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertMsgRCReturnVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Asserts a iprt status code successful and if it's not return.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * If RT_STRICT is defined the message will be printed and a breakpoint hit before it returns
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc iprt status code.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param msg printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark rc is references multiple times. In release mode is NOREF()'ed.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertMsgRCReturnVoid(rc, msg) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan do { AssertMsgReturnVoid(RT_SUCCESS_NP(rc), msg); NOREF(rc); } while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertMsgRCBreakStmt
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Asserts a iprt status code successful and break if it's not.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * If RT_STRICT is defined the message will be printed and a breakpoint hit before it returns
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc iprt status code.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param msg printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param stmt Statement to execute before break in case of a failed assertion.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark rc is references multiple times. In release mode is NOREF()'ed.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertMsgRCBreakStmt(rc, msg, stmt) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (1) { AssertMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt); NOREF(rc); } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertMsgRCBreakVoid
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Asserts a iprt status code successful and if it's not break.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * If RT_STRICT is defined the message will be printed and a breakpoint hit before it breaks
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param rc iprt status code.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @param msg printf argument list (in parenthesis).
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @remark rc is references multiple times. In release mode is NOREF()'ed.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * @todo Rename to AssertMsgRCBreak.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan */
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan#define AssertMsgRCBreakVoid(rc, msg) \
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan if (1) { AssertMsgBreakVoid(RT_SUCCESS(rc), msg); NOREF(rc); } else do {} while (0)
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan/** @def AssertRCSuccess
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * Asserts an iprt status code equals VINF_SUCCESS.
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan *
b494511a9cf72b1fc4eb13a0e593f55c624ab829Venki Rajagopalan * On failure it will print info about the rc and hit a breakpoint.
*
* @param rc iprt status code.
* @remark rc is references multiple times. In release mode is NOREF()'ed.
*/
#define AssertRCSuccess(rc) AssertMsg((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
/** @def AssertRCSuccessReturn
* Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
*
* @param rc iprt status code.
* @param rcRet What is to be presented to return.
* @remark rc is references multiple times. In release mode is NOREF()'ed.
*/
#define AssertRCSuccessReturn(rc, rcRet) AssertMsgReturn((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), rcRet)
/** @def AssertRCSuccessReturnVoid
* Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and return if it isn't.
*
* @param rc iprt status code.
* @remark rc is references multiple times. In release mode is NOREF()'ed.
*/
#define AssertRCSuccessReturnVoid(rc) AssertMsgReturnVoid((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
/** @def AssertRCSuccessBreakStmt
* Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
*
* @param rc iprt status code.
* @param stmt Statement to execute before break in case of a failed assertion.
* @remark rc is references multiple times. In release mode is NOREF()'ed.
*/
#define AssertRCSuccessBreakStmt(rc, stmt) AssertMsgBreakStmt((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), stmt)
/** @def AssertRCSuccessBreakVoid
* Asserts that an iprt status code equals VINF_SUCCESS, bitch (RT_STRICT mode only) and break if it isn't.
*
* @param rc iprt status code.
* @remark rc is references multiple times. In release mode is NOREF()'ed.
* @todo Rename to AssertRCSuccessBreak.
*/
#define AssertRCSuccessBreakVoid(rc) AssertMsgBreakVoid((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
/** @def AssertLogRelRC
* Asserts a iprt status code successful.
*
* @param rc iprt status code.
* @remark rc is references multiple times.
*/
#define AssertLogRelRC(rc) AssertLogRelMsgRC(rc, ("%Rra\n", (rc)))
/** @def AssertLogRelRCReturn
* Asserts a iprt status code successful, returning \a rc if it isn't.
*
* @param rc iprt status code.
* @param rcRet What is to be presented to return.
* @remark rc is references multiple times.
*/
#define AssertLogRelRCReturn(rc, rcRet) AssertLogRelMsgRCReturn(rc, ("%Rra\n", (rc)), rcRet)
/** @def AssertLogRelRCReturnVoid
* Asserts a iprt status code successful, returning (void) if it isn't.
*
* @param rc iprt status code.
* @remark rc is references multiple times.
*/
#define AssertLogRelRCReturnVoid(rc) AssertLogRelMsgRCReturnVoid(rc, ("%Rra\n", (rc)))
/** @def AssertLogRelRCBreak
* Asserts a iprt status code successful, breaking if it isn't.
*
* @param rc iprt status code.
* @remark rc is references multiple times.
*/
#define AssertLogRelRCBreak(rc) AssertLogRelMsgRCBreak(rc, ("%Rra\n", (rc)))
/** @def AssertLogRelRCBreakStmt
* Asserts a iprt status code successful, execute \a statement and break if it isn't.
*
* @param rc iprt status code.
* @param stmt Statement to execute before break in case of a failed assertion.
* @remark rc is references multiple times.
*/
#define AssertLogRelRCBreakStmt(rc, stmt) AssertLogRelMsgRCBreakStmt(rc, ("%Rra\n", (rc)), stmt)
/** @def AssertLogRelMsgRC
* Asserts a iprt status code successful.
*
* @param rc iprt status code.
* @param msg printf argument list (in parenthesis).
* @remark rc is references multiple times.
*/
#define AssertLogRelMsgRC(rc, msg) AssertLogRelMsg(RT_SUCCESS_NP(rc), msg)
/** @def AssertLogRelMsgRCReturn
* Asserts a iprt status code successful.
*
* @param rc iprt status code.
* @param msg printf argument list (in parenthesis).
* @param rcRet What is to be presented to return.
* @remark rc is references multiple times.
*/
#define AssertLogRelMsgRCReturn(rc, msg, rcRet) AssertLogRelMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet)
/** @def AssertLogRelMsgRCReturnVoid
* Asserts a iprt status code successful.
*
* @param rc iprt status code.
* @param msg printf argument list (in parenthesis).
* @remark rc is references multiple times.
*/
#define AssertLogRelMsgRCReturnVoid(rc, msg) AssertLogRelMsgReturnVoid(RT_SUCCESS_NP(rc), msg)
/** @def AssertLogRelMsgRCBreak
* Asserts a iprt status code successful.
*
* @param rc iprt status code.
* @param msg printf argument list (in parenthesis).
* @remark rc is references multiple times.
*/
#define AssertLogRelMsgRCBreak(rc, msg) AssertLogRelMsgBreak(RT_SUCCESS(rc), msg)
/** @def AssertLogRelMsgRCBreakStmt
* Asserts a iprt status code successful, execute \a stmt and break if it isn't.
*
* @param rc iprt status code.
* @param msg printf argument list (in parenthesis).
* @param stmt Statement to execute before break in case of a failed assertion.
* @remark rc is references multiple times.
*/
#define AssertLogRelMsgRCBreakStmt(rc, msg, stmt) AssertLogRelMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt)
/** @def AssertLogRelRCSuccess
* Asserts that an iprt status code equals VINF_SUCCESS.
*
* @param rc iprt status code.
* @remark rc is references multiple times.
*/
#define AssertLogRelRCSuccess(rc) AssertLogRelMsg((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
/** @def AssertLogRelRCSuccessReturn
* Asserts that an iprt status code equals VINF_SUCCESS.
*
* @param rc iprt status code.
* @param rcRet What is to be presented to return.
* @remark rc is references multiple times.
*/
#define AssertLogRelRCSuccessReturn(rc, rcRet) AssertLogRelMsgReturn((rc) == VINF_SUCCESS, ("%Rra\n", (rc)), rcRet)
/** @def AssertLogRelRCSuccessReturnVoid
* Asserts that an iprt status code equals VINF_SUCCESS.
*
* @param rc iprt status code.
* @remark rc is references multiple times.
*/
#define AssertLogRelRCSuccessReturnVoid(rc) AssertLogRelMsgReturnVoid((rc) == VINF_SUCCESS, ("%Rra\n", (rc)))
/** @def AssertLogRelRCSuccessBreak
* Asserts that an iprt status code equals VINF_SUCCESS.
*
* @param rc iprt status code.
* @remark rc is references multiple times.
*/
#define AssertLogRelRCSuccessBreak(rc) AssertLogRelMsgBreak((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
/** @def AssertLogRelRCSuccessBreakStmt
* Asserts that an iprt status code equals VINF_SUCCESS.
*
* @param rc iprt status code.
* @param stmt Statement to execute before break in case of a failed assertion.
* @remark rc is references multiple times.
*/
#define AssertLogRelRCSuccessBreakStmt(rc, stmt) AssertLogRelMsgBreakStmt((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), stmt)
/** @def AssertReleaseRC
* Asserts a iprt status code successful.
*
* On failure information about the error will be printed and a breakpoint hit.
*
* @param rc iprt status code.
* @remark rc is references multiple times.
*/
#define AssertReleaseRC(rc) AssertReleaseMsgRC(rc, ("%Vra\n", (rc)))
/** @def AssertReleaseRCReturn
* Asserts a iprt status code successful, returning if it isn't.
*
* On failure information about the error will be printed, a breakpoint hit
* and finally returning from the function if the breakpoint is somehow ignored.
*
* @param rc iprt status code.
* @param rcRet What is to be presented to return.
* @remark rc is references multiple times.
*/
#define AssertReleaseRCReturn(rc, rcRet) AssertReleaseMsgRCReturn(rc, ("%Vra\n", (rc)), rcRet)
/** @def AssertReleaseRCReturnVoid
* Asserts a iprt status code successful, returning if it isn't.
*
* On failure information about the error will be printed, a breakpoint hit
* and finally returning from the function if the breakpoint is somehow ignored.
*
* @param rc iprt status code.
* @remark rc is references multiple times.
*/
#define AssertReleaseRCReturnVoid(rc) AssertReleaseMsgRCReturnVoid(rc, ("%Vra\n", (rc)))
/** @def AssertReleaseRCBreakStmt
* Asserts a iprt status code successful, break if it isn't.
*
* On failure information about the error will be printed, a breakpoint hit
* and finally the break statement will be issued if the breakpoint is somehow ignored.
*
* @param rc iprt status code.
* @param stmt Statement to execute before break in case of a failed assertion.
* @remark rc is references multiple times.
*/
#define AssertReleaseRCBreakStmt(rc, stmt) AssertReleaseMsgRCBreakStmt(rc, ("%Vra\n", (rc)), stmt)
/** @def AssertReleaseRCBreakVoid
* Asserts a iprt status code successful, breaking if it isn't.
*
* On failure information about the error will be printed, a breakpoint hit
* and finally breaking the current statement if the breakpoint is somehow ignored.
*
* @param rc iprt status code.
* @remark rc is references multiple times.
* @todo Rename to AssertReleaseRCBreak.
*/
#define AssertReleaseRCBreakVoid(rc) AssertReleaseMsgRCBreakVoid(rc, ("%Vra\n", (rc)))
/** @def AssertReleaseMsgRC
* Asserts a iprt status code successful.
*
* On failure a custom message is printed and a breakpoint is hit.
*
* @param rc iprt status code.
* @param msg printf argument list (in parenthesis).
* @remark rc is references multiple times.
*/
#define AssertReleaseMsgRC(rc, msg) AssertReleaseMsg(RT_SUCCESS_NP(rc), msg)
/** @def AssertReleaseMsgRCReturn
* Asserts a iprt status code successful.
*
* On failure a custom message is printed, a breakpoint is hit, and finally
* returning from the function if the breakpoint is showhow ignored.
*
* @param rc iprt status code.
* @param msg printf argument list (in parenthesis).
* @param rcRet What is to be presented to return.
* @remark rc is references multiple times.
*/
#define AssertReleaseMsgRCReturn(rc, msg, rcRet) AssertReleaseMsgReturn(RT_SUCCESS_NP(rc), msg, rcRet)
/** @def AssertReleaseMsgRCReturnVoid
* Asserts a iprt status code successful.
*
* On failure a custom message is printed, a breakpoint is hit, and finally
* returning from the function if the breakpoint is showhow ignored.
*
* @param rc iprt status code.
* @param msg printf argument list (in parenthesis).
* @remark rc is references multiple times.
*/
#define AssertReleaseMsgRCReturnVoid(rc, msg) AssertReleaseMsgReturnVoid(RT_SUCCESS_NP(rc), msg)
/** @def AssertReleaseMsgRCBreakStmt
* Asserts a iprt status code successful.
*
* On failure a custom message is printed, a breakpoint is hit, and finally
* the brean statement is issued if the breakpoint is showhow ignored.
*
* @param rc iprt status code.
* @param msg printf argument list (in parenthesis).
* @param stmt Statement to execute before break in case of a failed assertion.
* @remark rc is references multiple times.
*/
#define AssertReleaseMsgRCBreakStmt(rc, msg, stmt) AssertReleaseMsgBreakStmt(RT_SUCCESS_NP(rc), msg, stmt)
/** @def AssertReleaseMsgRCBreakVoid
* Asserts a iprt status code successful.
*
* On failure a custom message is printed, a breakpoint is hit, and finally
* breaking the current status if the breakpoint is showhow ignored.
*
* @param rc iprt status code.
* @param msg printf argument list (in parenthesis).
* @remark rc is references multiple times.
* @todo Rename to AssertReleaseMsgRCBreak.
*/
#define AssertReleaseMsgRCBreakVoid(rc, msg) AssertReleaseMsgBreakVoid(RT_SUCCESS(rc), msg)
/** @def AssertReleaseRCSuccess
* Asserts that an iprt status code equals VINF_SUCCESS.
*
* On failure information about the error will be printed and a breakpoint hit.
*
* @param rc iprt status code.
* @remark rc is references multiple times.
*/
#define AssertReleaseRCSuccess(rc) AssertReleaseMsg((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
/** @def AssertReleaseRCSuccessReturn
* Asserts that an iprt status code equals VINF_SUCCESS.
*
* On failure information about the error will be printed, a breakpoint hit
* and finally returning from the function if the breakpoint is somehow ignored.
*
* @param rc iprt status code.
* @param rcRet What is to be presented to return.
* @remark rc is references multiple times.
*/
#define AssertReleaseRCSuccessReturn(rc, rcRet) AssertReleaseMsgReturn((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), rcRet)
/** @def AssertReleaseRCSuccessReturnVoid
* Asserts that an iprt status code equals VINF_SUCCESS.
*
* On failure information about the error will be printed, a breakpoint hit
* and finally returning from the function if the breakpoint is somehow ignored.
*
* @param rc iprt status code.
* @remark rc is references multiple times.
*/
#define AssertReleaseRCSuccessReturnVoid(rc) AssertReleaseMsgReturnVoid((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
/** @def AssertReleaseRCSuccessBreakStmt
* Asserts that an iprt status code equals VINF_SUCCESS.
*
* On failure information about the error will be printed, a breakpoint hit
* and finally the break statement will be issued if the breakpoint is somehow ignored.
*
* @param rc iprt status code.
* @param stmt Statement to execute before break in case of a failed assertion.
* @remark rc is references multiple times.
*/
#define AssertReleaseRCSuccessBreakStmt(rc, stmt) AssertReleaseMsgBreakStmt((rc) == VINF_SUCCESS, ("%Vra\n", (rc)), stmt)
/** @def AssertReleaseRCSuccessBreakVoid
* Asserts that an iprt status code equals VINF_SUCCESS.
*
* On failure information about the error will be printed, a breakpoint hit
* and finally breaking the current statement if the breakpoint is somehow ignored.
*
* @param rc iprt status code.
* @remark rc is references multiple times.
* @todo Rename to AssertReleaseRCSuccessBreak.
*/
#define AssertReleaseRCSuccessBreakVoid(rc) AssertReleaseMsgBreakVoid((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
/** @def AssertFatalRC
* Asserts a iprt status code successful.
*
* On failure information about the error will be printed and a breakpoint hit.
*
* @param rc iprt status code.
* @remark rc is references multiple times.
*/
#define AssertFatalRC(rc) AssertFatalMsgRC(rc, ("%Vra\n", (rc)))
/** @def AssertReleaseMsgRC
* Asserts a iprt status code successful.
*
* On failure a custom message is printed and a breakpoint is hit.
*
* @param rc iprt status code.
* @param msg printf argument list (in parenthesis).
* @remark rc is references multiple times.
*/
#define AssertFatalMsgRC(rc, msg) AssertFatalMsg(RT_SUCCESS_NP(rc), msg)
/** @def AssertFatalRCSuccess
* Asserts that an iprt status code equals VINF_SUCCESS.
*
* On failure information about the error will be printed and a breakpoint hit.
*
* @param rc iprt status code.
* @remark rc is references multiple times.
*/
#define AssertFatalRCSuccess(rc) AssertFatalMsg((rc) == VINF_SUCCESS, ("%Vra\n", (rc)))
/** @def AssertPtr
* Asserts that a pointer is valid.
*
* @param pv The pointer.
*/
#define AssertPtr(pv) AssertMsg(VALID_PTR(pv), ("%p\n", (pv)))
/** @def AssertPtrReturn
* Asserts that a pointer is valid.
*
* @param pv The pointer.
* @param rcRet What is to be presented to return.
*/
#define AssertPtrReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv), ("%p\n", (pv)), rcRet)
/** @def AssertPtrReturnVoid
* Asserts that a pointer is valid.
*
* @param pv The pointer.
*/
#define AssertPtrReturnVoid(pv) AssertMsgReturnVoid(VALID_PTR(pv), ("%p\n", (pv)))
/** @def AssertPtrBreakStmt
* Asserts that a pointer is valid.
*
* @param pv The pointer.
* @param stmt Statement to execute before break in case of a failed assertion.
*/
#define AssertPtrBreakStmt(pv, stmt) AssertMsgBreakStmt(VALID_PTR(pv), ("%p\n", (pv)), stmt)
/** @def AssertPtrBreakVoid
* Asserts that a pointer is valid.
*
* @param pv The pointer.
* @todo Rename to AssertPtrBreak.
*/
#define AssertPtrBreakVoid(pv) AssertMsgBreakVoid(VALID_PTR(pv), ("%p\n", (pv)))
/** @def AssertPtrNull
* Asserts that a pointer is valid or NULL.
*
* @param pv The pointer.
*/
#define AssertPtrNull(pv) AssertMsg(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
/** @def AssertPtrNullReturn
* Asserts that a pointer is valid or NULL.
*
* @param pv The pointer.
* @param rcRet What is to be presented to return.
*/
#define AssertPtrNullReturn(pv, rcRet) AssertMsgReturn(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), rcRet)
/** @def AssertPtrNullReturnVoid
* Asserts that a pointer is valid or NULL.
*
* @param pv The pointer.
*/
#define AssertPtrNullReturnVoid(pv) AssertMsgReturnVoid(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
/** @def AssertPtrNullBreakStmt
* Asserts that a pointer is valid or NULL.
*
* @param pv The pointer.
* @param stmt Statement to execute before break in case of a failed assertion.
*/
#define AssertPtrNullBreakStmt(pv, stmt) AssertMsgBreakStmt(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)), stmt)
/** @def AssertPtrNullBreakVoid
* Asserts that a pointer is valid or NULL.
*
* @param pv The pointer.
* @todo Rename to AssertPtrNullBreak.
*/
#define AssertPtrNullBreakVoid(pv) AssertMsgBreakVoid(VALID_PTR(pv) || (pv) == NULL, ("%p\n", (pv)))
/** @def AssertGCPhys32
* Asserts that the high dword of a physical address is zero
*
* @param GCPhys The address (RTGCPHYS).
*/
#define AssertGCPhys32(GCPhys) AssertMsg(VALID_PHYS32(GCPhys), ("%RGp\n", (RTGCPHYS)(GCPhys)))
/** @} */
#endif