Skip to content

Conversation

aidancully
Copy link
Contributor

pthread_key_create can be 0.
addresses issue #19567.

@alexcrichton
Copy link
Member

Thanks for the PR! Would it be possible to just +1 to all keys received instead of creating two keys?

@aidancully
Copy link
Contributor Author

As a practical matter, I think that would work on any sane platform (though it would impose a run-time cost of subtracting 1 from the stored value each time you try to actually use the key). From a pure portability standpoint, does the POSIX standard allow the created key to be -1? I think it does, which would mean the portability issue still exists (though it's much more difficult to imagine a platform that would actually return -1). To my mind, a better solution involves not having a reserved value for the key, though I'm not sure how that would work...

@alexcrichton
Copy link
Member

Sounds good to me, thanks @aidancully!

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Dec 9, 2014
pthread_key_create can be 0.
addresses issue rust-lang#19567.
@bors bors merged commit c394a6c into rust-lang:master Dec 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants