[OpenBIOS] [PATCH 2/3] Move cell2pointer and pointer2cell macros

Andreas Färber andreas.faerber at web.de
Mon Oct 18 01:18:24 CEST 2010


These will be needed elsewhere for ppc64.

Cc: Blue Swirl <blauwirbel at gmail.com>
Signed-off-by: Andreas Färber <andreas.faerber at web.de>
---
 NB: macros are not yet changed here.
 
 include/kernel/stack.h |   12 ++++++++++++
 kernel/cross.h         |    6 ------
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/include/kernel/stack.h b/include/kernel/stack.h
index 9fe52ce..809ffe9 100644
--- a/include/kernel/stack.h
+++ b/include/kernel/stack.h
@@ -30,6 +30,18 @@ typedef ucell phandle_t;
 
 
 
+#ifdef NATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH
+#define pointer2cell(x) ((ucell)(x))
+#define cell2pointer(x) ((u8 *)(x))
+#endif
+#ifdef NATIVE_BITWIDTH_SMALLER_THAN_HOST_BITWIDTH
+#define pointer2cell(x) ((ucell)(((unsigned long)(x))-base_address))
+#define cell2pointer(x) ((u8 *)(((unsigned long)(x))+base_address))
+#endif
+#ifdef NATIVE_BITWIDTH_LARGER_THAN_HOST_BITWIDTH
+#define pointer2cell(x) ((ucell)(unsigned long)(x))
+#define cell2pointer(x) ((u8 *)((unsigned long)(x)&0xFFFFFFFFUL))
+#endif
 
 static inline void PUSH(ucell value) {
 	dstack[++dstackcnt] = (value);
diff --git a/kernel/cross.h b/kernel/cross.h
index d4cfff1..1b7d448 100644
--- a/kernel/cross.h
+++ b/kernel/cross.h
@@ -103,8 +103,6 @@
 /* bit width handling */
 
 #ifdef NATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH
-#define pointer2cell(x) ((ucell)(x))
-#define cell2pointer(x) ((u8 *)(x))
 #if BITS==32
 #define FMT_CELL_x "x"
 #define FMT_CELL_d "d"
@@ -116,15 +114,11 @@
 
 #ifdef NATIVE_BITWIDTH_SMALLER_THAN_HOST_BITWIDTH
 extern unsigned long base_address;
-#define pointer2cell(x) ((ucell)(((unsigned long)(x))-base_address))
-#define cell2pointer(x) ((u8 *)(((unsigned long)(x))+base_address))
 #define FMT_CELL_x "x"
 #define FMT_CELL_d "d"
 #endif
 
 #ifdef NATIVE_BITWIDTH_LARGER_THAN_HOST_BITWIDTH
-#define pointer2cell(x) ((ucell)(unsigned long)(x))
-#define cell2pointer(x) ((u8 *)((unsigned long)(x)&0xFFFFFFFFUL))
 #define FMT_CELL_x "llx"
 #define FMT_CELL_d "lld"
 #endif
-- 
1.7.3




More information about the OpenBIOS mailing list