other-licenses/android/assertions.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/other-licenses/android/assertions.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,134 @@
     1.4 +/*	$NetBSD: assertions.h,v 1.1.1.1 2004/05/20 19:49:41 christos Exp $	*/
     1.5 +
     1.6 +/*
     1.7 + * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
     1.8 + * Copyright (c) 1997-1999 by Internet Software Consortium.
     1.9 + *
    1.10 + * Permission to use, copy, modify, and distribute this software for any
    1.11 + * purpose with or without fee is hereby granted, provided that the above
    1.12 + * copyright notice and this permission notice appear in all copies.
    1.13 + *
    1.14 + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
    1.15 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
    1.16 + * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
    1.17 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
    1.18 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
    1.19 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
    1.20 + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
    1.21 + */
    1.22 +
    1.23 +/*
    1.24 + * Id: assertions.h,v 1.1.206.1 2004/03/09 08:33:30 marka Exp
    1.25 + */
    1.26 +
    1.27 +/*
    1.28 + * This version of this file is derived from Android 2.3 "Gingerbread",
    1.29 + * which contains uncredited changes by Android/Google developers.  It has
    1.30 + * been modified in 2011 for use in the Android build of Mozilla Firefox by
    1.31 + * Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
    1.32 + * and Steve Workman <sjhworkman@gmail.com>).
    1.33 + * These changes are offered under the same license as the original NetBSD
    1.34 + * file, whose copyright and license are unchanged above.
    1.35 + */
    1.36 +
    1.37 +#ifndef ASSERTIONS_H
    1.38 +#define ASSERTIONS_H		1
    1.39 +
    1.40 +typedef enum {
    1.41 +	assert_require, assert_ensure, assert_insist, assert_invariant
    1.42 +} assertion_type;
    1.43 +
    1.44 +typedef void (*assertion_failure_callback)(const char *, int, assertion_type,
    1.45 +					   const char *, int);
    1.46 +
    1.47 +extern assertion_failure_callback __assertion_failed;
    1.48 +void set_assertion_failure_callback(assertion_failure_callback f);
    1.49 +const char *assertion_type_to_text(assertion_type type);
    1.50 +
    1.51 +#ifdef CHECK_ALL
    1.52 +#define CHECK_REQUIRE		1
    1.53 +#define CHECK_ENSURE		1
    1.54 +#define CHECK_INSIST		1
    1.55 +#define CHECK_INVARIANT		1
    1.56 +#endif
    1.57 +
    1.58 +#ifdef CHECK_NONE
    1.59 +#define CHECK_REQUIRE		0
    1.60 +#define CHECK_ENSURE		0
    1.61 +#define CHECK_INSIST		0
    1.62 +#define CHECK_INVARIANT		0
    1.63 +#endif
    1.64 +
    1.65 +#ifndef CHECK_REQUIRE
    1.66 +#define CHECK_REQUIRE		1
    1.67 +#endif
    1.68 +
    1.69 +#ifndef CHECK_ENSURE
    1.70 +#define CHECK_ENSURE		1
    1.71 +#endif
    1.72 +
    1.73 +#ifndef CHECK_INSIST
    1.74 +#define CHECK_INSIST		1
    1.75 +#endif
    1.76 +
    1.77 +#ifndef CHECK_INVARIANT
    1.78 +#define CHECK_INVARIANT		1
    1.79 +#endif
    1.80 +
    1.81 +#if CHECK_REQUIRE != 0
    1.82 +#define REQUIRE(cond) \
    1.83 +	((void) ((cond) || \
    1.84 +		 ((__assertion_failed)(__FILE__, __LINE__, assert_require, \
    1.85 +				       #cond, 0), 0)))
    1.86 +#define REQUIRE_ERR(cond) \
    1.87 +	((void) ((cond) || \
    1.88 +		 ((__assertion_failed)(__FILE__, __LINE__, assert_require, \
    1.89 +				       #cond, 1), 0)))
    1.90 +#else
    1.91 +#define REQUIRE(cond)		((void) (cond))
    1.92 +#define REQUIRE_ERR(cond)	((void) (cond))
    1.93 +#endif /* CHECK_REQUIRE */
    1.94 +
    1.95 +#if CHECK_ENSURE != 0
    1.96 +#define ENSURE(cond) \
    1.97 +	((void) ((cond) || \
    1.98 +		 ((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \
    1.99 +				       #cond, 0), 0)))
   1.100 +#define ENSURE_ERR(cond) \
   1.101 +	((void) ((cond) || \
   1.102 +		 ((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \
   1.103 +				       #cond, 1), 0)))
   1.104 +#else
   1.105 +#define ENSURE(cond)		((void) (cond))
   1.106 +#define ENSURE_ERR(cond)	((void) (cond))
   1.107 +#endif /* CHECK_ENSURE */
   1.108 +
   1.109 +#if CHECK_INSIST != 0
   1.110 +#define INSIST(cond) \
   1.111 +	((void) ((cond) || \
   1.112 +		 ((__assertion_failed)(__FILE__, __LINE__, assert_insist, \
   1.113 +				       #cond, 0), 0)))
   1.114 +#define INSIST_ERR(cond) \
   1.115 +	((void) ((cond) || \
   1.116 +		 ((__assertion_failed)(__FILE__, __LINE__, assert_insist, \
   1.117 +				       #cond, 1), 0)))
   1.118 +#else
   1.119 +#define INSIST(cond)		((void) (cond))
   1.120 +#define INSIST_ERR(cond)	((void) (cond))
   1.121 +#endif /* CHECK_INSIST */
   1.122 +
   1.123 +#if CHECK_INVARIANT != 0
   1.124 +#define INVARIANT(cond) \
   1.125 +	((void) ((cond) || \
   1.126 +		 ((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \
   1.127 +				       #cond, 0), 0)))
   1.128 +#define INVARIANT_ERR(cond) \
   1.129 +	((void) ((cond) || \
   1.130 +		 ((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \
   1.131 +				       #cond, 1), 0)))
   1.132 +#else
   1.133 +#define INVARIANT(cond)		((void) (cond))
   1.134 +#define INVARIANT_ERR(cond)	((void) (cond))
   1.135 +#endif /* CHECK_INVARIANT */
   1.136 +
   1.137 +#endif /* ASSERTIONS_H */

mercurial