Page MenuHomePhabricator

Use std::call_once for initialization
ClosedPublic

Authored by davide on Mar 31 2015, 11:16 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

davide updated this revision to Diff 23029.Mar 31 2015, 11:16 PM
davide retitled this revision from to Use std::call_once for initialization.
davide updated this object.
davide edited the test plan for this revision. (Show Details)
davide added reviewers: zturner, clayborg.
davide set the repository for this revision to rL LLVM.
davide added a subscriber: Unknown Object (MLST).
clayborg accepted this revision.Apr 1 2015, 9:28 AM
clayborg edited edge metadata.
This revision is now accepted and ready to land.Apr 1 2015, 9:28 AM
zturner added inline comments.Apr 1 2015, 10:03 AM
source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
59 ↗(On Diff #23029)

Can you change all these to:

static llvm::ManagedStatic<std::once_flag> g_once_flag;

std::call_once(*g_once_flag, ...);

The reason for this is that Windows and MSVC don't yet have thread-safe initialization of function local statics that have a constructor. On most platforms, members of once_flag are linker initialized, but on Windows they have an actual constructor.

You can add a TODO line that indicates that once we require MSVC 2015 as the minimum version, we can remove these and use regular std::once_flags. Same comment applies to all the rest of the occurrences in the file as well.

zturner edited edge metadata.Apr 1 2015, 10:04 AM

Maybe a comment indicating why it's a ManagedStatic would also be helpful so people are aware of the history.

This revision was automatically updated to reflect the committed changes.
davide added a comment.Apr 2 2015, 9:29 PM

Maybe a comment indicating why it's a ManagedStatic would also be helpful so people are aware of the history.

Ugh, I'm sorry. For some reason I didn't receive your comments via mail and noticed them only after commit.
I'll change them tomorrow morning and submit a new review.

Thanks,