summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2025-12-02 17:24:43 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2025-12-02 17:46:56 -0800
commit1b2b433fc0a62db933399eb37c8cae73e0446e86 (patch)
treed9e0b677729ef3dc32ae7be55889df75e982af37 /configure.ac
parent3930d12e4dcb2d79d70c3aa8a199aec0340d0b39 (diff)
Port to GNU/Linux HPPA malloc
On this platform, you cannot reliably malloc objects containing values of type pthread_mutex_t or pthread_cond_t, since malloc guarantees only 8-byte alignment but these two types require 16-byte alignment. See GCC bug 115750 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115750> reported by Sam James and Emacs bug 79936 <https://bugs.gnu.org/79936> reported by John Paul Adrian Glaubitz. * configure.ac (ALIGNOF_MAX_ALIGN_T, ALIGNOF_PTHREAD_COND_T) (ALIGNOF_PTHREAD_MUTEX_T) [HAVE_PTHREAD]: New C macros. * src/systhread.c (sys_mutex_init, sys_mutex_lock) (sys_mutex_unlock, sys_cond_init, sys_cond_wait) (sys_cond_signal, sys_cond_broadcast, sys_cond_destroy): Use SYTHREAD_ALIGN_PTR to convert sys_mutex_t and sys_cond_t to pthread_mutex_t and pthread_cond_t, since runtime conversion is needed on GNU/Linux HPPA. * src/systhread.h (SYSTHREAD_ALIGN_ROOM, SYSTHREAD_ALIGN_PTR): New macros, which affect the generated code only on unusual platforms like GNU/Linux HPPA. (sys_mutex_t, sys_cond_t) [HAVE_PTHREAD]: Use them.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac6
1 files changed, 6 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 39f1fb10091..d17dbfa4358 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3425,6 +3425,12 @@ if test "$ac_cv_header_pthread_h" && test "$opsys" != "mingw32"; then
done])
if test "$emacs_cv_pthread_lib" != no; then
AC_DEFINE([HAVE_PTHREAD], [1], [Define to 1 if you have POSIX threads.])
+ m4_foreach([emacs_type],
+ [[max_align_t], [pthread_cond_t], [pthread_mutex_t]],
+ [AC_CHECK_ALIGNOF(emacs_type,
+ [[#include <stddef.h>
+ #include <pthread.h>
+ ]])])
case $emacs_cv_pthread_lib in
-*) LIB_PTHREAD=$emacs_cv_pthread_lib;;
esac