This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports 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]

ARM 64 bit atomics


Hi,
  I've been adding 64bit atomic support using ARMv7's  ldrexd and
strexd to gcc and started looking at libc
to see if it wanted them as well, but I've got more questions than answers:

  1) For linux the right place would seem to be
ports/sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h
and I can see there is an __arch_compare_and_exchange_val_64_acq
currently set to produce
a link error - now I think I should be able to trivially do:

#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
  __sync_val_compare_and_swap ((mem), (oldval), (newval))

If gcc has it then it'll inline it, if gcc can't produce it then it'll
produce a fallback routine
that uses the kernel helpers, and if it's an older gcc this will
produce an error like
the original one did.   Does that seem reasonable? (if so I can add
that and also
the other gcc variants that I can see the atomic.h code can use for
adds etc to be
more efficient).

  2) But if that's so trivial why do the other sizes in that atomic.h
also not just
let gcc produce the fallback routines rather than have their own implementation?

  3) Would a 64bit implementation actually get called via libc?  I can't see any
uses within libc of greater than 32bits, and I can't see where these calls are
exposed to the users of libc except by things like pthread' - so is
there any point
adding the 64bit __arch_compare_and_exchange_val_64_acq to libc?

  4) Are there any stricter definitions of the semantics of the atomic
calls used inside
glibc - i.e. what barriers should exist when?

  5) When gcc generates a fallback (for an ARM earlier than ARMv6k) it ends up
using a kernel helper; but it needs to check that the kernel version
is new enough
at run time - it does this using an init_array function and abort()'s
the program pretty
early; that function only gets linked in if the 64bit fallback
functions are used.
This would be a problem if 64bit ops got linked in libc by default.

(The patches for gcc are just waiting for me to get a complete testsuite run and
then they'll get posted).

Thanks in advance,

Dave


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