Commit 008075ca authored by Michael Lee's avatar Michael Lee Committed by Facebook Github Bot

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
parent c495dd26
...@@ -124,11 +124,15 @@ namespace folly { ...@@ -124,11 +124,15 @@ namespace folly {
// Cannot depend on Portability.h when _LIBSTDCXX_FBSTRING. // Cannot depend on Portability.h when _LIBSTDCXX_FBSTRING.
#if defined(__GNUC__) #if defined(__GNUC__)
#define FOLLY_MALLOC_NOINLINE __attribute__((__noinline__)) #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 // This is for checked malloc-like functions (returns non-null pointer
// which cannot alias any outstanding pointer). // which cannot alias any outstanding pointer).
#define FOLLY_MALLOC_CHECKED_MALLOC \ #define FOLLY_MALLOC_CHECKED_MALLOC \
__attribute__((__returns_nonnull__, __malloc__)) __attribute__((__returns_nonnull__, __malloc__))
#else #else
#define FOLLY_MALLOC_CHECKED_MALLOC __attribute__((__malloc__))
#endif
#else
#define FOLLY_MALLOC_NOINLINE #define FOLLY_MALLOC_NOINLINE
#define FOLLY_MALLOC_CHECKED_MALLOC #define FOLLY_MALLOC_CHECKED_MALLOC
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment