public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Wilco Dijkstra via Libc-alpha <libc-alpha@sourceware.org>
Cc: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Subject: Re: [PATCH] Remove atomic-machine headers
Date: Thu, 28 Jul 2022 18:22:54 +0200	[thread overview]
Message-ID: <87czdpyzoh.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <AM5PR0801MB16685212691A165C68F70F1183969@AM5PR0801MB1668.eurprd08.prod.outlook.com> (Wilco Dijkstra via Libc-alpha's message of "Thu, 28 Jul 2022 14:30:30 +0000")

* Wilco Dijkstra via Libc-alpha:

> diff --git a/configure b/configure
> index ff2c406b3b573484c843742d292fc2e0ee0e3008..3efdf45f99af71a482509f559d9de90aa294700c 100755
> --- a/configure
> +++ b/configure
> @@ -727,6 +727,7 @@ infodir
>  docdir
>  oldincludedir
>  includedir
> +runstatedir
>  localstatedir
>  sharedstatedir
>  sysconfdir

Spurious difference.

> +typedef struct { long long t; } X;
> +extern void has_64b_atomics(void);
> +void f(void)
> +{
> +  X x;
> +  /* Use address of structure with 64-bit type.  This avoids incorrect
> +     implementations which return true even if long long is not 64-bit aligned.
> +     This works on GCC and LLVM - other cases have bugs and they disagree.  */
> +  if (__atomic_always_lock_free (sizeof (x), &x))
> +    has_64b_atomics();

Can you use _static_assert, given that it's supposed to yield a
compile-time constant?

I'd be suprised if __atomic_always_lock_free is correct on all
glibc-supported architectures, though.

> diff --git a/sysdeps/x86/atomic-machine.h b/sysdeps/x86/atomic-machine.h
> index 98541a2d06ff5e4aa8c789ab7405215097471971..303458d1296e4b1cd7cd654e0904ace0ffc52fae 100644
> --- a/sysdeps/x86/atomic-machine.h
> +++ b/sysdeps/x86/atomic-machine.h
> @@ -21,17 +21,6 @@
>  
>  #include <tls.h>			/* For mach.  */
>  
> -#ifdef __x86_64__
> -# define __HAVE_64B_ATOMICS		1
> -#else
> -/* Since the Pentium, i386 CPUs have supported 64-bit atomics, but the
> -   i386 psABI supplement provides only 4-byte alignment for uint64_t
> -   inside structs, so it is currently not possible to use 64-bit
> -   atomics on this platform.  */
> -# define __HAVE_64B_ATOMICS		0
> -#endif
> -#define ATOMIC_EXCHANGE_USES_CAS	0
> -
>  #define atomic_spin_nop() __asm ("pause")
>  
>  #endif /* atomic-machine.h */

Please preserve this comment somewhere.  Maybe folod it into the
configure test example.

Thanks,
Florian


  reply	other threads:[~2022-07-28 16:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-28 14:30 Wilco Dijkstra
2022-07-28 16:22 ` Florian Weimer [this message]
2022-07-29 13:39   ` Wilco Dijkstra

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=87czdpyzoh.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=Wilco.Dijkstra@arm.com \
    --cc=libc-alpha@sourceware.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).