This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

Re: PATCH: eliminate some endian #ifs


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))

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