summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTommi Rantala <tt.rantala@gmail.com>2012-09-19 14:00:20 +0300
committerTommi Rantala <tt.rantala@gmail.com>2012-09-28 13:52:22 +0300
commit9a3565ddc1e956ef1f52806093e949c7809f6e79 (patch)
tree083806a7ef8c213db6f9a8cbf292f24e33c17b27 /include
parent26fc1563fba945d0356e4a7dd935a6a57b3c03db (diff)
downloadlibunwind-9a3565ddc1e956ef1f52806093e949c7809f6e79.tar.gz
Simplify `sos_alloc()' implementation
Instead of maintaining a pointer to the `sos_memory' array, maintain an index that tells the next free position. When atomic operations are available, the allocation boils down to a single fetch-and-add operation.
Diffstat (limited to 'include')
-rw-r--r--include/libunwind_i.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/include/libunwind_i.h b/include/libunwind_i.h
index b1f9cee5..15a79735 100644
--- a/include/libunwind_i.h
+++ b/include/libunwind_i.h
@@ -110,11 +110,12 @@ cmpxchg_ptr (void *addr, void *old, void *new)
return AO_compare_and_swap(u.aop, (AO_t) old, (AO_t) new);
}
# define fetch_and_add1(_ptr) AO_fetch_and_add1(_ptr)
+# define fetch_and_add(_ptr, value) AO_fetch_and_add(_ptr, value)
/* GCC 3.2.0 on HP-UX crashes on cmpxchg_ptr() */
# if !(defined(__hpux) && __GNUC__ == 3 && __GNUC_MINOR__ == 2)
# define HAVE_CMPXCHG
# endif
-# define HAVE_FETCH_AND_ADD1
+# define HAVE_FETCH_AND_ADD
#else
# ifdef HAVE_IA64INTRIN_H
# include <ia64intrin.h>
@@ -132,8 +133,9 @@ cmpxchg_ptr (void *addr, void *old, void *new)
return __sync_bool_compare_and_swap(u.vlp, (long) old, (long) new);
}
# define fetch_and_add1(_ptr) __sync_fetch_and_add(_ptr, 1)
+# define fetch_and_add(_ptr, value) __sync_fetch_and_add(_ptr, value)
# define HAVE_CMPXCHG
-# define HAVE_FETCH_AND_ADD1
+# define HAVE_FETCH_AND_ADD
# endif
#endif
#define atomic_read(ptr) (*(ptr))