2 * @ingroup adf_os_public
3 * @file adf_os_bitops.h
4 * This file abstracts bit-level operations on a stream of bytes.
7 #ifndef _ADF_OS_BITOPS_H
8 #define _ADF_OS_BITOPS_H
10 #include <adf_os_types.h>
13 * @brief Set a bit atomically
14 * @param[in] nr Bit to change
15 * @param[in] addr Address to start counting from
17 * @note its atomic and cannot be re-ordered.
18 * Note that nr may be almost arbitrarily large; this function is not
19 * restricted to acting on a single-word quantity.
21 static inline void adf_os_set_bit_a(a_uint32_t nr, volatile a_uint32_t *addr)
23 __adf_os_set_bit_a(nr, addr);
28 * @param[in] nr Bit to change
29 * @param[in] addr Address to start counting from
31 * @note its not atomic and can be re-ordered.
32 * Note that nr may be almost arbitrarily large; this function is not
33 * restricted to acting on a single-word quantity.
35 static inline void adf_os_set_bit(a_uint32_t nr, volatile a_uint32_t *addr)
37 __adf_os_set_bit(nr, addr);
41 * @brief Clear a bit atomically
42 * @param[in] nr Bit to change
43 * @param[in] addr Address to start counting from
45 * @note its atomic and cannot be re-ordered.
46 * Note that nr may be almost arbitrarily large; this function is not
47 * restricted to acting on a single-word quantity.
49 static inline void adf_os_clear_bit_a(a_uint32_t nr, volatile a_uint32_t *addr)
51 __adf_os_clear_bit_a(nr, addr);
56 * @param[in] nr Bit to change
57 * @param[in] addr Address to start counting from
59 * @note its not atomic and can be re-ordered.
60 * Note that nr may be almost arbitrarily large; this function is not
61 * restricted to acting on a single-word quantity.
63 static inline void adf_os_clear_bit(a_uint32_t nr, volatile a_uint32_t *addr)
65 __adf_os_clear_bit(nr, addr);
69 * @brief Toggle a bit atomically
70 * @param[in] nr Bit to change
71 * @param[in] addr Address to start counting from
73 * @note its atomic and cannot be re-ordered.
74 * Note that nr may be almost arbitrarily large; this function is not
75 * restricted to acting on a single-word quantity.
77 static inline void adf_os_change_bit_a(a_uint32_t nr, volatile a_uint32_t *addr)
79 __adf_os_change_bit_a(nr, addr);
84 * @param[in] nr Bit to change
85 * @param[in] addr Address to start counting from
87 * @note its not atomic and can be re-ordered.
88 * Note that nr may be almost arbitrarily large; this function is not
89 * restricted to acting on a single-word quantity.
91 static inline void adf_os_change_bit(a_uint32_t nr, volatile a_uint32_t *addr)
93 __adf_os_change_bit(nr, addr);
97 * @brief Test and Set a bit atomically
98 * @param[in] nr Bit to set
99 * @param[in] addr Address to start counting from
101 * @note its atomic and cannot be re-ordered.
102 * Note that nr may be almost arbitrarily large; this function is not
103 * restricted to acting on a single-word quantity.
105 static inline void adf_os_test_and_set_bit_a(a_uint32_t nr,
106 volatile a_uint32_t *addr)
108 __adf_os_test_and_set_bit_a(nr, addr);
112 * @brief Test and Set a bit
113 * @param[in] nr Bit to set
114 * @param[in] addr Address to start counting from
116 * @note its not atomic and can be re-ordered.
117 * Note that nr may be almost arbitrarily large; this function is not
118 * restricted to acting on a single-word quantity.
120 static inline void adf_os_test_and_set_bit(a_uint32_t nr,
121 volatile a_uint32_t *addr)
123 __adf_os_test_and_set_bit(nr, addr);
127 * @brief Test and clear a bit atomically
128 * @param[in] nr Bit to set
129 * @param[in] addr Address to start counting from
131 * @note its atomic and cannot be re-ordered.
132 * Note that nr may be almost arbitrarily large; this function is not
133 * restricted to acting on a single-word quantity.
135 static inline void adf_os_test_and_clear_bit_a(a_uint32_t nr,
136 volatile a_uint32_t *addr)
138 __adf_os_test_and_clear_bit_a(nr, addr);
142 * @brief Test and clear a bit
143 * @param[in] nr Bit to set
144 * @param[in] addr Address to start counting from
146 * @note its not atomic and can be re-ordered.
147 * Note that nr may be almost arbitrarily large; this function is not
148 * restricted to acting on a single-word quantity.
150 static inline void adf_os_test_and_clear_bit(a_uint32_t nr,
151 volatile a_uint32_t *addr)
153 __adf_os_test_and_clear_bit(nr, addr);
157 * @brief Test and change a bit atomically
158 * @param[in] nr Bit to set
159 * @param[in] addr Address to start counting from
161 * @note its atomic and cannot be re-ordered.
162 * Note that nr may be almost arbitrarily large; this function is not
163 * restricted to acting on a single-word quantity.
165 static inline void adf_os_test_and_change_bit_a(a_uint32_t nr,
166 volatile a_uint32_t *addr)
168 __adf_os_test_and_change_bit_a(nr, addr);
172 * @brief Test and clear a bit
173 * @param[in] nr Bit to set
174 * @param[in] addr Address to start counting from
176 * @note its not atomic and can be re-ordered.
177 * Note that nr may be almost arbitrarily large; this function is not
178 * restricted to acting on a single-word quantity.
180 static inline void adf_os_test_and_change_bit(a_uint32_t nr,
181 volatile a_uint32_t *addr)
183 __adf_os_test_and_change_bit(nr, addr);
187 * @brief test_bit - Determine whether a bit is set
188 * @param[in] nr bit number to test
189 * @param[in] addr Address to start counting from
191 * @return 1 if set, 0 if not
193 static inline int adf_os_test_bit(a_uint32_t nr, volatile a_uint32_t *addr)
195 __adf_os_test_bit(nr, addr);
199 #endif /**_AOD_BITOPS_H*/