Andrew Scull | 5c496a3 | 2019-04-04 11:57:33 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 19 | #if !defined(__cplusplus) |
Andrew Scull | f825293 | 2019-04-04 13:51:22 +0100 | [diff] [blame^] | 20 | |
| 21 | #include "hf/panic.h" |
| 22 | |
| 23 | /** |
| 24 | * Only use for exceptional cases and never if the condition could be true e.g. |
| 25 | * when processing external inputs. |
| 26 | */ |
| 27 | #define assert(x) \ |
| 28 | do { \ |
| 29 | if (!(x)) { \ |
| 30 | panic("assertion failed (%s) at %s:%d", #x, __FILE__, \ |
| 31 | __LINE__); \ |
| 32 | } \ |
| 33 | } while (0) |
| 34 | |
Andrew Scull | 5c496a3 | 2019-04-04 11:57:33 +0100 | [diff] [blame] | 35 | #define static_assert _Static_assert |
Andrew Scull | f825293 | 2019-04-04 13:51:22 +0100 | [diff] [blame^] | 36 | |
Andrew Scull | 5c496a3 | 2019-04-04 11:57:33 +0100 | [diff] [blame] | 37 | #endif |