Andrew Scull | 5c496a3 | 2019-04-04 11:57:33 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 The Hafnium Authors. |
| 3 | * |
Andrew Walbran | e959ec1 | 2020-06-17 15:01:09 +0100 | [diff] [blame] | 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. |
Andrew Scull | 5c496a3 | 2019-04-04 11:57:33 +0100 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #pragma once |
| 10 | |
Andrew Scull | f825293 | 2019-04-04 13:51:22 +0100 | [diff] [blame] | 11 | #include "hf/panic.h" |
| 12 | |
| 13 | /** |
Andrew Scull | 877ae4b | 2019-07-02 12:52:33 +0100 | [diff] [blame] | 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. |
Andrew Scull | f825293 | 2019-04-04 13:51:22 +0100 | [diff] [blame] | 19 | */ |
Daniel Boulby | 6530adf | 2021-11-26 09:54:01 +0000 | [diff] [blame] | 20 | #define CHECK(x) \ |
| 21 | do { \ |
| 22 | if (!(x)) { \ |
| 23 | panic("check failed (%s) at %s:%d", #x, __FILE__, \ |
| 24 | __LINE__); \ |
| 25 | } \ |
Andrew Scull | f825293 | 2019-04-04 13:51:22 +0100 | [diff] [blame] | 26 | } while (0) |