diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-10-06 22:23:22 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-10-06 22:23:22 +0000 |
commit | 285ac0518281f5b0eeae8869761f25239364bcfa (patch) | |
tree | 00451145e6200d31a516d1fc672d0892fc9dff52 | |
parent | 46bf0021809e3e46bb981b2ab97946818f899b35 (diff) | |
parent | 5fb49e35e9c0928fe6e5bda34bcf7864bd301319 (diff) | |
download | libopus-android12-mainline-statsd-release.tar.gz |
Snap for 7799923 from 5fb49e35e9c0928fe6e5bda34bcf7864bd301319 to mainline-os-statsd-releaseandroid-mainline-12.0.0_r58android12-mainline-statsd-release
Change-Id: Id9fa7a76e1a08d1c69664d1c9fdfccb03180e36f
-rw-r--r-- | Android.bp | 1 | ||||
-rw-r--r-- | celt/stack_alloc.h | 25 |
2 files changed, 23 insertions, 3 deletions
@@ -208,6 +208,7 @@ cc_library { "-DOPUS_BUILD", "-DFIXED_POINT", "-DUSE_ALLOCA", + "-DSIMD_EXTRA_ALLOC_BYTES=16", "-DHAVE_LRINT", "-DHAVE_LRINTF", "-DENABLE_HARDENING", diff --git a/celt/stack_alloc.h b/celt/stack_alloc.h index ae40e2a1..b289facd 100644 --- a/celt/stack_alloc.h +++ b/celt/stack_alloc.h @@ -88,10 +88,22 @@ * @param type Type of element */ +#ifndef SIMD_EXTRA_ALLOC_BYTES +#error define SIMD_EXTRA_ALLOC_BYTES appropriately in your makefile +/* + * Useful values: + * 0 for an all-scalar processor, which should never over-read the arrays + * 16 for an implementation using ARM Neon or X86 SSE4 instructions, which work + * with blocks of 16 bytes (128 bits) + */ +#endif + #if defined(VAR_ARRAYS) #define VARDECL(type, var) -#define ALLOC(var, size, type) type var[size] +// include a full SIMD width afterwards; +#define ALLOC(var, size, type) type var[(size) + ((SIMD_EXTRA_ALLOC_BYTES)/sizeof(type))] + #define SAVE_STACK #define RESTORE_STACK #define ALLOC_STACK @@ -103,9 +115,11 @@ #define VARDECL(type, var) type *var # ifdef _WIN32 -# define ALLOC(var, size, type) var = ((type*)_alloca(sizeof(type)*(size))) +# define ALLOC(var, size, type) var = \ + ((type*)_alloca(sizeof(type)*(size) + SIMD_EXTRA_ALLOC_BYTES)) # else -# define ALLOC(var, size, type) var = ((type*)alloca(sizeof(type)*(size))) +# define ALLOC(var, size, type) var = \ + ((type*)alloca(sizeof(type)*(size) + SIMD_EXTRA_ALLOC_BYTES)) # endif #define SAVE_STACK @@ -151,6 +165,11 @@ extern char *global_stack_top; #endif /* ENABLE_VALGRIND */ +// this path has NOT been modified to be safe in the face of SIMD over-reads +#if SIMD_EXTRA_ALLOC_BYTES != 0 +#error "ALLOC() is not updated in this configuration to provide for SIMD over-reads" +#endif + #include "os_support.h" #define VARDECL(type, var) type *var #define ALLOC(var, size, type) var = PUSH(global_stack, size, type) |