| 298 | } |
| 299 | |
| 300 | uint32_t ThreadImpl::setAffinityMask(uint32_t mask) |
| 301 | { |
| 302 | // Same as windows impl if mask is zero |
| 303 | if(!mask) |
| 304 | return 0; |
| 305 | |
| 306 | getThread(this)->affinityMask = mask; |
| 307 | |
| 308 | uint64_t prevMask = 0; |
| 309 | |
| 310 | if(getThread(this)->state == _PxThreadStarted) |
| 311 | { |
| 312 | #if PX_PS4 |
| 313 | prevMask = setAffinityMaskPS4(getThread(this)->thread, mask); |
| 314 | #elif PX_EMSCRIPTEN |
| 315 | // not supported |
| 316 | #elif !PX_APPLE_FAMILY // Apple doesn't support syscall with getaffinity and setaffinity |
| 317 | int32_t errGet = syscall(__NR_sched_getaffinity, getThread(this)->tid, sizeof(prevMask), &prevMask); |
| 318 | if(errGet < 0) |
| 319 | return 0; |
| 320 | |
| 321 | int32_t errSet = syscall(__NR_sched_setaffinity, getThread(this)->tid, sizeof(mask), &mask); |
| 322 | if(errSet != 0) |
| 323 | return 0; |
| 324 | #endif |
| 325 | } |
| 326 | |
| 327 | return uint32_t(prevMask); |
| 328 | } |
| 329 | |
| 330 | void ThreadImpl::setName(const char* name) |
| 331 | { |
no test coverage detected