diff --git a/libcelt/celt_types.h b/libcelt/celt_types.h index 364f9603..b6a4fd7a 100644 --- a/libcelt/celt_types.h +++ b/libcelt/celt_types.h @@ -23,7 +23,7 @@ #define _CELT_TYPES_H /* Use the real stdint.h if it's there (taken from Paul Hsieh's pstdint.h) */ -#if (defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) ) +#if (defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) || defined (HAVE_STDINT_H)) #include typedef int16_t celt_int16_t; diff --git a/libcelt/stack_alloc.h b/libcelt/stack_alloc.h index ca1be2f0..ba984f82 100644 --- a/libcelt/stack_alloc.h +++ b/libcelt/stack_alloc.h @@ -108,14 +108,15 @@ #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 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)))) +#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 RESTORE_STACK ((global_stack = _saved_stack),VALGRIND_MAKE_NOACCESS(global_stack, 1000)) #else #define ALLOC_STACK(stack) (stack = (stack==0) ? celt_alloc_scratch(25000) : stack) +/* FIXME: Only align up to a certain size (not for structs) */ #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)))) +#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) #endif