ArmNN
 21.11
Threads.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include <armnnUtils/Threads.hpp>
7 
8 #if defined(__linux__)
9 #include <unistd.h>
10 #include <sys/syscall.h>
11 #define gettid() syscall(SYS_gettid)
12 #elif defined(_MSC_VER)
13 #include <common/include/WindowsWrapper.hpp>
14 #elif defined(__APPLE__)
15 #include "AvailabilityMacros.h"
16 #include <pthread.h>
17 #include <sys/syscall.h>
18 #include <sys/time.h>
19 #include <unistd.h>
20 #endif
21 
22 namespace armnnUtils
23 {
24 namespace Threads
25 {
26 
28 {
29 #if defined(__linux__)
30  return static_cast<int>(gettid());
31 #elif defined(_MSC_VER)
33 #elif defined(__APPLE__)
34  uint64_t threadId;
35  int iRet = pthread_threadid_np(NULL, &threadId);
36  if (iRet != 0)
37  {
38  return 0;
39  }
40  return static_cast<int>(threadId);
41 #endif
42 }
43 
44 }
45 }
int GetCurrentThreadId()
Definition: Threads.cpp:27