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