about summary refs log tree commit diff
path: root/absl/flags/flag.cc
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2019-07-17T20·35-0400
committerDerek Mauro <dmauro@google.com>2019-07-17T20·40-0400
commitc6c3c1b498e4ee939b24be59cae29d59c3863be8 (patch)
tree030b875cdbbd25d2d0b7bca0b68a71351eeb2c41 /absl/flags/flag.cc
parent44efe96dfca674a17b45ca53fc77fb69f1e29bf4 (diff)
Export of internal Abseil changes.
--
ed3a3431eee9e48e6553b0320e0308d2dde6725c by Derek Mauro <dmauro@google.com>:

Project import generated by Copybara.

PiperOrigin-RevId: 258631680
GitOrigin-RevId: ed3a3431eee9e48e6553b0320e0308d2dde6725c
Change-Id: I1d7ae86a79783842092d29504605ba039c369603
Diffstat (limited to 'absl/flags/flag.cc')
-rw-r--r--absl/flags/flag.cc26
1 files changed, 9 insertions, 17 deletions
diff --git a/absl/flags/flag.cc b/absl/flags/flag.cc
index ba002edd24f1..f16cc75e3843 100644
--- a/absl/flags/flag.cc
+++ b/absl/flags/flag.cc
@@ -24,24 +24,16 @@ namespace absl {
 // so in debug builds we always use the slower implementation, which always
 // validates the type.
 #ifndef NDEBUG
-#define ABSL_FLAGS_ATOMIC_GET(T)                              \
-  T GetFlag(const absl::Flag<T>& flag) {                      \
-    T result;                                                 \
-    flag.internal.Read(&result, &flags_internal::FlagOps<T>); \
-    return result;                                            \
-  }
+#define ABSL_FLAGS_ATOMIC_GET(T) \
+  T GetFlag(const absl::Flag<T>& flag) { return flag.Get(); }
 #else
-#define ABSL_FLAGS_ATOMIC_GET(T)                                            \
-  T GetFlag(const absl::Flag<T>& flag) {                                    \
-    const int64_t r = flag.internal.atomic.load(std::memory_order_acquire); \
-    if (r != flags_internal::CommandLineFlag::kAtomicInit) {                \
-      T t;                                                                  \
-      memcpy(&t, &r, sizeof(T));                                            \
-      return t;                                                             \
-    }                                                                       \
-    T result;                                                               \
-    flag.internal.Read(&result, &flags_internal::FlagOps<T>);               \
-    return result;                                                          \
+#define ABSL_FLAGS_ATOMIC_GET(T)         \
+  T GetFlag(const absl::Flag<T>& flag) { \
+    T result;                            \
+    if (flag.AtomicGet(&result)) {       \
+      return result;                     \
+    }                                    \
+    return flag.Get();                   \
   }
 #endif