RawSpeed
fast raw decoding library
Loading...
Searching...
No Matches
Invariant.h
Go to the documentation of this file.
1
/*
2
RawSpeed - RAW file decoder.
3
4
Copyright (C) 2023 Roman Lebedev
5
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2 of the License, or (at your option) any later version.
10
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
15
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
21
#pragma once
22
23
#ifndef NDEBUG
24
25
#include <cassert>
26
27
#define invariant(expr) assert(expr)
28
29
#else
// NDEBUG
30
31
#ifndef __has_builtin
// Optional of course.
32
#define __has_builtin(x) 0
// Compatibility with non-clang compilers.
33
#endif
34
35
#if __has_builtin(__builtin_assume)
36
37
#define invariant(expr) __builtin_assume(expr)
38
39
#else
// __has_builtin(__builtin_assume)
40
41
namespace
rawspeed
{
42
43
__attribute__
((always_inline))
constexpr
inline
void
invariant
(
bool
precond) {
44
if
(!precond)
45
__builtin_unreachable();
46
}
47
48
}
// namespace rawspeed
49
50
#endif
// __has_builtin(__builtin_assume)
51
52
#endif
// NDEBUG
invariant
#define invariant(expr)
Definition
Invariant.h:27
rawspeed
Definition
CoalescingOutputIteratorBenchmark.cpp:35
rawspeed::__attribute__
__attribute__((noinline)) __attribute__((visibility("default"))) JPEGStuffedByteStreamGenerator
Definition
BitStreamJPEGUtils.cpp:92
librawspeed
adt
Invariant.h
Generated by
1.15.0