Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Side by Side Diff: celt/stack_alloc.h

Issue 107243004: Updating Opus to release 1.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/opus
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « celt/rate.c ('k') | celt/x86/pitch_sse.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (C) 2002-2003 Jean-Marc Valin 1 /* Copyright (C) 2002-2003 Jean-Marc Valin
2 Copyright (C) 2007-2009 Xiph.Org Foundation */ 2 Copyright (C) 2007-2009 Xiph.Org Foundation */
3 /** 3 /**
4 @file stack_alloc.h 4 @file stack_alloc.h
5 @brief Temporary memory allocation on stack 5 @brief Temporary memory allocation on stack
6 */ 6 */
7 /* 7 /*
8 Redistribution and use in source and binary forms, with or without 8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions 9 modification, are permitted provided that the following conditions
10 are met: 10 are met:
(...skipping 14 matching lines...) Expand all
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32 #ifndef STACK_ALLOC_H 32 #ifndef STACK_ALLOC_H
33 #define STACK_ALLOC_H 33 #define STACK_ALLOC_H
34 34
35 #include "opus_types.h"
36 #include "opus_defines.h"
37
35 #if (!defined (VAR_ARRAYS) && !defined (USE_ALLOCA) && !defined (NONTHREADSAFE_P SEUDOSTACK)) 38 #if (!defined (VAR_ARRAYS) && !defined (USE_ALLOCA) && !defined (NONTHREADSAFE_P SEUDOSTACK))
36 #error "Opus requires one of VAR_ARRAYS, USE_ALLOCA, or NONTHREADSAFE_PSEUDOSTAC K be defined to select the temporary allocation mode." 39 #error "Opus requires one of VAR_ARRAYS, USE_ALLOCA, or NONTHREADSAFE_PSEUDOSTAC K be defined to select the temporary allocation mode."
37 #endif 40 #endif
38 41
39 #ifdef USE_ALLOCA 42 #ifdef USE_ALLOCA
40 # ifdef WIN32 43 # ifdef WIN32
41 # include <malloc.h> 44 # include <malloc.h>
42 # else 45 # else
43 # ifdef HAVE_ALLOCA_H 46 # ifdef HAVE_ALLOCA_H
44 # include <alloca.h> 47 # include <alloca.h>
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 * @param type Type of element 88 * @param type Type of element
86 */ 89 */
87 90
88 #if defined(VAR_ARRAYS) 91 #if defined(VAR_ARRAYS)
89 92
90 #define VARDECL(type, var) 93 #define VARDECL(type, var)
91 #define ALLOC(var, size, type) type var[size] 94 #define ALLOC(var, size, type) type var[size]
92 #define SAVE_STACK 95 #define SAVE_STACK
93 #define RESTORE_STACK 96 #define RESTORE_STACK
94 #define ALLOC_STACK 97 #define ALLOC_STACK
98 /* C99 does not allow VLAs of size zero */
99 #define ALLOC_NONE 1
95 100
96 #elif defined(USE_ALLOCA) 101 #elif defined(USE_ALLOCA)
97 102
98 #define VARDECL(type, var) type *var 103 #define VARDECL(type, var) type *var
99 104
100 # ifdef WIN32 105 # ifdef WIN32
101 # define ALLOC(var, size, type) var = ((type*)_alloca(sizeof(type)*(size))) 106 # define ALLOC(var, size, type) var = ((type*)_alloca(sizeof(type)*(size)))
102 # else 107 # else
103 # define ALLOC(var, size, type) var = ((type*)alloca(sizeof(type)*(size))) 108 # define ALLOC(var, size, type) var = ((type*)alloca(sizeof(type)*(size)))
104 # endif 109 # endif
105 110
106 #define SAVE_STACK 111 #define SAVE_STACK
107 #define RESTORE_STACK 112 #define RESTORE_STACK
108 #define ALLOC_STACK 113 #define ALLOC_STACK
114 #define ALLOC_NONE 0
109 115
110 #else 116 #else
111 117
112 #ifdef CELT_C 118 #ifdef CELT_C
113 char *global_stack=0; 119 char *global_stack=0;
114 #else 120 #else
115 extern char *global_stack; 121 extern char *global_stack;
116 #endif /* CELT_C */ 122 #endif /* CELT_C */
117 123
118 #ifdef ENABLE_VALGRIND 124 #ifdef ENABLE_VALGRIND
(...skipping 17 matching lines...) Expand all
136 #define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)/sizeof(char)),(stack )+=(size)*(sizeof(type)/sizeof(char)),(type*)((stack)-(size)*(sizeof(type)/sizeo f(char)))) 142 #define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)/sizeof(char)),(stack )+=(size)*(sizeof(type)/sizeof(char)),(type*)((stack)-(size)*(sizeof(type)/sizeo f(char))))
137 #define RESTORE_STACK (global_stack = _saved_stack) 143 #define RESTORE_STACK (global_stack = _saved_stack)
138 #define ALLOC_STACK char *_saved_stack; (global_stack = (global_stack==0) ? opus _alloc_scratch(GLOBAL_STACK_SIZE) : global_stack); _saved_stack = global_stack; 144 #define ALLOC_STACK char *_saved_stack; (global_stack = (global_stack==0) ? opus _alloc_scratch(GLOBAL_STACK_SIZE) : global_stack); _saved_stack = global_stack;
139 145
140 #endif /* ENABLE_VALGRIND */ 146 #endif /* ENABLE_VALGRIND */
141 147
142 #include "os_support.h" 148 #include "os_support.h"
143 #define VARDECL(type, var) type *var 149 #define VARDECL(type, var) type *var
144 #define ALLOC(var, size, type) var = PUSH(global_stack, size, type) 150 #define ALLOC(var, size, type) var = PUSH(global_stack, size, type)
145 #define SAVE_STACK char *_saved_stack = global_stack; 151 #define SAVE_STACK char *_saved_stack = global_stack;
152 #define ALLOC_NONE 0
146 153
147 #endif /* VAR_ARRAYS */ 154 #endif /* VAR_ARRAYS */
148 155
149 156
150 #ifdef ENABLE_VALGRIND 157 #ifdef ENABLE_VALGRIND
151 158
152 #include <valgrind/memcheck.h> 159 #include <valgrind/memcheck.h>
153 #define OPUS_CHECK_ARRAY(ptr, len) VALGRIND_CHECK_MEM_IS_DEFINED(ptr, len*sizeof (*ptr)) 160 #define OPUS_CHECK_ARRAY(ptr, len) VALGRIND_CHECK_MEM_IS_DEFINED(ptr, len*sizeof (*ptr))
154 #define OPUS_CHECK_VALUE(value) VALGRIND_CHECK_VALUE_IS_DEFINED(value) 161 #define OPUS_CHECK_VALUE(value) VALGRIND_CHECK_VALUE_IS_DEFINED(value)
155 #define OPUS_CHECK_ARRAY_COND(ptr, len) VALGRIND_CHECK_MEM_IS_DEFINED(ptr, len*s izeof(*ptr)) 162 #define OPUS_CHECK_ARRAY_COND(ptr, len) VALGRIND_CHECK_MEM_IS_DEFINED(ptr, len*s izeof(*ptr))
156 #define OPUS_CHECK_VALUE_COND(value) VALGRIND_CHECK_VALUE_IS_DEFINED(value) 163 #define OPUS_CHECK_VALUE_COND(value) VALGRIND_CHECK_VALUE_IS_DEFINED(value)
157 #define OPUS_PRINT_INT(value) do {fprintf(stderr, #value " = %d at %s:%d\n", val ue, __FILE__, __LINE__);}while(0) 164 #define OPUS_PRINT_INT(value) do {fprintf(stderr, #value " = %d at %s:%d\n", val ue, __FILE__, __LINE__);}while(0)
158 #define OPUS_FPRINTF fprintf 165 #define OPUS_FPRINTF fprintf
159 166
160 #else 167 #else
161 168
162 static inline int _opus_false(void) {return 0;} 169 static OPUS_INLINE int _opus_false(void) {return 0;}
163 #define OPUS_CHECK_ARRAY(ptr, len) _opus_false() 170 #define OPUS_CHECK_ARRAY(ptr, len) _opus_false()
164 #define OPUS_CHECK_VALUE(value) _opus_false() 171 #define OPUS_CHECK_VALUE(value) _opus_false()
165 #define OPUS_PRINT_INT(value) do{}while(0) 172 #define OPUS_PRINT_INT(value) do{}while(0)
166 #define OPUS_FPRINTF (void) 173 #define OPUS_FPRINTF (void)
167 174
168 #endif 175 #endif
169 176
170 177
171 #endif /* STACK_ALLOC_H */ 178 #endif /* STACK_ALLOC_H */
OLDNEW
« no previous file with comments | « celt/rate.c ('k') | celt/x86/pitch_sse.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698