[OpenBIOS] [PATCH] Convert cell2pointer() and pointer2cell() macros to inline functions

Andreas Färber andreas.faerber at web.de
Sun Oct 31 18:44:49 CET 2010


Use const void* for pointer2cell() due to const char* arguments.
Fix a misuse of pointer2cell().

Suggested by Blue.

Cc: Blue Swirl <blauwirbel at gmail.com>
Signed-off-by: Andreas Färber <andreas.faerber at web.de>
---
 include/kernel/stack.h |   14 +++++++++++---
 kernel/internal.c      |    2 +-
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/include/kernel/stack.h b/include/kernel/stack.h
index 2a78c62..a87c647 100644
--- a/include/kernel/stack.h
+++ b/include/kernel/stack.h
@@ -31,9 +31,17 @@ typedef ucell phandle_t;
 
 
 #ifdef NATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH
-// XXX Check whether we can take the larger-than code path for ppc64 instead.
-#define pointer2cell(x) ((ucell)(uintptr_t)(x))
-#define cell2pointer(x) ((u8 *)(uintptr_t)(x))
+
+static inline ucell pointer2cell(const void* x)
+{
+	return (ucell)(uintptr_t)x;
+}
+
+static inline void* cell2pointer(ucell x)
+{
+	return (void*)(uintptr_t)x;
+}
+
 #endif
 
 static inline void PUSH(ucell value) {
diff --git a/kernel/internal.c b/kernel/internal.c
index 760c66d..91ab440 100644
--- a/kernel/internal.c
+++ b/kernel/internal.c
@@ -645,7 +645,7 @@ do_source_dbg( struct debug_xt *debug_xt_item )
 			case 'F':
 				/* Start subordinate Forth interpreter */
 				PUSHR(PC - sizeof(cell));
-				PC = pointer2cell(findword("outer-interpreter")) + sizeof(ucell);
+				PC = findword("outer-interpreter") + sizeof(ucell);
 
 				/* Save rstack position for when we return */
 				dbgrstackcnt = rstackcnt;
-- 
1.7.3




More information about the OpenBIOS mailing list