diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2014-01-08 06:32:41 +0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2014-01-08 06:32:41 +0400 |
commit | e7750904270bbcad218f05bd7ca4313c6f080fbb (patch) | |
tree | aad74ebc3649bb65cf5478fbe7129a3fafc4dea5 /celt | |
parent | 0b9f7f994402df32d6b69f9aca3412f0f75bd43a (diff) |
pseudostack instrumentation (off by default)
Diffstat (limited to 'celt')
-rw-r--r-- | celt/stack_alloc.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/celt/stack_alloc.h b/celt/stack_alloc.h index 316a6ce1..2b51c8d8 100644 --- a/celt/stack_alloc.h +++ b/celt/stack_alloc.h @@ -116,9 +116,11 @@ #else #ifdef CELT_C +char *scratch_ptr=0; char *global_stack=0; #else extern char *global_stack; +extern char *scratch_ptr; #endif /* CELT_C */ #ifdef ENABLE_VALGRIND @@ -140,8 +142,12 @@ extern char *global_stack_top; #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)))) +#if 0 /* Set this to 1 to instrument pseudostack usage */ +#define RESTORE_STACK (printf("%ld %s:%d\n", global_stack-scratch_ptr, __FILE__, __LINE__),global_stack = _saved_stack) +#else #define RESTORE_STACK (global_stack = _saved_stack) -#define ALLOC_STACK char *_saved_stack; (global_stack = (global_stack==0) ? opus_alloc_scratch(GLOBAL_STACK_SIZE) : global_stack); _saved_stack = global_stack; +#endif +#define ALLOC_STACK char *_saved_stack; (global_stack = (global_stack==0) ? (scratch_ptr=opus_alloc_scratch(GLOBAL_STACK_SIZE)) : global_stack); _saved_stack = global_stack; #endif /* ENABLE_VALGRIND */ |