xref: /aosp_15_r20/external/cronet/base/observer_list_threadsafe.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2017 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "base/observer_list_threadsafe.h"
6 #include "base/compiler_specific.h"
7 #include "third_party/abseil-cpp/absl/base/attributes.h"
8 
9 namespace base {
10 namespace internal {
11 
12 ABSL_CONST_INIT thread_local const ObserverListThreadSafeBase::
13     NotificationDataBase* current_notification = nullptr;
14 
15 // static
16 const ObserverListThreadSafeBase::NotificationDataBase*&
GetCurrentNotification()17 ObserverListThreadSafeBase::GetCurrentNotification() {
18   // Workaround false-positive MSAN use-of-uninitialized-value on
19   // thread_local storage for loaded libraries:
20   // https://github.com/google/sanitizers/issues/1265
21   MSAN_UNPOISON(
22       &current_notification,
23       sizeof(const ObserverListThreadSafeBase::NotificationDataBase*));
24 
25   return current_notification;
26 }
27 
28 }  // namespace internal
29 }  // namespace base
30