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

Kanna Shimizu kannas at us.ibm.com
Thu Jun 28 16:20:42 EST 2007


libspe2: pass npc by value to callback handler

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>
Signed-off-by: Kanna Shimizu <kannas at us.ibm.com>

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
@@ -250,7 +250,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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/cbe-oss-dev/attachments/20070628/23981840/attachment.htm>


More information about the cbe-oss-dev mailing list