summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTim Rowley <[email protected]>2017-07-24 16:12:52 -0500
committerTim Rowley <[email protected]>2017-08-02 11:39:33 -0500
commite1091b08615d947b7ac6d6b97bf443b26edd2712 (patch)
treee5f512cc50c5f30dd0bf1e2620aef522d84d0edc /src
parent95c6a97464e7baaca6e09f829da0be5ac8c50297 (diff)
swr/rast: threadID via portable std::this_thread::get_id()
Replace use of Win32 GetCurrentThreadId() with portable std::this_thread::get_id(). Reviewed-by: Bruce Cherniak <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp
index 9017e8dc7d8..0ca9a7828db 100644
--- a/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp
+++ b/src/gallium/drivers/swr/rasterizer/codegen/templates/gen_ar_eventhandlerfile.hpp
@@ -36,6 +36,7 @@
#include "${event_header}"
#include <fstream>
#include <sstream>
+#include <thread>
namespace ArchRast
{
@@ -56,21 +57,22 @@ namespace ArchRast
std::stringstream outDir;
outDir << KNOB_DEBUG_OUTPUT_DIR << pBaseName << "_" << pid << std::ends;
CreateDirectory(outDir.str().c_str(), NULL);
-
- char buf[255];
+
// There could be multiple threads creating thread pools. We
// want to make sure they are uniquly identified by adding in
// the creator's thread id into the filename.
- sprintf(buf, "%s\\ar_event%d_%d.bin", outDir.str().c_str(), GetCurrentThreadId(), id);
- mFilename = std::string(buf);
+ std::stringstream fstr;
+ fstr << outDir.str().c_str() << "\\ar_event" << std::this_thread::get_id();
+ fstr << "_" << id << ".bin" << std::ends;
+ mFilename = fstr.str();
#else
- char buf[255];
// There could be multiple threads creating thread pools. We
// want to make sure they are uniquly identified by adding in
- // the creator's thread (process) id into the filename.
- // Assumes a 1:1 thread:LWP mapping as in linux.
- sprintf(buf, "%s/ar_event%d_%d.bin", "/tmp", GetCurrentProcessId(), id);
- mFilename = std::string(buf);
+ // the creator's thread id into the filename.
+ std::stringstream fstr;
+ fstr << "/tmp/ar_event" << std::this_thread::get_id();
+ fstr << "_" << id << ".bin" << std::ends;
+ mFilename = fstr.str();
#endif
}