assertions.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004-2009  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 1997-2001  Internet Software Consortium.
00004  *
00005  * Permission to use, copy, modify, and/or distribute this software for any
00006  * purpose with or without fee is hereby granted, provided that the above
00007  * copyright notice and this permission notice appear in all copies.
00008  *
00009  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00010  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00011  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00012  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00013  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00014  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00015  * PERFORMANCE OF THIS SOFTWARE.
00016  */
00017 
00018 /*
00019  * $Id: assertions.h,v 1.28 2009/09/29 23:48:04 tbox Exp $
00020  */
00021 /*! \file isc/assertions.h
00022  */
00023 
00024 #ifndef ISC_ASSERTIONS_H
00025 #define ISC_ASSERTIONS_H 1
00026 
00027 #include <isc/lang.h>
00028 #include <isc/platform.h>
00029 
00030 ISC_LANG_BEGINDECLS
00031 
00032 /*% isc assertion type */
00033 typedef enum {
00034         isc_assertiontype_require,
00035         isc_assertiontype_ensure,
00036         isc_assertiontype_insist,
00037         isc_assertiontype_invariant
00038 } isc_assertiontype_t;
00039 
00040 typedef void (*isc_assertioncallback_t)(const char *, int, isc_assertiontype_t,
00041                                         const char *);
00042 
00043 /* coverity[+kill] */
00044 ISC_PLATFORM_NORETURN_PRE
00045 void isc_assertion_failed(const char *, int, isc_assertiontype_t,
00046                           const char *) ISC_PLATFORM_NORETURN_POST;
00047 
00048 void
00049 isc_assertion_setcallback(isc_assertioncallback_t);
00050 
00051 const char *
00052 isc_assertion_typetotext(isc_assertiontype_t type);
00053 
00054 #if defined(ISC_CHECK_ALL) || defined(__COVERITY__)
00055 #define ISC_CHECK_REQUIRE               1
00056 #define ISC_CHECK_ENSURE                1
00057 #define ISC_CHECK_INSIST                1
00058 #define ISC_CHECK_INVARIANT             1
00059 #endif
00060 
00061 #if defined(ISC_CHECK_NONE) && !defined(__COVERITY__)
00062 #define ISC_CHECK_REQUIRE               0
00063 #define ISC_CHECK_ENSURE                0
00064 #define ISC_CHECK_INSIST                0
00065 #define ISC_CHECK_INVARIANT             0
00066 #endif
00067 
00068 #ifndef ISC_CHECK_REQUIRE
00069 #define ISC_CHECK_REQUIRE               1
00070 #endif
00071 
00072 #ifndef ISC_CHECK_ENSURE
00073 #define ISC_CHECK_ENSURE                1
00074 #endif
00075 
00076 #ifndef ISC_CHECK_INSIST
00077 #define ISC_CHECK_INSIST                1
00078 #endif
00079 
00080 #ifndef ISC_CHECK_INVARIANT
00081 #define ISC_CHECK_INVARIANT             1
00082 #endif
00083 
00084 #if ISC_CHECK_REQUIRE != 0
00085 #define ISC_REQUIRE(cond) \
00086         ((void) ((cond) || \
00087                  ((isc_assertion_failed)(__FILE__, __LINE__, \
00088                                          isc_assertiontype_require, \
00089                                          #cond), 0)))
00090 #else
00091 #define ISC_REQUIRE(cond)       ((void) 0)
00092 #endif /* ISC_CHECK_REQUIRE */
00093 
00094 #if ISC_CHECK_ENSURE != 0
00095 #define ISC_ENSURE(cond) \
00096         ((void) ((cond) || \
00097                  ((isc_assertion_failed)(__FILE__, __LINE__, \
00098                                          isc_assertiontype_ensure, \
00099                                          #cond), 0)))
00100 #else
00101 #define ISC_ENSURE(cond)        ((void) 0)
00102 #endif /* ISC_CHECK_ENSURE */
00103 
00104 #if ISC_CHECK_INSIST != 0
00105 #define ISC_INSIST(cond) \
00106         ((void) ((cond) || \
00107                  ((isc_assertion_failed)(__FILE__, __LINE__, \
00108                                          isc_assertiontype_insist, \
00109                                          #cond), 0)))
00110 #else
00111 #define ISC_INSIST(cond)        ((void) 0)
00112 #endif /* ISC_CHECK_INSIST */
00113 
00114 #if ISC_CHECK_INVARIANT != 0
00115 #define ISC_INVARIANT(cond) \
00116         ((void) ((cond) || \
00117                  ((isc_assertion_failed)(__FILE__, __LINE__, \
00118                                          isc_assertiontype_invariant, \
00119                                          #cond), 0)))
00120 #else
00121 #define ISC_INVARIANT(cond)     ((void) 0)
00122 #endif /* ISC_CHECK_INVARIANT */
00123 
00124 ISC_LANG_ENDDECLS
00125 
00126 #endif /* ISC_ASSERTIONS_H */

Generated on Tue Apr 28 17:41:04 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha