2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
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.
12 #ifndef VPX_MEM_INCLUDE_VPX_MEM_INTRNL_H_
13 #define VPX_MEM_INCLUDE_VPX_MEM_INTRNL_H_
14 #include "./vpx_config.h"
16 #ifndef CONFIG_MEM_TRACKER
17 # define CONFIG_MEM_TRACKER 1 /*include xvpx_* calls in the lib*/
20 #ifndef USE_GLOBAL_FUNCTION_POINTERS
21 # define USE_GLOBAL_FUNCTION_POINTERS 0 /*use function pointers instead of compiled functions.*/
24 #if CONFIG_MEM_TRACKER
25 # include "vpx_mem_tracker.h"
26 # if VPX_MEM_TRACKER_VERSION_CHIEF != 2 || VPX_MEM_TRACKER_VERSION_MAJOR != 5
27 # error "vpx_mem requires memory tracker version 2.5 to track memory usage"
31 #define ADDRESS_STORAGE_SIZE sizeof(size_t)
33 #ifndef DEFAULT_ALIGNMENT
35 # define DEFAULT_ALIGNMENT 32 /*default addr alignment to use in
36 calls to vpx_* functions other
39 # define DEFAULT_ALIGNMENT (2 * sizeof(void*)) /* NOLINT */
43 #if CONFIG_MEM_TRACKER
44 # define TRY_BOUNDS_CHECK 1 /*when set to 1 pads each allocation,
45 integrity can be checked using
46 vpx_memory_tracker_check_integrity
47 or on free by defining*/
48 /*TRY_BOUNDS_CHECK_ON_FREE*/
50 # define TRY_BOUNDS_CHECK 0
51 #endif /*CONFIG_MEM_TRACKER*/
54 # define TRY_BOUNDS_CHECK_ON_FREE 0 /*checks mem integrity on every
55 free, very expensive*/
56 # define BOUNDS_CHECK_VALUE 0xdeadbeef /*value stored before/after ea.
57 mem addr for bounds checking*/
58 # define BOUNDS_CHECK_PAD_SIZE 32 /*size of the padding before and
59 after ea allocation to be filled
60 with BOUNDS_CHECK_VALUE.
61 this should be a multiple of 4*/
63 # define BOUNDS_CHECK_VALUE 0
64 # define BOUNDS_CHECK_PAD_SIZE 0
65 #endif /*TRY_BOUNDS_CHECK*/
67 #ifndef REMOVE_PRINTFS
68 # define REMOVE_PRINTFS 0
71 /* Should probably use a vpx_mem logger function. */
78 /*returns an addr aligned to the byte boundary specified by align*/
79 #define align_addr(addr,align) (void*)(((size_t)(addr) + ((align) - 1)) & (size_t)-(align))
81 #endif // VPX_MEM_INCLUDE_VPX_MEM_INTRNL_H_