bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* Module suggestion: Atomic operations
@ 2020-05-24 13:36 Marc Nieper-Wißkirchen
  2020-05-24 20:54 ` Bruno Haible
  2020-07-01 21:37 ` Bruno Haible
  0 siblings, 2 replies; 7+ messages in thread
From: Marc Nieper-Wißkirchen @ 2020-05-24 13:36 UTC (permalink / raw)
  To: bug-gnulib

[-- Attachment #1: Type: text/plain, Size: 794 bytes --]

C11 has introduced atomic types and atomic operations.  When they are not
available, one can use locks/mutexes instead.

It would be nice if there was a Gnulib module that abstracts over this,
much like the threadlib module and friends abstract over a specific
threading implementation.

What I am thinking of is the following: Given a type T, a new Gnulib module
atomic allows the declaration of an atomic version of type T.  This is
straightforward on a platform that has <stdatomic.h>.  Otherwise the atomic
version of T would be a struct consisting of an object of type T together
with a lock.

The rest of the module would then provide some simple atomic primitives
like fetch_and_add, etc. that are either mapped to the C11 stdatomic
counterparts or are implemented using the lock.

Marc

[-- Attachment #2: Type: text/html, Size: 1404 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-07-01 21:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-24 13:36 Module suggestion: Atomic operations Marc Nieper-Wißkirchen
2020-05-24 20:54 ` Bruno Haible
2020-05-25  7:03   ` Marc Nieper-Wißkirchen
2020-05-25  7:24     ` Bruno Haible
2020-05-25 20:11       ` Marc Nieper-Wißkirchen
2020-05-27  8:30         ` Bruno Haible
2020-07-01 21:37 ` Bruno Haible

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