summaryrefslogtreecommitdiffstats
path: root/include/c/str/cpy/stp/_compiler.h
blob: 7b76f5fd41ab0d4b104da3edc4ce0a18f61b8247 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2022 Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier:  LGPL-3.0-or-later WITH LGPL-3.0-linking-exception


#ifndef INCLUDE_C_STR_CPY_STP__COMPILER_H_
#define INCLUDE_C_STR_CPY_STP__COMPILER_H_


#if (__STDC_VERSION__ < 202000L)
# warn "Minimum C version is C23"
#endif


#define c_impossible(e)  do                                                   \
{                                                                             \
	if (e)                                                                \
		c_unreachable();                                              \
} while (0)

#if defined(__clang__)
# define c_nullable       _Nullable
#else
# define c_nullable
#endif

#define c_unlikely(e)     __builtin_expect(!!(e), 0)

#if defined(unreachable)
# define c_unreachable()  unreachable()
#else
# define c_unreachable()  __builtin_unreachable()
#endif


#endif  // Header guard