diff --git a/starboard/nplb/thread_sampler_test.cc b/starboard/nplb/thread_sampler_test.cc index 4f105fd6871e..37b8d0967cd5 100644 --- a/starboard/nplb/thread_sampler_test.cc +++ b/starboard/nplb/thread_sampler_test.cc @@ -18,7 +18,7 @@ #include "starboard/common/atomic.h" #include "starboard/common/log.h" #include "starboard/common/time.h" -#include "starboard/nplb/thread_helpers.h" +#include "starboard/nplb/posix_compliance/posix_thread_helpers.h" #include "starboard/thread.h" #include "testing/gtest/include/gtest/gtest.h" @@ -26,7 +26,7 @@ namespace starboard { namespace nplb { namespace { -class CountingThread : public AbstractTestThread { +class CountingThread : public posix::AbstractTestThread { public: ~CountingThread() { Stop(); } @@ -64,7 +64,11 @@ TEST(ThreadSamplerTest, RainyDayCreateSamplerInvalidThread) { // Creating a sampler for an invalid thread should not succeed, and even // without without calling |SbThreadSamplerDelete| ASAN should not detect a // memory leak. +#if SB_API_VERSION < 16 SbThreadSampler sampler = SbThreadSamplerCreate(kSbThreadInvalid); +#else + SbThreadSampler sampler = SbThreadSamplerCreate(0); +#endif EXPECT_FALSE(SbThreadSamplerIsValid(sampler)); } diff --git a/starboard/shared/pthread/thread_sampler_create.cc b/starboard/shared/pthread/thread_sampler_create.cc index 6d6bbfafed8c..7d930c28b94a 100644 --- a/starboard/shared/pthread/thread_sampler_create.cc +++ b/starboard/shared/pthread/thread_sampler_create.cc @@ -14,8 +14,8 @@ #include "starboard/shared/pthread/thread_sampler_internal.h" -SbThreadSampler SbThreadSamplerCreate(SbThread thread) { - if (!SbThreadIsValid(thread)) { +SbThreadSampler SbThreadSamplerCreate(pthread_t thread) { + if (thread == 0) { return kSbThreadSamplerInvalid; } return new SbThreadSamplerPrivate(thread); diff --git a/starboard/shared/pthread/thread_sampler_internal.cc b/starboard/shared/pthread/thread_sampler_internal.cc index 741723357af9..282ae02dc2cc 100644 --- a/starboard/shared/pthread/thread_sampler_internal.cc +++ b/starboard/shared/pthread/thread_sampler_internal.cc @@ -14,6 +14,7 @@ #include "starboard/shared/pthread/thread_sampler_internal.h" +#include #include #include @@ -129,7 +130,7 @@ void SignalHandler::HandleProfilerSignal(int signal, } // namespace -SbThreadSamplerPrivate::SbThreadSamplerPrivate(SbThread thread) +SbThreadSamplerPrivate::SbThreadSamplerPrivate(pthread_t thread) : thread_(thread) { SignalHandler::AddSampler(); } diff --git a/starboard/shared/pthread/thread_sampler_internal.h b/starboard/shared/pthread/thread_sampler_internal.h index 2fa9ec6f996f..11fddf3623c5 100644 --- a/starboard/shared/pthread/thread_sampler_internal.h +++ b/starboard/shared/pthread/thread_sampler_internal.h @@ -15,20 +15,21 @@ #ifndef STARBOARD_SHARED_PTHREAD_THREAD_SAMPLER_INTERNAL_H_ #define STARBOARD_SHARED_PTHREAD_THREAD_SAMPLER_INTERNAL_H_ +#include + #include "starboard/thread.h" class SbThreadSamplerPrivate { public: - explicit SbThreadSamplerPrivate(SbThread thread); + explicit SbThreadSamplerPrivate(pthread_t thread); ~SbThreadSamplerPrivate(); SbThreadContext Freeze(); bool Thaw(); - - SbThread thread() { return thread_; } + pthread_t thread() { return thread_; } private: - SbThread thread_; + pthread_t thread_; }; #endif // STARBOARD_SHARED_PTHREAD_THREAD_SAMPLER_INTERNAL_H_ diff --git a/starboard/thread.h b/starboard/thread.h index 92d2650ac76c..18d9807a8df5 100644 --- a/starboard/thread.h +++ b/starboard/thread.h @@ -19,6 +19,8 @@ #ifndef STARBOARD_THREAD_H_ #define STARBOARD_THREAD_H_ +#include + #include "starboard/configuration.h" #include "starboard/export.h" #include "starboard/types.h" @@ -333,7 +335,7 @@ SB_EXPORT bool SbThreadSamplerIsSupported(); // // If successful, this function returns the newly created handle. // If unsuccessful, this function returns |kSbThreadSamplerInvalid|. -SB_EXPORT SbThreadSampler SbThreadSamplerCreate(SbThread thread); +SB_EXPORT SbThreadSampler SbThreadSamplerCreate(pthread_t thread); // Destroys the |sampler| and frees whatever resources it was using. SB_EXPORT void SbThreadSamplerDestroy(SbThreadSampler sampler); diff --git a/v8/src/libsampler/sampler.cc b/v8/src/libsampler/sampler.cc index f1785bc999c3..e29d2d80f869 100644 --- a/v8/src/libsampler/sampler.cc +++ b/v8/src/libsampler/sampler.cc @@ -176,7 +176,7 @@ namespace sampler { class Sampler::PlatformData { public: PlatformData() - : thread_(SbThreadGetCurrent()), + : thread_(pthread_self()), thread_sampler_(kSbThreadSamplerInvalid) {} ~PlatformData() { ReleaseThreadSampler(); } @@ -195,7 +195,7 @@ class Sampler::PlatformData { } private: - SbThread thread_; + pthread_t thread_; SbThreadSampler thread_sampler_; };