harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Deakin <oliver.dea...@googlemail.com>
Subject [classlib][misc] MemMacros.h get_unaligned and set_unaligned macros fail to compile on zLinux
Date Thu, 21 May 2009 15:51:54 GMT
Hi all,

I have a quick question about the macros get_unaligned() and 
set_unaligned() in MemMacros.h. When compiling on zSeries Linux 31 bit 
systems we fall into the macros defines section for IPF machines because 
we are on linux and __386__ is not defined. Unfortunately the "(const 
void*) (ptr)" tries to cast a jlong (64 bit) to a 32 bit pointer here 
and we get a "cast to pointer from integer of different size" warning 
which is treated as an error.

I'd like to fix the code to do the right thing here across all 
platforms. Does anyone know this code well? Does the IPF section 
(__linux__ && !__i386__) refer to Itanium machines only and not x86_64? 
If so, would it suffice to replace the code that is there with something 
like [1], so that only Itanium machines use the memmove() based macros 
and all the rest (linux, windows, zos, aix etc.) use the simpler cast 
based macros?

Thanks for any help you can give!

Regards,
Oliver

[1]
#if defined(__ia64__) && defined(__linux__)

#include <string.h>
#define get_unaligned(type, ptr)                                  \
({                                                                \
    type __tmp;                                                   \
    memmove(&__tmp, (const void*) (ptr), sizeof(type));           \
    __tmp;                                                        \
})

#define set_unaligned(type, ptr, val)                           \
({                                                              \
    memmove((void*) (ptr), &val, sizeof(type));                 \
    (void)0;                                                    \
})

#else

#define get_unaligned(type, ptr) ( *((type *)((uintptr_t)(ptr))) )
#define set_unaligned(type, ptr, val) ( (void) (*((type 
*)((uintptr_t)(ptr))) = val) )

#endif

-- 
Oliver Deakin
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598. 
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


Mime
View raw message