]> granicus.if.org Git - libvpx/commitdiff
move common attribute defs to compiler_attributes.h
authorJames Zern <jzern@google.com>
Sat, 15 Feb 2020 01:31:42 +0000 (17:31 -0800)
committerJames Zern <jzern@google.com>
Sat, 15 Feb 2020 04:44:01 +0000 (20:44 -0800)
BUG=b/148271109

Change-Id: I620e26ff1233fcd34ebe0723cb913e82eb58271c

examples.mk
md5_utils.c
vp8/common/reconintra4x4.c
vp9/encoder/vp9_pickmode.c
vpx_dsp/x86/convolve.h
vpx_ports/compiler_attributes.h [new file with mode: 0644]
vpx_ports/mem.h
vpx_ports/vpx_ports.mk

index 758ca7f88948c74b61365099c5bd8362d92f7ba0..a28e5293595986b3824b01d9dcc88ac9f3537fce 100644 (file)
@@ -65,6 +65,7 @@ endif
 # while EXAMPLES demonstrate specific portions of the API.
 UTILS-$(CONFIG_DECODERS)    += vpxdec.c
 vpxdec.SRCS                 += md5_utils.c md5_utils.h
+vpxdec.SRCS                 += vpx_ports/compiler_attributes.h
 vpxdec.SRCS                 += vpx_ports/mem_ops.h
 vpxdec.SRCS                 += vpx_ports/mem_ops_aligned.h
 vpxdec.SRCS                 += vpx_ports/msvc.h
@@ -167,6 +168,7 @@ decode_to_md5.SRCS                 += y4minput.c y4minput.h
 decode_to_md5.SRCS                 += tools_common.h tools_common.c
 decode_to_md5.SRCS                 += video_common.h
 decode_to_md5.SRCS                 += video_reader.h video_reader.c
+decode_to_md5.SRCS                 += vpx_ports/compiler_attributes.h
 decode_to_md5.SRCS                 += vpx_ports/mem_ops.h
 decode_to_md5.SRCS                 += vpx_ports/mem_ops_aligned.h
 decode_to_md5.SRCS                 += vpx_ports/msvc.h
index 9ddb104c8a618ce97750756f6016a5fbaa76dcea..c4106525f261a50264b2f607744148cc12ea9baf 100644 (file)
@@ -23,6 +23,7 @@
 #include <string.h> /* for memcpy() */
 
 #include "md5_utils.h"
+#include "vpx_ports/compiler_attributes.h"
 
 static void byteSwap(UWORD32 *buf, unsigned words) {
   md5byte *p;
@@ -145,17 +146,6 @@ void MD5Final(md5byte digest[16], struct MD5Context *ctx) {
 #define MD5STEP(f, w, x, y, z, in, s) \
   (w += f(x, y, z) + in, w = (w << s | w >> (32 - s)) + x)
 
-#if defined(__clang__) && defined(__has_attribute)
-#if __has_attribute(no_sanitize)
-#define VPX_NO_UNSIGNED_OVERFLOW_CHECK \
-  __attribute__((no_sanitize("unsigned-integer-overflow")))
-#endif
-#endif
-
-#ifndef VPX_NO_UNSIGNED_OVERFLOW_CHECK
-#define VPX_NO_UNSIGNED_OVERFLOW_CHECK
-#endif
-
 /*
  * The core of the MD5 algorithm, this alters an existing MD5 hash to
  * reflect the addition of 16 longwords of new data.  MD5Update blocks
@@ -244,6 +234,4 @@ VPX_NO_UNSIGNED_OVERFLOW_CHECK void MD5Transform(UWORD32 buf[4],
   buf[3] += d;
 }
 
-#undef VPX_NO_UNSIGNED_OVERFLOW_CHECK
-
 #endif
index 64d33a2873750438d0fc7a7879ca55405851bbfe..be936df5e0f6bb9b824dec61dbb299b9b0b8eea1 100644 (file)
@@ -16,7 +16,7 @@
 #include "blockd.h"
 #include "reconintra4x4.h"
 #include "vp8/common/common.h"
-#include "vpx_ports/mem.h"
+#include "vpx_ports/compiler_attributes.h"
 
 typedef void (*intra_pred_fn)(uint8_t *dst, ptrdiff_t stride,
                               const uint8_t *above, const uint8_t *left);
index 9b2e48505293204b9e6a57f90dcf5012c21b5eae..23c943c21d246e0de829c2f2d5b08309c3798da5 100644 (file)
@@ -19,7 +19,7 @@
 #include "vpx/vpx_codec.h"
 #include "vpx_dsp/vpx_dsp_common.h"
 #include "vpx_mem/vpx_mem.h"
-#include "vpx_ports/mem.h"
+#include "vpx_ports/compiler_attributes.h"
 
 #include "vp9/common/vp9_blockd.h"
 #include "vp9/common/vp9_common.h"
index 6fd40fef9333635802981a4e47bdaf85698c1404..c33960055694ab0d0992a96ee1531eef13f176d1 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "./vpx_config.h"
 #include "vpx/vpx_integer.h"
-#include "vpx_ports/mem.h"
+#include "vpx_ports/compiler_attributes.h"
 
 // TODO(chiyotsai@google.com): Refactor the code here. Currently this is pretty
 // hacky and awful to read. Note that there is a filter_x[3] == 128 check in
diff --git a/vpx_ports/compiler_attributes.h b/vpx_ports/compiler_attributes.h
new file mode 100644 (file)
index 0000000..3543520
--- /dev/null
@@ -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_
index 4e904130481f31892cd43e768f000e8512f0d809..5eccfe8f5006f51bfe7160c7444baa3be7dbe977 100644 (file)
 #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_
index 53fbd1e80086837ecad3e82924e4edd1337644fa..2331773693f4c167a2f8a3b089520301915a7b9a 100644 (file)
@@ -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