]> granicus.if.org Git - libvpx/blob - vpx_mem/include/vpx_mem_intrnl.h
vpx_mem: remove memory manager code
[libvpx] / vpx_mem / include / vpx_mem_intrnl.h
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_TRACKER
17 # define CONFIG_MEM_TRACKER     1 /*include xvpx_* calls in the lib*/
18 #endif
19
20 #ifndef CONFIG_MEM_CHECKS
21 # define CONFIG_MEM_CHECKS      0 /*include some basic safety checks in
22 vpx_memcpy, _memset, and _memmove*/
23 #endif
24
25 #ifndef USE_GLOBAL_FUNCTION_POINTERS
26 # define USE_GLOBAL_FUNCTION_POINTERS   0  /*use function pointers instead of compiled functions.*/
27 #endif
28
29 #if CONFIG_MEM_TRACKER
30 # include "vpx_mem_tracker.h"
31 # if VPX_MEM_TRACKER_VERSION_CHIEF != 2 || VPX_MEM_TRACKER_VERSION_MAJOR != 5
32 #  error "vpx_mem requires memory tracker version 2.5 to track memory usage"
33 # endif
34 #endif
35
36 #define ADDRESS_STORAGE_SIZE      sizeof(size_t)
37
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        (2 * sizeof(void*))  /* NOLINT */
45 # endif
46 #endif
47
48 #if CONFIG_MEM_TRACKER
49 # define TRY_BOUNDS_CHECK         1        /*when set to 1 pads each allocation,
50 integrity can be checked using
51 vpx_memory_tracker_check_integrity
52 or on free by defining*/
53 /*TRY_BOUNDS_CHECK_ON_FREE*/
54 #else
55 # define TRY_BOUNDS_CHECK         0
56 #endif /*CONFIG_MEM_TRACKER*/
57
58 #if TRY_BOUNDS_CHECK
59 # define TRY_BOUNDS_CHECK_ON_FREE 0          /*checks mem integrity on every
60 free, very expensive*/
61 # define BOUNDS_CHECK_VALUE       0xdeadbeef /*value stored before/after ea.
62 mem addr for bounds checking*/
63 # define BOUNDS_CHECK_PAD_SIZE    32         /*size of the padding before and
64 after ea allocation to be filled
65 with BOUNDS_CHECK_VALUE.
66 this should be a multiple of 4*/
67 #else
68 # define BOUNDS_CHECK_VALUE       0
69 # define BOUNDS_CHECK_PAD_SIZE    0
70 #endif /*TRY_BOUNDS_CHECK*/
71
72 #ifndef REMOVE_PRINTFS
73 # define REMOVE_PRINTFS 0
74 #endif
75
76 /* Should probably use a vpx_mem logger function. */
77 #if REMOVE_PRINTFS
78 # define _P(x)
79 #else
80 # define _P(x) x
81 #endif
82
83 /*returns an addr aligned to the byte boundary specified by align*/
84 #define align_addr(addr,align) (void*)(((size_t)(addr) + ((align) - 1)) & (size_t)-(align))
85
86 #endif  // VPX_MEM_INCLUDE_VPX_MEM_INTRNL_H_