1 /* 2 * Copyright (c) 2020 The WebM project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef VPX_VPX_PORTS_COMPILER_ATTRIBUTES_H_ 12 #define VPX_VPX_PORTS_COMPILER_ATTRIBUTES_H_ 13 14 #if !defined(__has_feature) 15 #define __has_feature(x) 0 16 #endif // !defined(__has_feature) 17 18 #if !defined(__has_attribute) 19 #define __has_attribute(x) 0 20 #endif // !defined(__has_attribute) 21 22 //------------------------------------------------------------------------------ 23 // Sanitizer attributes. 24 25 #if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__) 26 #define VPX_WITH_ASAN 1 27 #else 28 #define VPX_WITH_ASAN 0 29 #endif // __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__) 30 31 #if defined(__clang__) && __has_attribute(no_sanitize) 32 #define VPX_NO_UNSIGNED_OVERFLOW_CHECK \ 33 __attribute__((no_sanitize("unsigned-integer-overflow"))) 34 #endif 35 36 #ifndef VPX_NO_UNSIGNED_OVERFLOW_CHECK 37 #define VPX_NO_UNSIGNED_OVERFLOW_CHECK 38 #endif 39 40 //------------------------------------------------------------------------------ 41 // Variable attributes. 42 43 #if __has_attribute(uninitialized) 44 // Attribute "uninitialized" disables -ftrivial-auto-var-init=pattern for 45 // the specified variable. 46 // 47 // -ftrivial-auto-var-init is security risk mitigation feature, so attribute 48 // should not be used "just in case", but only to fix real performance 49 // bottlenecks when other approaches do not work. In general the compiler is 50 // quite effective at eliminating unneeded initializations introduced by the 51 // flag, e.g. when they are followed by actual initialization by a program. 52 // However if compiler optimization fails and code refactoring is hard, the 53 // attribute can be used as a workaround. 54 #define VPX_UNINITIALIZED __attribute__((uninitialized)) 55 #else 56 #define VPX_UNINITIALIZED 57 #endif // __has_attribute(uninitialized) 58 59 #endif // VPX_VPX_PORTS_COMPILER_ATTRIBUTES_H_ 60