[Cbe-oss-dev] [PATCH 1/2] libspe2: pass npc by value to callback handler

Jeremy Kerr jk at ozlabs.org
Wed May 30 21:01:15 EST 2007


The SPE npc value isn't updated by the callback code, so we don't need
to pass a pointer to it to handle_library_callback.

Signed-off-by: Jeremy Kerr <jk at ozlabs.org>

 spebase/lib_builtin.c |    5 +++--
 spebase/lib_builtin.h |    3 ++-
 spebase/run.c         |    2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

Index: libspe2/spebase/lib_builtin.c
===================================================================
--- libspe2.orig/spebase/lib_builtin.c
+++ libspe2/spebase/lib_builtin.c
@@ -135,7 +135,8 @@ int _base_spe_callback_handler_update(vo
 	return 0;
 }
 
-int handle_library_callback(struct spe_context * spe, int callnum, unsigned int * npc)
+int handle_library_callback(struct spe_context *spe, int callnum,
+		unsigned int npc)
 {
 	int (*handler)(void *, unsigned int);
 	int rc;
@@ -149,7 +150,7 @@ int handle_library_callback(struct spe_c
 
 	handler=handlers[callnum];
 	
-	rc = handler(spe->base_private->mem_mmap_base, *npc);
+	rc = handler(spe->base_private->mem_mmap_base, npc);
 	if (rc) {
 		DEBUG_PRINTF ("SPE library call unsupported.\n");
 		errno=ENOSYS;
Index: libspe2/spebase/lib_builtin.h
===================================================================
--- libspe2.orig/spebase/lib_builtin.h
+++ libspe2/spebase/lib_builtin.h
@@ -25,6 +25,7 @@
 #define MAX_CALLNUM 255
 #define RESERVED    4
 
-extern int handle_library_callback(struct spe_context * spe, int callnum, unsigned int * npc);
+extern int handle_library_callback(struct spe_context *spe, int callnum,
+		unsigned int npc);
 
 #endif
Index: libspe2/spebase/run.c
===================================================================
--- libspe2.orig/spebase/run.c
+++ libspe2/spebase/run.c
@@ -190,7 +190,7 @@ do_run:
 			/* execute library callback */
 			DEBUG_PRINTF("SPE library call: %d\n", callback_number);
 			callback_rc = handle_library_callback(spe,
-					callback_number, entry);
+					callback_number, *entry);
 
 			if (callback_rc) {
 				/* library callback failed; set errno and



More information about the cbe-oss-dev mailing list