1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-18 22:07:38 +01:00

(sos_alloc): Drop type-cast-avoiding union. If we really need it,

it should be done by cmpxchg_ptr().

(Logical change 1.138)
This commit is contained in:
mostang.com!davidm 2003-12-05 06:42:28 +00:00
parent 47c25b753c
commit 98f95e6ee4

View file

@ -46,14 +46,9 @@ sos_alloc (size_t size)
char *mem; char *mem;
#ifdef HAVE_CMPXCHG #ifdef HAVE_CMPXCHG
union {
long *lp;
char **cp;
} u;
char *old_mem; char *old_mem;
size = (size + MAX_ALIGN - 1) & -MAX_ALIGN; size = (size + MAX_ALIGN - 1) & -MAX_ALIGN;
u.cp = &sos_memp;
do do
{ {
old_mem = sos_memp; old_mem = sos_memp;
@ -63,7 +58,7 @@ sos_alloc (size_t size)
if (mem >= sos_memory + sizeof (sos_memory)) if (mem >= sos_memory + sizeof (sos_memory))
abort (); abort ();
} }
while (!cmpxchg_ptr (u.lp, old_mem, mem)); while (!cmpxchg_ptr (&sos_memp, old_mem, mem));
#else #else
static pthread_mutex_t sos_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t sos_lock = PTHREAD_MUTEX_INITIALIZER;
sigset_t saved_sigmask; sigset_t saved_sigmask;