diff --git a/include/core/SkPreConfig.h b/include/core/SkPreConfig.h index 9104fa47a..14767f681 100644 --- a/include/core/SkPreConfig.h +++ b/include/core/SkPreConfig.h @@ -189,5 +189,32 @@ # define SK_PURE_FUNC /* nothing */ #endif +////////////////////////////////////////////////////////////////////// + +/** + * SK_HAS_ATTRIBUTE() should return true iff the compiler + * supports __attribute__(()). 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 diff --git a/src/opts/SkBitmapProcState_opts_arm.cpp b/src/opts/SkBitmapProcState_opts_arm.cpp index 7a9687df7..4a7942fe3 100644 --- a/src/opts/SkBitmapProcState_opts_arm.cpp +++ b/src/opts/SkBitmapProcState_opts_arm.cpp @@ -16,7 +16,7 @@ void SI8_D16_nofilter_DX_arm( const SkBitmapProcState& s, const uint32_t* SK_RESTRICT xy, int count, - uint16_t* SK_RESTRICT colors) __attribute__((optimize("O1"))); + uint16_t* SK_RESTRICT colors) SK_ATTRIBUTE_OPTIMIZE_O1; void SI8_D16_nofilter_DX_arm(const SkBitmapProcState& s, const uint32_t* SK_RESTRICT xy, @@ -107,7 +107,7 @@ void SI8_opaque_D32_nofilter_DX_arm( const SkBitmapProcState& s, const uint32_t* SK_RESTRICT xy, int count, - SkPMColor* SK_RESTRICT colors) __attribute__((optimize("O1"))); + SkPMColor* SK_RESTRICT colors) SK_ATTRIBUTE_OPTIMIZE_O1; void SI8_opaque_D32_nofilter_DX_arm(const SkBitmapProcState& s, const uint32_t* SK_RESTRICT xy,