blob: 14564599100ce7f741808813326949c096fad98d [file] [log] [blame]
Andrew Scull5c496a32019-04-04 11:57:33 +01001/*
2 * Copyright 2019 The Hafnium Authors.
3 *
Andrew Walbrane959ec12020-06-17 15:01:09 +01004 * 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 Scull5c496a32019-04-04 11:57:33 +01007 */
8
9#pragma once
10
Andrew Scullf8252932019-04-04 13:51:22 +010011#include "hf/panic.h"
12
13/**
Andrew Scull877ae4b2019-07-02 12:52:33 +010014 * 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 Scullf8252932019-04-04 13:51:22 +010019 */
Daniel Boulby6530adf2021-11-26 09:54:01 +000020#define CHECK(x) \
21 do { \
22 if (!(x)) { \
23 panic("check failed (%s) at %s:%d", #x, __FILE__, \
24 __LINE__); \
25 } \
Andrew Scullf8252932019-04-04 13:51:22 +010026 } while (0)