shithub: opus

Download patch

ref: d25dd2bff9f111fcc8d2de802c1cca337db27873
parent: 403485d09be1a254e2bf0e67f22e46b631c26519
author: Jean-Marc Valin <[email protected]>
date: Tue Mar 29 03:54:27 EDT 2011

Fixes a declaration-after-statement error when using ALLOC_STACK

--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -953,7 +953,6 @@
    int anti_collapse_on=0;
    int silence=0;
    ALLOC_STACK;
-   SAVE_STACK;
 
    if (nbCompressedBytes<2 || pcm==NULL)
      return CELT_BAD_ARG;
@@ -1681,7 +1680,6 @@
    int j, ret, C, N;
    VARDECL(celt_int16, in);
    ALLOC_STACK;
-   SAVE_STACK;
 
    if (pcm==NULL)
       return CELT_BAD_ARG;
@@ -1710,7 +1708,6 @@
    int j, ret, C, N;
    VARDECL(celt_sig, in);
    ALLOC_STACK;
-   SAVE_STACK;
 
    if (pcm==NULL)
       return CELT_BAD_ARG;
@@ -2299,7 +2296,6 @@
    int silence;
    int C = CHANNELS(st->stream_channels);
    ALLOC_STACK;
-   SAVE_STACK;
 
    frame_size *= st->downsample;
 
@@ -2640,7 +2636,6 @@
    int j, ret, C, N;
    VARDECL(celt_int16, out);
    ALLOC_STACK;
-   SAVE_STACK;
 
    if (pcm==NULL)
       return CELT_BAD_ARG;
@@ -2665,7 +2660,6 @@
    int j, ret, C, N;
    VARDECL(celt_sig, out);
    ALLOC_STACK;
-   SAVE_STACK;
 
    if (pcm==NULL)
       return CELT_BAD_ARG;
--- a/libcelt/stack_alloc.h
+++ b/libcelt/stack_alloc.h
@@ -125,7 +125,7 @@
 #define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1))
 #define PUSH(stack, size, type) (VALGRIND_MAKE_MEM_NOACCESS(stack, global_stack_top-stack),ALIGN((stack),sizeof(type)/sizeof(char)),VALGRIND_MAKE_MEM_UNDEFINED(stack, ((size)*sizeof(type)/sizeof(char))),(stack)+=(2*(size)*sizeof(type)/sizeof(char)),(type*)((stack)-(2*(size)*sizeof(type)/sizeof(char))))
 #define RESTORE_STACK ((global_stack = _saved_stack),VALGRIND_MAKE_MEM_NOACCESS(global_stack, global_stack_top-global_stack))
-#define ALLOC_STACK ((global_stack = (global_stack==0) ? ((global_stack_top=celt_alloc_scratch(GLOBAL_STACK_SIZE*2)+(GLOBAL_STACK_SIZE*2))-(GLOBAL_STACK_SIZE*2)) : global_stack),VALGRIND_MAKE_MEM_NOACCESS(global_stack, global_stack_top-global_stack))
+#define ALLOC_STACK char *_saved_stack; ((global_stack = (global_stack==0) ? ((global_stack_top=celt_alloc_scratch(GLOBAL_STACK_SIZE*2)+(GLOBAL_STACK_SIZE*2))-(GLOBAL_STACK_SIZE*2)) : global_stack),VALGRIND_MAKE_MEM_NOACCESS(global_stack, global_stack_top-global_stack)); _saved_stack = global_stack;
 
 #else 
 
@@ -132,7 +132,7 @@
 #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 RESTORE_STACK (global_stack = _saved_stack)
-#define ALLOC_STACK (global_stack = (global_stack==0) ? celt_alloc_scratch(GLOBAL_STACK_SIZE) : global_stack)
+#define ALLOC_STACK char *_saved_stack; (global_stack = (global_stack==0) ? celt_alloc_scratch(GLOBAL_STACK_SIZE) : global_stack); _saved_stack = global_stack;
 
 #endif /*ENABLE_VALGRIND*/