aboutsummaryrefslogtreecommitdiff
path: root/src/armnnUtils
diff options
context:
space:
mode:
Diffstat (limited to 'src/armnnUtils')
-rw-r--r--src/armnnUtils/Threads.cpp31
-rw-r--r--src/armnnUtils/Threads.hpp16
2 files changed, 47 insertions, 0 deletions
diff --git a/src/armnnUtils/Threads.cpp b/src/armnnUtils/Threads.cpp
new file mode 100644
index 0000000000..561edcb8b7
--- /dev/null
+++ b/src/armnnUtils/Threads.cpp
@@ -0,0 +1,31 @@
+//
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#include "Threads.hpp"
+
+#if defined(__linux__)
+#include <unistd.h>
+#include <sys/syscall.h>
+#define gettid() syscall(SYS_gettid)
+#elif defined(_MSC_VER)
+#include "WindowsWrapper.hpp"
+#endif
+
+namespace armnnUtils
+{
+namespace Threads
+{
+
+int GetCurrentThreadId()
+{
+#if defined(__linux__)
+ return static_cast<int>(gettid());
+#elif defined(_MSC_VER)
+ return ::GetCurrentThreadId();
+#endif
+}
+
+}
+}
diff --git a/src/armnnUtils/Threads.hpp b/src/armnnUtils/Threads.hpp
new file mode 100644
index 0000000000..4cecfd5079
--- /dev/null
+++ b/src/armnnUtils/Threads.hpp
@@ -0,0 +1,16 @@
+//
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+namespace armnnUtils
+{
+namespace Threads
+{
+
+int GetCurrentThreadId();
+
+}
+}