[stdlib stubs] Fix up Linux build to know about pthread types.

Adds in Linux platform support for our pthread TLS. Replace usage of
PTHREAD_KEYS_MAX with a sentinel value, as it's tricky to define
cross-platform and was only lightly used inside sanity checks.
This commit is contained in:
Michael Ilseman
2017-05-10 15:23:12 -07:00
parent 6903dd3256
commit 75741a9dde
3 changed files with 5 additions and 11 deletions

View File

@@ -117,10 +117,11 @@ internal func _destroyTLS(_ ptr: UnsafeMutableRawPointer?) {
// Lazily created global key for use with pthread TLS
internal let _tlsKey: __swift_pthread_key_t = {
var key: __swift_pthread_key_t = _swift_stdlib_PTHREAD_KEYS_MAX()
let sentinelValue = __swift_pthread_key_t.max
var key: __swift_pthread_key_t = sentinelValue
let success = _swift_stdlib_pthread_key_create(&key, _destroyTLS)
_sanityCheck(success == 0, "somehow failed to create TLS key")
_sanityCheck(key != _swift_stdlib_PTHREAD_KEYS_MAX(), "Didn't make a new key")
_sanityCheck(key != sentinelValue, "Didn't make a new key")
return key
}()