Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: source/libvpx/vpx_mem/vpx_mem_tracker.c

Issue 7671004: Update libvpx snapshot to v0.9.7-p1 (Cayuga). (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libvpx/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vpx_mem/include/nds/vpx_mem_nds.h ('k') | source/libvpx/vpx_ports/asm_offsets.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 18 matching lines...) Expand all
29 #endif 29 #endif
30 30
31 #if HAVE_PTHREAD_H 31 #if HAVE_PTHREAD_H
32 # include <pthread.h> 32 # include <pthread.h>
33 #elif defined(WIN32) || defined(_WIN32_WCE) 33 #elif defined(WIN32) || defined(_WIN32_WCE)
34 # define WIN32_LEAN_AND_MEAN 34 # define WIN32_LEAN_AND_MEAN
35 # include <windows.h> 35 # include <windows.h>
36 # include <winbase.h> 36 # include <winbase.h>
37 #elif defined(VXWORKS) 37 #elif defined(VXWORKS)
38 # include <sem_lib.h> 38 # include <sem_lib.h>
39 #elif defined(NDS_NITRO)
40 # include <nitro.h>
41 # include <nitro/os.h>
42 #endif 39 #endif
43 40
44 #include <stdio.h> 41 #include <stdio.h>
45 #include <stdlib.h> 42 #include <stdlib.h>
46 #include <string.h> //VXWORKS doesn't have a malloc/memory.h file, 43 #include <string.h> //VXWORKS doesn't have a malloc/memory.h file,
47 //this should pull in malloc,free,etc. 44 //this should pull in malloc,free,etc.
48 #include <stdarg.h> 45 #include <stdarg.h>
49 46
50 #include "include/vpx_mem_tracker.h" 47 #include "include/vpx_mem_tracker.h"
51 48
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 totalsize; 102 totalsize;
106 unsigned int current_allocated, 103 unsigned int current_allocated,
107 max_allocated; 104 max_allocated;
108 105
109 #if HAVE_PTHREAD_H 106 #if HAVE_PTHREAD_H
110 pthread_mutex_t mutex; 107 pthread_mutex_t mutex;
111 #elif defined(WIN32) || defined(_WIN32_WCE) 108 #elif defined(WIN32) || defined(_WIN32_WCE)
112 HANDLE mutex; 109 HANDLE mutex;
113 #elif defined(VXWORKS) 110 #elif defined(VXWORKS)
114 SEM_ID mutex; 111 SEM_ID mutex;
115 #elif defined(NDS_NITRO)
116 OSMutex mutex;
117 #elif defined(NO_MUTEX) 112 #elif defined(NO_MUTEX)
118 #else 113 #else
119 #error "No mutex type defined for this platform!" 114 #error "No mutex type defined for this platform!"
120 #endif 115 #endif
121 116
122 int padding_size, 117 int padding_size,
123 pad_value; 118 pad_value;
124 }; 119 };
125 120
126 static struct memory_tracker memtrack; //our global memory allocation list 121 static struct memory_tracker memtrack; //our global memory allocation list
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 NULL); /*mutex attributes (NULL= default)*/ 181 NULL); /*mutex attributes (NULL= default)*/
187 #elif defined(WIN32) || defined(_WIN32_WCE) 182 #elif defined(WIN32) || defined(_WIN32_WCE)
188 memtrack.mutex = CreateMutex(NULL, /*security attributes*/ 183 memtrack.mutex = CreateMutex(NULL, /*security attributes*/
189 FALSE, /*we don't want initial owners hip*/ 184 FALSE, /*we don't want initial owners hip*/
190 NULL); /*mutex name*/ 185 NULL); /*mutex name*/
191 ret = !memtrack.mutex; 186 ret = !memtrack.mutex;
192 #elif defined(VXWORKS) 187 #elif defined(VXWORKS)
193 memtrack.mutex = sem_bcreate(SEM_Q_FIFO, /*SEM_Q_FIFO non-priority b ased mutex*/ 188 memtrack.mutex = sem_bcreate(SEM_Q_FIFO, /*SEM_Q_FIFO non-priority b ased mutex*/
194 SEM_FULL); /*SEM_FULL initial state is unlocked*/ 189 SEM_FULL); /*SEM_FULL initial state is unlocked*/
195 ret = !memtrack.mutex; 190 ret = !memtrack.mutex;
196 #elif defined(NDS_NITRO)
197 os_init_mutex(&memtrack.mutex);
198 ret = 0;
199 #elif defined(NO_MUTEX) 191 #elif defined(NO_MUTEX)
200 ret = 0; 192 ret = 0;
201 #endif 193 #endif
202 194
203 if (ret) 195 if (ret)
204 { 196 {
205 memtrack_log("vpx_memory_tracker_init: Error creating mutex!\n") ; 197 memtrack_log("vpx_memory_tracker_init: Error creating mutex!\n") ;
206 198
207 MEM_TRACK_FREE(memtrack.head); 199 MEM_TRACK_FREE(memtrack.head);
208 memtrack.head = NULL; 200 memtrack.head = NULL;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 } 236 }
245 237
246 memtrack.head = NULL; 238 memtrack.head = NULL;
247 memtrack.tail = NULL; 239 memtrack.tail = NULL;
248 memtrack.len = 0; 240 memtrack.len = 0;
249 memtrack.current_allocated = 0; 241 memtrack.current_allocated = 0;
250 memtrack.max_allocated = 0; 242 memtrack.max_allocated = 0;
251 243
252 if (!g_logging.type && g_logging.file && g_logging.file != stderr) 244 if (!g_logging.type && g_logging.file && g_logging.file != stderr)
253 { 245 {
254 #if !defined(NDS_NITRO)
255 fclose(g_logging.file); 246 fclose(g_logging.file);
256 #endif
257 g_logging.file = NULL; 247 g_logging.file = NULL;
258 } 248 }
259 249
260 memory_tracker_unlock_mutex(); 250 memory_tracker_unlock_mutex();
261 251
262 g_b_mem_tracker_inited = 0; 252 g_b_mem_tracker_inited = 0;
263 } 253 }
264 } 254 }
265 255
266 /* 256 /*
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 switch (type) 351 switch (type)
362 { 352 {
363 case 0: 353 case 0:
364 g_logging.type = 0; 354 g_logging.type = 0;
365 355
366 if (!option) 356 if (!option)
367 { 357 {
368 g_logging.file = stderr; 358 g_logging.file = stderr;
369 ret = 0; 359 ret = 0;
370 } 360 }
371
372 #if !defined(NDS_NITRO)
373 else 361 else
374 { 362 {
375 if ((g_logging.file = fopen((char *)option, "w"))) 363 if ((g_logging.file = fopen((char *)option, "w")))
376 ret = 0; 364 ret = 0;
377 } 365 }
378 366
379 #endif
380 break; 367 break;
381 #if defined(WIN32) && !defined(_WIN32_WCE) 368 #if defined(WIN32) && !defined(_WIN32_WCE)
382 case 1: 369 case 1:
383 g_logging.type = type; 370 g_logging.type = type;
384 ret = 0; 371 ret = 0;
385 break; 372 break;
386 #endif 373 #endif
387 default: 374 default:
388 break; 375 break;
389 } 376 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 memtrack_log("memblocks[%d].addr= 0x%.8x, memblocks[%d].size= %d, fi le:\n" 486 memtrack_log("memblocks[%d].addr= 0x%.8x, memblocks[%d].size= %d, fi le:\n"
500 " %s(%d):\n", i, 487 " %s(%d):\n", i,
501 p->addr, i, p->size, 488 p->addr, i, p->size,
502 p->file, p->line); 489 p->file, p->line);
503 else 490 else
504 #endif 491 #endif
505 memtrack_log("memblocks[%d].addr= 0x%.8x, memblocks[%d].size= %d, fi le: %s, line: %d\n", i, 492 memtrack_log("memblocks[%d].addr= 0x%.8x, memblocks[%d].size= %d, fi le: %s, line: %d\n", i,
506 p->addr, i, p->size, 493 p->addr, i, p->size,
507 p->file, p->line); 494 p->file, p->line);
508 495
509 #ifdef NDS_NITRO
510
511 if (!(i % 20)) os_sleep(500);
512
513 #endif
514
515 p = p->next; 496 p = p->next;
516 ++i; 497 ++i;
517 } 498 }
518 499
519 memtrack_log("\n"); 500 memtrack_log("\n");
520 } 501 }
521 502
522 /* 503 /*
523 memory_tracker_check_integrity(char* file, unsigned int file) 504 memory_tracker_check_integrity(char* file, unsigned int file)
524 file - the file name where the check was placed 505 file - the file name where the check was placed
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 693
713 if (g_b_mem_tracker_inited) 694 if (g_b_mem_tracker_inited)
714 { 695 {
715 696
716 #if HAVE_PTHREAD_H 697 #if HAVE_PTHREAD_H
717 ret = pthread_mutex_lock(&memtrack.mutex); 698 ret = pthread_mutex_lock(&memtrack.mutex);
718 #elif defined(WIN32) || defined(_WIN32_WCE) 699 #elif defined(WIN32) || defined(_WIN32_WCE)
719 ret = WaitForSingleObject(memtrack.mutex, INFINITE); 700 ret = WaitForSingleObject(memtrack.mutex, INFINITE);
720 #elif defined(VXWORKS) 701 #elif defined(VXWORKS)
721 ret = sem_take(memtrack.mutex, WAIT_FOREVER); 702 ret = sem_take(memtrack.mutex, WAIT_FOREVER);
722 #elif defined(NDS_NITRO)
723 os_lock_mutex(&memtrack.mutex);
724 ret = 0;
725 #endif 703 #endif
726 704
727 if (ret) 705 if (ret)
728 { 706 {
729 memtrack_log("memory_tracker_lock_mutex: mutex lock failed\n"); 707 memtrack_log("memory_tracker_lock_mutex: mutex lock failed\n");
730 } 708 }
731 } 709 }
732 710
733 return ret; 711 return ret;
734 } 712 }
(...skipping 12 matching lines...) Expand all
747 725
748 if (g_b_mem_tracker_inited) 726 if (g_b_mem_tracker_inited)
749 { 727 {
750 728
751 #if HAVE_PTHREAD_H 729 #if HAVE_PTHREAD_H
752 ret = pthread_mutex_unlock(&memtrack.mutex); 730 ret = pthread_mutex_unlock(&memtrack.mutex);
753 #elif defined(WIN32) || defined(_WIN32_WCE) 731 #elif defined(WIN32) || defined(_WIN32_WCE)
754 ret = !ReleaseMutex(memtrack.mutex); 732 ret = !ReleaseMutex(memtrack.mutex);
755 #elif defined(VXWORKS) 733 #elif defined(VXWORKS)
756 ret = sem_give(memtrack.mutex); 734 ret = sem_give(memtrack.mutex);
757 #elif defined(NDS_NITRO)
758 os_unlock_mutex(&memtrack.mutex);
759 ret = 0;
760 #endif 735 #endif
761 736
762 if (ret) 737 if (ret)
763 { 738 {
764 memtrack_log("memory_tracker_unlock_mutex: mutex unlock failed\n"); 739 memtrack_log("memory_tracker_unlock_mutex: mutex unlock failed\n");
765 } 740 }
766 } 741 }
767 742
768 return ret; 743 return ret;
769 } 744 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 (void)g_malloc_l; 789 (void)g_malloc_l;
815 (void)g_calloc_l; 790 (void)g_calloc_l;
816 (void)g_realloc_l; 791 (void)g_realloc_l;
817 (void)g_free_l; 792 (void)g_free_l;
818 (void)g_memcpy_l; 793 (void)g_memcpy_l;
819 (void)g_memset_l; 794 (void)g_memset_l;
820 (void)g_memmove_l; 795 (void)g_memmove_l;
821 return -1; 796 return -1;
822 #endif 797 #endif
823 } 798 }
OLDNEW
« no previous file with comments | « source/libvpx/vpx_mem/include/nds/vpx_mem_nds.h ('k') | source/libvpx/vpx_ports/asm_offsets.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698