diff options
author | 2012-08-28 15:22:37 +0000 | |
---|---|---|
committer | 2012-08-28 15:22:37 +0000 | |
commit | 536079b2099e986853c82c874059a6bcd7602742 (patch) | |
tree | a5ffcdf90637a4de5cef74e33a195203a0dee999 /include/core | |
parent | 0dd5ceb6d621c278ab09e97ea7e2172007990a5a (diff) |
Fix Clang build on Android.
The optimize attribute is not supported with Clang/ARM r161757.
This warning, turned into an error, is emitted by -Wattribute (implicitly set).
Review URL: https://codereview.appspot.com/6489045
git-svn-id: http://skia.googlecode.com/svn/trunk@5316 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkPreConfig.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/core/SkPreConfig.h b/include/core/SkPreConfig.h index 9104fa47a3..14767f6819 100644 --- a/include/core/SkPreConfig.h +++ b/include/core/SkPreConfig.h @@ -189,5 +189,32 @@ # define SK_PURE_FUNC /* nothing */ #endif +////////////////////////////////////////////////////////////////////// + +/** + * SK_HAS_ATTRIBUTE(<name>) should return true iff the compiler + * supports __attribute__((<name>)). Mostly important because + * Clang doesn't support all of GCC attributes. + */ +#if defined(__has_attribute) +# define SK_HAS_ATTRIBUTE(x) __has_attribute(x) +#elif defined(__GNUC__) +# define SK_HAS_ATTRIBUTE(x) 1 +#else +# define SK_HAS_ATTRIBUTE(x) 0 +#endif + +/** + * SK_ATTRIBUTE_OPTIMIZE_O1 can be used as a function attribute + * to specify individual optimization level of -O1, if the compiler + * supports it. + * + * NOTE: Clang/ARM (r161757) does not support the 'optimize' attribute. + */ +#if SK_HAS_ATTRIBUTE(optimize) +# define SK_ATTRIBUTE_OPTIMIZE_O1 __attribute__((optimize("O1"))) +#else +# define SK_ATTRIBUTE_OPTIMIZE_O1 /* nothing */ #endif +#endif |