aboutsummaryrefslogtreecommitdiff
path: root/src/threading.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/threading.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/threading.cpp b/src/threading.cpp
index 254b2e3..43bd107 100644
--- a/src/threading.cpp
+++ b/src/threading.cpp
@@ -139,9 +139,9 @@ void JTHREAD_SET_PRIORITY(std::jthread& thread_, int prio_, [[maybe_unused]] boo
139 139
140// ################################################################################################# 140// #################################################################################################
141 141
142void THREAD_SET_AFFINITY(unsigned int aff) 142void THREAD_SET_AFFINITY(unsigned int aff_)
143{ 143{
144 if (!SetThreadAffinityMask(GetCurrentThread(), aff)) { 144 if (!SetThreadAffinityMask(GetCurrentThread(), aff_)) {
145 FAIL("THREAD_SET_AFFINITY", GetLastError()); 145 FAIL("THREAD_SET_AFFINITY", GetLastError());
146 } 146 }
147} 147}
@@ -162,12 +162,12 @@ typedef struct tagTHREADNAME_INFO
162#pragma pack(pop) 162#pragma pack(pop)
163#endif // !__GNUC__ 163#endif // !__GNUC__
164 164
165void THREAD_SETNAME(char const* _name) 165void THREAD_SETNAME(std::string_view const& name_)
166{ 166{
167#if !defined __GNUC__ 167#if !defined __GNUC__
168 THREADNAME_INFO info; 168 THREADNAME_INFO info;
169 info.dwType = 0x1000; 169 info.dwType = 0x1000;
170 info.szName = _name; 170 info.szName = name_.data();
171 info.dwThreadID = GetCurrentThreadId(); 171 info.dwThreadID = GetCurrentThreadId();
172 info.dwFlags = 0; 172 info.dwFlags = 0;
173 173
@@ -385,7 +385,7 @@ void JTHREAD_SET_PRIORITY(std::jthread& thread_, int prio_, [[maybe_unused]] boo
385 385
386// ################################################################################################# 386// #################################################################################################
387 387
388void THREAD_SET_AFFINITY(unsigned int aff) 388void THREAD_SET_AFFINITY(unsigned int aff_)
389{ 389{
390 int bit = 0; 390 int bit = 0;
391#ifdef __NetBSD__ 391#ifdef __NetBSD__
@@ -397,12 +397,12 @@ void THREAD_SET_AFFINITY(unsigned int aff)
397 cpu_set_t cpuset; 397 cpu_set_t cpuset;
398 CPU_ZERO(&cpuset); 398 CPU_ZERO(&cpuset);
399#endif 399#endif
400 while (aff != 0) { 400 while (aff_ != 0) {
401 if (aff & 1) { 401 if (aff_ & 1) {
402 CPU_SET(bit, &cpuset); 402 CPU_SET(bit, &cpuset);
403 } 403 }
404 ++bit; 404 ++bit;
405 aff >>= 1; 405 aff_ >>= 1;
406 } 406 }
407#ifdef __ANDROID__ 407#ifdef __ANDROID__
408 PT_CALL(sched_setaffinity(pthread_self(), sizeof(cpu_set_t), &cpuset)); 408 PT_CALL(sched_setaffinity(pthread_self(), sizeof(cpu_set_t), &cpuset));
@@ -416,24 +416,24 @@ void THREAD_SET_AFFINITY(unsigned int aff)
416 416
417// ################################################################################################# 417// #################################################################################################
418 418
419void THREAD_SETNAME(char const* _name) 419void THREAD_SETNAME(std::string_view const& name_)
420{ 420{
421 // exact API to set the thread name is platform-dependant 421 // exact API to set the thread name is platform-dependant
422 // if you need to fix the build, or if you know how to fill a hole, tell me (bnt.germain@gmail.com) so that I can submit the fix in github. 422 // if you need to fix the build, or if you know how to fill a hole, tell me (bnt.germain@gmail.com) so that I can submit the fix in github.
423#if defined PLATFORM_BSD && !defined __NetBSD__ 423#if defined PLATFORM_BSD && !defined __NetBSD__
424 pthread_set_name_np(pthread_self(), _name); 424 pthread_set_name_np(pthread_self(), name_.data());
425#elif defined PLATFORM_BSD && defined __NetBSD__ 425#elif defined PLATFORM_BSD && defined __NetBSD__
426 pthread_setname_np(pthread_self(), "%s", (void*) _name); 426 pthread_setname_np(pthread_self(), "%s", (void*) name_.data());
427#elif defined PLATFORM_LINUX 427#elif defined PLATFORM_LINUX
428#if LINUX_USE_PTHREAD_SETNAME_NP 428#if LINUX_USE_PTHREAD_SETNAME_NP
429 pthread_setname_np(pthread_self(), _name); 429 pthread_setname_np(pthread_self(), name_.data());
430#else // LINUX_USE_PTHREAD_SETNAME_NP 430#else // LINUX_USE_PTHREAD_SETNAME_NP
431 prctl(PR_SET_NAME, _name, 0, 0, 0); 431 prctl(PR_SET_NAME, name_.data(), 0, 0, 0);
432#endif // LINUX_USE_PTHREAD_SETNAME_NP 432#endif // LINUX_USE_PTHREAD_SETNAME_NP
433#elif defined PLATFORM_QNX || defined PLATFORM_CYGWIN 433#elif defined PLATFORM_QNX || defined PLATFORM_CYGWIN
434 pthread_setname_np(pthread_self(), _name); 434 pthread_setname_np(pthread_self(), name_.data());
435#elif defined PLATFORM_OSX 435#elif defined PLATFORM_OSX
436 pthread_setname_np(_name); 436 pthread_setname_np(name_.data());
437#else 437#else
438 fprintf(stderr, "THREAD_SETNAME: unsupported platform\n"); 438 fprintf(stderr, "THREAD_SETNAME: unsupported platform\n");
439 abort(); 439 abort();