/media/libvpx/vpx_mem/include/vpx_mem_intrnl.h

http://github.com/zpao/v8monkey · C Header · 99 lines · 59 code · 16 blank · 24 comment · 6 complexity · 6dd525e686eea90035a5ef1ee0914769 MD5 · raw file

  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_MEM_INTRNL_H__
  11. #define __VPX_MEM_INTRNL_H__
  12. #include "vpx_ports/config.h"
  13. #ifndef CONFIG_MEM_MANAGER
  14. # if defined(VXWORKS)
  15. # define CONFIG_MEM_MANAGER 1 /*include heap manager functionality,*/
  16. /*default: enabled on vxworks*/
  17. # else
  18. # define CONFIG_MEM_MANAGER 0 /*include heap manager functionality*/
  19. # endif
  20. #endif /*CONFIG_MEM_MANAGER*/
  21. #ifndef CONFIG_MEM_TRACKER
  22. # define CONFIG_MEM_TRACKER 1 /*include xvpx_* calls in the lib*/
  23. #endif
  24. #ifndef CONFIG_MEM_CHECKS
  25. # define CONFIG_MEM_CHECKS 0 /*include some basic safety checks in
  26. vpx_memcpy, _memset, and _memmove*/
  27. #endif
  28. #ifndef USE_GLOBAL_FUNCTION_POINTERS
  29. # define USE_GLOBAL_FUNCTION_POINTERS 0 /*use function pointers instead of compiled functions.*/
  30. #endif
  31. #if CONFIG_MEM_TRACKER
  32. # include "vpx_mem_tracker.h"
  33. # if VPX_MEM_TRACKER_VERSION_CHIEF != 2 || VPX_MEM_TRACKER_VERSION_MAJOR != 5
  34. # error "vpx_mem requires memory tracker version 2.5 to track memory usage"
  35. # endif
  36. #endif
  37. #define ADDRESS_STORAGE_SIZE sizeof(size_t)
  38. #ifndef DEFAULT_ALIGNMENT
  39. # if defined(VXWORKS)
  40. # define DEFAULT_ALIGNMENT 32 /*default addr alignment to use in
  41. calls to vpx_* functions other
  42. than vpx_memalign*/
  43. # else
  44. # define DEFAULT_ALIGNMENT 1
  45. # endif
  46. #endif
  47. #if DEFAULT_ALIGNMENT < 1
  48. # error "DEFAULT_ALIGNMENT must be >= 1!"
  49. #endif
  50. #if CONFIG_MEM_TRACKER
  51. # define TRY_BOUNDS_CHECK 1 /*when set to 1 pads each allocation,
  52. integrity can be checked using
  53. vpx_memory_tracker_check_integrity
  54. or on free by defining*/
  55. /*TRY_BOUNDS_CHECK_ON_FREE*/
  56. #else
  57. # define TRY_BOUNDS_CHECK 0
  58. #endif /*CONFIG_MEM_TRACKER*/
  59. #if TRY_BOUNDS_CHECK
  60. # define TRY_BOUNDS_CHECK_ON_FREE 0 /*checks mem integrity on every
  61. free, very expensive*/
  62. # define BOUNDS_CHECK_VALUE 0xdeadbeef /*value stored before/after ea.
  63. mem addr for bounds checking*/
  64. # define BOUNDS_CHECK_PAD_SIZE 32 /*size of the padding before and
  65. after ea allocation to be filled
  66. with BOUNDS_CHECK_VALUE.
  67. this should be a multiple of 4*/
  68. #else
  69. # define BOUNDS_CHECK_VALUE 0
  70. # define BOUNDS_CHECK_PAD_SIZE 0
  71. #endif /*TRY_BOUNDS_CHECK*/
  72. #ifndef REMOVE_PRINTFS
  73. # define REMOVE_PRINTFS 0
  74. #endif
  75. /* Should probably use a vpx_mem logger function. */
  76. #if REMOVE_PRINTFS
  77. # define _P(x)
  78. #else
  79. # define _P(x) x
  80. #endif
  81. /*returns an addr aligned to the byte boundary specified by align*/
  82. #define align_addr(addr,align) (void*)(((size_t)(addr) + ((align) - 1)) & (size_t)-(align))
  83. #endif /*__VPX_MEM_INTRNL_H__*/