2 * Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license and patent
5 * grant that can be found in the LICENSE file in the root of the source
6 * tree. All contributing project authors may be found in the AUTHORS
7 * file in the root of the source tree.
11 #ifndef __VPX_MEM_INTRNL_H__
12 #define __VPX_MEM_INTRNL_H__
13 #include "vpx_ports/config.h"
15 #ifndef CONFIG_MEM_MANAGER
17 # define CONFIG_MEM_MANAGER 1 //include heap manager functionality,
18 //default: enabled on vxworks
20 # define CONFIG_MEM_MANAGER 0 //include heap manager functionality
22 #endif /*CONFIG_MEM_MANAGER*/
24 #ifndef CONFIG_MEM_TRACKER
25 # define CONFIG_MEM_TRACKER 1 //include xvpx_* calls in the lib
28 #ifndef CONFIG_MEM_CHECKS
29 # define CONFIG_MEM_CHECKS 0 //include some basic safety checks in
30 //vpx_memcpy, _memset, and _memmove
33 #ifndef USE_GLOBAL_FUNCTION_POINTERS
34 # define USE_GLOBAL_FUNCTION_POINTERS 0 //use function pointers instead of compiled functions.
37 #if CONFIG_MEM_TRACKER
38 # include "vpx_mem_tracker.h"
39 # if VPX_MEM_TRACKER_VERSION_CHIEF != 2 || VPX_MEM_TRACKER_VERSION_MAJOR != 5
40 # error "vpx_mem requires memory tracker version 2.5 to track memory usage"
44 #define ADDRESS_STORAGE_SIZE sizeof(size_t)
46 #ifndef DEFAULT_ALIGNMENT
48 # define DEFAULT_ALIGNMENT 32 //default addr alignment to use in
49 //calls to vpx_* functions other
52 # define DEFAULT_ALIGNMENT 1
56 #if DEFAULT_ALIGNMENT < 1
57 # error "DEFAULT_ALIGNMENT must be >= 1!"
60 #if CONFIG_MEM_TRACKER
61 # define TRY_BOUNDS_CHECK 1 //when set to 1 pads each allocation,
62 //integrity can be checked using
63 //vpx_memory_tracker_check_integrity
64 //or on free by defining
65 //TRY_BOUNDS_CHECK_ON_FREE
67 # define TRY_BOUNDS_CHECK 0
68 #endif /*CONFIG_MEM_TRACKER*/
71 # define TRY_BOUNDS_CHECK_ON_FREE 0 //checks mem integrity on every
72 //free, very expensive
73 # define BOUNDS_CHECK_VALUE 0xdeadbeef //value stored before/after ea.
74 //mem addr for bounds checking
75 # define BOUNDS_CHECK_PAD_SIZE 32 //size of the padding before and
76 //after ea allocation to be filled
77 //with BOUNDS_CHECK_VALUE.
78 //this should be a multiple of 4
80 # define BOUNDS_CHECK_VALUE 0
81 # define BOUNDS_CHECK_PAD_SIZE 0
82 #endif /*TRY_BOUNDS_CHECK*/
84 #ifndef REMOVE_PRINTFS
85 # define REMOVE_PRINTFS 0
88 /* Should probably use a vpx_mem logger function. */
95 /*returns an addr aligned to the byte boundary specified by align*/
96 #define align_addr(addr,align) (void*)(((size_t)(addr) + ((align) - 1)) & (size_t)-(align))
98 #endif /*__VPX_MEM_INTRNL_H__*/