This is an archive of the discontinued LLVM Phabricator instance.

Revamp llvm::once_flag to be closer to std::once_flag
ClosedPublic

Authored by krytarowski on Feb 5 2017, 8:52 AM.

Details

Summary

Make this interface reusable similarly to std::call_once and std::once_flag interface.

This makes porting LLDB to NetBSD easier as there was in the original approach a portable way to specify a non-static once_flag. With this change translating std::once_flag to llvm::once_flag is mechanical.

Sponsored by <The NetBSD Foundation>

Diff Detail

Repository
rL LLVM

Event Timeline

krytarowski created this revision.Feb 5 2017, 8:52 AM
krytarowski retitled this revision from Revamp the llvm::once_flag to be closer to std::once_flag to Revamp llvm::once_flag to be closer to std::once_flag.
mehdi_amini added inline comments.Feb 5 2017, 9:00 AM
include/llvm/Support/Threading.h
71

If I understand correctly, this wrapper is only here to ensure that the status is always initialized right? Then this should be enough:

struct once_flag {
  volatile sys::cas_flag status = Uninitialized;
}

Also comment the struct.

krytarowski updated this revision to Diff 87154.Feb 5 2017, 9:44 AM

Turn once_flag into struct.

Document once_flag.

Build tested with LLDB.

mehdi_amini accepted this revision.Feb 5 2017, 9:48 AM

LGTM (see 1 inline comment)

include/llvm/Support/Threading.h
70

I meant: document the fact that we have this structure for the sole purpose of forcing initialization.

(also on a side note we deprecate the use of \brief by enabling auto-brief in doxygen)

This revision is now accepted and ready to land.Feb 5 2017, 9:48 AM
krytarowski updated this revision to Diff 87155.Feb 5 2017, 9:57 AM

Document autoinitialization purpose of llvm::once_flag.

For now leave \brief as it is, to be consistent with the rest of this file.

krytarowski closed this revision.Feb 5 2017, 1:24 PM