boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

atomic_arch.h (1191B)


      1 /* tcc-build aarch64 atomic_arch.h replacement.
      2  *
      3  * Stock musl's atomic primitives are inline asm with output operands
      4  * (LL/SC pairs and the `dmb ish` named option), none of which
      5  * arm64-asm.c phase 1+2 handles. We can't decompose into separate
      6  * extern a_ll / a_sc — function-call boundaries between ldaxr and
      7  * stlxr clear the exclusive monitor on real hardware (and on
      8  * QEMU/Apple Silicon), making the LL/SC retry loop deadloop.
      9  *
     10  * Provide a_cas (32-bit) and a_cas_p (64-bit, since aarch64 pointers
     11  * are 64-bit) as single-function externs implemented in
     12  * src/internal/aarch64/atomic.s; the LL/SC pair lives inside one
     13  * call. musl's src/internal/atomic.h derives a_swap, a_fetch_add,
     14  * a_or, a_and, a_inc, a_dec, a_store and friends from a_cas.
     15  *
     16  * Phase 3 of arm64-asm.c will let us inline these. */
     17 
     18 extern int   a_cas    (volatile int *, int, int);
     19 extern void *a_cas_p  (volatile void *, void *, void *);
     20 extern void  a_barrier(void);
     21 extern int   a_ctz_64 (unsigned long long);
     22 extern int   a_clz_64 (unsigned long long);
     23 
     24 #define a_cas      a_cas
     25 #define a_cas_p    a_cas_p
     26 #define a_barrier  a_barrier
     27 #define a_ctz_64   a_ctz_64
     28 #define a_clz_64   a_clz_64