Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: build/build_config_functions.h

Issue 103293003: Add build_config_functions.h to avoid #ifdef (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/build_config.h ('k') | content/common/sandbox_seccomp_bpf_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_
OLDNEW
« no previous file with comments | « build/build_config.h ('k') | content/common/sandbox_seccomp_bpf_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698