-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompiler_extensions.h
57 lines (45 loc) · 1.11 KB
/
compiler_extensions.h
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// SPDX-License-Identifier: 0BSD
// Copyright (C) 2022 Ayman El Didi
#ifndef COMPILER_EXTENSIONS_H
#define COMPILER_EXTENSIONS_H
// This file contains commonly implemented extensions which we make use of.
#if !defined(ENCODING_PUBLIC)
#define ENCODING_PUBLIC
#endif
// Finding the C version
#if !defined(ENCODING_C23)
#define ENCODING_C23 0
#endif
#if !defined(ENCODING_C11)
#define ENCODING_C11 0
#endif
#if defined(__STDC_VERSION__)
#if __STDC_VERSION__ >= 201112L
#undef ENCODING_C11
#define ENCODING_C11 1
#endif
#if __STDC_VERSION__ >= 202311L
#undef ENCODING_C23
#define ENCODING_C23 1
#endif
#endif // defined(__STDC_VERSION__)
#ifndef ENCODING_CPP17
#define ENCODING_CPP17 0
#endif
#if defined(__cplusplus)
#if __cplusplus >= 201703L
#undef ENCODING_CPP17
#define ENCODING_CPP17 1
#endif
#endif
// Finding supported attributes
#if !defined(UNLIKELY)
#define UNLIKELY(expr) (expr)
#if defined(__has_builtin)
#if __has_builtin(__builtin_expect)
#undef UNLIKELY
#define UNLIKELY(expr) __builtin_expect(!!(expr), 0)
#endif
#endif // defined(__has_builtin)
#endif // !defined(UNLIKELY)
#endif // COMPILER_EXTENSIONS_H