15185a700Sflorian /* 25185a700Sflorian * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 35185a700Sflorian * 45185a700Sflorian * Permission to use, copy, modify, and/or distribute this software for any 55185a700Sflorian * purpose with or without fee is hereby granted, provided that the above 65185a700Sflorian * copyright notice and this permission notice appear in all copies. 75185a700Sflorian * 85185a700Sflorian * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 95185a700Sflorian * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 105185a700Sflorian * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 115185a700Sflorian * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 125185a700Sflorian * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 135185a700Sflorian * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 145185a700Sflorian * PERFORMANCE OF THIS SOFTWARE. 155185a700Sflorian */ 165185a700Sflorian 175185a700Sflorian /* 18*e9ec1762Sflorian * $Id: assertions.h,v 1.5 2022/07/03 16:00:11 florian Exp $ 195185a700Sflorian */ 205185a700Sflorian /*! \file isc/assertions.h 215185a700Sflorian */ 225185a700Sflorian 235185a700Sflorian #ifndef ISC_ASSERTIONS_H 245185a700Sflorian #define ISC_ASSERTIONS_H 1 255185a700Sflorian 26*e9ec1762Sflorian #include <sys/types.h> 275185a700Sflorian 285185a700Sflorian /*% isc assertion type */ 295185a700Sflorian typedef enum { 305185a700Sflorian isc_assertiontype_require, 315185a700Sflorian isc_assertiontype_ensure, 325185a700Sflorian isc_assertiontype_insist, 335185a700Sflorian isc_assertiontype_invariant 345185a700Sflorian } isc_assertiontype_t; 355185a700Sflorian 365185a700Sflorian typedef void (*isc_assertioncallback_t)(const char *, int, isc_assertiontype_t, 375185a700Sflorian const char *); 385185a700Sflorian 395185a700Sflorian __dead void isc_assertion_failed(const char *, int, isc_assertiontype_t, 405185a700Sflorian const char *); 415185a700Sflorian 425185a700Sflorian const char * 435185a700Sflorian isc_assertion_typetotext(isc_assertiontype_t type); 445185a700Sflorian 455185a700Sflorian #define ISC_REQUIRE(cond) \ 465185a700Sflorian ((void) ((cond) || \ 475185a700Sflorian ((isc_assertion_failed)(__FILE__, __LINE__, \ 485185a700Sflorian isc_assertiontype_require, \ 495185a700Sflorian #cond), 0))) 505185a700Sflorian #define ISC_ENSURE(cond) \ 515185a700Sflorian ((void) ((cond) || \ 525185a700Sflorian ((isc_assertion_failed)(__FILE__, __LINE__, \ 535185a700Sflorian isc_assertiontype_ensure, \ 545185a700Sflorian #cond), 0))) 555185a700Sflorian #define ISC_INSIST(cond) \ 565185a700Sflorian ((void) ((cond) || \ 575185a700Sflorian ((isc_assertion_failed)(__FILE__, __LINE__, \ 585185a700Sflorian isc_assertiontype_insist, \ 595185a700Sflorian #cond), 0))) 605185a700Sflorian 615185a700Sflorian #define ISC_INVARIANT(cond) \ 625185a700Sflorian ((void) ((cond) || \ 635185a700Sflorian ((isc_assertion_failed)(__FILE__, __LINE__, \ 645185a700Sflorian isc_assertiontype_invariant, \ 655185a700Sflorian #cond), 0))) 665185a700Sflorian 675185a700Sflorian #endif /* ISC_ASSERTIONS_H */ 68