2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
12 #ifndef VPX_PORTS_MEM_H_
13 #define VPX_PORTS_MEM_H_
15 #include "vpx_config.h"
16 #include "vpx/vpx_integer.h"
18 #if (defined(__GNUC__) && __GNUC__) || defined(__SUNPRO_C)
19 #define DECLARE_ALIGNED(n,typ,val) typ val __attribute__ ((aligned (n)))
20 #elif defined(_MSC_VER)
21 #define DECLARE_ALIGNED(n,typ,val) __declspec(align(n)) typ val
23 #warning No alignment directives known for this compiler.
24 #define DECLARE_ALIGNED(n,typ,val) typ val
27 /* Indicates that the usage of the specified variable has been audited to assure
28 * that it's safe to use uninitialized. Silences 'may be used uninitialized'
31 #if defined(__GNUC__) && __GNUC__
32 #define UNINITIALIZED_IS_SAFE(x) x=x
34 #define UNINITIALIZED_IS_SAFE(x) x
37 #if HAVE_NEON && defined(_MSC_VER)
38 #define __builtin_prefetch(x)
41 /* Shift down with rounding */
42 #define ROUND_POWER_OF_TWO(value, n) \
43 (((value) + (1 << ((n) - 1))) >> (n))
45 #define ALIGN_POWER_OF_TWO(value, n) \
46 (((value) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1))
48 #if CONFIG_VP9_HIGHBITDEPTH
49 #define CONVERT_TO_SHORTPTR(x) ((uint16_t*)(((uintptr_t)x) << 1))
50 #define CONVERT_TO_BYTEPTR(x) ((uint8_t*)(((uintptr_t)x) >> 1))
51 #endif // CONFIG_VP9_HIGHBITDEPTH
53 #endif // VPX_PORTS_MEM_H_