From 008075cac3e70a06a7d15c7f808638685462e289 Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Wed, 5 Oct 2016 16:15:02 -0700 Subject: [PATCH] Gate `__returns_nonnull__` attribute to gcc 4.9 or later Summary: The attribute `__returns_nonnull__` is only applicable for gcc 4.9 or later (https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/Function-Attributes.html#Function-Attributes) Reviewed By: ot Differential Revision: D3976598 fbshipit-source-id: 3c678a11c5046e5a8b7686327dbb3ebc9b598616 --- folly/Malloc.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/folly/Malloc.h b/folly/Malloc.h index de75e451..3aeb765c 100644 --- a/folly/Malloc.h +++ b/folly/Malloc.h @@ -124,11 +124,15 @@ namespace folly { // Cannot depend on Portability.h when _LIBSTDCXX_FBSTRING. #if defined(__GNUC__) #define FOLLY_MALLOC_NOINLINE __attribute__((__noinline__)) +#if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL) >= 40900 // This is for checked malloc-like functions (returns non-null pointer // which cannot alias any outstanding pointer). #define FOLLY_MALLOC_CHECKED_MALLOC \ __attribute__((__returns_nonnull__, __malloc__)) #else +#define FOLLY_MALLOC_CHECKED_MALLOC __attribute__((__malloc__)) +#endif +#else #define FOLLY_MALLOC_NOINLINE #define FOLLY_MALLOC_CHECKED_MALLOC #endif -- 2.34.1