Chromium Code Reviews| Index: build/build_config_functions.h |
| diff --git a/build/build_config_functions.h b/build/build_config_functions.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1e61e629ed46015e5f210fea1c627cf247124772 |
| --- /dev/null |
| +++ b/build/build_config_functions.h |
| @@ -0,0 +1,94 @@ |
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +// These helpers allow to avoid the use of an #ifdef when the code can |
| +// compile without them. Thanks to compiler optimizations, the final generated |
| +// 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
|
| + |
| +#ifndef BUILD_BUILD_CONFIG_FUNCTIONS_H_ |
| +#define BUILD_BUILD_CONFIG_FUNCTIONS_H_ |
| + |
| +#include "build/build_config.h" |
| + |
|
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
|
| +inline bool IsASANBuild() { |
| +#if defined(ADDRESS_SANITIZER) |
| + return true; |
| +#else |
| + return false; |
| +#endif |
| +} |
| + |
| +inline bool IsLinux() { |
| +#if defined(OS_LINUX) |
| + return true; |
| +#else |
| + return false; |
| +#endif |
| +} |
| + |
| +inline bool IsChromeOS() { |
| +#if defined(OS_CHROMEOS) |
| + return true; |
| +#else |
| + return false; |
| +#endif |
| +} |
| + |
| +inline bool IsAndroid() { |
| +#if defined(OS_ANDROID) |
| + return true; |
| +#else |
| + return false; |
| +#endif |
| +} |
| + |
| +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.
|
| +#if defined(OS_POSIX) |
| + return true; |
| +#else |
| + return false; |
| +#endif |
| +} |
| + |
| +inline bool IsWindows() { |
| +#if defined(OS_WIN) |
| + return true; |
| +#else |
| + return false; |
| +#endif |
| +} |
| + |
|
Robert Sesek
2013/12/04 18:41:22
IsMac() ?
jln (very slow on Chromium)
2013/12/04 20:37:36
Done.
|
| +inline bool IsArchitectureX86_64() { |
| +#if defined(__x86_64__) |
| + return true; |
| +#else |
| + return false; |
| +#endif |
| +} |
| + |
| +inline bool IsArchitectureI386() { |
| +#if defined(__i386__) |
| + return true; |
| +#else |
| + return false; |
| +#endif |
| +} |
| + |
| +inline bool IsArchitectureArm() { |
| +#if defined(__arm__) |
| + return true; |
| +#else |
| + return false; |
| +#endif |
| +} |
| + |
| +inline bool IsUsingToolKitGtk() { |
| +#if defined(TOOLKIT_GTK) |
| + return true; |
| +#else |
| + return false; |
| +#endif |
| +} |
| + |
| +#endif // BUILD_BUILD_CONFIG_FUNCTIONS_H_ |