diff options
author | John Koleszar <jkoleszar@google.com> | 2011-02-17 06:59:48 -0500 |
---|---|---|
committer | John Koleszar <jkoleszar@google.com> | 2011-02-18 09:09:49 -0500 |
commit | cbf923b12cec2fe7ceea0b94091d64953e56b1fe (patch) | |
tree | 20509d6aa1e7a569131fc544ac3f11eb34000e48 /vpx_mem | |
parent | 562f1470ceed6c7d122e61dc5ca63300ab312830 (diff) | |
download | libvpx-cbf923b12cec2fe7ceea0b94091d64953e56b1fe.tar libvpx-cbf923b12cec2fe7ceea0b94091d64953e56b1fe.tar.gz libvpx-cbf923b12cec2fe7ceea0b94091d64953e56b1fe.tar.bz2 libvpx-cbf923b12cec2fe7ceea0b94091d64953e56b1fe.zip |
clean up unused files
Removed a number of files that were unused or little-used.
Change-Id: If9ae5e5b11390077581a9a879e8a0defe709f5da
Diffstat (limited to 'vpx_mem')
-rw-r--r-- | vpx_mem/intel_linux/vpx_mem.c | 951 | ||||
-rw-r--r-- | vpx_mem/intel_linux/vpx_mem_tracker.c | 812 | ||||
-rw-r--r-- | vpx_mem/nds/vpx_mem_nds.c | 66 | ||||
-rw-r--r-- | vpx_mem/ti_c6x/vpx_mem_ti_6cx.c | 116 |
4 files changed, 0 insertions, 1945 deletions
diff --git a/vpx_mem/intel_linux/vpx_mem.c b/vpx_mem/intel_linux/vpx_mem.c deleted file mode 100644 index 00150acd5..000000000 --- a/vpx_mem/intel_linux/vpx_mem.c +++ /dev/null @@ -1,951 +0,0 @@ -/* - * Copyright (c) 2010 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -#define __VPX_MEM_C__ - -#include "vpx_mem.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#ifndef CONFIG_MEM_MANAGER -# if defined(VXWORKS) -# define CONFIG_MEM_MANAGER 1 //include heap manager functionality, -//default: enabled on vxworks -# else -# define CONFIG_MEM_MANAGER 0 //include heap manager functionality -# endif -#endif - -#ifndef CONFIG_MEM_TRACKER -# define CONFIG_MEM_TRACKER 1 //include xvpx_* calls in the lib -#endif - -#ifndef CONFIG_MEM_CHECKS -# define CONFIG_MEM_CHECKS 0 //include some basic safety checks in -//vpx_memcpy, _memset, and _memmove -#endif - -#ifndef USE_GLOBAL_FUNCTION_POINTERS -# define USE_GLOBAL_FUNCTION_POINTERS 0 //use function pointers instead of compiled functions. -#endif - -#if CONFIG_MEM_TRACKER -# include "vpx_mem_tracker.h" -# if VPX_MEM_TRACKER_VERSION_CHIEF != 2 || VPX_MEM_TRACKER_VERSION_MAJOR != 5 -# error "vpx_mem requires memory tracker version 2.5 to track memory usage" -# endif -#endif - -#define ADDRESS_STORAGE_SIZE sizeof(size_t) - -#ifndef DEFAULT_ALIGNMENT -# if defined(VXWORKS) -# define DEFAULT_ALIGNMENT 32 //default addr alignment to use in -//calls to vpx_* functions other -//than vpx_memalign -# else -# define DEFAULT_ALIGNMENT 1 -# endif -#endif - -#if DEFAULT_ALIGNMENT < 1 -# error "DEFAULT_ALIGNMENT must be >= 1!" -#endif - -#if CONFIG_MEM_TRACKER -# define TRY_BOUNDS_CHECK 1 //when set to 1 pads each allocation, -//integrity can be checked using -//vpx_memory_tracker_check_integrity -//or on free by defining -//TRY_BOUNDS_CHECK_ON_FREE -static unsigned long g_alloc_count = 0; - -#else -# define TRY_BOUNDS_CHECK 0 -#endif - -#if TRY_BOUNDS_CHECK -# define TRY_BOUNDS_CHECK_ON_FREE 0 //checks mem integrity on every -//free, very expensive -# define BOUNDS_CHECK_VALUE 0xdeadbeef //value stored before/after ea. -//mem addr for bounds checking -# define BOUNDS_CHECK_PAD_SIZE 32 //size of the padding before and -//after ea allocation to be filled -//with BOUNDS_CHECK_VALUE. -//this should be a multiple of 4 -#else -# define BOUNDS_CHECK_VALUE 0 -# define BOUNDS_CHECK_PAD_SIZE 0 -#endif - -#if CONFIG_MEM_MANAGER -# include "heapmm.h" -# include "hmm_intrnl.h" - -# define SHIFT_HMM_ADDR_ALIGN_UNIT 5 -# define TOTAL_MEMORY_TO_ALLOCATE 20971520 // 20 * 1024 * 1024 - -# define MM_DYNAMIC_MEMORY 1 -# if MM_DYNAMIC_MEMORY -static unsigned char *g_p_mng_memory_raw = NULL; -static unsigned char *g_p_mng_memory = NULL; -# else -static unsigned char g_p_mng_memory[TOTAL_MEMORY_TO_ALLOCATE]; -# endif - -static size_t g_mm_memory_size = TOTAL_MEMORY_TO_ALLOCATE; - -static hmm_descriptor hmm_d; -static int g_mng_memory_allocated = 0; - -static int vpx_mm_create_heap_memory(); -static void *vpx_mm_realloc(void *memblk, size_t size); -#endif //CONFIG_MEM_MANAGER - -#if USE_GLOBAL_FUNCTION_POINTERS - -struct GLOBAL_FUNC_POINTERS -{ - g_malloc_func g_malloc; - g_calloc_func g_calloc; - g_realloc_func g_realloc; - g_free_func g_free; - g_memcpy_func g_memcpy; - g_memset_func g_memset; - g_memmove_func g_memmove; -}; -struct GLOBAL_FUNC_POINTERS *g_func = 0; - -# define VPX_MALLOC_L g_func->g_malloc -# define VPX_REALLOC_L g_func->g_realloc -# define VPX_FREE_L g_func->g_free -# define VPX_MEMCPY_L g_func->g_memcpy -# define VPX_MEMSET_L g_func->g_memset -# define VPX_MEMMOVE_L g_func->g_memmove - -#else -# define VPX_MALLOC_L malloc -# define VPX_REALLOC_L realloc -# define VPX_FREE_L free -# define VPX_MEMCPY_L memcpy -# define VPX_MEMSET_L memset -# define VPX_MEMMOVE_L memmove -#endif // USE_GLOBAL_FUNCTION_POINTERS - -/* Should probably use a vpx_mem logger function. */ -#define __REMOVE_PRINTFS -#ifdef __REMOVE_PRINTFS -#define _P(x) -#else -#define _P(x) x -#endif - -/*returns an addr aligned to the byte boundary specified by align*/ -#define align_addr(addr,align) \ - (void*)(((size_t)(addr) + ((align) - 1)) & (size_t)-(align)) - -unsigned int vpx_mem_get_version() -{ - unsigned int ver = ((unsigned int)(unsigned char)VPX_MEM_VERSION_CHIEF << 24 | - (unsigned int)(unsigned char)VPX_MEM_VERSION_MAJOR << 16 | - (unsigned int)(unsigned char)VPX_MEM_VERSION_MINOR << 8 | - (unsigned int)(unsigned char)VPX_MEM_VERSION_PATCH); - return ver; -} - -int vpx_mem_set_heap_size(size_t size) -{ - int ret = -1; - -#if CONFIG_MEM_MANAGER -#if MM_DYNAMIC_MEMORY - - if (!g_mng_memory_allocated && size) - { - g_mm_memory_size = size; - ret = 0; - } - else - ret = -3; - -#else - ret = -2; -#endif -#else - (void)size; -#endif - - return ret; -} - -void *vpx_memalign(size_t align, size_t size) -{ - void *addr, - * x = NULL; - -#if CONFIG_MEM_MANAGER - int number_aau; - - if (vpx_mm_create_heap_memory() < 0) - { - _P(printf("[vpx][mm] ERROR vpx_memalign() Couldn't create memory for Heap.\n");) - } - - number_aau = ((size + align - 1 + ADDRESS_STORAGE_SIZE) >> - SHIFT_HMM_ADDR_ALIGN_UNIT) + 1; - - addr = hmm_alloc(&hmm_d, number_aau); -#else - addr = VPX_MALLOC_L(size + align - 1 + ADDRESS_STORAGE_SIZE); -#endif //CONFIG_MEM_MANAGER - - if (addr) - { - x = align_addr((unsigned char *)addr + ADDRESS_STORAGE_SIZE, (int)align); - /* save the actual malloc address */ - ((size_t *)x)[-1] = (size_t)addr; - } - - return x; -} - -void *vpx_malloc(size_t size) -{ - return vpx_memalign(DEFAULT_ALIGNMENT, size); -} - -void *vpx_calloc(size_t num, size_t size) -{ - void *x; - - x = vpx_memalign(DEFAULT_ALIGNMENT, num * size); - - if (x) - VPX_MEMSET_L(x, 0, num * size); - - return x; -} - -void *vpx_realloc(void *memblk, size_t size) -{ - void *addr, - * new_addr = NULL; - int align = DEFAULT_ALIGNMENT; - - /* - The realloc() function changes the size of the object pointed to by - ptr to the size specified by size, and returns a pointer to the - possibly moved block. The contents are unchanged up to the lesser - of the new and old sizes. If ptr is null, realloc() behaves like - malloc() for the specified size. If size is zero (0) and ptr is - not a null pointer, the object pointed to is freed. - */ - if (!memblk) - new_addr = vpx_malloc(size); - else if (!size) - vpx_free(memblk); - else - { - addr = (void *)(((size_t *)memblk)[-1]); - memblk = NULL; - -#if CONFIG_MEM_MANAGER - new_addr = vpx_mm_realloc(addr, size + align + ADDRESS_STORAGE_SIZE); -#else - new_addr = VPX_REALLOC_L(addr, size + align + ADDRESS_STORAGE_SIZE); -#endif - - if (new_addr) - { - addr = new_addr; - new_addr = (void *)(((size_t) - ((unsigned char *)new_addr + ADDRESS_STORAGE_SIZE) + (align - 1)) & - (size_t) - align); - /* save the actual malloc address */ - ((size_t *)new_addr)[-1] = (size_t)addr; - } - } - - return new_addr; -} - -void vpx_free(void *memblk) -{ - if (memblk) - { - void *addr = (void *)(((size_t *)memblk)[-1]); -#if CONFIG_MEM_MANAGER - hmm_free(&hmm_d, addr); -#else - VPX_FREE_L(addr); -#endif - } -} - -void *vpx_mem_alloc(int id, size_t size, size_t align) -{ -#if defined CHIP_DM642 || defined __uClinux__ - void *mem = (void *)mem_alloc(id, size, align); - - if (!mem) - { - _P(fprintf(stderr, - "\n" - "*********************************************************\n" - "WARNING: mem_alloc returned 0 for id=%p size=%u align=%u.\n" - "*********************************************************\n", - mem, size, align)); - // should no longer need this. Softier says it's fixed. 2005-01-21 tjf - //#if defined __uClinux__ - //while(1)usleep(1000000); - //#endif - } - -#if defined __uClinux__ - else if (mem == (void *)0xFFFFFFFF) - { - // out of memory/error - mem = (void *)0; - - _P(fprintf(stderr, - "\n" - "******************************************************\n" - "ERROR: mem_alloc id=%p size=%u align=%u OUT OF MEMORY.\n" - "******************************************************\n", - mem, size, align)); - } - -#endif // __uClinux__ - - return mem; -#else - (void)id; - (void)size; - (void)align; - return (void *)0; -#endif -} - -void vpx_mem_free(int id, void *mem, size_t size) -{ -#if defined CHIP_DM642 || defined __uClinux__ - - if (!mem) - { - _P(fprintf(stderr, - "\n" - "**************************************\n" - "WARNING: 0 being free'd id=%p size=%u.\n" - "**************************************\n", - id, size)); - - // should no longer need this. Softier says it's fixed. 2005-01-21 tjf - //#if defined __uClinux__ - //while(1)usleep(1000000); - //#endif - } - - mem_free(id, mem, size); -#else - (void)id; - (void)mem; - (void)size; -#endif -} - - -#if CONFIG_MEM_TRACKER - -void *xvpx_mem_alloc(int id, size_t size, size_t align, char *file, int line) -{ - void *mem = vpx_mem_alloc(id, size, align); - - vpx_memory_tracker_add((size_t)mem, size, file, line, 0); - - return mem; -} - -void xvpx_mem_free(int id, void *mem, size_t size, char *file, int line) -{ - if (vpx_memory_tracker_remove((size_t)mem) == -2) - { -#if REMOVE_PRINTFS - (void)file; - (void)line; -#endif - _P(fprintf(stderr, "[vpx_mem][xvpx_mem_free] addr: %p (id=%p size=%u) " - "not found in list; freed from file:%s" - " line:%d\n", mem, id, size, file, line)); - } - - vpx_mem_free(id, mem, size); -} - -void *xvpx_memalign(size_t align, size_t size, char *file, int line) -{ -#if TRY_BOUNDS_CHECK - unsigned char *x_bounds; -#endif - - void *x; - - if (g_alloc_count == 0) - { -#if TRY_BOUNDS_CHECK - int i_rv = vpx_memory_tracker_init(BOUNDS_CHECK_PAD_SIZE, BOUNDS_CHECK_VALUE); -#else - int i_rv = vpx_memory_tracker_init(0, 0); -#endif - - if (i_rv < 0) - { - _P(printf("ERROR xvpx_malloc MEM_TRACK_USAGE error vpx_memory_tracker_init().\n");) - } - } - -#if TRY_BOUNDS_CHECK - { - int i; - unsigned int tempme = BOUNDS_CHECK_VALUE; - - x_bounds = vpx_memalign(align, size + (BOUNDS_CHECK_PAD_SIZE * 2)); - - if (x_bounds) - { - /*we're aligning the address twice here but to keep things - consistent we want to have the padding come before the stored - address so no matter what free function gets called we will - attempt to free the correct address*/ - x_bounds = (unsigned char *)(((size_t *)x_bounds)[-1]); - x = align_addr(x_bounds + BOUNDS_CHECK_PAD_SIZE + ADDRESS_STORAGE_SIZE, - (int)align); - /* save the actual malloc address */ - ((size_t *)x)[-1] = (size_t)x_bounds; - - for (i = 0; i < BOUNDS_CHECK_PAD_SIZE; i += sizeof(unsigned int)) - { - VPX_MEMCPY_L(x_bounds + i, &tempme, sizeof(unsigned int)); - VPX_MEMCPY_L((unsigned char *)x + size + i, - &tempme, sizeof(unsigned int)); - } - } - else - x = NULL; - } -#else - x = vpx_memalign(align, size); -#endif //TRY_BOUNDS_CHECK - - g_alloc_count++; - - vpx_memory_tracker_add((size_t)x, size, file, line, 1); - - return x; -} - -void *xvpx_malloc(size_t size, char *file, int line) -{ - return xvpx_memalign(DEFAULT_ALIGNMENT, size, file, line); -} - -void *xvpx_calloc(size_t num, size_t size, char *file, int line) -{ - void *x = xvpx_memalign(DEFAULT_ALIGNMENT, num * size, file, line); - - if (x) - VPX_MEMSET_L(x, 0, num * size); - - return x; -} - -void *xvpx_realloc(void *memblk, size_t size, char *file, int line) -{ - struct mem_block *p = NULL; - int orig_size = 0, - orig_line = 0; - char *orig_file = NULL; - -#if TRY_BOUNDS_CHECK - unsigned char *x_bounds = memblk ? - (unsigned char *)(((size_t *)memblk)[-1]) : - NULL; -#endif - - void *x; - - if (g_alloc_count == 0) - { -#if TRY_BOUNDS_CHECK - - if (!vpx_memory_tracker_init(BOUNDS_CHECK_PAD_SIZE, BOUNDS_CHECK_VALUE)) -#else - if (!vpx_memory_tracker_init(0, 0)) -#endif - { - _P(printf("ERROR xvpx_malloc MEM_TRACK_USAGE error vpx_memory_tracker_init().\n");) - } - } - - if (p = vpx_memory_tracker_find((size_t)memblk)) - { - orig_size = p->size; - orig_file = p->file; - orig_line = p->line; - } - -#if TRY_BOUNDS_CHECK_ON_FREE - vpx_memory_tracker_check_integrity(file, line); -#endif - - //have to do this regardless of success, because - //the memory that does get realloc'd may change - //the bounds values of this block - vpx_memory_tracker_remove((size_t)memblk); - -#if TRY_BOUNDS_CHECK - { - int i; - unsigned int tempme = BOUNDS_CHECK_VALUE; - - x_bounds = vpx_realloc(memblk, size + (BOUNDS_CHECK_PAD_SIZE * 2)); - - if (x_bounds) - { - x_bounds = (unsigned char *)(((size_t *)x_bounds)[-1]); - x = align_addr(x_bounds + BOUNDS_CHECK_PAD_SIZE + ADDRESS_STORAGE_SIZE, - (int)DEFAULT_ALIGNMENT); - /* save the actual malloc address */ - ((size_t *)x)[-1] = (size_t)x_bounds; - - for (i = 0; i < BOUNDS_CHECK_PAD_SIZE; i += sizeof(unsigned int)) - { - VPX_MEMCPY_L(x_bounds + i, &tempme, sizeof(unsigned int)); - VPX_MEMCPY_L((unsigned char *)x + size + i, - &tempme, sizeof(unsigned int)); - } - } - else - x = NULL; - } -#else - x = vpx_realloc(memblk, size); -#endif //TRY_BOUNDS_CHECK - - if (x) - vpx_memory_tracker_add((size_t)x, size, file, line, 1); - else - vpx_memory_tracker_add((size_t)memblk, orig_size, orig_file, orig_line, 1); - - return x; -} - -void xvpx_free(void *p_address, char *file, int line) -{ -#if TRY_BOUNDS_CHECK - unsigned char *p_bounds_address = (unsigned char *)p_address; - //p_bounds_address -= BOUNDS_CHECK_PAD_SIZE; -#endif - -#if !TRY_BOUNDS_CHECK_ON_FREE - (void)file; - (void)line; -#endif - - if (p_address) - { -#if TRY_BOUNDS_CHECK_ON_FREE - vpx_memory_tracker_check_integrity(file, line); -#endif - - //if the addr isn't found in the list, assume it was allocated via - //vpx_ calls not xvpx_, therefore it does not contain any padding - if (vpx_memory_tracker_remove((size_t)p_address) == -2) - { - p_bounds_address = p_address; - _P(fprintf(stderr, "[vpx_mem][xvpx_free] addr: %p not found in" - " list; freed from file:%s" - " line:%d\n", p_address, file, line)); - } - else - --g_alloc_count; - -#if TRY_BOUNDS_CHECK - vpx_free(p_bounds_address); -#else - vpx_free(p_address); -#endif - - if (!g_alloc_count) - vpx_memory_tracker_destroy(); - } -} - -#endif /*CONFIG_MEM_TRACKER*/ - -#if CONFIG_MEM_CHECKS -#if defined(VXWORKS) -#include <task_lib.h> //for task_delay() -/* This function is only used to get a stack trace of the player -object so we can se where we are having a problem. */ -static int get_my_tt(int task) -{ - tt(task); - - return 0; -} - -static void vx_sleep(int msec) -{ - int ticks_to_sleep = 0; - - if (msec) - { - int msec_per_tick = 1000 / sys_clk_rate_get(); - - if (msec < msec_per_tick) - ticks_to_sleep++; - else - ticks_to_sleep = msec / msec_per_tick; - } - - task_delay(ticks_to_sleep); -} -#endif -#endif - -void *vpx_memcpy(void *dest, const void *source, size_t length) -{ -#if CONFIG_MEM_CHECKS - - if (((int)dest < 0x4000) || ((int)source < 0x4000)) - { - _P(printf("WARNING: vpx_memcpy dest:0x%x source:0x%x len:%d\n", (int)dest, (int)source, length);) - -#if defined(VXWORKS) - sp(get_my_tt, task_id_self(), 0, 0, 0, 0, 0, 0, 0, 0); - - vx_sleep(10000); -#endif - } - -#endif - - return VPX_MEMCPY_L(dest, source, length); -} - -void *vpx_memset(void *dest, int val, size_t length) -{ -#if CONFIG_MEM_CHECKS - - if ((int)dest < 0x4000) - { - _P(printf("WARNING: vpx_memset dest:0x%x val:%d len:%d\n", (int)dest, val, length);) - -#if defined(VXWORKS) - sp(get_my_tt, task_id_self(), 0, 0, 0, 0, 0, 0, 0, 0); - - vx_sleep(10000); -#endif - } - -#endif - - return VPX_MEMSET_L(dest, val, length); -} - -void *vpx_memmove(void *dest, const void *src, size_t count) -{ -#if CONFIG_MEM_CHECKS - - if (((int)dest < 0x4000) || ((int)src < 0x4000)) - { - _P(printf("WARNING: vpx_memmove dest:0x%x src:0x%x count:%d\n", (int)dest, (int)src, count);) - -#if defined(VXWORKS) - sp(get_my_tt, task_id_self(), 0, 0, 0, 0, 0, 0, 0, 0); - - vx_sleep(10000); -#endif - } - -#endif - - return VPX_MEMMOVE_L(dest, src, count); -} - -#if CONFIG_MEM_MANAGER - -static int vpx_mm_create_heap_memory() -{ - int i_rv = 0; - - if (!g_mng_memory_allocated) - { -#if MM_DYNAMIC_MEMORY - g_p_mng_memory_raw = - (unsigned char *)malloc(g_mm_memory_size + HMM_ADDR_ALIGN_UNIT); - - if (g_p_mng_memory_raw) - { - g_p_mng_memory = (unsigned char *)((((unsigned int)g_p_mng_memory_raw) + - HMM_ADDR_ALIGN_UNIT - 1) & - -(int)HMM_ADDR_ALIGN_UNIT); - - _P(printf("[vpx][mm] total memory size:%d g_p_mng_memory_raw:0x%x g_p_mng_memory:0x%x\n" - , g_mm_memory_size + HMM_ADDR_ALIGN_UNIT - , (unsigned int)g_p_mng_memory_raw - , (unsigned int)g_p_mng_memory);) - } - else - { - _P(printf("[vpx][mm] Couldn't allocate memory:%d for vpx memory manager.\n" - , g_mm_memory_size);) - - i_rv = -1; - } - - if (g_p_mng_memory) -#endif - { - int chunk_size = 0; - - g_mng_memory_allocated = 1; - - hmm_init(&hmm_d); - - chunk_size = g_mm_memory_size >> SHIFT_HMM_ADDR_ALIGN_UNIT; - - chunk_size -= DUMMY_END_BLOCK_BAUS; - - _P(printf("[vpx][mm] memory size:%d for vpx memory manager. g_p_mng_memory:0x%x chunk_size:%d\n" - , g_mm_memory_size - , (unsigned int)g_p_mng_memory - , chunk_size);) - - hmm_new_chunk(&hmm_d, (void *)g_p_mng_memory, chunk_size); - } - -#if MM_DYNAMIC_MEMORY - else - { - _P(printf("[vpx][mm] Couldn't allocate memory:%d for vpx memory manager.\n" - , g_mm_memory_size);) - - i_rv = -1; - } - -#endif - } - - return i_rv; -} - -static void *vpx_mm_realloc(void *memblk, size_t size) -{ - void *p_ret = NULL; - - if (vpx_mm_create_heap_memory() < 0) - { - _P(printf("[vpx][mm] ERROR vpx_mm_realloc() Couldn't create memory for Heap.\n");) - } - else - { - int i_rv = 0; - int old_num_aaus; - int new_num_aaus; - - old_num_aaus = hmm_true_size(memblk); - new_num_aaus = (size >> SHIFT_HMM_ADDR_ALIGN_UNIT) + 1; - - if (old_num_aaus == new_num_aaus) - { - p_ret = memblk; - } - else - { - i_rv = hmm_resize(&hmm_d, memblk, new_num_aaus); - - if (i_rv == 0) - { - p_ret = memblk; - } - else - { - /* Error. Try to malloc and then copy data. */ - void *p_from_malloc; - - new_num_aaus = (size >> SHIFT_HMM_ADDR_ALIGN_UNIT) + 1; - p_from_malloc = hmm_alloc(&hmm_d, new_num_aaus); - - if (p_from_malloc) - { - vpx_memcpy(p_from_malloc, memblk, size); - hmm_free(&hmm_d, memblk); - - p_ret = p_from_malloc; - } - } - } - } - - return p_ret; -} -#endif //CONFIG_MEM_MANAGER - -#if USE_GLOBAL_FUNCTION_POINTERS -# if CONFIG_MEM_TRACKER -extern int vpx_memory_tracker_set_functions(g_malloc_func g_malloc_l - , g_calloc_func g_calloc_l - , g_realloc_func g_realloc_l - , g_free_func g_free_l - , g_memcpy_func g_memcpy_l - , g_memset_func g_memset_l - , g_memmove_func g_memmove_l); -# endif -#endif -int vpx_mem_set_functions(g_malloc_func g_malloc_l - , g_calloc_func g_calloc_l - , g_realloc_func g_realloc_l - , g_free_func g_free_l - , g_memcpy_func g_memcpy_l - , g_memset_func g_memset_l - , g_memmove_func g_memmove_l) -{ -#if USE_GLOBAL_FUNCTION_POINTERS - - /* If use global functions is turned on then the - application must set the global functions before - it does anything else or vpx_mem will have - unpredictable results. */ - if (!g_func) - { - g_func = (struct GLOBAL_FUNC_POINTERS *)g_malloc_l(sizeof(struct GLOBAL_FUNC_POINTERS)); - - if (!g_func) - { - return -1; - } - } - -#if CONFIG_MEM_TRACKER - { - int rv = 0; - rv = vpx_memory_tracker_set_functions(g_malloc_l - , g_calloc_l - , g_realloc_l - , g_free_l - , g_memcpy_l - , g_memset_l - , g_memmove_l); - - if (rv < 0) - { - return rv; - } - } -#endif - - if (g_malloc_l) - g_func->g_malloc = g_malloc_l; - else - g_func->g_malloc = 0; - - if (g_calloc_l) - g_func->g_calloc = g_calloc_l; - else - g_func->g_calloc = 0; - - if (g_realloc_l) - g_func->g_realloc = g_realloc_l; - else - g_func->g_realloc = 0; - - if (g_free_l) - g_func->g_free = g_free_l; - else - g_func->g_free = 0; - - if (g_memcpy_l) - g_func->g_memcpy = g_memcpy_l; - else - g_func->g_memcpy = 0; - - if (g_memset_l) - g_func->g_memset = g_memset_l; - else - g_func->g_memset = 0; - - if (g_memmove_l) - g_func->g_memmove = g_memmove_l; - else - g_func->g_memmove = 0; - - return 0; -#else - (void)g_malloc_l; - (void)g_calloc_l; - (void)g_realloc_l; - (void)g_free_l; - (void)g_memcpy_l; - (void)g_memset_l; - (void)g_memmove_l; - return -1; -#endif -} - -int vpx_mem_unset_functions() -{ -#if USE_GLOBAL_FUNCTION_POINTERS - - if (g_func) - { - g_free_func temp_free; - - temp_free = g_func->g_free; - - temp_free(g_func); - g_func = 0; - } - -#endif - return 0; -} - -#ifdef _INTEL_LINUX -void *_intel_fast_memcpy(void *dest, const void *src, size_t count) -{ - - //memcpy(dest, src, count); - char *dst8 = (char *)dest; - char *src8 = (char *)src; - - while (count--) - { - *dst8++ = *src8++; - } - - return dest; -} - -void *_intel_fast_memset(void *dest, int c, size_t count) -{ - memset(dest, c, count); - return dest; -} - -void *_VEC_memzero(void *dest, int c, size_t count) -{ - memset(dest, 0, count); - return dest; -} - -#endif //_ICC diff --git a/vpx_mem/intel_linux/vpx_mem_tracker.c b/vpx_mem/intel_linux/vpx_mem_tracker.c deleted file mode 100644 index 5bed4b50d..000000000 --- a/vpx_mem/intel_linux/vpx_mem_tracker.c +++ /dev/null @@ -1,812 +0,0 @@ -/* - * Copyright (c) 2010 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -/* - vpx_mem_tracker.c - - jwz 2003-09-30: - Stores a list of addreses, their size, and file and line they came from. - All exposed lib functions are prefaced by vpx_ and allow the global list - to be thread safe. - Current supported platforms are: - Linux, Win32, win_ce and vx_works - Further support can be added by defining the platform specific mutex - in the memory_tracker struct as well as calls to create/destroy/lock/unlock - the mutex in vpx_memory_tracker_init/Destroy and memory_tracker_lock_mutex/unlock_mutex -*/ - -#define NO_MUTEX - -#if defined(__uClinux__) -# include <lddk.h> -#endif - -#if defined(LINUX) || defined(__uClinux__) -# include <pthread.h> -#elif defined(WIN32) || defined(_WIN32_WCE) -# define WIN32_LEAN_AND_MEAN -# include <windows.h> -# include <winbase.h> -#elif defined(VXWORKS) -# include <sem_lib.h> -#elif defined(NDS_NITRO) -# include <nitro.h> -# include <nitro/os.h> -#endif - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> //VXWORKS doesn't have a malloc/memory.h file, -//this should pull in malloc,free,etc. -#include <stdarg.h> - -#include "vpx_mem_tracker.h" - -#undef vpx_malloc //undefine any vpx_mem macros that may affect calls to -#undef vpx_free //memory functions in this file -#undef vpx_memcpy -#undef vpx_memset - - -#ifndef USE_GLOBAL_FUNCTION_POINTERS -# define USE_GLOBAL_FUNCTION_POINTERS 0 //use function pointers instead of compiled functions. -#endif - -#if USE_GLOBAL_FUNCTION_POINTERS -static mem_track_malloc_func g_malloc = malloc; -static mem_track_calloc_func g_calloc = calloc; -static mem_track_realloc_func g_realloc = realloc; -static mem_track_free_func g_free = free; -static mem_track_memcpy_func g_memcpy = memcpy; -static mem_track_memset_func g_memset = memset; -static mem_track_memmove_func g_memmove = memmove; -# define MEM_TRACK_MALLOC g_malloc -# define MEM_TRACK_FREE g_free -# define MEM_TRACK_MEMCPY g_memcpy -# define MEM_TRACK_MEMSET g_memset -#else -# define MEM_TRACK_MALLOC vpx_malloc -# define MEM_TRACK_FREE vpx_free -# define MEM_TRACK_MEMCPY vpx_memcpy -# define MEM_TRACK_MEMSET vpx_memset -#endif // USE_GLOBAL_FUNCTION_POINTERS - - -struct memory_tracker -{ - struct mem_block *head, - * tail; - int len, - totalsize; - unsigned int current_allocated, - max_allocated; - -#if defined(LINUX) || defined(__uClinux__) - pthread_mutex_t mutex; -#elif defined(WIN32) || defined(_WIN32_WCE) - HANDLE mutex; -#elif defined(VXWORKS) - SEM_ID mutex; -#elif defined(NDS_NITRO) - OSMutex mutex; -#elif defined(NO_MUTEX) -#else -#error "No mutex type defined for this platform!" -#endif - - int padding_size, - pad_value; -}; - -/* prototypes for internal library functions */ -static void memtrack_log(const char *fmt, ...); -static void memory_tracker_dump(); -static void memory_tracker_check_integrity(char *file, unsigned int line); -static void memory_tracker_add(size_t addr, unsigned int size, - char *file, unsigned int line, - int padded); -static int memory_tracker_remove(size_t addr); -static struct mem_block *memory_tracker_find(size_t addr); - -#if defined(NO_MUTEX) -# define memory_tracker_lock_mutex() (!g_b_mem_tracker_inited) -# define memory_tracker_unlock_mutex() -#else -static int memory_tracker_lock_mutex(); -static int memory_tracker_unlock_mutex(); -#endif - -static struct memory_tracker memtrack; //our global memory allocation list -static int g_b_mem_tracker_inited = 0; //indicates whether the global list has -//been initialized (1:yes/0:no) -static struct -{ - FILE *file; - int type; - void (*func)(void *userdata, const char *fmt, va_list args); - void *userdata; -} g_logging = {0}; - -extern void *vpx_malloc(size_t size); -extern void vpx_free(void *memblk); -extern void *vpx_memcpy(void *dest, const void *src, size_t length); -extern void *vpx_memset(void *dest, int val, size_t length); - -/* - * - * Exposed library functions - * -*/ - -/* - vpx_memory_tracker_init(int padding_size, int pad_value) - padding_size - the size of the padding before and after each mem addr. - Values > 0 indicate that integrity checks can be performed - by inspecting these areas. - pad_value - the initial value within the padding area before and after - each mem addr. - - Initializes global memory tracker structure - Allocates the head of the list -*/ -int vpx_memory_tracker_init(int padding_size, int pad_value) -{ - if (!g_b_mem_tracker_inited) - { - if (memtrack.head = (struct mem_block *)MEM_TRACK_MALLOC(sizeof(struct mem_block))) - { - int ret; - - MEM_TRACK_MEMSET(memtrack.head, 0, sizeof(struct mem_block)); - - memtrack.tail = memtrack.head; - - memtrack.current_allocated = 0; - memtrack.max_allocated = 0; - - memtrack.padding_size = padding_size; - memtrack.pad_value = pad_value; - -#if defined(LINUX) || defined(__uClinux__) - ret = pthread_mutex_init(&memtrack.mutex, - NULL); /*mutex attributes (NULL=default)*/ -#elif defined(WIN32) || defined(_WIN32_WCE) - memtrack.mutex = create_mutex(NULL, /*security attributes*/ - FALSE, /*we don't want initial ownership*/ - NULL); /*mutex name*/ - ret = !memtrack.mutex; -#elif defined(VXWORKS) - memtrack.mutex = sem_bcreate(SEM_Q_FIFO, /*SEM_Q_FIFO non-priority based mutex*/ - SEM_FULL); /*SEM_FULL initial state is unlocked*/ - ret = !memtrack.mutex; -#elif defined(NDS_NITRO) - os_init_mutex(&memtrack.mutex); - ret = 0; -#elif defined(NO_MUTEX) - ret = 0; -#endif - - if (ret) - { - memtrack_log("vpx_memory_tracker_init: Error creating mutex!\n"); - - MEM_TRACK_FREE(memtrack.head); - memtrack.head = NULL; - } - else - { - memtrack_log("Memory Tracker init'd, v."vpx_mem_tracker_version" pad_size:%d pad_val:0x%x %d\n" - , padding_size - , pad_value - , pad_value); - g_b_mem_tracker_inited = 1; - } - } - } - - return g_b_mem_tracker_inited; -} - -/* - vpx_memory_tracker_destroy() - If our global struct was initialized zeros out all its members, - frees memory and destroys it's mutex -*/ -void vpx_memory_tracker_destroy() -{ - - if (!memory_tracker_lock_mutex()) - { - struct mem_block *p = memtrack.head, - * p2 = memtrack.head; - - memory_tracker_dump(); - - while (p) - { - p2 = p; - p = p->next; - - MEM_TRACK_FREE(p2); - } - - memtrack.head = NULL; - memtrack.tail = NULL; - memtrack.len = 0; - memtrack.current_allocated = 0; - memtrack.max_allocated = 0; - - if ((g_logging.type == 0) && (g_logging.file != 0)) //&& (g_logging.file != stderr) ) - { -#if !defined(NDS_NITRO) - fclose(g_logging.file); -#endif - g_logging.file = NULL; - } - - memory_tracker_unlock_mutex(); - - g_b_mem_tracker_inited = 0; - - } - -} - -/* - vpx_memory_tracker_add(size_t addr, unsigned int size, - char * file, unsigned int line) - addr - memory address to be added to list - size - size of addr - file - the file addr was referenced from - line - the line in file addr was referenced from - Adds memory address addr, it's size, file and line it came from - to the global list via the thread safe internal library function -*/ -void vpx_memory_tracker_add(size_t addr, unsigned int size, - char *file, unsigned int line, - int padded) -{ - memory_tracker_add(addr, size, file, line, padded); -} - -/* - vpx_memory_tracker_remove(size_t addr) - addr - memory address to be removed from list - Removes addr from the global list via the thread safe - internal remove function - Return: - Same as described for memory_tracker_remove -*/ -int vpx_memory_tracker_remove(size_t addr) -{ - return memory_tracker_remove(addr); -} - -/* - vpx_memory_tracker_find(size_t addr) - addr - address to be found in list - Return: - If found, pointer to the memory block that matches addr - NULL otherwise -*/ -struct mem_block *vpx_memory_tracker_find(size_t addr) -{ - struct mem_block *p = NULL; - - if (!memory_tracker_lock_mutex()) - { - p = memory_tracker_find(addr); - memory_tracker_unlock_mutex(); - } - - return p; -} - -/* - vpx_memory_tracker_dump() - Locks the memory tracker's mutex and calls the internal - library function to dump the current contents of the - global memory allocation list -*/ -void vpx_memory_tracker_dump() -{ - if (!memory_tracker_lock_mutex()) - { - memory_tracker_dump(); - memory_tracker_unlock_mutex(); - } -} - -/* - vpx_memory_tracker_check_integrity(char* file, unsigned int line) - file - The file name where the check was placed - line - The line in file where the check was placed - Locks the memory tracker's mutex and calls the internal - integrity check function to inspect every address in the global - memory allocation list -*/ -void vpx_memory_tracker_check_integrity(char *file, unsigned int line) -{ - if (!memory_tracker_lock_mutex()) - { - memory_tracker_check_integrity(file, line); - memory_tracker_unlock_mutex(); - } -} - -/* - vpx_memory_tracker_set_log_type - Sets the logging type for the memory tracker. Based on the value it will - direct its output to the appropriate place. - Return: - 0: on success - -1: if the logging type could not be set, because the value was invalid - or because a file could not be opened -*/ -int vpx_memory_tracker_set_log_type(int type, char *option) -{ - int ret = -1; - - - switch (type) - { - case 0: - g_logging.type = 0; - - if (!option) - { - // g_logging.file = stderr; - ret = 0; - } - -#if !defined(NDS_NITRO) - else - { - if (g_logging.file = fopen((char *)option, "w")) - ret = 0; - } - -#endif - break; -#if defined(WIN32) && !defined(_WIN32_WCE) - case 1: - g_logging.type = type; - ret = 0; - break; -#endif - default: - break; - } - - //output the version to the new logging destination - if (!ret) - memtrack_log("Memory Tracker logging initialized, " - "Memory Tracker v."vpx_mem_tracker_version"\n"); - - return ret; -} - -/* - vpx_memory_tracker_set_log_func - Sets a logging function to be used by the memory tracker. - Return: - 0: on success - -1: if the logging type could not be set because logfunc was NULL -*/ -int vpx_memory_tracker_set_log_func(void *userdata, - void(*logfunc)(void *userdata, - const char *fmt, va_list args)) -{ - int ret = -1; - - if (logfunc) - { - g_logging.type = -1; - g_logging.userdata = userdata; - g_logging.func = logfunc; - ret = 0; - } - - //output the version to the new logging destination - if (!ret) - memtrack_log("Memory Tracker logging initialized, " - "Memory Tracker v."vpx_mem_tracker_version"\n"); - - return ret; -} - -/* - * - * END - Exposed library functions - * -*/ - - -/* - * - * Internal library functions - * -*/ - -static void memtrack_log(const char *fmt, ...) -{ - va_list list; - - va_start(list, fmt); - - switch (g_logging.type) - { - case -1: - - if (g_logging.func) - g_logging.func(g_logging.userdata, fmt, list); - - break; - case 0: - - if (g_logging.file) - { - vfprintf(g_logging.file, fmt, list); - fflush(g_logging.file); - } - - break; -#if defined(WIN32) && !defined(_WIN32_WCE) - case 1: - { - char temp[1024]; - _vsnprintf(temp, sizeof(temp) / sizeof(char) - 1, fmt, list); - output_debug_string(temp); - } - break; -#endif - default: - break; - } - - va_end(list); -} - -/* - memory_tracker_dump() - Dumps the current contents of the global memory allocation list -*/ -static void memory_tracker_dump() -{ - int i = 0; - struct mem_block *p = (memtrack.head ? memtrack.head->next : NULL); - - memtrack_log("\n_currently Allocated= %d; Max allocated= %d\n", - memtrack.current_allocated, memtrack.max_allocated); - - while (p) - { -#if defined(WIN32) && !defined(_WIN32_WCE) - - /*when using outputdebugstring, output filenames so they - can be clicked to be opened in visual studio*/ - if (g_logging.type == 1) - memtrack_log("memblocks[%d].addr= 0x%.8x, memblocks[%d].size= %d, file:\n" - " %s(%d):\n", i, - p->addr, i, p->size, - p->file, p->line); - else -#endif - memtrack_log("memblocks[%d].addr= 0x%.8x, memblocks[%d].size= %d, file: %s, line: %d\n", i, - p->addr, i, p->size, - p->file, p->line); - - p = p->next; - ++i; - } - - memtrack_log("\n"); -} - -/* - memory_tracker_check_integrity(char* file, unsigned int file) - file - the file name where the check was placed - line - the line in file where the check was placed - If a padding_size was supplied to vpx_memory_tracker_init() - this function will check ea. addr in the list verifying that - addr-padding_size and addr+padding_size is filled with pad_value -*/ -static void memory_tracker_check_integrity(char *file, unsigned int line) -{ - if (memtrack.padding_size) - { - int i, - index = 0; - unsigned char *p_show_me, - * p_show_me2; - unsigned int tempme = memtrack.pad_value, - dead1, - dead2; - unsigned char *x_bounds; - struct mem_block *p = memtrack.head->next; - - while (p) - { - //x_bounds = (unsigned char*)p->addr; - //back up VPX_BYTE_ALIGNMENT - //x_bounds -= memtrack.padding_size; - - if (p->padded) // can the bounds be checked? - { - /*yes, move to the address that was actually allocated - by the vpx_* calls*/ - x_bounds = (unsigned char *)(((size_t *)p->addr)[-1]); - - for (i = 0; i < memtrack.padding_size; i += sizeof(unsigned int)) - { - p_show_me = (x_bounds + i); - p_show_me2 = (unsigned char *)(p->addr + p->size + i); - - MEM_TRACK_MEMCPY(&dead1, p_show_me, sizeof(unsigned int)); - MEM_TRACK_MEMCPY(&dead2, p_show_me2, sizeof(unsigned int)); - - if ((dead1 != tempme) || (dead2 != tempme)) - { - memtrack_log("\n[vpx_mem integrity check failed]:\n" - " index[%d] {%s:%d} addr=0x%x, size=%d," - " file: %s, line: %d c0:0x%x c1:0x%x\n", - index, file, line, p->addr, p->size, p->file, - p->line, dead1, dead2); - } - } - } - - ++index; - p = p->next; - } - } -} - -/* - memory_tracker_add(size_t addr, unsigned int size, - char * file, unsigned int line) - Adds an address (addr), it's size, file and line number to our list. - Adjusts the total bytes allocated and max bytes allocated if necessary. - If memory cannot be allocated the list will be destroyed. -*/ -void memory_tracker_add(size_t addr, unsigned int size, - char *file, unsigned int line, - int padded) -{ - if (!memory_tracker_lock_mutex()) - { - struct mem_block *p; - - p = MEM_TRACK_MALLOC(sizeof(struct mem_block)); - - if (p) - { - p->prev = memtrack.tail; - p->prev->next = p; - p->addr = addr; - p->size = size; - p->line = line; - p->file = file; - p->padded = padded; - p->next = NULL; - - memtrack.tail = p; - - memtrack.current_allocated += size; - - if (memtrack.current_allocated > memtrack.max_allocated) - memtrack.max_allocated = memtrack.current_allocated; - - //memtrack_log("memory_tracker_add: added addr=0x%.8x\n", addr); - - memory_tracker_unlock_mutex(); - } - else - { - memtrack_log("memory_tracker_add: error allocating memory!\n"); - memory_tracker_unlock_mutex(); - vpx_memory_tracker_destroy(); - } - } -} - -/* - memory_tracker_remove(size_t addr) - Removes an address and its corresponding size (if they exist) - from the memory tracker list and adjusts the current number - of bytes allocated. - Return: - 0: on success - -1: if the mutex could not be locked - -2: if the addr was not found in the list -*/ -int memory_tracker_remove(size_t addr) -{ - int ret = -1; - - if (!memory_tracker_lock_mutex()) - { - struct mem_block *p; - - if (p = memory_tracker_find(addr)) - { - memtrack.current_allocated -= p->size; - - p->prev->next = p->next; - - if (p->next) - p->next->prev = p->prev; - else - memtrack.tail = p->prev; - - ret = 0; - MEM_TRACK_FREE(p); - } - else - { - memtrack_log("memory_tracker_remove(): addr not found in list, 0x%.8x\n", addr); - ret = -2; - } - - memory_tracker_unlock_mutex(); - } - - return ret; -} - -/* - memory_tracker_find(size_t addr) - Finds an address in our addrs list - NOTE: the mutex MUST be locked in the other internal - functions before calling this one. This avoids - the need for repeated locking and unlocking as in Remove - Returns: pointer to the mem block if found, NULL otherwise -*/ -static struct mem_block *memory_tracker_find(size_t addr) -{ - struct mem_block *p = NULL; - - if (memtrack.head) - { - p = memtrack.head->next; - - while (p && (p->addr != addr)) - p = p->next; - } - - return p; -} - - -#if !defined(NO_MUTEX) -/* - memory_tracker_lock_mutex() - Locks the memory tracker mutex with a platform specific call - Returns: - 0: Success - <0: Failure, either the mutex was not initialized - or the call to lock the mutex failed -*/ -static int memory_tracker_lock_mutex() -{ - int ret = -1; - - if (g_b_mem_tracker_inited) - { - -#if defined(LINUX) || defined(__uClinux__) - ret = pthread_mutex_lock(&memtrack.mutex); -#elif defined(WIN32) || defined(_WIN32_WCE) - ret = WaitForSingleObject(memtrack.mutex, INFINITE); -#elif defined(VXWORKS) - ret = sem_take(memtrack.mutex, WAIT_FOREVER); -#elif defined(NDS_NITRO) - os_lock_mutex(&memtrack.mutex); - ret = 0; -#endif - - if (ret) - { - memtrack_log("memory_tracker_lock_mutex: mutex lock failed\n"); - } - } - - return ret; -} - -/* - memory_tracker_unlock_mutex() - Unlocks the memory tracker mutex with a platform specific call - Returns: - 0: Success - <0: Failure, either the mutex was not initialized - or the call to unlock the mutex failed -*/ -static int memory_tracker_unlock_mutex() -{ - int ret = -1; - - if (g_b_mem_tracker_inited) - { - -#if defined(LINUX) || defined(__uClinux__) - ret = pthread_mutex_unlock(&memtrack.mutex); -#elif defined(WIN32) || defined(_WIN32_WCE) - ret = !release_mutex(memtrack.mutex); -#elif defined(VXWORKS) - ret = sem_give(memtrack.mutex); -#elif defined(NDS_NITRO) - os_unlock_mutex(&memtrack.mutex); - ret = 0; -#endif - - if (ret) - { - memtrack_log("memory_tracker_unlock_mutex: mutex unlock failed\n"); - } - } - - return ret; -} -#endif - -/* - vpx_memory_tracker_set_functions - - Sets the function pointers for the standard library functions. - - Return: - 0: on success - -1: if the use global function pointers is not set. -*/ -int vpx_memory_tracker_set_functions(mem_track_malloc_func g_malloc_l - , mem_track_calloc_func g_calloc_l - , mem_track_realloc_func g_realloc_l - , mem_track_free_func g_free_l - , mem_track_memcpy_func g_memcpy_l - , mem_track_memset_func g_memset_l - , mem_track_memmove_func g_memmove_l) -{ -#if USE_GLOBAL_FUNCTION_POINTERS - - if (g_malloc_l) - g_malloc = g_malloc_l; - - if (g_calloc_l) - g_calloc = g_calloc_l; - - if (g_realloc_l) - g_realloc = g_realloc_l; - - if (g_free_l) - g_free = g_free_l; - - if (g_memcpy_l) - g_memcpy = g_memcpy_l; - - if (g_memset_l) - g_memset = g_memset_l; - - if (g_memmove_l) - g_memmove = g_memmove_l; - - return 0; -#else - (void)g_malloc_l; - (void)g_calloc_l; - (void)g_realloc_l; - (void)g_free_l; - (void)g_memcpy_l; - (void)g_memset_l; - (void)g_memmove_l; - return -1; -#endif -} diff --git a/vpx_mem/nds/vpx_mem_nds.c b/vpx_mem/nds/vpx_mem_nds.c deleted file mode 100644 index 11ac95cba..000000000 --- a/vpx_mem/nds/vpx_mem_nds.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2010 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -#define __VPX_MEM_C__ -#include "vpx_mem.h" -#include <nitro.h> -#include "vpx_mem_intrnl.h" - -// Allocate memory from the Arena specified by id. Align it to -// the value specified by align. -void *vpx_mem_nds_alloc(osarena_id id, osheap_handle handle, size_t size, size_t align) -{ - void *addr, - * x = NULL; - - addr = os_alloc_from_heap((osarena_id) id, handle, - size + align - 1 + ADDRESS_STORAGE_SIZE); - - if (addr) - { - x = align_addr((unsigned char *)addr + ADDRESS_STORAGE_SIZE, (int)align); - - // save the actual malloc address - ((size_t *)x)[-1] = (size_t)addr; - } - - return x; -} - -// Free them memory allocated by vpx_mem_nds_alloc -void vpx_mem_nds_free(osarena_id id, osheap_handle handle, void *mem) -{ - if (mem) - { - void *addr = (void *)(((size_t *)mem)[-1]); - os_free_to_heap(id, handle, addr); - } -} - -int vpx_nds_alloc_heap(osarena_id id, u32 size) -{ - osheap_handle arena_handle; - void *nstart; - void *heap_start; - - nstart = os_init_alloc(id, os_get_arena_lo(id), os_get_arena_hi(id), 1); - os_set_arena_lo(id, nstart); - - heap_start = os_alloc_from_arena_lo(id, size, 32); - arena_handle = os_create_heap(id, heap_start, (void *)((u32)heap_start + size)); - - if (os_check_heap(id, arena_handle) == -1) - return -1; //ERROR: DTCM heap is not consistent - - (void)os_set_current_heap(id, arena_handle); - - return arena_handle; -} diff --git a/vpx_mem/ti_c6x/vpx_mem_ti_6cx.c b/vpx_mem/ti_c6x/vpx_mem_ti_6cx.c deleted file mode 100644 index d55b7d92c..000000000 --- a/vpx_mem/ti_c6x/vpx_mem_ti_6cx.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2010 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -#define __VPX_MEM_C__ - -#include "..\include\vpx_mem.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include "..\include\vpx_mem_intrnl.h" - -void *vpx_mem_alloc(int id, size_t size, size_t align) -{ -#if defined CHIP_DM642 || defined __uClinux__ - void *mem = (void *)mem_alloc(id, size, align); - - if (!mem) - { - _P(fprintf(stderr, - "\n" - "*********************************************************\n" - "WARNING: mem_alloc returned 0 for id=%p size=%u align=%u.\n" - "*********************************************************\n", - mem, size, align)); - // should no longer need this. Softier says it's fixed. 2005-01-21 tjf - //#if defined __uClinux__ - //while(1)usleep(1000000); - //#endif - } - -#if defined __uClinux__ - else if (mem == (void *)0xFFFFFFFF) - { - // out of memory/error - mem = (void *)0; - - _P(fprintf(stderr, - "\n" - "******************************************************\n" - "ERROR: mem_alloc id=%p size=%u align=%u OUT OF MEMORY.\n" - "******************************************************\n", - mem, size, align)); - } - -#endif // __uClinux__ - - return mem; -#else - (void)id; - (void)size; - (void)align; - return (void *)0; -#endif -} - -void vpx_mem_free(int id, void *mem, size_t size) -{ -#if defined CHIP_DM642 || defined __uClinux__ - - if (!mem) - { - _P(fprintf(stderr, - "\n" - "**************************************\n" - "WARNING: 0 being free'd id=%p size=%u.\n" - "**************************************\n", - id, size)); - - // should no longer need this. Softier says it's fixed. 2005-01-21 tjf - //#if defined __uClinux__ - //while(1)usleep(1000000); - //#endif - } - - mem_free(id, mem, size); -#else - (void)id; - (void)mem; - (void)size; -#endif -} - -#if CONFIG_MEM_TRACKER -void *xvpx_mem_alloc(int id, size_t size, size_t align, char *file, int line) -{ - void *mem = vpx_mem_alloc(id, size, align); - - vpx_memory_tracker_add((size_t)mem, size, file, line, 0); - - return mem; -} - -void xvpx_mem_free(int id, void *mem, size_t size, char *file, int line) -{ - if (vpx_memory_tracker_remove((size_t)mem) == -2) - { -#if REMOVE_PRINTFS - (void)file; - (void)line; -#endif - _P(fprintf(stderr, "[vpx_mem][xvpx_mem_free] addr: %p (id=%p size=%u) " - "not found in list; freed from file:%s" - " line:%d\n", mem, id, size, file, line)); - } - - vpx_mem_free(id, mem, size); -} -#endif /*CONFIG_MEM_TRACKER*/ |