bmv2
Designing your own switch target with bmv2
Loading...
Searching...
No Matches
_assert.h
1/* Copyright 2013-present Barefoot Networks, Inc.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/*
17 * Antonin Bas (antonin@barefootnetworks.com)
18 *
19 */
20
21#ifndef BM_BM_SIM__ASSERT_H_
22#define BM_BM_SIM__ASSERT_H_
23
24// An assert that cannot be removed with NDEBUG
25
26namespace bm {
27
28[[ noreturn ]] void _bm_assert(const char* expr, const char* file, int line);
29
30} // namespace bm
31
32#define _BM_ASSERT(expr) \
33 ((expr) ? (void)0 : bm::_bm_assert(#expr, __FILE__, __LINE__))
34
35#define _BM_UNREACHABLE(msg) bm::_bm_assert(msg, __FILE__, __LINE__)
36
37#define _BM_UNUSED(x) ((void)x)
38
39#endif // BM_BM_SIM__ASSERT_H_