aboutsummaryrefslogtreecommitdiff
path: root/third_party/fuchsia/repo/zircon/system/ulib/lazy_init/include/lib/lazy_init/options.h
blob: c044a406c31f8bbc11c5a0244001a1cb75bb4fb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef LIB_LAZY_INIT_OPTIONS_H_
#define LIB_LAZY_INIT_OPTIONS_H_

namespace lazy_init {

// Enum that specifies what kind of debug init checks to perform for a
// lazy-initialized global variable.
enum class CheckType {
  // No checks are performed.
  None,

  // Initialization checks are performed. If multiple threads will access the
  // global variable, initialization must be manually serialized with respect
  // to the guard variable.
  Basic,

  // Initialization checks are performed using atomic operations. Checks are
  // guaranteed to be consistent, even when races occur over initialization.
  Atomic,

  // The default check type as specified by the build. This is the check type
  // used when not explicitly specified. It may also be specified explicitly
  // to defer to the build configuration when setting other options.
  // TODO(eieio): Add the build arg and conditional logic.
  Default = None,
};

// Enum that specifies whether to enable a lazy-initialized global variable's
// destructor. Disabling global destructors avoids destructor registration.
// However, destructors can be conditionally enabled on builds that require
// them, such as ASAN.
enum class Destructor {
  Disabled,
  Enabled,

  // The default destructor enablement as specified by the build. This is the
  // enablement used when not explicitly specified. It may also be specified
  // explicitly to defer to the build configuration when setting other
  // options.
  // TODO(eieio): Add the build arg and conditional logic.
  Default = Disabled,
};

}  // namespace lazy_init

#endif  // LIB_LAZY_INIT_OPTIONS_H_