xref: /aosp_15_r20/external/pigweed/third_party/fuchsia/repo/zircon/system/ulib/lazy_init/include/lib/lazy_init/options.h (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1 // Copyright 2021 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef LIB_LAZY_INIT_OPTIONS_H_
6 #define LIB_LAZY_INIT_OPTIONS_H_
7 
8 namespace lazy_init {
9 
10 // Enum that specifies what kind of debug init checks to perform for a
11 // lazy-initialized global variable.
12 enum class CheckType {
13   // No checks are performed.
14   None,
15 
16   // Initialization checks are performed. If multiple threads will access the
17   // global variable, initialization must be manually serialized with respect
18   // to the guard variable.
19   Basic,
20 
21   // Initialization checks are performed using atomic operations. Checks are
22   // guaranteed to be consistent, even when races occur over initialization.
23   Atomic,
24 
25   // The default check type as specified by the build. This is the check type
26   // used when not explicitly specified. It may also be specified explicitly
27   // to defer to the build configuration when setting other options.
28   // TODO(eieio): Add the build arg and conditional logic.
29   Default = None,
30 };
31 
32 // Enum that specifies whether to enable a lazy-initialized global variable's
33 // destructor. Disabling global destructors avoids destructor registration.
34 // However, destructors can be conditionally enabled on builds that require
35 // them, such as ASAN.
36 enum class Destructor {
37   Disabled,
38   Enabled,
39 
40   // The default destructor enablement as specified by the build. This is the
41   // enablement used when not explicitly specified. It may also be specified
42   // explicitly to defer to the build configuration when setting other
43   // options.
44   // TODO(eieio): Add the build arg and conditional logic.
45   Default = Disabled,
46 };
47 
48 }  // namespace lazy_init
49 
50 #endif  // LIB_LAZY_INIT_OPTIONS_H_
51