ref: 7c39e6ab30e2e57467996ad9a2b4d6f6e75c071b
parent: 53f5a06f5a56e4c5b9f217bca146763812937c03
author: Mark Harris <[email protected]>
date: Sat Jul 14 18:17:01 EDT 2018
Include alloca.h when needed, remove unused cruft Fixes illumos compiler warning.
--- a/configure.ac
+++ b/configure.ac
@@ -26,7 +26,7 @@
AM_PROG_CC_C_O
AC_PROG_CC_C99
-AC_CHECK_HEADERS([inttypes.h])
+AC_CHECK_HEADERS([inttypes.h alloca.h])
AC_C_BIGENDIAN
AC_C_CONST
AC_C_INLINE
--- a/src/resample.c
+++ b/src/resample.c
@@ -976,8 +976,7 @@
const spx_uint32_t xlen = st->mem_alloc_size - (st->filt_len - 1);
#ifdef VAR_ARRAYS
const unsigned int ylen = (olen < FIXED_STACK_ALLOC) ? olen : FIXED_STACK_ALLOC;
- VARDECL(spx_word16_t *ystack);
- ALLOC(ystack, ylen, spx_word16_t);
+ spx_word16_t ystack[ylen];
#else
const unsigned int ylen = FIXED_STACK_ALLOC;
spx_word16_t ystack[FIXED_STACK_ALLOC];
--- a/src/stack_alloc.h
+++ b/src/stack_alloc.h
@@ -35,10 +35,10 @@
#ifndef STACK_ALLOC_H
#define STACK_ALLOC_H
-#ifdef WIN32
+#if defined WIN32 || defined _WIN32
# include <malloc.h>
# ifndef alloca
-# define alloca(_x) _alloca(_x);
+# define alloca(n) _alloca(n)
# endif
#else
# ifdef HAVE_ALLOCA_H
@@ -47,70 +47,5 @@
# include <stdlib.h>
# endif
#endif
-
-/**
- * @def ALIGN(stack, size)
- *
- * Aligns the stack to a 'size' boundary
- *
- * @param stack Stack
- * @param size New size boundary
- */
-
-/**
- * @def PUSH(stack, size, type)
- *
- * Allocates 'size' elements of type 'type' on the stack
- *
- * @param stack Stack
- * @param size Number of elements
- * @param type Type of element
- */
-
-/**
- * @def VARDECL(var)
- *
- * Declare variable on stack
- *
- * @param var Variable to declare
- */
-
-/**
- * @def ALLOC(var, size, type)
- *
- * Allocate 'size' elements of 'type' on stack
- *
- * @param var Name of variable to allocate
- * @param size Number of elements
- * @param type Type of element
- */
-
-#ifdef ENABLE_VALGRIND
-
-# include <valgrind/memcheck.h>
-
-# define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
-
-# define PUSH(stack, size, type) (VALGRIND_MAKE_NOACCESS(stack, 1000),ALIGN((stack),sizeof(type)),VALGRIND_MAKE_WRITABLE(stack, ((size)*sizeof(type))),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type))))
-
-#else
-
-# define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
-
-# define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type))))
-
-#endif
-
-#if defined(VAR_ARRAYS)
-# define VARDECL(var)
-# define ALLOC(var, size, type) type var[size]
-#elif defined(USE_ALLOCA)
-# define VARDECL(var) var
-# define ALLOC(var, size, type) var = alloca(sizeof(type)*(size))
-#else
-# define VARDECL(var) var
-# define ALLOC(var, size, type) var = PUSH(stack, size, type)
-#endif
-
#endif
--- a/win32/config.h
+++ b/win32/config.h
@@ -12,8 +12,6 @@
#define OPUSTOOLS 1
#define inline __inline
-#define alloca _alloca
-#define USE_ALLOCA 1
#ifdef HAVE_LIBFLAC
#ifdef FLAC__NO_DLL