PATCH: eliminate some endian #ifs
Greg McGary
greg@mcgary.org
Thu Jul 6 14:43:00 GMT 2000
Jakub Jelinek <jakub@redhat.com> writes:
> This will not correctly if 32bit value (such as off_t on 32bit arch; see
> pread/pwrite below e.g.) is passed to __LONG_LONG_SPLIT.
> You'll get a
> warning: right shift count >= width of type
> and undefined result.
> You must either use something like:
> #define __LONG_LONG_SPLIT(LL) \
> __LONG_LONG_PAIR (((unsigned long long)(LL)) >> 32, (LL) & 0xffffffff)
> or not use __LONG_LONG_SPLIT on 32bit types.
>
> Jakub
Thanks. Here's the revised def'n:
/* This macro intended to break apart a off64_t into two 32-bit off_t
halves, presented as a comma-separated pair for subsequent passing
as separate arguments to INLINE_SYSCALL, in an order determined by
__BYTE_ORDER. Note that we cast LL to unsigned types. off_t and
off64_t are signed, but pread and pwrite internally convert
negative 32-bit quantities to unsigned 64-bit. */
#define __LONG_LONG_SPLIT(LL) \
__LONG_LONG_PAIR ((uint32_t) (((uint64_t) (LL)) >> 32), \
(uint64_t) ((LL) & 0xffffffff))
More information about the Libc-hacker
mailing list