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: [PATCHv3 00/24] ILP32 support in ARM64


On 02/17/2015 01:38 PM, Zack Weinberg wrote:
>     typedef __S32_TYPE __nseconds_t;
> 
>     struct timespec {
>         __time_t tv_sec;
>     #if __BYTE_ORDER == __BIG_ENDIAN
>         __S32_TYPE   __unused;
>         __nseconds_t tv_nsec;
>     #else
>         __nseconds_t tv_nsec;
>         __S32_TYPE   __unused;
>     #endif
>     };
> 
> And then change the kernel not to read or write the __unused field.

It just occurred to me that there's a way to cut the baby in half,
namely bitfields.

    struct timespec {
         __time_t tv_sec;
    #if __BYTE_ORDER == __BIG_ENDIAN
         long  __unused    : 32;
         long  tv_nsec     : 32;
    #else
         long  tv_nsec     : 32;
         long  __unused    : 32;
    #endif
    };

This breaks code which takes pointers to tv_nsec, but I expect that is
vanishingly rare -- certainly much less frequent than printing it with %ld.

zw


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