Skip to content

Commit

Permalink
arm: libbacktrace: Check if the compiler supports __sync atomics
Browse files Browse the repository at this point in the history
Older versions of the Arm architecture lack support for __sync
operations directly in hardware and require calls into appropriate
operating-system hooks.  But such hooks obviously don't exist in a
freestanding environment.

Consquently, it is incorrect to assume during configure that such
functions will exist and we need a configure-time check to determine
whether or not these routines will work.

libbacktrace:

	* configure.ac: Always check if the compiler supports __sync
	operations.
	* configure: Regenerated.
  • Loading branch information
Richard Earnshaw authored and ianlancetaylor committed Jan 30, 2025
1 parent 1db8564 commit 5da31b9
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
23 changes: 23 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -12209,6 +12209,29 @@ else
if test -n "${with_target_subdir}"; then
case "${host}" in
hppa*-*-hpux*) libbacktrace_cv_sys_sync=no ;;
arm*-*-eabi*)
# Older versions of the Arm architecture lack the necessary instructions
# for these constructs, so check whether we can use them.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int i;
int
main ()
{
__sync_bool_compare_and_swap (&i, i, i);
__sync_lock_test_and_set (&i, 1);
__sync_lock_release (&i);
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
libbacktrace_cv_sys_sync=yes
else
libbacktrace_cv_sys_sync=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext;;
*) libbacktrace_cv_sys_sync=yes ;;
esac
else
Expand Down
10 changes: 10 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ AC_CACHE_CHECK([__sync extensions],
[if test -n "${with_target_subdir}"; then
case "${host}" in
hppa*-*-hpux*) libbacktrace_cv_sys_sync=no ;;
arm*-*-eabi*)
# Older versions of the Arm architecture lack the necessary instructions
# for these constructs, so check whether we can use them.
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([int i;],
[__sync_bool_compare_and_swap (&i, i, i);
__sync_lock_test_and_set (&i, 1);
__sync_lock_release (&i);])],
[libbacktrace_cv_sys_sync=yes],
[libbacktrace_cv_sys_sync=no]);;
*) libbacktrace_cv_sys_sync=yes ;;
esac
else
Expand Down

0 comments on commit 5da31b9

Please sign in to comment.