[libcxx-commits] [PATCH] D88599: [SystemZ][ZOS] Porting pthread_t related functionality within libc++ to z/OS
Ulrich Weigand via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Oct 1 02:28:55 PDT 2020
uweigand added inline comments.
================
Comment at: libcxx/include/__threading_support:495
{
- return pthread_equal(t1, t2) != 0;
+ return t1 == t2;
}
----------------
zibi wrote:
> mclow.lists wrote:
> > This is what this code used to be. It's wrong, because `pthread_t` is not a type that we control, and there's no guarantee that it has an `operator==`. That's why there's a call `pthread_equal`
> > This is what this code used to be. It's wrong, because `pthread_t` is not a type that we control, and there's no guarantee that it has an `operator==`. That's why there's a call `pthread_equal`
>
>
> Thx Marshall, the problem with the original call to `'thread_equal` is that it was passing wrong parameters by mixing thread_id with thread_t. We need clear separation between them and don't use them interchangeably.
Note that even in the current code, `__libcpp_thread_id` is implicitly assumed to be a numeric type, see in particular the routine `__libcpp_thread_is_less` immediately below.
My suggestion has been to use `__libcpp_thread_t` for the platform-specific opaque thread handle (e.g. `pthread_t`), and to use `__libcpp_thread_id` for a numeric ID. On platforms where `pthread_t` happens to be numeric itself, the types can be the same; other platforms need to provide a different definition for `__libcpp_thread_id` (as done by this patch for z/OS).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88599/new/
https://reviews.llvm.org/D88599
More information about the libcxx-commits
mailing list