diff --git a/tools/profiler/Makefile.in b/tools/profiler/Makefile.in index 55381a9a6bc..9b430997d78 100644 --- a/tools/profiler/Makefile.in +++ b/tools/profiler/Makefile.in @@ -78,7 +78,7 @@ EXTRA_JS_MODULES = \ Profiler.jsm \ $(NULL) -ifeq ($(OS_TARGET),Android) +ifneq (,$(filter Android Linux,$(OS_TARGET))) DEFINES += -DMOZ_ENABLE_PROFILER_SPS diff --git a/tools/profiler/sampler.h b/tools/profiler/sampler.h index 786d9b86d51..e6d5bce8ec6 100644 --- a/tools/profiler/sampler.h +++ b/tools/profiler/sampler.h @@ -86,7 +86,7 @@ #endif // Redefine the macros for platforms where SPS is supported. -#if defined(ANDROID) || defined(XP_MACOSX) || defined(XP_WIN) +#if defined(ANDROID) || defined(XP_LINUX) || defined(XP_MACOSX) || defined(XP_WIN) #include "sps_sampler.h" @@ -106,6 +106,7 @@ #define SAMPLER_GET_RESPONSIVENESS() NULL #define SAMPLE_LABEL(name_space, info) #define SAMPLE_MARKER(info) -#endif #endif + +#endif // ifndef SAMPLER_H diff --git a/tools/profiler/sps/platform-linux.cc b/tools/profiler/sps/platform-linux.cc index 7793e5b04dc..8d4b4d855d1 100644 --- a/tools/profiler/sps/platform-linux.cc +++ b/tools/profiler/sps/platform-linux.cc @@ -47,6 +47,15 @@ #define PATH_MAX_TOSTRING(x) #x #define PATH_MAX_STRING(x) PATH_MAX_TOSTRING(x) +#if defined(__GLIBC__) +// glibc doesn't implement gettid(2). +#include +pid_t gettid() +{ + return (pid_t) syscall(SYS_gettid); +} +#endif + #ifdef ENABLE_SPS_LEAF_DATA /* a crapy version of getline, because it's not included in bionic */ static ssize_t getline(char **lineptr, size_t *n, FILE *stream) @@ -194,7 +203,6 @@ class Sampler::PlatformData : public Malloced { : sampler_(sampler), signal_handler_installed_(false), vm_tgid_(getpid()), - // Glibc doesn't provide a wrapper for gettid(2). vm_tid_(gettid()), signal_sender_launched_(false) { } diff --git a/tools/profiler/sps/sps_sampler.h b/tools/profiler/sps/sps_sampler.h index c3842706636..2bc1c7b8f97 100644 --- a/tools/profiler/sps/sps_sampler.h +++ b/tools/profiler/sps/sps_sampler.h @@ -37,6 +37,7 @@ * ***** END LICENSE BLOCK ***** */ #include +#include #include "thread_helper.h" #include "nscore.h" #include "mozilla/TimeStamp.h"