aboutsummaryrefslogtreecommitdiff
path: root/libbacktrace/internal.h
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2013-11-19 01:09:47 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2013-11-19 01:09:47 +0000
commit49579c7e20da4cf0dc82bf1c8458bf4fc7a38007 (patch)
treea715cbe6fb809ff31f1487b709ea67a6f616cec5 /libbacktrace/internal.h
parent7f369373da8aa1cfe4aa172d29ae2180a2b31139 (diff)
downloadgcc-49579c7e20da4cf0dc82bf1c8458bf4fc7a38007.zip
gcc-49579c7e20da4cf0dc82bf1c8458bf4fc7a38007.tar.gz
gcc-49579c7e20da4cf0dc82bf1c8458bf4fc7a38007.tar.bz2
configure.ac: Check for support of __atomic extensions.
* configure.ac: Check for support of __atomic extensions. * internal.h: Declare or #define atomic functions for use in backtrace code. * atomic.c: New file. * dwarf.c (dwarf_lookup_pc): Use atomic functions. (dwarf_fileline, backtrace_dwarf_add): Likewise. * elf.c (elf_add_syminfo_data, elf_syminfo): Likewise. (backtrace_initialize): Likewise. * fileline.c (fileline_initialize): Likewise. * Makefile.am (libbacktrace_la_SOURCES): Add atomic.c. * configure, config.h.in, Makefile.in: Rebuild. From-SVN: r204994
Diffstat (limited to 'libbacktrace/internal.h')
-rw-r--r--libbacktrace/internal.h43
1 files changed, 42 insertions, 1 deletions
diff --git a/libbacktrace/internal.h b/libbacktrace/internal.h
index 1ea664a..c93e89f 100644
--- a/libbacktrace/internal.h
+++ b/libbacktrace/internal.h
@@ -65,7 +65,48 @@ POSSIBILITY OF SUCH DAMAGE. */
#define __sync_lock_test_and_set(A, B) (abort(), 0)
#define __sync_lock_release(A) abort()
-#endif /* !defined(HAVE_SYNC_FUNCTIONS) */
+#endif /* !defined (HAVE_SYNC_FUNCTIONS) */
+
+#ifdef HAVE_ATOMIC_FUNCTIONS
+
+/* We have the atomic builtin functions. */
+
+#define backtrace_atomic_load_pointer(p) \
+ __atomic_load_n ((p), __ATOMIC_ACQUIRE)
+#define backtrace_atomic_load_int(p) \
+ __atomic_load_n ((p), __ATOMIC_ACQUIRE)
+#define backtrace_atomic_store_pointer(p, v) \
+ __atomic_store_n ((p), (v), __ATOMIC_RELEASE)
+#define backtrace_atomic_store_size_t(p, v) \
+ __atomic_store_n ((p), (v), __ATOMIC_RELEASE)
+#define backtrace_atomic_store_int(p, v) \
+ __atomic_store_n ((p), (v), __ATOMIC_RELEASE)
+
+#else /* !defined (HAVE_ATOMIC_FUNCTIONS) */
+#ifdef HAVE_SYNC_FUNCTIONS
+
+/* We have the sync functions but not the atomic functions. Define
+ the atomic ones in terms of the sync ones. */
+
+extern void *backtrace_atomic_load_pointer (void *);
+extern int backtrace_atomic_load_int (int *);
+extern void backtrace_atomic_store_pointer (void *, void *);
+extern void backtrace_atomic_store_size_t (size_t *, size_t);
+extern void backtrace_atomic_store_int (int *, int);
+
+#else /* !defined (HAVE_SYNC_FUNCTIONS) */
+
+/* We have neither the sync nor the atomic functions. These will
+ never be called. */
+
+#define backtrace_atomic_load_pointer(p) (abort(), 0)
+#define backtrace_atomic_load_int(p) (abort(), 0)
+#define backtrace_atomic_store_pointer(p, v) abort()
+#define backtrace_atomic_store_size_t(p, v) abort()
+#define backtrace_atomic_store_int(p, v) abort()
+
+#endif /* !defined (HAVE_SYNC_FUNCTIONS) */
+#endif /* !defined (HAVE_ATOMIC_FUNCTIONS) */
/* The type of the function that collects file/line information. This
is like backtrace_pcinfo. */