blob: d9e60167e8680455195bfc50e49f3fe527e47299 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
//
// 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(ARMNN_DISABLE_THREADS)
#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
#else
return 0;
#endif
}
} // namespace pipe
} // namespace arm
|