IVGCVSW-6852 Break the remaining dependencies on Arm NN in the profiling code

Change-Id: I18b8ca22896567904768170350ee5eb22edd4a22
Signed-off-by: Jim Flynn <jim.flynn@arm.com>
diff --git a/profiling/common/include/Processes.hpp b/profiling/common/include/Processes.hpp
index cc59d8b..0a15368 100644
--- a/profiling/common/include/Processes.hpp
+++ b/profiling/common/include/Processes.hpp
@@ -10,7 +10,7 @@
 namespace pipe
 {
 
-int GetCurrentId();
+int GetCurrentProcessId();
 
 } // namespace arm
 } // namespace pipe
diff --git a/profiling/common/include/Threads.hpp b/profiling/common/include/Threads.hpp
new file mode 100644
index 0000000..1c24a30
--- /dev/null
+++ b/profiling/common/include/Threads.hpp
@@ -0,0 +1,16 @@
+//
+// Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
+// SPDX-License-Identifier: MIT
+//
+
+#pragma once
+
+namespace arm
+{
+namespace pipe
+{
+
+int GetCurrentThreadId();
+
+} // namespace pipe
+} // namespace arm
diff --git a/profiling/common/src/CMakeLists.txt b/profiling/common/src/CMakeLists.txt
index 3932186..e02c785 100644
--- a/profiling/common/src/CMakeLists.txt
+++ b/profiling/common/src/CMakeLists.txt
@@ -10,12 +10,13 @@
         CommandHandlerKey.cpp
         CommandHandlerRegistry.cpp
         CommonProfilingUtils.cpp
+        LabelsAndEventClasses.cpp
         Logging.cpp
         NetworkSockets.cpp
         PacketVersionResolver.cpp
         Processes.cpp
         SwTrace.cpp
-        LabelsAndEventClasses.cpp)
+        Threads.cpp)
 
     include_directories(${PROJECT_SOURCE_DIR}/profiling/common/include)
     include_directories(${PROJECT_SOURCE_DIR}/common/include)
diff --git a/profiling/common/src/Processes.cpp b/profiling/common/src/Processes.cpp
index d6d4ca4..94e8095 100644
--- a/profiling/common/src/Processes.cpp
+++ b/profiling/common/src/Processes.cpp
@@ -16,7 +16,7 @@
 namespace pipe
 {
 
-int GetCurrentId()
+int GetCurrentProcessId()
 {
 #if defined(__unix__) || defined(__APPLE__)
     return getpid();
diff --git a/profiling/common/src/Threads.cpp b/profiling/common/src/Threads.cpp
new file mode 100644
index 0000000..10533b7
--- /dev/null
+++ b/profiling/common/src/Threads.cpp
@@ -0,0 +1,45 @@
+//
+// 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 <common/include/WindowsWrapper.hpp>
+#elif defined(__APPLE__)
+#include "AvailabilityMacros.h"
+#include <pthread.h>
+#include <sys/syscall.h>
+#include <sys/time.h>
+#include <unistd.h>
+#endif
+
+namespace arm
+{
+namespace pipe
+{
+
+int GetCurrentThreadId()
+{
+#if defined(__linux__)
+    return static_cast<int>(gettid());
+#elif defined(_MSC_VER)
+    return ::GetCurrentThreadId();
+#elif defined(__APPLE__)
+    uint64_t threadId;
+    int iRet = pthread_threadid_np(NULL, &threadId);
+    if (iRet != 0)
+    {
+        return 0;
+    }
+    return static_cast<int>(threadId);
+#endif
+}
+
+} // namespace pipe
+} // namespace arm