Use a macro instead of direct noinline attributes.

This is a prerequisite of MSVC support, as it uses a different syntax.
This commit is contained in:
Zsolt Parragi 2019-08-24 12:06:34 +02:00
parent 7cf5ece17d
commit 4dfd5e6e24
3 changed files with 8 additions and 9 deletions

View File

@ -65,6 +65,8 @@
#endif #endif
#endif #endif
#define NOINLINE __attribute__((noinline))
#include <algorithm> #include <algorithm>
#include <cctype> #include <cctype>
#include <cstdio> #include <cstdio>
@ -710,9 +712,8 @@ template <typename F> size_t unwind(F f, size_t depth) {
template <> template <>
class StackTraceImpl<system_tag::current_tag> : public StackTraceImplHolder { class StackTraceImpl<system_tag::current_tag> : public StackTraceImplHolder {
public: public:
__attribute__((noinline)) // TODO use some macro NOINLINE
size_t size_t load_here(size_t depth = 32) {
load_here(size_t depth = 32) {
load_thread_info(); load_thread_info();
if (depth == 0) { if (depth == 0) {
return 0; return 0;
@ -751,9 +752,8 @@ private:
template <> template <>
class StackTraceImpl<system_tag::current_tag> : public StackTraceImplHolder { class StackTraceImpl<system_tag::current_tag> : public StackTraceImplHolder {
public: public:
__attribute__((noinline)) // TODO use some macro NOINLINE
size_t size_t load_here(size_t depth = 32) {
load_here(size_t depth = 32) {
load_thread_info(); load_thread_info();
if (depth == 0) { if (depth == 0) {
return 0; return 0;

View File

@ -50,8 +50,7 @@ namespace titi {
struct foo { struct foo {
union bar { union bar {
__attribute__((noinline)) static int trampoline(stacktrace_t &st, NOINLINE static int trampoline(stacktrace_t &st, int level) {
int level) {
return rec(st, level); return rec(st, level);
} }
}; };

View File

@ -43,7 +43,7 @@ void c(StackTrace &st) { return d(st); }
void b(StackTrace &st) { return c(st); } void b(StackTrace &st) { return c(st); }
__attribute__((noinline)) void a(StackTrace &st) { return b(st); } NOINLINE void a(StackTrace &st) { return b(st); }
TEST(smalltrace) { TEST(smalltrace) {
StackTrace st; StackTrace st;