mem.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
  3. *
  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.
  9. */
  10. #ifndef VPX_VPX_PORTS_MEM_H_
  11. #define VPX_VPX_PORTS_MEM_H_
  12. #include "vpx_config.h"
  13. #include "vpx/vpx_integer.h"
  14. #if (defined(__GNUC__) && __GNUC__) || defined(__SUNPRO_C)
  15. #define DECLARE_ALIGNED(n, typ, val) typ val __attribute__((aligned(n)))
  16. #elif defined(_MSC_VER)
  17. #define DECLARE_ALIGNED(n, typ, val) __declspec(align(n)) typ val
  18. #else
  19. #warning No alignment directives known for this compiler.
  20. #define DECLARE_ALIGNED(n, typ, val) typ val
  21. #endif
  22. #if HAVE_NEON && defined(_MSC_VER)
  23. #define __builtin_prefetch(x)
  24. #endif
  25. /* Shift down with rounding */
  26. #define ROUND_POWER_OF_TWO(value, n) (((value) + (1 << ((n)-1))) >> (n))
  27. #define ROUND64_POWER_OF_TWO(value, n) (((value) + (1ULL << ((n)-1))) >> (n))
  28. #define ALIGN_POWER_OF_TWO(value, n) \
  29. (((value) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1))
  30. #define CONVERT_TO_SHORTPTR(x) ((uint16_t *)(((uintptr_t)(x)) << 1))
  31. #define CAST_TO_SHORTPTR(x) ((uint16_t *)((uintptr_t)(x)))
  32. #if CONFIG_VP9_HIGHBITDEPTH
  33. #define CONVERT_TO_BYTEPTR(x) ((uint8_t *)(((uintptr_t)(x)) >> 1))
  34. #define CAST_TO_BYTEPTR(x) ((uint8_t *)((uintptr_t)(x)))
  35. #endif // CONFIG_VP9_HIGHBITDEPTH
  36. #if !defined(__has_feature)
  37. #define __has_feature(x) 0
  38. #endif // !defined(__has_feature)
  39. #if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
  40. #define VPX_WITH_ASAN 1
  41. #else
  42. #define VPX_WITH_ASAN 0
  43. #endif // __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
  44. #endif // VPX_VPX_PORTS_MEM_H_