[Cbe-oss-dev] [PATCH] Fix the definition of the PPE-assisted callback handler array

Jeremy Kerr jk at ozlabs.org
Thu Jul 26 10:22:57 EST 2007


Each entry of the callback handler array is defined explicitly, which
makes it hard to properly place new definitions. This change uses the
c99 array initialisation syntax, to make things much clearer.

Because I have no way of testing anything but c99 callbacks (which have
the first entry in the array, so makes a bad testcase), we can check
the relocation table to inspect this array. My build puts the handers
array at 0x0002571c, and here are the appropriate relocation table
entries:

$ objdump -R libspe2.so.2.2.0  | grep _base_spe_default
0002571c R_PPC_ADDR32      _base_spe_default_c99_handler
00025720 R_PPC_ADDR32      _base_spe_default_posix1_handler
00025730 R_PPC_ADDR32      _base_spe_default_libea_handler

(0x0002571c - 0x0002571c) / 4 = 0 (c99)
(0x00025720 - 0x0002571c) / 4 = 1 (posix1)
(0x00025720 - 0x0002571c) / 4 = 5 (libea)

So all looks fine here, c99 callbacks work too. libea testing welcome.

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

---

 spebase/lib_builtin.c |   30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

Index: libspe2/spebase/lib_builtin.c
===================================================================
--- libspe2.orig/spebase/lib_builtin.c
+++ libspe2/spebase/lib_builtin.c
@@ -26,26 +26,16 @@
 #include "default_posix1_handler.h"
 #include "default_libea_handler.h"
 
-/*Default SPE library call handlers for 21xx stop-and-signal.
-*/
-static void *handlers[] = {
-        _base_spe_default_c99_handler, _base_spe_default_posix1_handler,
-        NULL,NULL,_base_spe_default_libea_handler ,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-        NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-        NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-        NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-        NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-        NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-        NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-        NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-        NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-        NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-        NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-        NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-        NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-        NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-        NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
-        NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
+#define HANDLER_IDX(x) (x & 0xff)
+
+/*
+ * Default SPE library call handlers for 21xx stop-and-signal.
+ */
+static void *handlers[256] = {
+	[HANDLER_IDX(SPE_C99_CLASS)]	= _base_spe_default_c99_handler,
+	[HANDLER_IDX(SPE_POSIX1_CLASS)]	= _base_spe_default_posix1_handler,
+	[HANDLER_IDX(SPE_LIBEA_CLASS)]	= _base_spe_default_libea_handler
+};
 
 int _base_spe_callback_handler_register(void * handler, unsigned int callnum, unsigned int mode)
 {



More information about the cbe-oss-dev mailing list