diff options
author | Abseil Team <absl-team@google.com> | 2020-02-13 06:52:24 -0800 |
---|---|---|
committer | Mark Barolak <mbar@google.com> | 2020-02-13 13:56:56 -0500 |
commit | c44657f55692eddf5504156645d1f4ec7b3acabd (patch) | |
tree | 3a0da3d468193fd9c3b5485777da30f64f06f93e /absl/flags/internal/flag.h | |
parent | 98eb410c93ad059f9bba1bf43f5bb916fc92a5ea (diff) |
Export of internal Abseil changes
--
dc6d2715f0415082fcc8da8bf74e74bce69b236c by Derek Mauro <dmauro@google.com>:
Correctly detect C++ exceptions support on Clang for Windows
PiperOrigin-RevId: 294905116
--
b43c44501b4820f4a2f396e426619bd02565707e by Derek Mauro <dmauro@google.com>:
Set CMAKE_CXX_STANDARD on the MacOS CMake build
PiperOrigin-RevId: 294730418
--
184a078649167f9738da60b0f12108256bcfd67b by Abseil Team <absl-team@google.com>:
No need for custom spec to deal with limited platforms.
PiperOrigin-RevId: 294700133
--
b437c7f659b809fc84a45eab284265fec497a3e3 by Abseil Team <absl-team@google.com>:
Not calling sigaltstack on WatchOS and TVOS since they don't allow it.
PiperOrigin-RevId: 294699951
--
23ab8dd381ee4104125dece8455bc96b81239789 by Gennadiy Rozental <rogeeff@google.com>:
Replace use of atomic+global Mutex+bool with absl::call_once for Flag initialization.
This simplifies the initialization logic and helps with upcoming work with value storage rework.
PiperOrigin-RevId: 294654938
--
cee576163a2753c6138bc254e81de4800ea3307a by Gennadiy Rozental <rogeeff@google.com>:
Separate const bits from mutable bits.
Since bit field is not atomic unit for reading/writing, we can't have constant bits which are not protected by data guard to share the space with mutable bits which are protected.
This CL just reorder fields in class and does not make any other changes.
PiperOrigin-RevId: 294501780
--
b4d0e2ab559d04f655c93f008594562234773c15 by Abseil Team <absl-team@google.com>:
Correct the comment.
PiperOrigin-RevId: 294499328
--
a788cf71af6247df033298c49939ba0414d71693 by Derek Mauro <dmauro@google.com>:
Move the FAQ to the top level directory
PiperOrigin-RevId: 294493863
GitOrigin-RevId: dc6d2715f0415082fcc8da8bf74e74bce69b236c
Change-Id: I71b0d8cd401b48d41433417858ae0d69398b6602
Diffstat (limited to 'absl/flags/internal/flag.h')
-rw-r--r-- | absl/flags/internal/flag.h | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/absl/flags/internal/flag.h b/absl/flags/internal/flag.h index ef30a22f..b426ccb5 100644 --- a/absl/flags/internal/flag.h +++ b/absl/flags/internal/flag.h @@ -24,6 +24,7 @@ #include <string> #include <type_traits> +#include "absl/base/call_once.h" #include "absl/base/config.h" #include "absl/base/thread_annotations.h" #include "absl/flags/config.h" @@ -281,10 +282,8 @@ class FlagImpl { help_(help.source), help_source_kind_(static_cast<uint8_t>(help.kind)), def_kind_(static_cast<uint8_t>(FlagDefaultKind::kGenFunc)), - is_data_guard_inited_(false), modified_(false), on_command_line_(false), - inited_(false), counter_(0), callback_(nullptr), default_src_(default_value_gen), @@ -406,20 +405,28 @@ class FlagImpl { // Indicates if help message was supplied as literal or generator func. const uint8_t help_source_kind_ : 1; + // ------------------------------------------------------------------------ + // The bytes containing the const bitfields must not be shared with bytes + // containing the mutable bitfields. + // ------------------------------------------------------------------------ + + // Unique tag for absl::call_once call to initialize this flag. + // + // The placement of this variable between the immutable and mutable bitfields + // is important as prevents them from occupying the same byte. If you remove + // this variable, make sure to maintain this property. + absl::once_flag init_control_; + // Mutable flag's state (guarded by `data_guard_`). // If def_kind_ == kDynamicValue, default_src_ holds a dynamically allocated // value. uint8_t def_kind_ : 1 ABSL_GUARDED_BY(*DataGuard()); - // Protects against multiple concurrent constructions of `data_guard_`. - bool is_data_guard_inited_ : 1; // Has this flag's value been modified? bool modified_ : 1 ABSL_GUARDED_BY(*DataGuard()); // Has this flag been specified on command line. bool on_command_line_ : 1 ABSL_GUARDED_BY(*DataGuard()); - // Indicates that the flag state is initialized. - std::atomic<bool> inited_; // Mutation counter int64_t counter_ ABSL_GUARDED_BY(*DataGuard()); // Optional flag's callback and absl::Mutex to guard the invocations. |