harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Hindess <mark.hind...@googlemail.com>
Subject Re: [classlib][misc] MemMacros.h get_unaligned and set_unaligned macros fail to compile on zLinux
Date Wed, 17 Jun 2009 07:00:29 GMT

In message <4A366B53.5090700@googlemail.com>, Oliver Deakin writes:
>
> Can anyone confirm that the change I appended for MemMacros.h does not 
> cause any breakage on Linux x86_64? I'll give it a few days before I 
> commit this change so there's some time to speak up.

Well it most likely wouldn't break since IIRC unaligned accesses are trapped
and handled by the kernel.  However, the key thing is that __i386__ is *not*
defined on x86_64 so the memmove case is used by both x86_64 and ia64.

-Mark.

> Oliver Deakin wrote:
> > The change I appended to my original mail fixes the build problem on 
> > zLinux 31 now. Can anyone confirm that everything works as expected on 
> > Linux x86_64 please? I think it is only that platform that is in 
> > danger of being affected by this modification.
> >
> > Regards,
> > Oliver
> >
> > Oliver Deakin wrote:
> >> 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



Mime
View raw message