From a708bebbfd33db44fc80b1d363608d33a588ddd7 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 27 Jan 2019 13:41:32 +0100 Subject: [PATCH] Use language neutral header for callstack capability detection. This fixes call stack collection in C API when TRACY_CALLSTACK is defined. --- TracyC.h | 2 ++ client/TracyCallstack.h | 16 ++++++++++++++++ client/TracyCallstack.hpp | 18 ++++++------------ 3 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 client/TracyCallstack.h diff --git a/TracyC.h b/TracyC.h index d4e34053..786e72af 100644 --- a/TracyC.h +++ b/TracyC.h @@ -4,6 +4,8 @@ #include #include +#include "client/TracyCallstack.h" + #ifdef __cplusplus extern "C" { #endif diff --git a/client/TracyCallstack.h b/client/TracyCallstack.h new file mode 100644 index 00000000..8b84e7f3 --- /dev/null +++ b/client/TracyCallstack.h @@ -0,0 +1,16 @@ +#ifndef __TRACYCALLSTACK_H__ +#define __TRACYCALLSTACK_H__ + +#if defined _WIN32 || defined __CYGWIN__ +# define TRACY_HAS_CALLSTACK 1 +#elif defined __ANDROID__ +# define TRACY_HAS_CALLSTACK 2 +#elif defined __linux +# if defined _GNU_SOURCE && defined __GLIBC__ +# define TRACY_HAS_CALLSTACK 3 +# else +# define TRACY_HAS_CALLSTACK 2 +# endif +#endif + +#endif diff --git a/client/TracyCallstack.hpp b/client/TracyCallstack.hpp index 8b61c5ec..b4b2c017 100644 --- a/client/TracyCallstack.hpp +++ b/client/TracyCallstack.hpp @@ -1,24 +1,18 @@ #ifndef __TRACYCALLSTACK_HPP__ #define __TRACYCALLSTACK_HPP__ -#if defined _WIN32 || defined __CYGWIN__ -# define TRACY_HAS_CALLSTACK 1 +#include "TracyCallstack.h" + +#if TRACY_HAS_CALLSTACK == 1 extern "C" { typedef unsigned long (__stdcall *t_RtlWalkFrameChain)( void**, unsigned long, unsigned long ); extern t_RtlWalkFrameChain RtlWalkFrameChain; } -#elif defined __ANDROID__ -# define TRACY_HAS_CALLSTACK 2 +#elif TRACY_HAS_CALLSTACK == 2 # include -#elif defined __linux -# if defined _GNU_SOURCE && defined __GLIBC__ -# define TRACY_HAS_CALLSTACK 3 -# include -# else -# define TRACY_HAS_CALLSTACK 2 -# include -# endif +#elif TRACY_HAS_CALLSTACK == 3 +# include #endif