[Cbe-oss-dev] [patch 4/4 v2] MARS: Use generic assert

Geoff Levand geoffrey.levand at am.sony.com
Mon Sep 1 08:03:18 EST 2008


Replace the MARS_ASSERT() macro with the standard C assert().

Fixes these build warnings:
mars_kernel_task.c: In function 'task_stop':
mars_kernel_task.c:65: warning: unused parameter 'task'

Signed-off-by: Geoff Levand <geoffrey.levand at am.sony.com>
---

V2:
 o Rebase to series.

 include/common/mars/mars_debug.h  |   18 +++---------
 include/host/mars/mars_atomic.h   |    4 +-
 include/mpu/mars/mars_atomic.h    |    8 ++---
 include/mpu/mars/mars_dma.h       |   54 +++++++++++++++++++-------------------
 src/host/lib/mars.c               |    6 ++--
 src/mpu/kernel/mars_kernel_task.c |   19 +++++++------
 6 files changed, 51 insertions(+), 58 deletions(-)

--- a/include/common/mars/mars_debug.h
+++ b/include/common/mars/mars_debug.h
@@ -42,6 +42,7 @@
  * \brief MARS Debug Macros
  */
 
+#include <assert.h>
 #include <stdio.h>
 
 #define MARS_DEBUG_ENABLE_PRINT		0
@@ -119,26 +120,18 @@
 	__BREAKPOINT__;\
 }
 
-#define MARS_ASSERT(exp) {\
-	if(!(exp)) {\
-		__PRINT__("%s(line %d):%s() - ASSERT("#exp") FAILED\n",\
-			__FILE__, __LINE__, __PRETTY_FUNCTION__);\
-		__BREAKPOINT__;\
-	}\
-}
-
 #define MARS_CHECK(exp) {\
-	MARS_ASSERT(exp);\
+	assert(exp);\
 	if(!(exp)) return;\
 }
 
 #define MARS_CHECK_RET(exp, ret) {\
-	MARS_ASSERT(exp);\
+	assert(exp);\
 	if(!(exp)) return ret;\
 }
 
 #define MARS_CHECK_CLEANUP(exp, clean) {\
-	MARS_ASSERT(exp);\
+	assert(exp);\
 	if(!(exp)) {\
 		clean;\
 		return;\
@@ -146,7 +139,7 @@
 }
 
 #define MARS_CHECK_CLEANUP_RET(exp, clean, ret) {\
-	MARS_ASSERT(exp);\
+	assert(exp);\
 	if(!(exp)) {\
 		clean;\
 		return ret;\
@@ -155,7 +148,6 @@
 
 #else
 #define MARS_BREAK()
-#define MARS_ASSERT(exp)
 #define MARS_CHECK(exp)				{if(!(exp))return;}
 #define MARS_CHECK_RET(exp, ret)		{if(!(exp))return ret;}
 #define MARS_CHECK_CLEANUP(exp, clean)		{if(!(exp)){clean;return;}}
--- a/include/host/mars/mars_atomic.h
+++ b/include/host/mars/mars_atomic.h
@@ -49,14 +49,14 @@ extern "C" {
 
 static inline int atomic_get(void *addr)
 {
-	MARS_ASSERT(((uintptr_t)addr & MARS_ATOMIC_ALIGNMENT_MASK) == 0);
+	assert(((uintptr_t)addr & MARS_ATOMIC_ALIGNMENT_MASK) == 0);
 
 	return __lwarx(addr);
 }
 
 static inline int atomic_put(void *addr, uint32_t val)
 {
-	MARS_ASSERT(((uintptr_t)addr & MARS_ATOMIC_ALIGNMENT_MASK) == 0);
+	assert(((uintptr_t)addr & MARS_ATOMIC_ALIGNMENT_MASK) == 0);
 
 	__lwsync();
 	return __stwcx(addr, val);
--- a/include/mpu/mars/mars_atomic.h
+++ b/include/mpu/mars/mars_atomic.h
@@ -75,8 +75,8 @@ static inline void atomic_event_wait(voi
 
 static inline void atomic_get(void *ls, uint64_t ea)
 {
-	MARS_ASSERT(((uintptr_t)ls & MARS_ATOMIC_ALIGNMENT_MASK) == 0);
-	MARS_ASSERT((ea & MARS_ATOMIC_ALIGNMENT_MASK) == 0);
+	assert(((uintptr_t)ls & MARS_ATOMIC_ALIGNMENT_MASK) == 0);
+	assert((ea & MARS_ATOMIC_ALIGNMENT_MASK) == 0);
 
 	mfc_getllar(ls, ea, 0, 0);
 	mfc_read_atomic_status();
@@ -84,8 +84,8 @@ static inline void atomic_get(void *ls, 
 
 static inline int atomic_put(void *ls, uint64_t ea)
 {
-	MARS_ASSERT(((uintptr_t)ls & MARS_ATOMIC_ALIGNMENT_MASK) == 0);
-	MARS_ASSERT((ea & MARS_ATOMIC_ALIGNMENT_MASK) == 0);
+	assert(((uintptr_t)ls & MARS_ATOMIC_ALIGNMENT_MASK) == 0);
+	assert((ea & MARS_ATOMIC_ALIGNMENT_MASK) == 0);
 
 	spu_dsync();
 	mfc_putllc(ls, ea, 0, 0);
--- a/include/mpu/mars/mars_dma.h
+++ b/include/mpu/mars/mars_dma.h
@@ -115,7 +115,7 @@ static inline void mars_dma_wait(uint32_
 	MARS_PRINTF("tag=%d\n", tag);
 #endif
 #if MARS_DEBUG_ENABLE_DMA_ASSERTS
-	MARS_ASSERT(tag <= MARS_DMA_TAG_MAX);
+	assert(tag <= MARS_DMA_TAG_MAX);
 #endif
 	mfc_write_tag_mask(1 << tag);
 	mfc_write_tag_update_all();
@@ -151,11 +151,11 @@ static inline void mars_dma_get(void *ls
 	MARS_PRINTF("ls=%p ea=%#llx size=%d tag=%d\n", ls, ea, size, tag);
 #endif
 #if MARS_DEBUG_ENABLE_DMA_ASSERTS
-	MARS_ASSERT(((uintptr_t)ls & MARS_DMA_ALIGN_MASK) == 0);
-	MARS_ASSERT(((uintptr_t)ea & MARS_DMA_ALIGN_MASK) == 0);
-	MARS_ASSERT((size & MARS_DMA_SIZE_MASK) == 0);
-	MARS_ASSERT(size && size <= MARS_DMA_SIZE_MAX);
-	MARS_ASSERT(tag <= MARS_DMA_TAG_MAX);
+	assert(((uintptr_t)ls & MARS_DMA_ALIGN_MASK) == 0);
+	assert(((uintptr_t)ea & MARS_DMA_ALIGN_MASK) == 0);
+	assert((size & MARS_DMA_SIZE_MASK) == 0);
+	assert(size && size <= MARS_DMA_SIZE_MAX);
+	assert(tag <= MARS_DMA_TAG_MAX);
 #endif
 	mfc_get((volatile void *)ls, ea, size, tag, 0, 0);
 }
@@ -210,11 +210,11 @@ static inline void mars_dma_put(const vo
 	MARS_PRINTF("ls=%p ea=%#llx size=%d tag=%d\n", ls, ea, size, tag);
 #endif
 #if MARS_DEBUG_ENABLE_DMA_ASSERTS
-	MARS_ASSERT(((uintptr_t)ls & MARS_DMA_ALIGN_MASK) == 0);
-	MARS_ASSERT(((uintptr_t)ea & MARS_DMA_ALIGN_MASK) == 0);
-	MARS_ASSERT((size & MARS_DMA_SIZE_MASK) == 0);
-	MARS_ASSERT(size && size <= MARS_DMA_SIZE_MAX);
-	MARS_ASSERT(tag <= MARS_DMA_TAG_MAX);
+	assert(((uintptr_t)ls & MARS_DMA_ALIGN_MASK) == 0);
+	assert(((uintptr_t)ea & MARS_DMA_ALIGN_MASK) == 0);
+	assert((size & MARS_DMA_SIZE_MASK) == 0);
+	assert(size && size <= MARS_DMA_SIZE_MAX);
+	assert(tag <= MARS_DMA_TAG_MAX);
 #endif
 	spu_dsync();
 	mfc_put((volatile void *)ls, ea, size, tag, 0, 0);
@@ -269,10 +269,10 @@ static inline void mars_dma_small_get(vo
 	MARS_PRINTF("ls=%p ea=%#llx size=%d tag=%d\n", ls, ea, size, tag);
 #endif
 #if MARS_DEBUG_ENABLE_DMA_ASSERTS
-	MARS_ASSERT(((uintptr_t)ls & MARS_DMA_ALIGN_MASK) == 0);
-	MARS_ASSERT(((uintptr_t)ea & MARS_DMA_ALIGN_MASK) == 0);
-	MARS_ASSERT(size == 1 || size == 2 || size == 4 || size == 8);
-	MARS_ASSERT(tag <= MARS_DMA_TAG_MAX);
+	assert(((uintptr_t)ls & MARS_DMA_ALIGN_MASK) == 0);
+	assert(((uintptr_t)ea & MARS_DMA_ALIGN_MASK) == 0);
+	assert(size == 1 || size == 2 || size == 4 || size == 8);
+	assert(tag <= MARS_DMA_TAG_MAX);
 #endif
 	mfc_get(ls, ea, size, tag, 0, 0);
 }
@@ -326,10 +326,10 @@ static inline void mars_dma_small_put(co
 	MARS_PRINTF("ls=%p ea=%#llx size=%d tag=%d\n", ls, ea, size, tag);
 #endif
 #if MARS_DEBUG_ENABLE_DMA_ASSERTS
-	MARS_ASSERT(((uintptr_t)ls & MARS_DMA_ALIGN_MASK) == 0);
-	MARS_ASSERT(((uintptr_t)ea & MARS_DMA_ALIGN_MASK) == 0);
-	MARS_ASSERT(size == 1 || size == 2 || size == 4 || size == 8);
-	MARS_ASSERT(tag <= MARS_DMA_TAG_MAX);
+	assert(((uintptr_t)ls & MARS_DMA_ALIGN_MASK) == 0);
+	assert(((uintptr_t)ea & MARS_DMA_ALIGN_MASK) == 0);
+	assert(size == 1 || size == 2 || size == 4 || size == 8);
+	assert(tag <= MARS_DMA_TAG_MAX);
 #endif
 	spu_dsync();
 	mfc_put((volatile void *)ls, ea, size, tag, 0, 0);
@@ -385,10 +385,10 @@ static inline void mars_dma_large_get(vo
 	MARS_PRINTF("ls=%p ea=%#llx size=%d tag=%d\n", ls, ea, size, tag);
 #endif
 #if MARS_DEBUG_ENABLE_DMA_ASSERTS
-	MARS_ASSERT(((uintptr_t)ls & MARS_DMA_ALIGN_MASK) == 0);
-	MARS_ASSERT(((uintptr_t)ea & MARS_DMA_ALIGN_MASK) == 0);
-	MARS_ASSERT(size);
-	MARS_ASSERT(tag <= MARS_DMA_TAG_MAX);
+	assert(((uintptr_t)ls & MARS_DMA_ALIGN_MASK) == 0);
+	assert(((uintptr_t)ea & MARS_DMA_ALIGN_MASK) == 0);
+	assert(size);
+	assert(tag <= MARS_DMA_TAG_MAX);
 #endif
 	_mars_dma_large_get(ls, ea, size, tag);
 }
@@ -443,10 +443,10 @@ static inline void mars_dma_large_put(co
 	MARS_PRINTF("ls=%p ea=%#llx size=%d tag=%d\n", ls, ea, size, tag);
 #endif
 #if MARS_DEBUG_ENABLE_DMA_ASSERTS
-	MARS_ASSERT(((uintptr_t)ls & MARS_DMA_ALIGN_MASK) == 0);
-	MARS_ASSERT(((uintptr_t)ea & MARS_DMA_ALIGN_MASK) == 0);
-	MARS_ASSERT(size);
-	MARS_ASSERT(tag <= MARS_DMA_TAG_MAX);
+	assert(((uintptr_t)ls & MARS_DMA_ALIGN_MASK) == 0);
+	assert(((uintptr_t)ea & MARS_DMA_ALIGN_MASK) == 0);
+	assert(size);
+	assert(tag <= MARS_DMA_TAG_MAX);
 #endif
 	_mars_dma_large_put(ls, ea, size, tag);
 }
--- a/src/host/lib/mars.c
+++ b/src/host/lib/mars.c
@@ -55,7 +55,7 @@ static unsigned int num_mpus_max(void)
 
 static void *mpu_context_thread(void *arg)
 {
-	MARS_ASSERT(arg);
+	assert(arg);
 
 	int ret;
 	unsigned int entry = SPE_DEFAULT_ENTRY;
@@ -79,7 +79,7 @@ static void *mpu_context_thread(void *ar
 
 static int create_mpu_contexts(struct mars_context *mars, int num_mpu_contexts)
 {
-	MARS_ASSERT(mars);
+	assert(mars);
 
 	int ret;
 	int i;
@@ -105,7 +105,7 @@ static int create_mpu_contexts(struct ma
 
 static int destroy_mpu_contexts(struct mars_context *mars)
 {
-	MARS_ASSERT(mars);
+	assert(mars);
 
 	int ret;
 	void *p_ret;
--- a/src/mpu/kernel/mars_kernel_task.c
+++ b/src/mpu/kernel/mars_kernel_task.c
@@ -35,6 +35,7 @@
  * LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
  */
 
+#include <assert.h>
 #include <string.h>
 #include "mars/mars_kernel.h"
 
@@ -42,7 +43,7 @@ extern void *process_stack;
 
 void task_run(struct mars_task_context *task)
 {
-	MARS_ASSERT(task);
+	assert(task);
 
 	if (!task->stack) {
 		/* dma the exec code into mpu storage from host storage */
@@ -64,14 +65,14 @@ void task_run(struct mars_task_context *
 
 void task_stop(struct mars_task_context *task)
 {
-	MARS_ASSERT(task);
+	assert(task);
 }
 
 void task_save(struct mars_task_context *task)
 {
-	MARS_ASSERT(task);
-	MARS_ASSERT(task->context_save_area);
-	MARS_ASSERT(task->context_save_size);
+	assert(task);
+	assert(task->context_save_area);
+	assert(task->context_save_size);
 
 	/* save process stack pointer */
 	task->stack = (uint32_t)process_stack;
@@ -85,9 +86,9 @@ void task_save(struct mars_task_context 
 
 void task_restore(struct mars_task_context *task)
 {
-	MARS_ASSERT(task);
-	MARS_ASSERT(task->context_save_area);
-	MARS_ASSERT(task->context_save_size);
+	assert(task);
+	assert(task->context_save_area);
+	assert(task->context_save_size);
 
 	/* restore process stack pointer */
 	process_stack = (void *)task->stack;
@@ -101,7 +102,7 @@ void task_restore(struct mars_task_conte
 
 void task_schedule(struct mars_task_context *task, struct mars_task_args *args)
 {
-	MARS_ASSERT(task);
+	assert(task);
 
 	/* initialize task specific context variables */
 	task->stack = 0;






More information about the cbe-oss-dev mailing list