diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-14 12:25:23 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-14 12:25:23 +0200 |
commit | 792128255b6c6add22f97ea60734181cb915f2ae (patch) | |
tree | c3d8e3a3466639591245495ec0148d49732193c3 /src/threading.cpp | |
parent | 6177a3c6b5a05ac2c64978ccf3ca11de9793505b (diff) | |
download | lanes-792128255b6c6add22f97ea60734181cb915f2ae.tar.gz lanes-792128255b6c6add22f97ea60734181cb915f2ae.tar.bz2 lanes-792128255b6c6add22f97ea60734181cb915f2ae.zip |
More fixes to make clang happy
Diffstat (limited to 'src/threading.cpp')
-rw-r--r-- | src/threading.cpp | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/src/threading.cpp b/src/threading.cpp index ebac0da..af2142b 100644 --- a/src/threading.cpp +++ b/src/threading.cpp | |||
@@ -131,11 +131,11 @@ void THREAD_SET_PRIORITY(int prio_, [[maybe_unused]] bool sudo_) | |||
131 | 131 | ||
132 | // ################################################################################################# | 132 | // ################################################################################################# |
133 | 133 | ||
134 | void JTHREAD_SET_PRIORITY(std::jthread& thread_, int prio_, [[maybe_unused]] bool sudo_) | 134 | void THREAD_SET_PRIORITY(std::thread& thread_, int prio_, [[maybe_unused]] bool sudo_) |
135 | { | 135 | { |
136 | // prio range [-3,+3] was checked by the caller | 136 | // prio range [-3,+3] was checked by the caller |
137 | if (!SetThreadPriority(thread_.native_handle(), gs_prio_remap[prio_ + 3])) { | 137 | if (!SetThreadPriority(thread_.native_handle(), gs_prio_remap[prio_ + 3])) { |
138 | FAIL("JTHREAD_SET_PRIORITY", GetLastError()); | 138 | FAIL("THREAD_SET_PRIORITY", GetLastError()); |
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
@@ -349,14 +349,6 @@ static int const gs_prio_remap[] = { | |||
349 | #endif // _PRIO_0 | 349 | #endif // _PRIO_0 |
350 | }; | 350 | }; |
351 | 351 | ||
352 | [[nodiscard]] static int select_prio(int prio /* -3..+3 */) | ||
353 | { | ||
354 | if (prio == kThreadPrioDefault) | ||
355 | prio = 0; | ||
356 | // prio range [-3,+3] was checked by the caller | ||
357 | return gs_prio_remap[prio + 3]; | ||
358 | } | ||
359 | |||
360 | void THREAD_SET_PRIORITY(int prio_, [[maybe_unused]] bool sudo_) | 352 | void THREAD_SET_PRIORITY(int prio_, [[maybe_unused]] bool sudo_) |
361 | { | 353 | { |
362 | #ifdef PLATFORM_LINUX | 354 | #ifdef PLATFORM_LINUX |
@@ -372,7 +364,7 @@ void THREAD_SET_PRIORITY(int prio_, [[maybe_unused]] bool sudo_) | |||
372 | 364 | ||
373 | // ################################################################################################# | 365 | // ################################################################################################# |
374 | 366 | ||
375 | void JTHREAD_SET_PRIORITY(std::jthread& thread_, int prio_, [[maybe_unused]] bool sudo_) | 367 | void THREAD_SET_PRIORITY(std::thread& thread_, int prio_, [[maybe_unused]] bool sudo_) |
376 | { | 368 | { |
377 | #ifdef PLATFORM_LINUX | 369 | #ifdef PLATFORM_LINUX |
378 | if (!sudo_) // only root-privileged process can change priorities | 370 | if (!sudo_) // only root-privileged process can change priorities |
@@ -387,6 +379,15 @@ void JTHREAD_SET_PRIORITY(std::jthread& thread_, int prio_, [[maybe_unused]] boo | |||
387 | 379 | ||
388 | // ################################################################################################# | 380 | // ################################################################################################# |
389 | 381 | ||
382 | #ifdef __PROSPERO__ | ||
383 | |||
384 | void THREAD_SET_AFFINITY(unsigned int aff_) | ||
385 | { | ||
386 | scePthreadSetaffinity(scePthreadSelf(), aff_); | ||
387 | } | ||
388 | |||
389 | #else // __PROSPERO__ | ||
390 | |||
390 | void THREAD_SET_AFFINITY(unsigned int aff_) | 391 | void THREAD_SET_AFFINITY(unsigned int aff_) |
391 | { | 392 | { |
392 | int bit = 0; | 393 | int bit = 0; |
@@ -416,8 +417,19 @@ void THREAD_SET_AFFINITY(unsigned int aff_) | |||
416 | #endif | 417 | #endif |
417 | } | 418 | } |
418 | 419 | ||
420 | #endif // __PROSPERO__ | ||
421 | |||
419 | // ################################################################################################# | 422 | // ################################################################################################# |
420 | 423 | ||
424 | #ifdef __PROSPERO__ | ||
425 | |||
426 | void THREAD_SETNAME(std::string_view const& name_) | ||
427 | { | ||
428 | scePthreadRename(scePthreadSelf(), name_.data()); | ||
429 | } | ||
430 | |||
431 | #else // __PROSPERO__ | ||
432 | |||
421 | void THREAD_SETNAME(std::string_view const& name_) | 433 | void THREAD_SETNAME(std::string_view const& name_) |
422 | { | 434 | { |
423 | // exact API to set the thread name is platform-dependant | 435 | // exact API to set the thread name is platform-dependant |
@@ -442,6 +454,8 @@ void THREAD_SETNAME(std::string_view const& name_) | |||
442 | #endif | 454 | #endif |
443 | } | 455 | } |
444 | 456 | ||
457 | #endif // __PROSPERO__ | ||
458 | |||
445 | #endif // THREADAPI == THREADAPI_PTHREAD | 459 | #endif // THREADAPI == THREADAPI_PTHREAD |
446 | // ################################################################################################# | 460 | // ################################################################################################# |
447 | // ################################################################################################# | 461 | // ################################################################################################# |