Author: afaerber Date: Tue Nov 9 23:50:48 2010 New Revision: 951 URL: http://tracker.coreboot.org/trac/openbios/changeset/951
Log: Convert cell2pointer() and pointer2cell() macros to inline functions
Inline functions suggested by Blue.
Use const void* for pointer2cell() due to const char* arguments.
Fix a misuse of pointer2cell().
Drop comment on reusing different host bitness code path; any special handling for different target bitnesses should go into these new functions.
v2: * Use QEMU-style indentation for new inline functions.
Cc: Blue Swirl blauwirbel@gmail.com Signed-off-by: Andreas Färber andreas.faerber@web.de
Modified: trunk/openbios-devel/include/kernel/stack.h trunk/openbios-devel/kernel/internal.c
Modified: trunk/openbios-devel/include/kernel/stack.h ============================================================================== --- trunk/openbios-devel/include/kernel/stack.h Tue Nov 9 21:12:35 2010 (r950) +++ trunk/openbios-devel/include/kernel/stack.h Tue Nov 9 23:50:48 2010 (r951) @@ -31,9 +31,17 @@
#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) {
Modified: trunk/openbios-devel/kernel/internal.c ============================================================================== --- trunk/openbios-devel/kernel/internal.c Tue Nov 9 21:12:35 2010 (r950) +++ trunk/openbios-devel/kernel/internal.c Tue Nov 9 23:50:48 2010 (r951) @@ -645,7 +645,7 @@ 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;