tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] [PATCH] stdatomic: ld/st/xchg/cmpxchg on simple types


From: Michael Matz
Subject: Re: [Tinycc-devel] [PATCH] stdatomic: ld/st/xchg/cmpxchg on simple types
Date: Mon, 22 Mar 2021 17:22:03 +0100 (CET)
User-agent: Alpine 2.21 (LSU 202 2017-01-01)

Hello,

On Fri, 19 Mar 2021, Dmitry Selyutin wrote:

Some complex types can still be small and simple enough to fit into
register. Other compilers allow some operations on these types, and it
seems to be quite a reasonable choice. From now on, we should be able
to compile the following artificial example:

   struct combo {
       uint16_t lo;
       uint16_t hi;
   };

   struct combo load(const _Atomic(struct combo) *atom)
   {
       return atomic_load(atom);
   }

Is the above atomic_load supposed to be similar to the GCC __atomic_load intrinsic? If so, then it doesn't return a value. It rather takes a pointer to the return value, hence structs aren't passed around, pointers are, and as such don't need special calling convention massaging. I.e. it's declared similar to this:

void __atomic_load (size_t size, void *mem, void *return, int model);

Even when you encode the size directly and hence have a return type it's uintN, and hence not convertible to a struct type:

  struct combo c;
  c = __atomic_load_4(atom, __ATOMIC_SEQ_CST);

doesn't compile (and it shouldn't).

   void store(_Atomic(struct combo) *atom, struct combo value)
   {
       atomic_store(atom, value);
   }

Same for atomic_store and the rest: it doesn't take 'value' by value but by reference.

So, what exactly are you trying to implement? Please make a full compilable (with GCC) example.



Ciao,
Michael.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]