[OpenBIOS] [RFC 2/5] Fix for pointer2cell() and cell2pointer()
Andreas Färber
andreas.faerber at web.de
Wed Oct 27 22:56:41 CEST 2010
Am 27.10.2010 um 21:48 schrieb Blue Swirl:
> On Tue, Oct 26, 2010 at 11:08 PM, Andreas Färber <andreas.faerber at web.de
> > wrote:
>> ---
>> include/kernel/stack.h | 4 ++--
>> 1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/kernel/stack.h b/include/kernel/stack.h
>> index 809ffe9..44fef0f 100644
>> --- a/include/kernel/stack.h
>> +++ b/include/kernel/stack.h
>> @@ -31,8 +31,8 @@ typedef ucell phandle_t;
>>
>>
>> #ifdef NATIVE_BITWIDTH_EQUALS_HOST_BITWIDTH
>> -#define pointer2cell(x) ((ucell)(x))
>> -#define cell2pointer(x) ((u8 *)(x))
>> +#define pointer2cell(x) ((ucell)(uintptr_t)(x))
>> +#define cell2pointer(x) ((u8 *)(uintptr_t)(x))
>
> Perhaps this should be changed to inline function which returns void
> *, then we may avoid a few casts.
I wouldn't mind inline functions either.
I doubt this quickfix is right at all though. It makes things compile
with minimal impact, but these decisions seem seriously flawed. switch-
arch and these macros all assume that just pointer size matters. IMO
we would need CELL_BITWIDTH_EQUALS_POINTER_BITWIDTH instead and should
be using CELL_BITWIDTH_SMALLER_THAN_POINTER_BITWIDTH (two #ifdefs
below) for ppc64 instead of making the equality code path (hardcoded
in Makefile.target) handle the smaller-than case as well now.
If we want to go ahead with my above patch I should at least add a
TODO that this is wrong, no?
Andreas
More information about the OpenBIOS
mailing list