Index: libvpx/source/libvpx/vpx_mem/vpx_mem_tracker.c |
diff --git a/libvpx/source/libvpx/vpx_mem/vpx_mem_tracker.c b/libvpx/source/libvpx/vpx_mem/vpx_mem_tracker.c |
index 9e8623a9a30d2363eb0cd386e2fe778a62c4910e..938ad0716cdc3250e45e384dab67c3ab7747dbae 100644 |
--- a/libvpx/source/libvpx/vpx_mem/vpx_mem_tracker.c |
+++ b/libvpx/source/libvpx/vpx_mem/vpx_mem_tracker.c |
@@ -36,6 +36,9 @@ |
# 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> |
@@ -109,6 +112,8 @@ struct memory_tracker |
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!" |
@@ -188,6 +193,9 @@ int vpx_memory_tracker_init(int padding_size, int pad_value) |
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 |
@@ -243,7 +251,9 @@ void vpx_memory_tracker_destroy() |
if (!g_logging.type && g_logging.file && g_logging.file != stderr) |
{ |
+#if !defined(NDS_NITRO) |
fclose(g_logging.file); |
+#endif |
g_logging.file = NULL; |
} |
@@ -358,12 +368,15 @@ int vpx_memory_tracker_set_log_type(int type, char *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: |
@@ -493,6 +506,12 @@ static void memory_tracker_dump() |
p->addr, i, p->size, |
p->file, p->line); |
+#ifdef NDS_NITRO |
+ |
+ if (!(i % 20)) os_sleep(500); |
+ |
+#endif |
+ |
p = p->next; |
++i; |
} |
@@ -700,6 +719,9 @@ static int memory_tracker_lock_mutex() |
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) |
@@ -732,6 +754,9 @@ static int memory_tracker_unlock_mutex() |
ret = !ReleaseMutex(memtrack.mutex); |
#elif defined(VXWORKS) |
ret = sem_give(memtrack.mutex); |
+#elif defined(NDS_NITRO) |
+ os_unlock_mutex(&memtrack.mutex); |
+ ret = 0; |
#endif |
if (ret) |