]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/third-party/folly/folly/Portability.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / rocksdb / third-party / folly / folly / Portability.h
CommitLineData
f67539c2
TL
1// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2// This source code is licensed under both the GPLv2 (found in the
3// COPYING file in the root directory) and Apache 2.0 License
4// (found in the LICENSE.Apache file in the root directory).
5
6#pragma once
7
8#include <folly/CPortability.h>
9
10#if defined(__arm__)
11#define FOLLY_ARM 1
12#else
13#define FOLLY_ARM 0
14#endif
15
16#if defined(__x86_64__) || defined(_M_X64)
17#define FOLLY_X64 1
18#else
19#define FOLLY_X64 0
20#endif
21
22#if defined(__aarch64__)
23#define FOLLY_AARCH64 1
24#else
25#define FOLLY_AARCH64 0
26#endif
27
28#if defined(__powerpc64__)
29#define FOLLY_PPC64 1
30#else
31#define FOLLY_PPC64 0
32#endif
33
34#if defined(__has_builtin)
35#define FOLLY_HAS_BUILTIN(...) __has_builtin(__VA_ARGS__)
36#else
37#define FOLLY_HAS_BUILTIN(...) 0
38#endif
39
40#if defined(__has_cpp_attribute)
41#if __has_cpp_attribute(nodiscard)
42#define FOLLY_NODISCARD [[nodiscard]]
43#endif
44#endif
45#if !defined FOLLY_NODISCARD
46#if defined(_MSC_VER) && (_MSC_VER >= 1700)
47#define FOLLY_NODISCARD _Check_return_
48#elif defined(__GNUC__)
49#define FOLLY_NODISCARD __attribute__((__warn_unused_result__))
50#else
51#define FOLLY_NODISCARD
52#endif
53#endif
54
55namespace folly {
56constexpr bool kIsArchArm = FOLLY_ARM == 1;
57constexpr bool kIsArchAmd64 = FOLLY_X64 == 1;
58constexpr bool kIsArchAArch64 = FOLLY_AARCH64 == 1;
59constexpr bool kIsArchPPC64 = FOLLY_PPC64 == 1;
60} // namespace folly
61
62namespace folly {
63#ifdef NDEBUG
64constexpr auto kIsDebug = false;
65#else
66constexpr auto kIsDebug = true;
67#endif
68} // namespace folly
69
70namespace folly {
71#if defined(_MSC_VER)
72constexpr bool kIsMsvc = true;
73#else
74constexpr bool kIsMsvc = false;
75#endif
76} // namespace folly
77
78namespace folly {
79#if FOLLY_SANITIZE_THREAD
80constexpr bool kIsSanitizeThread = true;
81#else
82constexpr bool kIsSanitizeThread = false;
83#endif
84} // namespace folly
20effc67
TL
85
86namespace folly {
87#if defined(__linux__) && !FOLLY_MOBILE
88constexpr auto kIsLinux = true;
89#else
90constexpr auto kIsLinux = false;
91#endif
92} // namespace folly