3
3
* Copyright (c) 2019 Haivision Systems Inc.
4
4
*
5
5
* This Source Code Form is subject to the terms of the Mozilla Public
6
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
6
+
* License, v.2.0. If a copy of the MPL was not distributed with this
7
7
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
8
*
9
9
*/
10
10
/*****************************************************************************
11
11
The file contains various planform and compiler dependent attribute definitions
12
12
used by SRT library internally.
13
-
14
-
1. Attributes for thread safety analysis
15
-
- Clang (https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutexheader).
16
-
- Other compilers: none.
17
-
18
13
*****************************************************************************/
19
14
20
15
#ifndef INC_SRT_ATTR_DEFS_H
21
16
#define INC_SRT_ATTR_DEFS_H
22
17
18
+
// ATTRIBUTES:
19
+
//
20
+
// SRT_ATR_UNUSED: declare an entity ALLOWED to be unused (prevents warnings)
21
+
// ATR_DEPRECATED: declare an entity deprecated (compiler should warn when used)
22
+
// ATR_NOEXCEPT: The true `noexcept` from C++11, or nothing if compiling in pre-C++11 mode
23
+
// ATR_NOTHROW: In C++11: `noexcept`. In pre-C++11: `throw()`. Required for GNU libstdc++.
24
+
// ATR_CONSTEXPR: In C++11: `constexpr`. Otherwise empty.
25
+
// ATR_OVERRIDE: In C++11: `override`. Otherwise empty.
26
+
// ATR_FINAL: In C++11: `final`. Otherwise empty.
27
+
28
+
#ifdef __GNUG__
29
+
#define ATR_DEPRECATED __attribute__((deprecated))
30
+
#else
31
+
#define ATR_DEPRECATED
32
+
#endif
33
+
34
+
#if defined(__cplusplus) && __cplusplus > 199711L
35
+
#define HAVE_CXX11 1
36
+
// For gcc 4.7, claim C++11 is supported, as long as experimental C++0x is on,
37
+
// however it's only the "most required C++11 support".
38
+
#if defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC__ == 4 && __GNUC_MINOR__ >= 7 // 4.7 only!
39
+
#define ATR_NOEXCEPT
40
+
#define ATR_NOTHROW throw()
41
+
#define ATR_CONSTEXPR
42
+
#define ATR_OVERRIDE
43
+
#define ATR_FINAL
44
+
#else
45
+
#define HAVE_FULL_CXX11 1
46
+
#define ATR_NOEXCEPT noexcept
47
+
#define ATR_NOTHROW noexcept
48
+
#define ATR_CONSTEXPR constexpr
49
+
#define ATR_OVERRIDE override
50
+
#define ATR_FINAL final
51
+
#endif
52
+
#elif defined(_MSC_VER) && _MSC_VER >= 1800
53
+
// Microsoft Visual Studio supports C++11, but not fully,
54
+
// and still did not change the value of __cplusplus. Treat
55
+
// this special way.
56
+
// _MSC_VER == 1800 means Microsoft Visual Studio 2013.
57
+
#define HAVE_CXX11 1
58
+
#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 190023026
59
+
#define HAVE_FULL_CXX11 1
60
+
#define ATR_NOEXCEPT noexcept
61
+
#define ATR_NOTHROW noexcept
62
+
#define ATR_CONSTEXPR constexpr
63
+
#define ATR_OVERRIDE override
64
+
#define ATR_FINAL final
65
+
#else
66
+
#define ATR_NOEXCEPT
67
+
#define ATR_NOTHROW throw()
68
+
#define ATR_CONSTEXPR
69
+
#define ATR_OVERRIDE
70
+
#define ATR_FINAL
71
+
#endif
72
+
#else
73
+
#define HAVE_CXX11 0
74
+
#define ATR_NOEXCEPT
75
+
#define ATR_NOTHROW throw()
76
+
#define ATR_CONSTEXPR
77
+
#define ATR_OVERRIDE
78
+
#define ATR_FINAL
79
+
#endif // __cplusplus
80
+
81
+
#if !HAVE_CXX11 && defined(REQUIRE_CXX11) && REQUIRE_CXX11 == 1
82
+
#error "The currently compiled application required C++11, but your compiler doesn't support it."
83
+
#endif
84
+
85
+
///////////////////////////////////////////////////////////////////////////////
86
+
// Attributes for thread safety analysis
87
+
// - Clang TSA (https://clang.llvm.org/docs/ThreadSafetyAnalysis.html#mutexheader).
88
+
// - MSVC SAL (partially).
89
+
// - Other compilers: none.
90
+
///////////////////////////////////////////////////////////////////////////////
23
91
#if _MSC_VER >= 1920
24
92
// In case of MSVC these attributes have to preceed the attributed objects (variable, function).
25
93
// E.g. SRT_ATTR_GUARDED_BY(mtx) int object;
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4