Mercurial > hg > th-libs
comparison th_util.h @ 727:b415b70254fa
Add set_bit/test_bit helpers.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 06 Jan 2022 13:12:16 +0200 |
parents | 29e44a58bc73 |
children | a557d1b2a356 |
comparison
equal
deleted
inserted
replaced
726:29e44a58bc73 | 727:b415b70254fa |
---|---|
150 void th_free_r_real(void **ptr); | 150 void th_free_r_real(void **ptr); |
151 | 151 |
152 #define th_free_r(ptr) th_free_r_real((void **) ptr) | 152 #define th_free_r(ptr) th_free_r_real((void **) ptr) |
153 | 153 |
154 | 154 |
155 #define th_test_bit(pdata, nbit) \ | |
156 (pdata[nbit >> 3] & (1 << (nbit & 7))) | |
157 | |
158 static inline void th_set_bit(uint8_t *pdata, const size_t nbit, const int value) | |
159 { | |
160 if (value) | |
161 pdata[nbit >> 3] |= (1 << (nbit & 7)); | |
162 else | |
163 pdata[nbit >> 3] &= ~(1 << (nbit & 7)); | |
164 } | |
165 | |
166 | |
155 #ifdef __cplusplus | 167 #ifdef __cplusplus |
156 } | 168 } |
157 #endif | 169 #endif |
158 #endif // TH_UTIL_H | 170 #endif // TH_UTIL_H |