michael@0: /* michael@0: * Copyright (c) 2010 The WebM project authors. All Rights Reserved. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license michael@0: * that can be found in the LICENSE file in the root of the source michael@0: * tree. An additional intellectual property rights grant can be found michael@0: * in the file PATENTS. All contributing project authors may michael@0: * be found in the AUTHORS file in the root of the source tree. michael@0: */ michael@0: michael@0: michael@0: #ifndef __VPX_MEM_INTRNL_H__ michael@0: #define __VPX_MEM_INTRNL_H__ michael@0: #include "./vpx_config.h" michael@0: michael@0: #ifndef CONFIG_MEM_MANAGER michael@0: # if defined(VXWORKS) michael@0: # define CONFIG_MEM_MANAGER 1 /*include heap manager functionality,*/ michael@0: /*default: enabled on vxworks*/ michael@0: # else michael@0: # define CONFIG_MEM_MANAGER 0 /*include heap manager functionality*/ michael@0: # endif michael@0: #endif /*CONFIG_MEM_MANAGER*/ michael@0: michael@0: #ifndef CONFIG_MEM_TRACKER michael@0: # define CONFIG_MEM_TRACKER 1 /*include xvpx_* calls in the lib*/ michael@0: #endif michael@0: michael@0: #ifndef CONFIG_MEM_CHECKS michael@0: # define CONFIG_MEM_CHECKS 0 /*include some basic safety checks in michael@0: vpx_memcpy, _memset, and _memmove*/ michael@0: #endif michael@0: michael@0: #ifndef USE_GLOBAL_FUNCTION_POINTERS michael@0: # define USE_GLOBAL_FUNCTION_POINTERS 0 /*use function pointers instead of compiled functions.*/ michael@0: #endif michael@0: michael@0: #if CONFIG_MEM_TRACKER michael@0: # include "vpx_mem_tracker.h" michael@0: # if VPX_MEM_TRACKER_VERSION_CHIEF != 2 || VPX_MEM_TRACKER_VERSION_MAJOR != 5 michael@0: # error "vpx_mem requires memory tracker version 2.5 to track memory usage" michael@0: # endif michael@0: #endif michael@0: michael@0: #define ADDRESS_STORAGE_SIZE sizeof(size_t) michael@0: michael@0: #ifndef DEFAULT_ALIGNMENT michael@0: # if defined(VXWORKS) michael@0: # define DEFAULT_ALIGNMENT 32 /*default addr alignment to use in michael@0: calls to vpx_* functions other michael@0: than vpx_memalign*/ michael@0: # else michael@0: # define DEFAULT_ALIGNMENT (2 * sizeof(void*)) /* NOLINT */ michael@0: # endif michael@0: #endif michael@0: michael@0: #if CONFIG_MEM_TRACKER michael@0: # define TRY_BOUNDS_CHECK 1 /*when set to 1 pads each allocation, michael@0: integrity can be checked using michael@0: vpx_memory_tracker_check_integrity michael@0: or on free by defining*/ michael@0: /*TRY_BOUNDS_CHECK_ON_FREE*/ michael@0: #else michael@0: # define TRY_BOUNDS_CHECK 0 michael@0: #endif /*CONFIG_MEM_TRACKER*/ michael@0: michael@0: #if TRY_BOUNDS_CHECK michael@0: # define TRY_BOUNDS_CHECK_ON_FREE 0 /*checks mem integrity on every michael@0: free, very expensive*/ michael@0: # define BOUNDS_CHECK_VALUE 0xdeadbeef /*value stored before/after ea. michael@0: mem addr for bounds checking*/ michael@0: # define BOUNDS_CHECK_PAD_SIZE 32 /*size of the padding before and michael@0: after ea allocation to be filled michael@0: with BOUNDS_CHECK_VALUE. michael@0: this should be a multiple of 4*/ michael@0: #else michael@0: # define BOUNDS_CHECK_VALUE 0 michael@0: # define BOUNDS_CHECK_PAD_SIZE 0 michael@0: #endif /*TRY_BOUNDS_CHECK*/ michael@0: michael@0: #ifndef REMOVE_PRINTFS michael@0: # define REMOVE_PRINTFS 0 michael@0: #endif michael@0: michael@0: /* Should probably use a vpx_mem logger function. */ michael@0: #if REMOVE_PRINTFS michael@0: # define _P(x) michael@0: #else michael@0: # define _P(x) x michael@0: #endif michael@0: michael@0: /*returns an addr aligned to the byte boundary specified by align*/ michael@0: #define align_addr(addr,align) (void*)(((size_t)(addr) + ((align) - 1)) & (size_t)-(align)) michael@0: michael@0: #endif /*__VPX_MEM_INTRNL_H__*/