Merge "Correct bit allocation when the alternative reference frame"
[profile/ivi/libvpx.git] / vpx_ports / mem.h
1 /*
2  *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license and patent
5  *  grant that can be found in the LICENSE file in the root of the source
6  *  tree. All contributing project authors may be found in the AUTHORS
7  *  file in the root of the source tree.
8  */
9
10
11 #ifndef VPX_PORTS_MEM_H
12 #define VPX_PORTS_MEM_H
13 #include "vpx_config.h"
14 #include "vpx/vpx_integer.h"
15
16 #if defined(__GNUC__) && __GNUC__
17 #define DECLARE_ALIGNED(n,typ,val)  typ val __attribute__ ((aligned (n)))
18 #elif defined(_MSC_VER)
19 #define DECLARE_ALIGNED(n,typ,val)  __declspec(align(n)) typ val
20 #else
21 #warning No alignment directives known for this compiler.
22 #define DECLARE_ALIGNED(n,typ,val)  typ val
23 #endif
24 #endif
25
26
27 /* Declare an aligned array on the stack, for situations where the stack
28  * pointer may not have the alignment we expect. Creates an array with a
29  * modified name, then defines val to be a pointer, and aligns that pointer
30  * within the array.
31  */
32 #define DECLARE_ALIGNED_ARRAY(a,typ,val,n)\
33 typ val##_[(n)+(a)/sizeof(typ)+1];\
34 typ *val = (typ*)((((intptr_t)val##_)+(a)-1)&((intptr_t)-(a)))
35
36
37 /* Indicates that the usage of the specified variable has been audited to assure
38  * that it's safe to use uninitialized. Silences 'may be used uninitialized'
39  * warnings on gcc.
40  */
41 #if defined(__GNUC__) && __GNUC__
42 #define UNINITIALIZED_IS_SAFE(x) x=x
43 #else
44 #define UNINITIALIZED_IS_SAFE(x) x
45 #endif