summaryrefslogtreecommitdiff
path: root/vpx_ports
diff options
context:
space:
mode:
Diffstat (limited to 'vpx_ports')
-rw-r--r--vpx_ports/compiler_attributes.h59
-rw-r--r--vpx_ports/mem.h30
-rw-r--r--vpx_ports/vpx_ports.mk1
3 files changed, 60 insertions, 30 deletions
diff --git a/vpx_ports/compiler_attributes.h b/vpx_ports/compiler_attributes.h
new file mode 100644
index 000000000..354352016
--- /dev/null
+++ b/vpx_ports/compiler_attributes.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2020 The WebM project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#ifndef VPX_VPX_PORTS_COMPILER_ATTRIBUTES_H_
+#define VPX_VPX_PORTS_COMPILER_ATTRIBUTES_H_
+
+#if !defined(__has_feature)
+#define __has_feature(x) 0
+#endif // !defined(__has_feature)
+
+#if !defined(__has_attribute)
+#define __has_attribute(x) 0
+#endif // !defined(__has_attribute)
+
+//------------------------------------------------------------------------------
+// Sanitizer attributes.
+
+#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
+#define VPX_WITH_ASAN 1
+#else
+#define VPX_WITH_ASAN 0
+#endif // __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
+
+#if defined(__clang__) && __has_attribute(no_sanitize)
+#define VPX_NO_UNSIGNED_OVERFLOW_CHECK \
+ __attribute__((no_sanitize("unsigned-integer-overflow")))
+#endif
+
+#ifndef VPX_NO_UNSIGNED_OVERFLOW_CHECK
+#define VPX_NO_UNSIGNED_OVERFLOW_CHECK
+#endif
+
+//------------------------------------------------------------------------------
+// Variable attributes.
+
+#if __has_attribute(uninitialized)
+// Attribute "uninitialized" disables -ftrivial-auto-var-init=pattern for
+// the specified variable.
+//
+// -ftrivial-auto-var-init is security risk mitigation feature, so attribute
+// should not be used "just in case", but only to fix real performance
+// bottlenecks when other approaches do not work. In general the compiler is
+// quite effective at eliminating unneeded initializations introduced by the
+// flag, e.g. when they are followed by actual initialization by a program.
+// However if compiler optimization fails and code refactoring is hard, the
+// attribute can be used as a workaround.
+#define VPX_UNINITIALIZED __attribute__((uninitialized))
+#else
+#define VPX_UNINITIALIZED
+#endif // __has_attribute(uninitialized)
+
+#endif // VPX_VPX_PORTS_COMPILER_ATTRIBUTES_H_
diff --git a/vpx_ports/mem.h b/vpx_ports/mem.h
index 4e9041304..5eccfe8f5 100644
--- a/vpx_ports/mem.h
+++ b/vpx_ports/mem.h
@@ -41,34 +41,4 @@
#define CAST_TO_BYTEPTR(x) ((uint8_t *)((uintptr_t)(x)))
#endif // CONFIG_VP9_HIGHBITDEPTH
-#if !defined(__has_feature)
-#define __has_feature(x) 0
-#endif // !defined(__has_feature)
-
-#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
-#define VPX_WITH_ASAN 1
-#else
-#define VPX_WITH_ASAN 0
-#endif // __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
-
-#if !defined(__has_attribute)
-#define __has_attribute(x) 0
-#endif // !defined(__has_attribute)
-
-#if __has_attribute(uninitialized)
-// Attribute "uninitialized" disables -ftrivial-auto-var-init=pattern for
-// the specified variable.
-//
-// -ftrivial-auto-var-init is security risk mitigation feature, so attribute
-// should not be used "just in case", but only to fix real performance
-// bottlenecks when other approaches do not work. In general the compiler is
-// quite effective at eliminating unneeded initializations introduced by the
-// flag, e.g. when they are followed by actual initialization by a program.
-// However if compiler optimization fails and code refactoring is hard, the
-// attribute can be used as a workaround.
-#define VPX_UNINITIALIZED __attribute__((uninitialized))
-#else
-#define VPX_UNINITIALIZED
-#endif // __has_attribute(uninitialized)
-
#endif // VPX_VPX_PORTS_MEM_H_
diff --git a/vpx_ports/vpx_ports.mk b/vpx_ports/vpx_ports.mk
index 53fbd1e80..233177369 100644
--- a/vpx_ports/vpx_ports.mk
+++ b/vpx_ports/vpx_ports.mk
@@ -12,6 +12,7 @@
PORTS_SRCS-yes += vpx_ports.mk
PORTS_SRCS-yes += bitops.h
+PORTS_SRCS-yes += compiler_attributes.h
PORTS_SRCS-yes += mem.h
PORTS_SRCS-yes += msvc.h
PORTS_SRCS-yes += static_assert.h