This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [v4 PATCH] sha2: new header <sha2.h>
- From: Richard Henderson <rth at twiddle dot net>
- To: Shawn Landden <shawn at churchofgit dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Sat, 11 Apr 2015 07:52:18 -1000
- Subject: Re: [v4 PATCH] sha2: new header <sha2.h>
- Authentication-results: sourceware.org; auth=none
- References: <1428454974-39008-1-git-send-email-shawn at churchofgit dot com> <5526C8E0 dot 2090907 at twiddle dot net> <20150411090736 dot GA1356 at churchofgit dot com>
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~