Message275761
There is no need to ifdef anything, the memcpy is the only correct way to do it. As memcpy is also a reserved identifier in C, the compiler can and will optimize this into a 64-bit access on those platforms where it can be safely done so (x86 for example), e.g. GCC compiles
uint64_t func(char *buf) {
uint64_t rv;
memcpy(&rv, buf+3, sizeof(rv));
return rv;
}
into
movq 3(%rdi), %rax
ret
On Linux 64-bit ABI. |
|
Date |
User |
Action |
Args |
2016-09-11 10:00:33 | ztane | set | recipients:
+ ztane, doko, christian.heimes, benjamin.peterson |
2016-09-11 10:00:33 | ztane | set | messageid: <1473588033.59.0.675771231528.issue28055@psf.upfronthosting.co.za> |
2016-09-11 10:00:33 | ztane | link | issue28055 messages |
2016-09-11 10:00:33 | ztane | create | |
|