Commit 2c2e0f6e authored by Elizabeth Smith's avatar Elizabeth Smith Committed by Sara Golemon

MSVC always_inline and noinline __attributes__ translation

Summary:
Provide translations for gcc always_inline and noinline attribute

Change to using a macro from portability.h for attributes for using always_inline and noinline for cross platform support

Test Plan: fbmake runtests

Reviewed By: delong.j@fb.com

FB internal diff: D1279652
parent 30a71566
......@@ -50,6 +50,23 @@ struct MaxAlign { char c; } __attribute__((aligned));
# define FOLLY_NORETURN
#endif
// noinline
#ifdef _MSC_VER
# define FOLLY_NOINLINE __declspec(noinline)
#elif defined(__clang__) || defined(__GNUC__)
# define FOLLY_NOINLINE __attribute__((noinline))
#else
# define FOLLY_NOINLINE
#endif
// always inline
#ifdef _MSC_VER
# define FOLLY_ALWAYS_INLINE __forceinline
#elif defined(__clang__) || defined(__GNUC__)
# define FOLLY_ALWAYS_INLINE inline __attribute__((always_inline))
#else
# define FOLLY_ALWAYS_INLINE
#endif
// portable version check
#ifndef __GNUC_PREREQ
......
......@@ -130,7 +130,7 @@ static void fetchStackLimits() {
assert((tls_stackLimit & (s_pageSize - 1)) == 0);
}
static __attribute__((noinline)) uintptr_t getStackPtr() {
FOLLY_NOINLINE static uintptr_t getStackPtr() {
char marker;
auto rv = uintptr_t(&marker);
return rv;
......
......@@ -96,7 +96,7 @@ extern "C" StackTraceStack* getExceptionStackTraceStack() {
namespace {
// Make sure we're counting stack frames correctly, don't inline.
void addActiveException() __attribute__((noinline));
FOLLY_NOINLINE void addActiveException();
void addActiveException() {
pthread_once(&initialized, initialize);
......
......@@ -198,7 +198,7 @@ constexpr size_t kDefaultCapacity = 500;
auto gSignalSafeElfCache = new SignalSafeElfCache(kDefaultCapacity);
} // namespace
void dumpStackTrace(bool symbolize) __attribute__((noinline));
FOLLY_NOINLINE void dumpStackTrace(bool symbolize);
void dumpStackTrace(bool symbolize) {
SCOPE_EXIT { fsyncNoInt(STDERR_FILENO); };
......
......@@ -91,14 +91,14 @@ bool fixFrameArray(FrameArray<N>& fa, ssize_t n) {
// Always inline these functions; they don't do much, and unittests rely
// on them never showing up in a stack trace.
template <size_t N>
inline bool getStackTrace(FrameArray<N>& fa) __attribute__((always_inline));
FOLLY_ALWAYS_INLINE bool getStackTrace(FrameArray<N>& fa);
template <size_t N>
inline bool getStackTrace(FrameArray<N>& fa) {
return detail::fixFrameArray(fa, getStackTrace(fa.addresses, N));
}
template <size_t N>
inline bool getStackTraceSafe(FrameArray<N>& fa) __attribute__((always_inline));
FOLLY_ALWAYS_INLINE bool getStackTraceSafe(FrameArray<N>& fa);
template <size_t N>
inline bool getStackTraceSafe(FrameArray<N>& fa) {
......
......@@ -23,8 +23,8 @@
using namespace folly;
using namespace folly::symbolizer;
void foo1() __attribute__((noinline));
void foo2() __attribute__((noinline));
FOLLY_NOINLINE void foo1();
FOLLY_NOINLINE void foo2();
void verifyStackTraces() {
constexpr size_t kMaxAddresses = 100;
......
......@@ -55,7 +55,7 @@ int comparator(const void* ap, const void* bp) {
}
// Test stack frames...
void bar() __attribute__((noinline));
FOLLY_NOINLINE void bar();
void bar() {
int a[2] = {1, 2};
......
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