Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* $NetBSD: assertions.h,v 1.1.1.1 2004/05/20 19:49:41 christos Exp $ */ |
michael@0 | 2 | |
michael@0 | 3 | /* |
michael@0 | 4 | * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") |
michael@0 | 5 | * Copyright (c) 1997-1999 by Internet Software Consortium. |
michael@0 | 6 | * |
michael@0 | 7 | * Permission to use, copy, modify, and distribute this software for any |
michael@0 | 8 | * purpose with or without fee is hereby granted, provided that the above |
michael@0 | 9 | * copyright notice and this permission notice appear in all copies. |
michael@0 | 10 | * |
michael@0 | 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES |
michael@0 | 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
michael@0 | 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR |
michael@0 | 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
michael@0 | 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
michael@0 | 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
michael@0 | 17 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
michael@0 | 18 | */ |
michael@0 | 19 | |
michael@0 | 20 | /* |
michael@0 | 21 | * Id: assertions.h,v 1.1.206.1 2004/03/09 08:33:30 marka Exp |
michael@0 | 22 | */ |
michael@0 | 23 | |
michael@0 | 24 | /* |
michael@0 | 25 | * This version of this file is derived from Android 2.3 "Gingerbread", |
michael@0 | 26 | * which contains uncredited changes by Android/Google developers. It has |
michael@0 | 27 | * been modified in 2011 for use in the Android build of Mozilla Firefox by |
michael@0 | 28 | * Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>, |
michael@0 | 29 | * and Steve Workman <sjhworkman@gmail.com>). |
michael@0 | 30 | * These changes are offered under the same license as the original NetBSD |
michael@0 | 31 | * file, whose copyright and license are unchanged above. |
michael@0 | 32 | */ |
michael@0 | 33 | |
michael@0 | 34 | #ifndef ASSERTIONS_H |
michael@0 | 35 | #define ASSERTIONS_H 1 |
michael@0 | 36 | |
michael@0 | 37 | typedef enum { |
michael@0 | 38 | assert_require, assert_ensure, assert_insist, assert_invariant |
michael@0 | 39 | } assertion_type; |
michael@0 | 40 | |
michael@0 | 41 | typedef void (*assertion_failure_callback)(const char *, int, assertion_type, |
michael@0 | 42 | const char *, int); |
michael@0 | 43 | |
michael@0 | 44 | extern assertion_failure_callback __assertion_failed; |
michael@0 | 45 | void set_assertion_failure_callback(assertion_failure_callback f); |
michael@0 | 46 | const char *assertion_type_to_text(assertion_type type); |
michael@0 | 47 | |
michael@0 | 48 | #ifdef CHECK_ALL |
michael@0 | 49 | #define CHECK_REQUIRE 1 |
michael@0 | 50 | #define CHECK_ENSURE 1 |
michael@0 | 51 | #define CHECK_INSIST 1 |
michael@0 | 52 | #define CHECK_INVARIANT 1 |
michael@0 | 53 | #endif |
michael@0 | 54 | |
michael@0 | 55 | #ifdef CHECK_NONE |
michael@0 | 56 | #define CHECK_REQUIRE 0 |
michael@0 | 57 | #define CHECK_ENSURE 0 |
michael@0 | 58 | #define CHECK_INSIST 0 |
michael@0 | 59 | #define CHECK_INVARIANT 0 |
michael@0 | 60 | #endif |
michael@0 | 61 | |
michael@0 | 62 | #ifndef CHECK_REQUIRE |
michael@0 | 63 | #define CHECK_REQUIRE 1 |
michael@0 | 64 | #endif |
michael@0 | 65 | |
michael@0 | 66 | #ifndef CHECK_ENSURE |
michael@0 | 67 | #define CHECK_ENSURE 1 |
michael@0 | 68 | #endif |
michael@0 | 69 | |
michael@0 | 70 | #ifndef CHECK_INSIST |
michael@0 | 71 | #define CHECK_INSIST 1 |
michael@0 | 72 | #endif |
michael@0 | 73 | |
michael@0 | 74 | #ifndef CHECK_INVARIANT |
michael@0 | 75 | #define CHECK_INVARIANT 1 |
michael@0 | 76 | #endif |
michael@0 | 77 | |
michael@0 | 78 | #if CHECK_REQUIRE != 0 |
michael@0 | 79 | #define REQUIRE(cond) \ |
michael@0 | 80 | ((void) ((cond) || \ |
michael@0 | 81 | ((__assertion_failed)(__FILE__, __LINE__, assert_require, \ |
michael@0 | 82 | #cond, 0), 0))) |
michael@0 | 83 | #define REQUIRE_ERR(cond) \ |
michael@0 | 84 | ((void) ((cond) || \ |
michael@0 | 85 | ((__assertion_failed)(__FILE__, __LINE__, assert_require, \ |
michael@0 | 86 | #cond, 1), 0))) |
michael@0 | 87 | #else |
michael@0 | 88 | #define REQUIRE(cond) ((void) (cond)) |
michael@0 | 89 | #define REQUIRE_ERR(cond) ((void) (cond)) |
michael@0 | 90 | #endif /* CHECK_REQUIRE */ |
michael@0 | 91 | |
michael@0 | 92 | #if CHECK_ENSURE != 0 |
michael@0 | 93 | #define ENSURE(cond) \ |
michael@0 | 94 | ((void) ((cond) || \ |
michael@0 | 95 | ((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \ |
michael@0 | 96 | #cond, 0), 0))) |
michael@0 | 97 | #define ENSURE_ERR(cond) \ |
michael@0 | 98 | ((void) ((cond) || \ |
michael@0 | 99 | ((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \ |
michael@0 | 100 | #cond, 1), 0))) |
michael@0 | 101 | #else |
michael@0 | 102 | #define ENSURE(cond) ((void) (cond)) |
michael@0 | 103 | #define ENSURE_ERR(cond) ((void) (cond)) |
michael@0 | 104 | #endif /* CHECK_ENSURE */ |
michael@0 | 105 | |
michael@0 | 106 | #if CHECK_INSIST != 0 |
michael@0 | 107 | #define INSIST(cond) \ |
michael@0 | 108 | ((void) ((cond) || \ |
michael@0 | 109 | ((__assertion_failed)(__FILE__, __LINE__, assert_insist, \ |
michael@0 | 110 | #cond, 0), 0))) |
michael@0 | 111 | #define INSIST_ERR(cond) \ |
michael@0 | 112 | ((void) ((cond) || \ |
michael@0 | 113 | ((__assertion_failed)(__FILE__, __LINE__, assert_insist, \ |
michael@0 | 114 | #cond, 1), 0))) |
michael@0 | 115 | #else |
michael@0 | 116 | #define INSIST(cond) ((void) (cond)) |
michael@0 | 117 | #define INSIST_ERR(cond) ((void) (cond)) |
michael@0 | 118 | #endif /* CHECK_INSIST */ |
michael@0 | 119 | |
michael@0 | 120 | #if CHECK_INVARIANT != 0 |
michael@0 | 121 | #define INVARIANT(cond) \ |
michael@0 | 122 | ((void) ((cond) || \ |
michael@0 | 123 | ((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \ |
michael@0 | 124 | #cond, 0), 0))) |
michael@0 | 125 | #define INVARIANT_ERR(cond) \ |
michael@0 | 126 | ((void) ((cond) || \ |
michael@0 | 127 | ((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \ |
michael@0 | 128 | #cond, 1), 0))) |
michael@0 | 129 | #else |
michael@0 | 130 | #define INVARIANT(cond) ((void) (cond)) |
michael@0 | 131 | #define INVARIANT_ERR(cond) ((void) (cond)) |
michael@0 | 132 | #endif /* CHECK_INVARIANT */ |
michael@0 | 133 | |
michael@0 | 134 | #endif /* ASSERTIONS_H */ |