+ // Although thread_num is a void *, we actually use it as a uintptr_t
+ uintptr_t this_thread_num =
+ reinterpret_cast<uintptr_t>(static_cast<void *>(thread_num));
+ if (!this_thread_num) {
+ this_thread_num = next_thread_num++;
+ thread_num = reinterpret_cast<void *>(this_thread_num);
+ }
+
+ assert(this_thread_num);
+ unsigned thread_id = this_thread_num - 1;
+ unsigned call_no = Writer::beginEnter(sig, thread_id);
+ if (!fake && os::backtrace_is_needed(sig->name)) {
+ std::vector<RawStackFrame> backtrace = os::get_backtrace();
+ beginBacktrace(backtrace.size());
+ for (unsigned i = 0; i < backtrace.size(); ++i) {
+ writeStackFrame(&backtrace[i]);
+ }
+ endBacktrace();
+ }
+ return call_no;