Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jesswong committed Dec 2, 2024
1 parent 1f1289d commit 8370068
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion include/unifex/tracing/async_stack-inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ inline AsyncStackFrame* AsyncStackRoot::getTopFrame() const noexcept {
}

inline void AsyncStackRoot::setStackFrameContext(
frame_ptr framePtr, instruction_ptr ip, uint64_t tId) noexcept {
frame_ptr framePtr, instruction_ptr ip, std::uint64_t tId) noexcept {
stackFramePtr = framePtr;
returnAddress = ip;
threadId = tId;
Expand Down
18 changes: 3 additions & 15 deletions include/unifex/tracing/async_stack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,6 @@
#include <thread>

#include <unifex/detail/prologue.hpp>
#if defined(__linux__)
#include <unistd.h>
#include <sys/syscall.h>
#endif

#if defined(__APPLE__)
#define UNIFEX_SYS_gettid SYS_thread_selfid
#elif defined(SYS_gettid)
#define UNIFEX_SYS_gettid SYS_gettid
#else
#define UNIFEX_SYS_gettid __NR_gettid
#endif

namespace unifex {

Expand Down Expand Up @@ -165,7 +153,7 @@ class ScopedAsyncStackRoot;
} // namespace detail

namespace utils {
uint64_t getOSThreadID();
uint64_t get_os_thread_id();
} // namespace utils

// Get access to the current thread's top-most AsyncStackRoot.
Expand Down Expand Up @@ -471,7 +459,7 @@ struct AsyncStackRoot {
void setStackFrameContext(
frame_ptr fp = frame_ptr::read_frame_pointer(),
instruction_ptr ip = instruction_ptr::read_return_address(),
uint64_t tId = utils::getOSThreadID()) noexcept;
std::uint64_t tId = utils::get_os_thread_id()) noexcept;
frame_ptr getStackFramePointer() const noexcept;
instruction_ptr getReturnAddress() const noexcept;

Expand Down Expand Up @@ -518,7 +506,7 @@ struct AsyncStackRoot {
// Typically initialise with instruction_ptr::read_return_address() or
// setStackFrameContext().
instruction_ptr returnAddress;
uint64_t threadId = 0;
std::uint64_t threadId = 0;
};

namespace detail {
Expand Down
10 changes: 6 additions & 4 deletions source/async_stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

#if defined(_WIN32)
#include <windows.h>
#elif defined(__linux__)
#include <unistd.h>
#endif

#if !defined(UNIFEX_ASYNC_STACK_ROOT_USE_PTHREAD)
Expand Down Expand Up @@ -150,15 +152,15 @@ static thread_local AsyncStackRootHolder currentThreadAsyncStackRoot;
} // namespace

namespace utils {
uint64_t getOSThreadID() {
std::uint64_t get_os_thread_id() {
#if defined(__APPLE__)
uint64_t tid;
std::uint64_t tid;
pthread_threadid_np(nullptr, &tid);
return tid;
#elif defined(_WIN32)
return uint64_t(GetCurrentThreadId());
return std::uint64_t(GetCurrentThreadId());
#else
return uint64_t(syscall(UNIFEX_SYS_gettid));
return std::uint64_t(gettid())
#endif
}
}
Expand Down

0 comments on commit 8370068

Please sign in to comment.