2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
24 #define BITARRAY_BIT_OP(array, bit, op) ((array)[(bit) / (sizeof((array)[0]) * 8)] op (1 << ((bit) % (sizeof((array)[0]) * 8))))
26 bool bitArrayGet(const void *array
, unsigned bit
)
28 return BITARRAY_BIT_OP((uint32_t*)array
, bit
, &);
31 void bitArraySet(void *array
, unsigned bit
)
33 BITARRAY_BIT_OP((uint32_t*)array
, bit
, |=);
36 void bitArrayClr(void *array
, unsigned bit
)
38 BITARRAY_BIT_OP((uint32_t*)array
, bit
, &=~);
41 void bitArrayXor(void *dest
, size_t size
, void *op1
, void *op2
)
43 for (size_t i
= 0; i
< size
; i
++) {
44 ((uint8_t*)dest
)[i
] = ((uint8_t*)op1
)[i
] ^ ((uint8_t*)op2
)[i
];