PageRenderTime 44ms CodeModel.GetById 41ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/ntp/include/isc/assertions.h

https://bitbucket.org/freebsd/freebsd-head/
C++ Header | 120 lines | 80 code | 21 blank | 19 comment | 8 complexity | fe459f9e021b73a9c21571bf72f5c9f3 MD5 | raw file
  1/*
  2 * Copyright (C) 1997-2001  Internet Software Consortium.
  3 *
  4 * Permission to use, copy, modify, and distribute this software for any
  5 * purpose with or without fee is hereby granted, provided that the above
  6 * copyright notice and this permission notice appear in all copies.
  7 *
  8 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
  9 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
 10 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
 11 * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
 12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
 13 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 14 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 15 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 16 */
 17
 18/*
 19 * $Id: assertions.h,v 1.17 2001/07/12 05:58:21 mayer Exp $
 20 */
 21
 22#ifndef ISC_ASSERTIONS_H
 23#define ISC_ASSERTIONS_H 1
 24
 25#include <isc/lang.h>
 26#include <isc/platform.h>
 27
 28ISC_LANG_BEGINDECLS
 29
 30typedef enum {
 31	isc_assertiontype_require,
 32	isc_assertiontype_ensure,
 33	isc_assertiontype_insist,
 34	isc_assertiontype_invariant
 35} isc_assertiontype_t;
 36
 37typedef void (*isc_assertioncallback_t)(const char *, int, isc_assertiontype_t,
 38					const char *);
 39
 40LIBISC_EXTERNAL_DATA extern isc_assertioncallback_t isc_assertion_failed;
 41
 42void
 43isc_assertion_setcallback(isc_assertioncallback_t);
 44
 45const char *
 46isc_assertion_typetotext(isc_assertiontype_t type);
 47
 48#ifdef ISC_CHECK_ALL
 49#define ISC_CHECK_REQUIRE		1
 50#define ISC_CHECK_ENSURE		1
 51#define ISC_CHECK_INSIST		1
 52#define ISC_CHECK_INVARIANT		1
 53#endif
 54
 55#ifdef ISC_CHECK_NONE
 56#define ISC_CHECK_REQUIRE		0
 57#define ISC_CHECK_ENSURE		0
 58#define ISC_CHECK_INSIST		0
 59#define ISC_CHECK_INVARIANT		0
 60#endif
 61
 62#ifndef ISC_CHECK_REQUIRE
 63#define ISC_CHECK_REQUIRE		1
 64#endif
 65
 66#ifndef ISC_CHECK_ENSURE
 67#define ISC_CHECK_ENSURE		1
 68#endif
 69
 70#ifndef ISC_CHECK_INSIST
 71#define ISC_CHECK_INSIST		1
 72#endif
 73
 74#ifndef ISC_CHECK_INVARIANT
 75#define ISC_CHECK_INVARIANT		1
 76#endif
 77
 78#if ISC_CHECK_REQUIRE != 0
 79#define ISC_REQUIRE(cond) \
 80	((void) ((cond) || \
 81		 ((isc_assertion_failed)(__FILE__, __LINE__, \
 82					 isc_assertiontype_require, \
 83					 #cond), 0)))
 84#else
 85#define ISC_REQUIRE(cond)	((void) 0)
 86#endif /* ISC_CHECK_REQUIRE */
 87
 88#if ISC_CHECK_ENSURE != 0
 89#define ISC_ENSURE(cond) \
 90	((void) ((cond) || \
 91		 ((isc_assertion_failed)(__FILE__, __LINE__, \
 92					 isc_assertiontype_ensure, \
 93					 #cond), 0)))
 94#else
 95#define ISC_ENSURE(cond)	((void) 0)
 96#endif /* ISC_CHECK_ENSURE */
 97
 98#if ISC_CHECK_INSIST != 0
 99#define ISC_INSIST(cond) \
100	((void) ((cond) || \
101		 ((isc_assertion_failed)(__FILE__, __LINE__, \
102					 isc_assertiontype_insist, \
103					 #cond), 0)))
104#else
105#define ISC_INSIST(cond)	((void) 0)
106#endif /* ISC_CHECK_INSIST */
107
108#if ISC_CHECK_INVARIANT != 0
109#define ISC_INVARIANT(cond) \
110	((void) ((cond) || \
111		 ((isc_assertion_failed)(__FILE__, __LINE__, \
112					 isc_assertiontype_invariant, \
113					 #cond), 0)))
114#else
115#define ISC_INVARIANT(cond)	((void) 0)
116#endif /* ISC_CHECK_INVARIANT */
117
118ISC_LANG_ENDDECLS
119
120#endif /* ISC_ASSERTIONS_H */