NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
3rd argument of pthread_setname_np [Was: SYS_gettid alternative on NetBSD]
On Fri, Jul 22, 2022 at 12:07:36PM +0530, Mayuresh wrote:
> /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
> }
On NetBSD pthread_setname_np takes 3rd argument, which is described as:
arg The printf(3) argument used with name.
Does it mean pass something like "%s" for above code which does not have
the 3rd argument on Linux?
--
Mayuresh
Home |
Main Index |
Thread Index |
Old Index