1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_StaticPrefsBase_h
8 #define mozilla_StaticPrefsBase_h
10 #include <type_traits>
12 #include "mozilla/Atomics.h"
16 class SharedPrefMapBuilder
;
18 // These typedefs are for use within init/StaticPrefList*.h.
20 typedef const char* String
;
22 typedef Atomic
<bool, Relaxed
> RelaxedAtomicBool
;
23 typedef Atomic
<bool, ReleaseAcquire
> ReleaseAcquireAtomicBool
;
24 typedef Atomic
<bool, SequentiallyConsistent
> SequentiallyConsistentAtomicBool
;
26 typedef Atomic
<int32_t, Relaxed
> RelaxedAtomicInt32
;
27 typedef Atomic
<int32_t, ReleaseAcquire
> ReleaseAcquireAtomicInt32
;
28 typedef Atomic
<int32_t, SequentiallyConsistent
>
29 SequentiallyConsistentAtomicInt32
;
31 typedef Atomic
<uint32_t, Relaxed
> RelaxedAtomicUint32
;
32 typedef Atomic
<uint32_t, ReleaseAcquire
> ReleaseAcquireAtomicUint32
;
33 typedef Atomic
<uint32_t, SequentiallyConsistent
>
34 SequentiallyConsistentAtomicUint32
;
36 // XXX: Atomic<float> currently doesn't work (see bug 1552086). Once it's
37 // supported we will be able to use Atomic<float> here.
38 typedef std::atomic
<float> AtomicFloat
;
41 struct StripAtomicImpl
{
45 template <typename T
, MemoryOrdering Order
>
46 struct StripAtomicImpl
<Atomic
<T
, Order
>> {
51 struct StripAtomicImpl
<std::atomic
<T
>> {
56 using StripAtomic
= typename StripAtomicImpl
<T
>::Type
;
59 struct IsAtomic
: std::false_type
{};
61 template <typename T
, MemoryOrdering Order
>
62 struct IsAtomic
<Atomic
<T
, Order
>> : std::true_type
{};
65 struct IsAtomic
<std::atomic
<T
>> : std::true_type
{};
67 namespace StaticPrefs
{
69 void MaybeInitOncePrefs();
71 } // namespace StaticPrefs
73 } // namespace mozilla
75 #endif // mozilla_StaticPrefsBase_h