From 5730f94366fba1d4f44b8369b6af9deec93cadb7 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Fri, 5 Aug 2022 19:41:21 +0100 Subject: [PATCH 1/2] annotate `alloc` on unixes. --- src/snmalloc/mem/localalloc.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/snmalloc/mem/localalloc.h b/src/snmalloc/mem/localalloc.h index 592625eb5..dc5390e51 100644 --- a/src/snmalloc/mem/localalloc.h +++ b/src/snmalloc/mem/localalloc.h @@ -1,7 +1,9 @@ #pragma once -#ifdef _MSC_VER -# define ALLOCATOR __declspec(allocator) +#if defined(_MSC_VER) +# define ALLOCATOR __declspec(allocator) __declspec(restrict) +#elif defined(__GNUC__) +# define ALLOCATOR __attribute__((__malloc__)) #else # define ALLOCATOR #endif From 2138a95e68c338a047261bab9fe0065c8546674e Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sat, 6 Aug 2022 13:35:04 +0100 Subject: [PATCH 2/2] changes from feedback --- src/snmalloc/mem/localalloc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/snmalloc/mem/localalloc.h b/src/snmalloc/mem/localalloc.h index dc5390e51..2fca90949 100644 --- a/src/snmalloc/mem/localalloc.h +++ b/src/snmalloc/mem/localalloc.h @@ -2,8 +2,8 @@ #if defined(_MSC_VER) # define ALLOCATOR __declspec(allocator) __declspec(restrict) -#elif defined(__GNUC__) -# define ALLOCATOR __attribute__((__malloc__)) +#elif __has_attribute(malloc) +# define ALLOCATOR __attribute__((malloc)) #else # define ALLOCATOR #endif