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.
11 #ifndef VPX_PORTS_MEM_H_
12 #define VPX_PORTS_MEM_H_
14 #include "vpx_config.h"
15 #include "vpx/vpx_integer.h"
17 #if (defined(__GNUC__) && __GNUC__) || defined(__SUNPRO_C)
18 #define DECLARE_ALIGNED(n, typ, val) typ val __attribute__((aligned(n)))
19 #elif defined(_MSC_VER)
20 #define DECLARE_ALIGNED(n, typ, val) __declspec(align(n)) typ val
22 #warning No alignment directives known for this compiler.
23 #define DECLARE_ALIGNED(n, typ, val) typ val
26 /* Indicates that the usage of the specified variable has been audited to assure
27 * that it's safe to use uninitialized. Silences 'may be used uninitialized'
30 #if defined(__GNUC__) && __GNUC__
31 #define UNINITIALIZED_IS_SAFE(x) x = x
33 #define UNINITIALIZED_IS_SAFE(x) x
36 #if HAVE_NEON && defined(_MSC_VER)
37 #define __builtin_prefetch(x)
40 /* Shift down with rounding */
41 #define ROUND_POWER_OF_TWO(value, n) (((value) + (1 << ((n)-1))) >> (n))
42 #define ROUND64_POWER_OF_TWO(value, n) (((value) + (1ULL << ((n)-1))) >> (n))
44 #define ALIGN_POWER_OF_TWO(value, n) \
45 (((value) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1))
47 #define CONVERT_TO_SHORTPTR(x) ((uint16_t *)(((uintptr_t)(x)) << 1))
48 #if CONFIG_VP9_HIGHBITDEPTH
49 #define CONVERT_TO_BYTEPTR(x) ((uint8_t *)(((uintptr_t)(x)) >> 1))
50 #endif // CONFIG_VP9_HIGHBITDEPTH
52 #if !defined(__has_feature)
53 #define __has_feature(x) 0
54 #endif // !defined(__has_feature)
56 #if __has_feature(address_sanitizer) || __SANITIZE_ADDRESS__
57 #define VPX_WITH_ASAN 1
59 #define VPX_WITH_ASAN 0
60 #endif // __has_feature(address_sanitizer) || __SANITIZE_ADDRESS
62 #endif // VPX_PORTS_MEM_H_