diff options
Diffstat (limited to 'runtime/shims/process.cpp')
| -rw-r--r-- | runtime/shims/process.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/runtime/shims/process.cpp b/runtime/shims/process.cpp index 407cea8ad..08023ea78 100644 --- a/runtime/shims/process.cpp +++ b/runtime/shims/process.cpp | |||
| @@ -213,8 +213,14 @@ DWORD_PTR __stdcall game_set_thread_affinity_mask(HANDLE thread, DWORD_PTR mask) | |||
| 213 | // the call returns TRUE and the out parameter gets the affinity the thread had. An empty mask names no CPU on any | 213 | // the call returns TRUE and the out parameter gets the affinity the thread had. An empty mask names no CPU on any |
| 214 | // machine and a bad handle is the host's own error: both are passed to the host and fail as on Windows. | 214 | // machine and a bad handle is the host's own error: both are passed to the host and fail as on Windows. |
| 215 | BOOL __stdcall game_set_thread_group_affinity(HANDLE thread, const GROUP_AFFINITY* requested, PGROUP_AFFINITY previous) { | 215 | BOOL __stdcall game_set_thread_group_affinity(HANDLE thread, const GROUP_AFFINITY* requested, PGROUP_AFFINITY previous) { |
| 216 | // An empty mask names no CPU on any machine. Some Windows builds accept it and clear the affinity instead of | ||
| 217 | // failing, so answer the documented error before the host call rather than depending on the build. | ||
| 218 | if (!requested || requested->Mask == 0) { | ||
| 219 | SetLastError(ERROR_INVALID_PARAMETER); | ||
| 220 | return FALSE; | ||
| 221 | } | ||
| 216 | if (SetThreadGroupAffinity(thread, requested, previous)) return TRUE; | 222 | if (SetThreadGroupAffinity(thread, requested, previous)) return TRUE; |
| 217 | if (!requested || requested->Mask == 0 || GetLastError() != ERROR_INVALID_PARAMETER) return FALSE; | 223 | if (GetLastError() != ERROR_INVALID_PARAMETER) return FALSE; |
| 218 | GROUP_AFFINITY actual = {}; | 224 | GROUP_AFFINITY actual = {}; |
| 219 | if (!GetThreadGroupAffinity(thread, &actual)) return FALSE; // the host's error stands | 225 | if (!GetThreadGroupAffinity(thread, &actual)) return FALSE; // the host's error stands |
| 220 | if (previous) *previous = actual; | 226 | if (previous) *previous = actual; |