X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Ftrace_writer_local.cpp;h=feb5c912dfd06b2a61f2a003f9f9759bc23255e0;hb=93d51c3065260cdb088f33d3e6d5bdfb4707c1a9;hp=a3ab720b2dd13f9c89536e4905ed63981ead0b2f;hpb=a9d7f8edfea904f8dc84f2ad472cd542437935f7;p=apitrace diff --git a/common/trace_writer_local.cpp b/common/trace_writer_local.cpp index a3ab720..feb5c91 100644 --- a/common/trace_writer_local.cpp +++ b/common/trace_writer_local.cpp @@ -89,7 +89,11 @@ LocalWriter::open(void) { #endif process.trimDirectory(); - os::String prefix = os::getCurrentDir(); +#ifdef ANDROID + os::String prefix = "/data"; +#else + os::String prefix = os::getCurrentDir(); +#endif prefix.join(process); for (;;) { @@ -124,8 +128,8 @@ LocalWriter::open(void) { #endif } -static unsigned next_thread_id = 0; -static os::thread_specific_ptr thread_id_specific_ptr; +static unsigned next_thread_num = 1; +static thread_specific unsigned thread_num = 0; unsigned LocalWriter::beginEnter(const FunctionSig *sig) { mutex.lock(); @@ -135,17 +139,13 @@ unsigned LocalWriter::beginEnter(const FunctionSig *sig) { open(); } - unsigned *thread_id_ptr = thread_id_specific_ptr.get(); - unsigned thread_id; - if (thread_id_ptr) { - thread_id = *thread_id_ptr; - } else { - thread_id = next_thread_id++; - thread_id_ptr = new unsigned; - *thread_id_ptr = thread_id; - thread_id_specific_ptr.reset(thread_id_ptr); + unsigned this_thread_num = thread_num; + if (!this_thread_num) { + this_thread_num = thread_num = next_thread_num++; } + assert(thread_num > 0); + unsigned thread_id = thread_num - 1; return Writer::beginEnter(sig, thread_id); }