blob: 1ec51bb5f4ae3f25d15c308be62db5353bb4fede [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 */
Andrew Scull877ae4b2019-07-02 12:52:33 +010020#define CHECK(x) \
Andrew Scullf8252932019-04-04 13:51:22 +010021 do { \
22 if (!(x)) { \
23 panic("assertion failed (%s) at %s:%d", #x, __FILE__, \
24 __LINE__); \
25 } \
26 } while (0)