blob: 41e005f56b9c9f3b5b250edd517e7029ec88df91 [file] [log] [blame]
Andrew Scull5c496a32019-04-04 11:57:33 +01001/*
2 * Copyright 2019 The Hafnium Authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
Andrew Scullf8252932019-04-04 13:51:22 +010019#include "hf/panic.h"
20
21/**
Andrew Scull877ae4b2019-07-02 12:52:33 +010022 * Only use to check assumptions which, if false, mean the system is in a bad
23 * state and it is unsafe to continue.
24 *
25 * Do not use if the condition could ever be legitimately false e.g. when
26 * processing external inputs.
Andrew Scullf8252932019-04-04 13:51:22 +010027 */
Andrew Scull877ae4b2019-07-02 12:52:33 +010028#define CHECK(x) \
Andrew Scullf8252932019-04-04 13:51:22 +010029 do { \
30 if (!(x)) { \
31 panic("assertion failed (%s) at %s:%d", #x, __FILE__, \
32 __LINE__); \
33 } \
34 } while (0)