1 /*
2  * Copyright 2019 The Hafnium Authors.
3  *
4  * Use of this source code is governed by a BSD-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/BSD-3-Clause.
7  */
8 
9 #pragma once
10 
11 #include "hf/panic.h"
12 
13 /**
14  * Only use to check assumptions which, if false, mean the system is in a bad
15  * state and it is unsafe to continue.
16  *
17  * Do not use if the condition could ever be legitimately false e.g. when
18  * processing external inputs.
19  */
20 #define CHECK(x)                                                          \
21 	do {                                                              \
22 		if (!(x)) {                                               \
23 			panic("check failed (%s) at %s:%d", #x, __FILE__, \
24 			      __LINE__);                                  \
25 		}                                                         \
26 	} while (0)
27