This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v4 PATCH] sha2: new header <sha2.h>


On 04/10/2015 11:07 PM, Shawn Landden wrote:
>> Storing through a packed structure is the easiest way to make gcc produce what
>> you want, without having to make every port define _STRING_ARCH_unaligned.
>>
>> E.g.
>>
>> static inline void put_be32(void *p, uint32_t v)
>> {
>>   struct __attribute__((packed, may_alias)) { uint32_t x; } *u = p;
>>   u->x = be32toh(v);
>> }
> Nice! I assume this could be used for get_unaligned too?
> 
> static inline uint32_t get_unaligned_be32(void *p)
> {
>   struct __attribute__((packed, may_alias)) { uint32_t x; } *u = p;
>   return be32toh(u->x);
> }

Of course.


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]