]> sourceware.org Git - valgrind.git/commitdiff
Darwin: try to improve posix_memalign / zone_memalign wrapper
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 1 Apr 2023 20:28:36 +0000 (22:28 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 1 Apr 2023 20:28:36 +0000 (22:28 +0200)
It still doesn't set errno though.

coregrind/m_replacemalloc/vg_replace_malloc.c

index db2fc5f30907055051ef3643f85f95aacaf3e98d..5977fa317b698437efa092173f822e1417249942 100644 (file)
@@ -1575,7 +1575,8 @@ extern int *___errno (void) __attribute__((weak));
   *
   */
 
- /* @todo PJF exactly what is the behaviour if this? */
+ /* Probably in the wrong place, this is the function
+ called by posix_memalign, at least on macOS 10.13 */
 #define ZONEMEMALIGN(soname, fnname) \
    \
    void* VG_REPLACE_FUNCTION_EZU(10100,soname,fnname) \
@@ -1591,6 +1592,12 @@ extern int *___errno (void) __attribute__((weak));
       MALLOC_TRACE("zone_memalign(%p, al %llu, size %llu)", \
                    zone, (ULong)alignment, (ULong)n );  \
       \
+      if (alignment == 0 \
+          || alignment % sizeof (void *) != 0 \
+          || (alignment & (alignment - 1)) != 0) { \
+         SET_ERRNO_EINVAL; \
+         return NULL; \
+      } \
       /* Round up to minimum alignment if necessary. */ \
       if (alignment < VG_MIN_MALLOC_SZB) \
          alignment = VG_MIN_MALLOC_SZB; \
This page took 0.034425 seconds and 5 git commands to generate.