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 
55 namespace folly {
56 constexpr bool kIsArchArm = FOLLY_ARM == 1;
57 constexpr bool kIsArchAmd64 = FOLLY_X64 == 1;
58 constexpr bool kIsArchAArch64 = FOLLY_AARCH64 == 1;
59 constexpr bool kIsArchPPC64 = FOLLY_PPC64 == 1;
60 } // namespace folly
61 
62 namespace folly {
63 #ifdef NDEBUG
64 constexpr auto kIsDebug = false;
65 #else
66 constexpr auto kIsDebug = true;
67 #endif
68 } // namespace folly
69 
70 namespace folly {
71 #if defined(_MSC_VER)
72 constexpr bool kIsMsvc = true;
73 #else
74 constexpr bool kIsMsvc = false;
75 #endif
76 } // namespace folly
77 
78 namespace folly {
79 #if FOLLY_SANITIZE_THREAD
80 constexpr bool kIsSanitizeThread = true;
81 #else
82 constexpr bool kIsSanitizeThread = false;
83 #endif
84 } // namespace folly
85 
86 namespace folly {
87 #if defined(__linux__) && !FOLLY_MOBILE
88 constexpr auto kIsLinux = true;
89 #else
90 constexpr auto kIsLinux = false;
91 #endif
92 } // namespace folly
93