NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
SYS_gettid alternative on NetBSD
When trying to build wip/py-torch on NetBSD 9.2 amd64, I get the following
errors:
/usr/pkgsrc/work/wip/py-torch/work/pytorch/third_party/kineto/libkineto/src/ThreadUtil.cpp:52:32: error: 'SYS_gettid' was not declared in this scope
_sysTid = (int32_t)syscall(SYS_gettid);
The concerned function is:
int32_t systemThreadId() {
if (!_sysTid) {
#ifdef __APPLE__
_sysTid = (int32_t)syscall(SYS_thread_selfid);
#elif defined _MSC_VER
_sysTid = (int32_t)GetCurrentThreadId();
#else
_sysTid = (int32_t)syscall(SYS_gettid);
#endif
}
return _sysTid;
}
One more error and concerned function is:
/usr/pkgsrc/work/wip/py-torch/work/pytorch/third_party/kineto/libkineto/src/ThreadUtil.cpp: In function 'bool libkineto::setThreadName(const string&)':
/usr/pkgsrc/work/wip/py-torch/work/pytorch/third_party/kineto/libkineto/src/ThreadUtil.cpp:105:62: error: too few arguments to function 'int pthread_setname_np(pthread_t, const char*, void*)'
bool setThreadName(const std::string& name) {
#ifdef __APPLE__
return 0 == pthread_setname_np(name.c_str());
#elif defined _MSC_VER
// Per https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreaddescription
// Use runtime linking to set thread description
static auto _SetThreadDescription = reinterpret_cast<decltype(&SetThreadDescription)>(getKernel32Func("SetThreadDescription"));
if (!_SetThreadDescription) {
return false;
}
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> conv;
std::wstring wname = conv.from_bytes(name);
HRESULT hr = _SetThreadDescription(GetCurrentThread(), wname.c_str());
return SUCCEEDED(hr);
#else
return 0 == pthread_setname_np(pthread_self(), name.c_str());
#endif
}
Would appreciate suggestions for patches.
--
Mayuresh
Home |
Main Index |
Thread Index |
Old Index