mirror of
https://github.com/xiph/opus.git
synced 2025-05-17 08:58:30 +00:00
pseudo-stack no longer checks on every function entry whether it has been
allocated
This commit is contained in:
parent
ba8295241c
commit
f7cec83c59
5 changed files with 14 additions and 5 deletions
|
@ -37,6 +37,7 @@
|
||||||
#include "modes.h"
|
#include "modes.h"
|
||||||
#include "rate.h"
|
#include "rate.h"
|
||||||
#include "os_support.h"
|
#include "os_support.h"
|
||||||
|
#include "stack_alloc.h"
|
||||||
|
|
||||||
#ifdef STATIC_MODES
|
#ifdef STATIC_MODES
|
||||||
#include "static_modes.c"
|
#include "static_modes.c"
|
||||||
|
@ -225,6 +226,7 @@ CELTMode EXPORT *celt_mode_create(celt_int32_t Fs, int channels, int frame_size,
|
||||||
const CELTMode *m = NULL;
|
const CELTMode *m = NULL;
|
||||||
CELTMode *mode=NULL;
|
CELTMode *mode=NULL;
|
||||||
int i;
|
int i;
|
||||||
|
ALLOC_STACK;
|
||||||
for (i=0;i<TOTAL_MODES;i++)
|
for (i=0;i<TOTAL_MODES;i++)
|
||||||
{
|
{
|
||||||
if (Fs == static_mode_list[i]->Fs &&
|
if (Fs == static_mode_list[i]->Fs &&
|
||||||
|
@ -250,6 +252,7 @@ CELTMode EXPORT *celt_mode_create(celt_int32_t Fs, int channels, int frame_size,
|
||||||
int i;
|
int i;
|
||||||
CELTMode *mode;
|
CELTMode *mode;
|
||||||
celt_word16_t *window;
|
celt_word16_t *window;
|
||||||
|
ALLOC_STACK;
|
||||||
|
|
||||||
/* The good thing here is that permutation of the arguments will automatically be invalid */
|
/* The good thing here is that permutation of the arguments will automatically be invalid */
|
||||||
|
|
||||||
|
|
|
@ -149,10 +149,10 @@ static inline void celt_notify(const char *str)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __GNUC__
|
/*#ifdef __GNUC__
|
||||||
#pragma GCC poison printf sprintf
|
#pragma GCC poison printf sprintf
|
||||||
#pragma GCC poison malloc free realloc calloc
|
#pragma GCC poison malloc free realloc calloc
|
||||||
#endif
|
#endif*/
|
||||||
|
|
||||||
#endif /* OS_SUPPORT_H */
|
#endif /* OS_SUPPORT_H */
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,7 @@
|
||||||
#define ALLOC(var, size, type) type var[size]
|
#define ALLOC(var, size, type) type var[size]
|
||||||
#define SAVE_STACK
|
#define SAVE_STACK
|
||||||
#define RESTORE_STACK
|
#define RESTORE_STACK
|
||||||
|
#define ALLOC_STACK
|
||||||
|
|
||||||
#elif defined(USE_ALLOCA)
|
#elif defined(USE_ALLOCA)
|
||||||
|
|
||||||
|
@ -98,6 +99,7 @@
|
||||||
#define ALLOC(var, size, type) var = ((type*)alloca(sizeof(type)*(size)))
|
#define ALLOC(var, size, type) var = ((type*)alloca(sizeof(type)*(size)))
|
||||||
#define SAVE_STACK
|
#define SAVE_STACK
|
||||||
#define RESTORE_STACK
|
#define RESTORE_STACK
|
||||||
|
#define ALLOC_STACK
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -105,7 +107,6 @@
|
||||||
|
|
||||||
#include <valgrind/memcheck.h>
|
#include <valgrind/memcheck.h>
|
||||||
|
|
||||||
#define ALLOC_STACK(stack) (stack = (stack==0) ? celt_alloc_scratch(25000) : stack, VALGRIND_MAKE_NOACCESS(stack, 1000))
|
|
||||||
#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
|
#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
|
||||||
|
|
||||||
#define PUSH(stack, size, type) (VALGRIND_MAKE_NOACCESS(stack, 1000),ALIGN((stack),sizeof(type)/sizeof(char)),VALGRIND_MAKE_WRITABLE(stack, ((size)*sizeof(type)/sizeof(char))),(stack)+=((size)*sizeof(type)/sizeof(char)),(type*)((stack)-((size)*sizeof(type)/sizeof(char))))
|
#define PUSH(stack, size, type) (VALGRIND_MAKE_NOACCESS(stack, 1000),ALIGN((stack),sizeof(type)/sizeof(char)),VALGRIND_MAKE_WRITABLE(stack, ((size)*sizeof(type)/sizeof(char))),(stack)+=((size)*sizeof(type)/sizeof(char)),(type*)((stack)-((size)*sizeof(type)/sizeof(char))))
|
||||||
|
@ -113,7 +114,6 @@
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define ALLOC_STACK(stack) (stack = (stack==0) ? celt_alloc_scratch(25000) : stack)
|
|
||||||
/* FIXME: Only align up to a certain size (not for structs) */
|
/* FIXME: Only align up to a certain size (not for structs) */
|
||||||
#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
|
#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
|
||||||
#define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)/sizeof(char)),(stack)+=((size)*sizeof(type)/sizeof(char)),(type*)((stack)-((size)*sizeof(type)/sizeof(char))))
|
#define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)/sizeof(char)),(stack)+=((size)*sizeof(type)/sizeof(char)),(type*)((stack)-((size)*sizeof(type)/sizeof(char))))
|
||||||
|
@ -130,7 +130,9 @@ extern char *global_stack;
|
||||||
#include "os_support.h"
|
#include "os_support.h"
|
||||||
#define VARDECL(type, var) type *var
|
#define VARDECL(type, var) type *var
|
||||||
#define ALLOC(var, size, type) var = PUSH(global_stack, size, type)
|
#define ALLOC(var, size, type) var = PUSH(global_stack, size, type)
|
||||||
#define SAVE_STACK char *_saved_stack; ALLOC_STACK(global_stack);_saved_stack = global_stack;
|
#define SAVE_STACK char *_saved_stack = global_stack;
|
||||||
|
#define ALLOC_STACK (global_stack = (global_stack==0) ? celt_alloc_scratch(25000) : global_stack)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "laplace.h"
|
#include "laplace.h"
|
||||||
|
#include "stack_alloc.h"
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
@ -14,6 +15,7 @@ int main(void)
|
||||||
ec_dec dec;
|
ec_dec dec;
|
||||||
ec_byte_buffer buf;
|
ec_byte_buffer buf;
|
||||||
int val[10000], decay[10000];
|
int val[10000], decay[10000];
|
||||||
|
ALLOC_STACK;
|
||||||
ec_byte_writeinit(&buf);
|
ec_byte_writeinit(&buf);
|
||||||
ec_enc_init(&enc,&buf);
|
ec_enc_init(&enc,&buf);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "mdct.h"
|
#include "mdct.h"
|
||||||
|
#include "stack_alloc.h"
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
void check(kiss_fft_scalar * in,kiss_fft_scalar * out,int nfft,int isinverse)
|
void check(kiss_fft_scalar * in,kiss_fft_scalar * out,int nfft,int isinverse)
|
||||||
|
@ -114,6 +115,7 @@ void test1d(int nfft,int isinverse)
|
||||||
|
|
||||||
int main(int argc,char ** argv)
|
int main(int argc,char ** argv)
|
||||||
{
|
{
|
||||||
|
ALLOC_STACK;
|
||||||
if (argc>1) {
|
if (argc>1) {
|
||||||
int k;
|
int k;
|
||||||
for (k=1;k<argc;++k) {
|
for (k=1;k<argc;++k) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue