OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // These helpers allow to avoid the use of an #ifdef when the code can | |
6 // compile without them. Thanks to compiler optimizations, the final generated | |
7 // binary will look the same when using these. | |
Robert Sesek
2013/12/04 18:41:22
Is this guaranteed on every platform/arch on which
jln (very slow on Chromium)
2013/12/04 20:37:36
No, "inline" itself is not even guaranteed, changi
Robert Sesek
2013/12/05 14:51:46
Yes, so I worry that extensive use of these may me
| |
8 | |
9 #ifndef BUILD_BUILD_CONFIG_FUNCTIONS_H_ | |
10 #define BUILD_BUILD_CONFIG_FUNCTIONS_H_ | |
11 | |
12 #include "build/build_config.h" | |
13 | |
Robert Sesek
2013/12/04 18:41:22
Should these be in base:: ?
jln (very slow on Chromium)
2013/12/04 20:37:36
Yes, I think you're right, this would be better in
| |
14 inline bool IsASANBuild() { | |
15 #if defined(ADDRESS_SANITIZER) | |
16 return true; | |
17 #else | |
18 return false; | |
19 #endif | |
20 } | |
21 | |
22 inline bool IsLinux() { | |
23 #if defined(OS_LINUX) | |
24 return true; | |
25 #else | |
26 return false; | |
27 #endif | |
28 } | |
29 | |
30 inline bool IsChromeOS() { | |
31 #if defined(OS_CHROMEOS) | |
32 return true; | |
33 #else | |
34 return false; | |
35 #endif | |
36 } | |
37 | |
38 inline bool IsAndroid() { | |
39 #if defined(OS_ANDROID) | |
40 return true; | |
41 #else | |
42 return false; | |
43 #endif | |
44 } | |
45 | |
46 inline bool IsPosix() { | |
Robert Sesek
2013/12/04 18:41:22
You capitalize ASAN above, but not POSIX here.
jln (very slow on Chromium)
2013/12/04 20:37:36
Done.
| |
47 #if defined(OS_POSIX) | |
48 return true; | |
49 #else | |
50 return false; | |
51 #endif | |
52 } | |
53 | |
54 inline bool IsWindows() { | |
55 #if defined(OS_WIN) | |
56 return true; | |
57 #else | |
58 return false; | |
59 #endif | |
60 } | |
61 | |
Robert Sesek
2013/12/04 18:41:22
IsMac() ?
jln (very slow on Chromium)
2013/12/04 20:37:36
Done.
| |
62 inline bool IsArchitectureX86_64() { | |
63 #if defined(__x86_64__) | |
64 return true; | |
65 #else | |
66 return false; | |
67 #endif | |
68 } | |
69 | |
70 inline bool IsArchitectureI386() { | |
71 #if defined(__i386__) | |
72 return true; | |
73 #else | |
74 return false; | |
75 #endif | |
76 } | |
77 | |
78 inline bool IsArchitectureArm() { | |
79 #if defined(__arm__) | |
80 return true; | |
81 #else | |
82 return false; | |
83 #endif | |
84 } | |
85 | |
86 inline bool IsUsingToolKitGtk() { | |
87 #if defined(TOOLKIT_GTK) | |
88 return true; | |
89 #else | |
90 return false; | |
91 #endif | |
92 } | |
93 | |
94 #endif // BUILD_BUILD_CONFIG_FUNCTIONS_H_ | |
OLD | NEW |