other-licenses/android/assertions.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial