[libc++] Fix PR22606 - Leak pthread_key with static storage duration to ensure all of thread-local destructors are called.

Summary:
See https://llvm.org/bugs/show_bug.cgi?id=22606 for more discussion.

Most of the changes in this patch are file reorganization to help ensure assumptions about how __thread_specific_pointer is used hold. The assumptions are:

* `__thread_specific_ptr<Tp>` is only created with a `__thread_struct` pointer.
* `__thread_specific_ptr<Tp>` can only be constructed inside the `__thread_local_data()` function.

I'll remove the comments before committing. They are there for clarity during review.

Reviewers: earthdok, mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D8802

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245334 91177308-0d34-0410-b5e6-96231b3b80d8
1 file changed