[Cbe-oss-dev] [patch 3/4] MARS: Fix build warnings

Andrew Pinski pinskia at gmail.com
Mon Aug 25 14:13:24 EST 2008


On Sun, Aug 24, 2008 at 9:04 PM, Kazunori Asayama <asayama at sm.sony.co.jp> wrote:
>>
>> Even worse, if malloc earlier had returned a pointer that happens to
>> have any bit 0-31 set, then we produce the incorrect code.  So getting
>
> The task.context_save_area is uint64_t. Is it insufficient?

Oh I missed that.  Then this is ok.  I did not notice if Geoff was
compiling for 32bits or 64bits.  Yes it is better to use a macro.
Plus the macro could add extra debugging to make sure that the size of
the integer is greater than or equal to the size of the pointer.
Something like (using GCC 2 extensions, typeof and statement
expressions):

#define CONVERT_FROM_INT(a) ({ __typeof(a) b = (a);  typedef int
not_the_correct_size[sizeof(b) >= sizeof(void*) ? 1: -1];
(void*)(uintptr_t)b;})

This has a nice effect of checking at compile time that the size is at
least as big as the pointer size.

Thanks,
Andrew Pinski



More information about the cbe-oss-dev mailing list