]> granicus.if.org Git - libvpx/blob - vpx_mem/include/vpx_mem_intrnl.h
Initial WebM release
[libvpx] / vpx_mem / include / vpx_mem_intrnl.h
1 /*
2  *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
3  *
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.
8  */
9
10
11 #ifndef __VPX_MEM_INTRNL_H__
12 #define __VPX_MEM_INTRNL_H__
13 #include "vpx_ports/config.h"
14
15 #ifndef CONFIG_MEM_MANAGER
16 # if defined(VXWORKS)
17 #  define CONFIG_MEM_MANAGER  1 //include heap manager functionality,
18 //default: enabled on vxworks
19 # else
20 #  define CONFIG_MEM_MANAGER  0 //include heap manager functionality
21 # endif
22 #endif /*CONFIG_MEM_MANAGER*/
23
24 #ifndef CONFIG_MEM_TRACKER
25 # define CONFIG_MEM_TRACKER     1 //include xvpx_* calls in the lib
26 #endif
27
28 #ifndef CONFIG_MEM_CHECKS
29 # define CONFIG_MEM_CHECKS      0 //include some basic safety checks in
30 //vpx_memcpy, _memset, and _memmove
31 #endif
32
33 #ifndef USE_GLOBAL_FUNCTION_POINTERS
34 # define USE_GLOBAL_FUNCTION_POINTERS   0  //use function pointers instead of compiled functions.
35 #endif
36
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"
41 # endif
42 #endif
43
44 #define ADDRESS_STORAGE_SIZE      sizeof(size_t)
45
46 #ifndef DEFAULT_ALIGNMENT
47 # if defined(VXWORKS)
48 #  define DEFAULT_ALIGNMENT        32        //default addr alignment to use in
49 //calls to vpx_* functions other
50 //than vpx_memalign
51 # else
52 #  define DEFAULT_ALIGNMENT        1
53 # endif
54 #endif
55
56 #if DEFAULT_ALIGNMENT < 1
57 # error "DEFAULT_ALIGNMENT must be >= 1!"
58 #endif
59
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
66 #else
67 # define TRY_BOUNDS_CHECK         0
68 #endif /*CONFIG_MEM_TRACKER*/
69
70 #if TRY_BOUNDS_CHECK
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
79 #else
80 # define BOUNDS_CHECK_VALUE       0
81 # define BOUNDS_CHECK_PAD_SIZE    0
82 #endif /*TRY_BOUNDS_CHECK*/
83
84 #ifndef REMOVE_PRINTFS
85 # define REMOVE_PRINTFS 0
86 #endif
87
88 /* Should probably use a vpx_mem logger function. */
89 #if REMOVE_PRINTFS
90 # define _P(x)
91 #else
92 # define _P(x) x
93 #endif
94
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))
97
98 #endif /*__VPX_MEM_INTRNL_H__*/