473745 must-be-redirected function - strlen
473870 FreeBSD 14 applications fail early at startup
473944 Handle mold linker split RW PT_LOAD segments correctly
+474332 aligned_alloc under Valgrind returns nullptr when alignment is not a multiple of sizeof(void *)
n-i-bz Allow arguments with spaces in .valgrindrc files
To see details of a given bug, visit
AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
[test x$ac_have_shared_pointer_annotation = xyes])
+# checking for GNU libc C17 aligned_alloc
+# just check glibc version rather than trying to muck around
+# checking the runtime behaviour or seeing if it is a weak alias
+AC_MSG_CHECKING([for AT_GNU_LIBC_C17_ALIGNED_ALLOC])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <features.h>
+]], [[
+#if !defined(__GLIBC__) || __GLIBC__ != 2 || !defined(__GLIBC_MINOR__) || __GLIBC_MINOR__ < 38
+#error "not GNU libc 2.38 or later"
+#endif
+]])], [
+ AC_MSG_RESULT([yes])
+ AC_DEFINE([HAVE_GNU_LIBC_C17_ALIGNED_ALLOC], 1,
+ [Define to 1 if you have GNU libc C17 aligned_alloc.])
+
+], [
+ AC_MSG_RESULT([no])
+])
+
+
#----------------------------------------------------------------------------
# Ok. We're done checking.
#define VG_ALIGNED_ALLOC_NO_SIZE_ZERO 1
#endif
-#if defined (VGO_linux) && !defined(MUSL_LIBC)
+#if defined (VGO_linux) && !defined(MUSL_LIBC) && !defined(HAVE_GNU_LIBC_C17_ALIGNED_ALLOC)
+
+/*
+ * Normally for GNU libc <= 2.37 aligned_alloc is a weak alias for memalign
+ * so this redir is not used.
+ * For libc 2.38 and later it is a separate function but then HAVE_GNU_LIBC_C17_ALIGNED_ALLOC
+ * should be true and this version doesn't get compiled.
+ * Leaving it here to be on the safe side.
+ */
#define ALIGNED_ALLOC(soname, fnname) \
\
VERIFY_ALIGNMENT(&aligned_alloc_info); \
MALLOC_TRACE("aligned_alloc(al %llu, size %llu)", \
(ULong)alignment, (ULong)size ); \
- /* Test whether the alignment argument is valid. It must be \
- a power of two multiple of sizeof (void *). */ \
- if (alignment == 0 \
- || alignment % sizeof (void *) != 0 \
- || (alignment & (alignment - 1)) != 0) \
- return 0; \
+ \
+ /* Round up to minimum alignment if necessary. */ \
+ if (alignment < VG_MIN_MALLOC_SZB) \
+ alignment = VG_MIN_MALLOC_SZB; \
+ \
+ /* Round up to nearest power-of-two if necessary (like glibc). */ \
+ while (0 != (alignment & (alignment - 1))) alignment++; \
\
mem = (void*)VALGRIND_NON_SIMD_CALL3( info.tl_memalign, \
alignment, orig_alignment, size ); \