[parisc-linux] glibc 2.3.1 - It's alive! - patches

Carlos O'Donell carlos@baldric.uwo.ca
Mon, 18 Nov 2002 14:30:07 -0500


> > - Implement atomic_add, echange_and_add, and compare and swap, which are
> >   required in atomicity.h
> 
> I added an implementation of atomic_add and echange_and_add to libstdc++
> recently.  You can probably copy most of it for glibc, although the libstdc++
> implementation is for c++.  The main problem would be in initializing
> the 16 byte lock structure.
> 

We already have a 16-byte aligned lock structure in glibc for pthreads, 
and I plan to use the same construct in atomicity.h.

...
typedef struct {
       int lock;
} __attribute__((aligned (16))) __atomic_lock_t;
...
#define __LOCK_INIT = { 1 };
static __atomic_lock_t __hppa_lock = __LOCK_INIT;
...
Ref the above lock in my __asm statement and use ldcw and a loop to make
sure the C function stays atomic for those threads (similar
implementation to sparc and mips).

c.