From: Michael Lee Date: Wed, 5 Oct 2016 23:15:02 +0000 (-0700) Subject: Gate `__returns_nonnull__` attribute to gcc 4.9 or later X-Git-Tag: v2016.10.10.00~10 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=008075cac3e70a06a7d15c7f808638685462e289;p=folly.git 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 --- 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