runtime: correct _stdlib_thread_key_create

The mapping of the return value of the `FlsAlloc` was flipped resulting
in the failure of the TLS key creation.  The test suite would fail to
generate the TLS key resulting in failures.
This commit is contained in:
Saleem Abdulrasool
2018-12-23 09:22:49 -08:00
parent 8e38b67d66
commit 40da65a43f
2 changed files with 4 additions and 2 deletions

View File

@@ -43,7 +43,9 @@ static inline int
_stdlib_thread_key_create(__swift_thread_key_t * _Nonnull key,
__swift_thread_key_destructor _Nullable destructor) {
*key = FlsAlloc(destroyTLS_CCAdjustmentThunk);
return *key != FLS_OUT_OF_INDEXES;
if (*key == FLS_OUT_OF_INDEXES)
return GetLastError();
return 0;
}
#endif