This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add implementation of pthread_once.
ClosedPublic

Authored by sivachandra on Sep 27 2022, 1:20 AM.

Details

Summary

The existing thrd_once function has been refactored so that the
implementation can be shared between thrd_once and pthread_once
functions.

Diff Detail

Event Timeline

sivachandra created this revision.Sep 27 2022, 1:20 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptSep 27 2022, 1:20 AM
sivachandra requested review of this revision.Sep 27 2022, 1:20 AM
michaelrj accepted this revision.Sep 27 2022, 10:21 AM

Overall LGTM

libc/src/__support/threads/linux/callonce.cpp
47

you just defined status to be START, so this condition seems like it can never be true.

This revision is now accepted and ready to land.Sep 27 2022, 10:21 AM
sivachandra added inline comments.Sep 27 2022, 10:27 AM
libc/src/__support/threads/linux/callonce.cpp
47

If compare_exchange_strong fails, it will write the current value of futex_word into status (which is a reference parameter to compare_exchange_strong.

michaelrj added inline comments.Sep 27 2022, 11:36 AM
libc/src/__support/threads/linux/callonce.cpp
47

ah, that makes sense. LGTM

This revision was automatically updated to reflect the committed changes.