This is an archive of the discontinued LLVM Phabricator instance.

[SystemZ][ZOS] Fix the usage of pthread_t within libc++
ClosedPublic

Authored by zibi on Nov 20 2020, 8:58 AM.

Details

Reviewers
ldionne
Group Reviewers
Restricted Project
Commits
rGe6c89a499d91: [SystemZ][ZOS] Fix the usage of pthread_t within libc++
Summary

This is the the minimal change introduced in D88599 to unblock the controversial change and discussion of proper separation between thread from thread id which will continue in D88599.

This patch will address the differences of definition of pthread_t on z/OS vs. Linux and other OS. Main trick to make the code work on z/OS relies on redefining libcpp_thread_id type and _LIBCPP_NULL_THREAD macro. This is necessary to separate initialization of libcxx_thread_id from the one of __libcxx_thread_t;

Diff Detail

Event Timeline

zibi created this revision.Nov 20 2020, 8:58 AM
Herald added a reviewer: Restricted Project. · View Herald TranscriptNov 20 2020, 8:58 AM
zibi requested review of this revision.Nov 20 2020, 8:58 AM

Properly separating __libcpp_thread_t from __libcpp_thread_id seems like a conceptual "bugfix" to me, so I like it.

However, POSIX says of pthread_t:

Used to identify a thread.

It's not much, but I would expect pthread_t to look like a thread ID of some sort, like something you can compare. Are you sure the pthread_t on zOS is conforming?

zibi added a comment.Nov 20 2020, 1:04 PM

It's not much, but I would expect pthread_t to look like a thread ID of some sort, like something you can compare. Are you sure the pthread_t on zOS is conforming?

The pthread_t is conforming on z/OS. It can be compared to other pthread_t objects via the pthread_equal function as specified in POSIX.4a.

ldionne requested changes to this revision.Dec 1 2020, 3:31 PM
ldionne added inline comments.
libcxx/include/__threading_support
97

Why don't we always define it that way? This is valid also on other platforms, no?

This revision now requires changes to proceed.Dec 1 2020, 3:31 PM
zibi marked an inline comment as done.Dec 4 2020, 11:28 AM
zibi added inline comments.
libcxx/include/__threading_support
97

Yeap, let's do that. Thanks for suggestion.

zibi updated this revision to Diff 309592.Dec 4 2020, 11:29 AM
zibi marked an inline comment as done.

Unify pthread_t initialization across all platforms.

ldionne accepted this revision.Dec 4 2020, 1:11 PM
This revision is now accepted and ready to land.Dec 4 2020, 1:11 PM
This revision was automatically updated to reflect the committed changes.