mn_atomic_flags.hpp
Go to the documentation of this file.
1 /*
2 *This file is part of the Mini Thread Library (https://github.com/RoseLeBlood/MiniThread ).
3 *Copyright (c) 2021 Amber-Sophia Schroeck
4 *
5 *The Mini Thread Library is free software; you can redistribute it and/or modify
6 *it under the terms of the GNU Lesser General Public License as published by
7 *the Free Software Foundation, version 3, or (at your option) any later version.
8 
9 *The Mini Thread Library is distributed in the hope that it will be useful, but
10 *WITHOUT ANY WARRANTY; without even the implied warranty of
11 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 *General Public License for more details.
13 *
14 *You should have received a copy of the GNU Lesser General Public
15 *License along with the Mini Thread Library; if not, see
16 *<https://www.gnu.org/licenses/>;.
17 */
18 #ifndef _MINLIB_affb92a0_d933_4bcc_9fbe_ffcabf0fb903_H_
19 #define _MINLIB_affb92a0_d933_4bcc_9fbe_ffcabf0fb903_H_
20 
21 #ifndef __ATOMIC_RELAXED
22 #define __ATOMIC_RELAXED 0
23 #endif
24 #ifndef __ATOMIC_CONSUME
25 #define __ATOMIC_CONSUME 1
26 #endif
27 #ifndef __ATOMIC_ACQUIRE
28 #define __ATOMIC_ACQUIRE 2
29 #endif
30 #ifndef __ATOMIC_RELEASE
31 #define __ATOMIC_RELEASE 3
32 #endif
33 #ifndef __ATOMIC_ACQ_REL
34 #define __ATOMIC_ACQ_REL 4
35 #endif
36 #ifndef __ATOMIC_SEQ_CST
37 #define __ATOMIC_SEQ_CST 5
38 #endif
39 
40 namespace mn {
41  enum class memory_order : int {
48  };
49  namespace modifier {
50 
52  Mask = 0x0ffff,
53  ModifierMask = 0xffff0000,
54  HleAcquire = 0x10000,
55  HleRelease = 0x20000
56  };
58  }
60  return memory_order(int(mMemOrder) | int(mod));
61  }
62 
64  return memory_order(int(mMemOrder) & int(mod));
65  }
66 
67  namespace internal {
68  template <typename TFlag>
69  struct atomic_flag {
70  using flag_type = TFlag;
72 
73  constexpr atomic_flag(const flag_type& flag) : __flag(flag) { }
74  };
75  }
76 
77 
78 
79 }
80 
81 #endif
#define __ATOMIC_SEQ_CST
Definition: mn_atomic_flags.hpp:37
#define __ATOMIC_RELEASE
Definition: mn_atomic_flags.hpp:31
#define __ATOMIC_ACQUIRE
Definition: mn_atomic_flags.hpp:28
#define __ATOMIC_CONSUME
Definition: mn_atomic_flags.hpp:25
#define __ATOMIC_RELAXED
Definition: mn_atomic_flags.hpp:22
#define __ATOMIC_ACQ_REL
Definition: mn_atomic_flags.hpp:34
basic_atomic_gcc_memory_order_modifier
Definition: mn_atomic_flags.hpp:51
@ HleRelease
Definition: mn_atomic_flags.hpp:55
@ HleAcquire
Definition: mn_atomic_flags.hpp:54
@ ModifierMask
Definition: mn_atomic_flags.hpp:53
@ Mask
Definition: mn_atomic_flags.hpp:52
Definition: mn_allocator_typetraits.hpp:25
memory_order operator&(memory_order mMemOrder, modifier::memory_order mod)
Definition: mn_atomic_flags.hpp:63
memory_order
Definition: mn_atomic_flags.hpp:41
memory_order operator|(memory_order mMemOrder, modifier::memory_order mod)
Definition: mn_atomic_flags.hpp:59
Definition: mn_atomic_flags.hpp:69
flag_type __flag
Definition: mn_atomic_flags.hpp:71
TFlag flag_type
Definition: mn_atomic_flags.hpp:70
constexpr atomic_flag(const flag_type &flag)
Definition: mn_atomic_flags.hpp:73