1N/A/*
1N/A * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
1N/A * All rights reserved.
1N/A *
1N/A * By using this file, you agree to the terms and conditions set
1N/A * forth in the LICENSE file which can be found at the top level of
1N/A * the sendmail distribution.
1N/A *
1N/A * $Id: assert.h,v 1.10 2001/06/07 20:04:53 ca Exp $
1N/A */
1N/A
1N/A#pragma ident "%Z%%M% %I% %E% SMI"
1N/A
1N/A/*
1N/A** libsm abnormal program termination and assertion checking
1N/A** See libsm/assert.html for documentation.
1N/A*/
1N/A
1N/A#ifndef SM_ASSERT_H
1N/A# define SM_ASSERT_H
1N/A
1N/A# include <sm/gen.h>
1N/A# include <sm/debug.h>
1N/A
1N/A/*
1N/A** abnormal program termination
1N/A*/
1N/A
1N/Atypedef void (*SM_ABORT_HANDLER_T) __P((const char *, int, const char *));
1N/A
1N/Aextern SM_DEAD(void
1N/Asm_abort_at __P((
1N/A const char *,
1N/A int,
1N/A const char *)));
1N/A
1N/Aextern void
1N/Asm_abort_sethandler __P((
1N/A SM_ABORT_HANDLER_T));
1N/A
1N/Aextern SM_DEAD(void PRINTFLIKE(1, 2)
1N/Asm_abort __P((
1N/A char *,
1N/A ...)));
1N/A
1N/A/*
1N/A** assertion checking
1N/A*/
1N/A
1N/A# ifndef SM_CHECK_ALL
1N/A# define SM_CHECK_ALL 1
1N/A# endif /* ! SM_CHECK_ALL */
1N/A
1N/A# ifndef SM_CHECK_REQUIRE
1N/A# define SM_CHECK_REQUIRE SM_CHECK_ALL
1N/A# endif /* ! SM_CHECK_REQUIRE */
1N/A
1N/A# ifndef SM_CHECK_ENSURE
1N/A# define SM_CHECK_ENSURE SM_CHECK_ALL
1N/A# endif /* ! SM_CHECK_ENSURE */
1N/A
1N/A# ifndef SM_CHECK_ASSERT
1N/A# define SM_CHECK_ASSERT SM_CHECK_ALL
1N/A# endif /* ! SM_CHECK_ASSERT */
1N/A
1N/A# if SM_CHECK_REQUIRE
1N/A# if defined(__STDC__) || defined(__cplusplus)
1N/A# define SM_REQUIRE(cond) \
1N/A ((void) ((cond) || (sm_abort_at(__FILE__, __LINE__, \
1N/A "SM_REQUIRE(" #cond ") failed"), 0)))
1N/A# else /* defined(__STDC__) || defined(__cplusplus) */
1N/A# define SM_REQUIRE(cond) \
1N/A ((void) ((cond) || (sm_abort_at(__FILE__, __LINE__, \
1N/A "SM_REQUIRE(cond) failed"), 0)))
1N/A# endif /* defined(__STDC__) || defined(__cplusplus) */
1N/A# else /* SM_CHECK_REQUIRE */
1N/A# define SM_REQUIRE(cond) ((void) 0)
1N/A# endif /* SM_CHECK_REQUIRE */
1N/A
1N/A# define SM_REQUIRE_ISA(obj, magic) \
1N/A SM_REQUIRE((obj) != NULL && (obj)->sm_magic == (magic))
1N/A
1N/A# if SM_CHECK_ENSURE
1N/A# if defined(__STDC__) || defined(__cplusplus)
1N/A# define SM_ENSURE(cond) \
1N/A ((void) ((cond) || (sm_abort_at(__FILE__, __LINE__, \
1N/A "SM_ENSURE(" #cond ") failed"), 0)))
1N/A# else /* defined(__STDC__) || defined(__cplusplus) */
1N/A# define SM_ENSURE(cond) \
1N/A ((void) ((cond) || (sm_abort_at(__FILE__, __LINE__, \
1N/A "SM_ENSURE(cond) failed"), 0)))
1N/A# endif /* defined(__STDC__) || defined(__cplusplus) */
1N/A# else /* SM_CHECK_ENSURE */
1N/A# define SM_ENSURE(cond) ((void) 0)
1N/A# endif /* SM_CHECK_ENSURE */
1N/A
1N/A# if SM_CHECK_ASSERT
1N/A# if defined(__STDC__) || defined(__cplusplus)
1N/A# define SM_ASSERT(cond) \
1N/A ((void) ((cond) || (sm_abort_at(__FILE__, __LINE__, \
1N/A "SM_ASSERT(" #cond ") failed"), 0)))
1N/A# else /* defined(__STDC__) || defined(__cplusplus) */
1N/A# define SM_ASSERT(cond) \
1N/A ((void) ((cond) || (sm_abort_at(__FILE__, __LINE__, \
1N/A "SM_ASSERT(cond) failed"), 0)))
1N/A# endif /* defined(__STDC__) || defined(__cplusplus) */
1N/A# else /* SM_CHECK_ASSERT */
1N/A# define SM_ASSERT(cond) ((void) 0)
1N/A# endif /* SM_CHECK_ASSERT */
1N/A
1N/Aextern SM_DEBUG_T SmExpensiveRequire;
1N/Aextern SM_DEBUG_T SmExpensiveEnsure;
1N/Aextern SM_DEBUG_T SmExpensiveAssert;
1N/A
1N/A#endif /* ! SM_ASSERT_H */