mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2025-03-11 19:00:07 +01:00
(sos_alloc): Do type-punning through a union to be ANSI-9x compliant
and avoid a warning from gcc. (Logical change 1.104)
This commit is contained in:
parent
29f2f89a8f
commit
522e2ccbe0
1 changed files with 6 additions and 1 deletions
|
@ -46,6 +46,10 @@ 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;
|
||||||
|
@ -57,8 +61,9 @@ sos_alloc (size_t size)
|
||||||
mem += size;
|
mem += size;
|
||||||
if (mem >= sos_memory + sizeof (sos_memory))
|
if (mem >= sos_memory + sizeof (sos_memory))
|
||||||
abort ();
|
abort ();
|
||||||
|
u.cp = sos_memp;
|
||||||
}
|
}
|
||||||
while (cmpxchg_ptr (&sos_memp, old_mem, mem) != old_mem);
|
while (cmpxchg_ptr (&u.lp, old_mem, mem) != old_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;
|
||||||
|
|
Loading…
Add table
Reference in a new issue