public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
Cc: Zack Weinberg <zack@owlfolio.org>,
	 Adhemerval Zanella <adhemerval.zanella@linaro.org>
Subject: Re: [PATCH] linux: Use 'long int' for timespec tv_nsec on x32 (BZ #16437)
Date: Thu, 09 Dec 2021 20:19:18 +0100	[thread overview]
Message-ID: <87r1alegcp.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20211209191048.4031643-1-adhemerval.zanella@linaro.org> (Adhemerval Zanella via Libc-alpha's message of "Thu, 9 Dec 2021 16:10:48 -0300")

* Adhemerval Zanella via Libc-alpha:

> diff --git a/time/bits/types/struct_timespec.h b/time/bits/types/struct_timespec.h
> index 489e81136d..b962d3f95f 100644
> --- a/time/bits/types/struct_timespec.h
> +++ b/time/bits/types/struct_timespec.h
> @@ -15,19 +15,9 @@ struct timespec
>  #else
>    __time_t tv_sec;		/* Seconds.  */
>  #endif
> -#if __WORDSIZE == 64 \
> -  || (defined __SYSCALL_WORDSIZE && __SYSCALL_WORDSIZE == 64) \
> -  || (__TIMESIZE == 32 && !defined __USE_TIME_BITS64)
> -  __syscall_slong_t tv_nsec;	/* Nanoseconds.  */
> -#else
> -# if __BYTE_ORDER == __BIG_ENDIAN
> -  int: 32;           /* Padding.  */
> -  long int tv_nsec;  /* Nanoseconds.  */
> -# else
> -  long int tv_nsec;  /* Nanoseconds.  */
> -  int: 32;           /* Padding.  */
> -# endif
> -#endif
> +  int : 8 * (sizeof (time_t) - sizeof (long)) * (__BYTE_ORDER == __BIG_ENDIAN);
> +  long int tv_nsec;
> +  int : 8 * (sizeof (time_t) - sizeof (long)) * (__BYTE_ORDER == __LITTLE_ENDIAN);
>  };

I think zero-width bitfields are problematic from an ABI perspective:

  zero width bitfields and ABIs
  <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102024>

The change is also not entirely ABI-compatible because existing code on
x32 depends on the implementation clearing the upper 32 bits, and if new
code copies around structs, it won't necessary copy the zero bits.

Thanks,
Florian


  reply	other threads:[~2021-12-09 19:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-09 19:10 Adhemerval Zanella
2021-12-09 19:19 ` Florian Weimer [this message]
2021-12-09 19:35   ` Adhemerval Zanella
2021-12-10 11:23     ` Arnd Bergmann
2021-12-10 11:29       ` Florian Weimer
2021-12-10 12:48         ` Arnd Bergmann
2021-12-10 12:51           ` Florian Weimer
2021-12-10 13:11             ` Arnd Bergmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r1alegcp.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    --cc=zack@owlfolio.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).