From 421693f4327e783fe12bda8453752a38a19ec886 Mon Sep 17 00:00:00 2001 From: Paul Floyd Date: Sun, 2 Apr 2023 11:06:18 +0200 Subject: [PATCH] Darwin: add support for setting errno from alloc wrappers --- coregrind/m_replacemalloc/vg_replace_malloc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/coregrind/m_replacemalloc/vg_replace_malloc.c b/coregrind/m_replacemalloc/vg_replace_malloc.c index 5977fa317b..64d9b67c1e 100644 --- a/coregrind/m_replacemalloc/vg_replace_malloc.c +++ b/coregrind/m_replacemalloc/vg_replace_malloc.c @@ -234,6 +234,13 @@ extern int *___errno (void) __attribute__((weak)); (*___errno ()) = VKI_ENOMEM; #define SET_ERRNO_EINVAL if (___errno) \ (*___errno ()) = VKI_EINVAL; +#elif defined(VGO_darwin) +extern int * __error(void) __attribute__((weak)); +#define SET_ERRNO_ENOMEM if (__error) \ + (*__error ()) = VKI_ENOMEM; +#define SET_ERRNO_EINVAL if (__error) \ + (*__error ()) = VKI_EINVAL; + #else #define SET_ERRNO_ENOMEM {} #define SET_ERRNO_EINVAL {} -- 2.43.5