vstat
Loading...
Searching...
No Matches
util.hpp
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: Copyright 2020-2023 Heal Research
3
4#ifndef VSTAT_UTIL_HPP
5#define VSTAT_UTIL_HPP
6
7#if defined(__GNUC__) || defined(__GNUG__)
8#define VSTAT_FORCE_INLINE __attribute__((always_inline)) inline
9#else
10#define VSTAT_FORCE_INLINE inline
11#endif
12
13#define VSTAT_EXPECT(cond) \
14 if (!(cond)) { \
15 std::cerr << "precondition " << #cond << " failed at " << __FILE__ << ": " << __LINE__ << "\n"; \
16 std::terminate(); \
17 }
18
19#define VSTAT_ENSURE(cond) \
20 if (!(cond)) { \
21 std::cerr << "postcondition " << #cond << " failed at " << __FILE__ << ": " << __LINE__ << "\n"; \
22 std::terminate(); \
23 }
24
25#if !defined(VSTAT_NAMESPACE)
26#define VSTAT_NAMESPACE vstat
27#endif
28
29#endif