1 // Copyright 2020 The Chromium 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 QUICHE_COMMON_PLATFORM_DEFAULT_QUICHE_PLATFORM_IMPL_QUICHE_FLAGS_IMPL_H_
6 #define QUICHE_COMMON_PLATFORM_DEFAULT_QUICHE_PLATFORM_IMPL_QUICHE_FLAGS_IMPL_H_
7
8 #include <cstdint>
9 #include <map>
10 #include <memory>
11 #include <string>
12 #include <vector>
13
14 #include "quiche/common/platform/api/quiche_export.h"
15
16 #define QUIC_FLAG(flag, value) QUICHE_EXPORT extern bool FLAGS_##flag;
17 #include "quiche/quic/core/quic_flags_list.h"
18 #undef QUIC_FLAG
19
20 // Protocol flags. TODO(bnc): Move to quiche_protocol_flags_list.h.
21 #define QUIC_PROTOCOL_FLAG(type, flag, ...) \
22 QUICHE_EXPORT extern type FLAGS_##flag;
23 #include "quiche/quic/core/quic_protocol_flags_list.h"
24 #undef QUIC_PROTOCOL_FLAG
25
26 // Protocol flags.
27 #define QUICHE_PROTOCOL_FLAG(type, flag, ...) \
28 QUICHE_EXPORT extern type FLAGS_##flag;
29 #include "quiche/common/quiche_protocol_flags_list.h"
30 #undef QUICHE_PROTOCOL_FLAG
31
32 #define GetQuicheFlagImpl(flag) GetQuicheFlagImplImpl(FLAGS_##flag)
GetQuicheFlagImplImpl(bool flag)33 inline bool GetQuicheFlagImplImpl(bool flag) { return flag; }
GetQuicheFlagImplImpl(int32_t flag)34 inline int32_t GetQuicheFlagImplImpl(int32_t flag) { return flag; }
GetQuicheFlagImplImpl(int64_t flag)35 inline int64_t GetQuicheFlagImplImpl(int64_t flag) { return flag; }
GetQuicheFlagImplImpl(uint64_t flag)36 inline uint64_t GetQuicheFlagImplImpl(uint64_t flag) { return flag; }
GetQuicheFlagImplImpl(double flag)37 inline double GetQuicheFlagImplImpl(double flag) { return flag; }
GetQuicheFlagImplImpl(const std::string & flag)38 inline std::string GetQuicheFlagImplImpl(const std::string& flag) {
39 return flag;
40 }
41 #define SetQuicheFlagImpl(flag, value) ((FLAGS_##flag) = (value))
42
43 // ------------------------------------------------------------------------
44 // QUICHE feature flags implementation.
45 // ------------------------------------------------------------------------
46 #define QUICHE_RELOADABLE_FLAG(flag) quic_reloadable_flag_##flag
47 #define QUICHE_RESTART_FLAG(flag) quic_restart_flag_##flag
48 #define GetQuicheReloadableFlagImpl(module, flag) \
49 GetQuicheFlag(QUICHE_RELOADABLE_FLAG(flag))
50 #define SetQuicheReloadableFlagImpl(module, flag, value) \
51 SetQuicheFlag(QUICHE_RELOADABLE_FLAG(flag), value)
52 #define GetQuicheRestartFlagImpl(module, flag) \
53 GetQuicheFlag(QUICHE_RESTART_FLAG(flag))
54 #define SetQuicheRestartFlagImpl(module, flag, value) \
55 SetQuicheFlag(QUICHE_RESTART_FLAG(flag), value)
56
57 #endif // QUICHE_COMMON_PLATFORM_DEFAULT_QUICHE_PLATFORM_IMPL_QUICHE_FLAGS_IMPL_H_
58