xref: /freebsd/sys/dev/random/fenestrasX/fx_priv.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1a3c41f8bSConrad Meyer /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3a3c41f8bSConrad Meyer  *
4a3c41f8bSConrad Meyer  * Copyright (c) 2019 Conrad Meyer <cem@FreeBSD.org>
5a3c41f8bSConrad Meyer  *
6a3c41f8bSConrad Meyer  * Redistribution and use in source and binary forms, with or without
7a3c41f8bSConrad Meyer  * modification, are permitted provided that the following conditions
8a3c41f8bSConrad Meyer  * are met:
9a3c41f8bSConrad Meyer  * 1. Redistributions of source code must retain the above copyright
10a3c41f8bSConrad Meyer  *    notice, this list of conditions and the following disclaimer.
11a3c41f8bSConrad Meyer  * 2. Redistributions in binary form must reproduce the above copyright
12a3c41f8bSConrad Meyer  *    notice, this list of conditions and the following disclaimer in the
13a3c41f8bSConrad Meyer  *    documentation and/or other materials provided with the distribution.
14a3c41f8bSConrad Meyer  *
15a3c41f8bSConrad Meyer  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16a3c41f8bSConrad Meyer  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17a3c41f8bSConrad Meyer  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18a3c41f8bSConrad Meyer  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19a3c41f8bSConrad Meyer  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20a3c41f8bSConrad Meyer  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21a3c41f8bSConrad Meyer  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22a3c41f8bSConrad Meyer  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23a3c41f8bSConrad Meyer  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24a3c41f8bSConrad Meyer  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25a3c41f8bSConrad Meyer  * SUCH DAMAGE.
26a3c41f8bSConrad Meyer  */
27a3c41f8bSConrad Meyer #pragma once
28a3c41f8bSConrad Meyer 
29a3c41f8bSConrad Meyer #define	ASSERT(x, fmt, ...) do {					\
30a3c41f8bSConrad Meyer 	if (__predict_true(x))					\
31a3c41f8bSConrad Meyer 		break;							\
32a3c41f8bSConrad Meyer 	panic("%s:%d: Assertion '" #x "' in function %s failed: " fmt, 	\
33a3c41f8bSConrad Meyer 	    __FILE__, __LINE__, __func__, ## __VA_ARGS__);		\
34a3c41f8bSConrad Meyer } while (false)
35a3c41f8bSConrad Meyer #ifdef INVARIANTS
36a3c41f8bSConrad Meyer #define	ASSERT_DEBUG(x, fmt, ...) do {					\
37a3c41f8bSConrad Meyer 	if (__predict_true(x))					\
38a3c41f8bSConrad Meyer 		break;							\
39a3c41f8bSConrad Meyer 	panic("%s:%d: Assertion '" #x "' in function %s failed: " fmt, 	\
40a3c41f8bSConrad Meyer 	    __FILE__, __LINE__, __func__, ## __VA_ARGS__);		\
41a3c41f8bSConrad Meyer } while (false)
42a3c41f8bSConrad Meyer #else
43a3c41f8bSConrad Meyer #define	ASSERT_DEBUG(...)
44a3c41f8bSConrad Meyer #endif
45a3c41f8bSConrad Meyer 
46a3c41f8bSConrad Meyer extern struct fxrng_buffered_rng fxrng_root;
47