/* Copyright (C) 2021,2022 fef . All rights reserved. */ #pragma once #include #include #include /** * @brief Test whether a bit in a bitfield is set. * * @param bitfield Bitfield to test a bit of * @param pos Index of the bit within the bitfield, counting from 0 * @return `true` if the bit is set, `false` if not */ bool bit_tst(const unsigned long *bitfield, usize pos); /** * @brief Set a single bit in a bitfield. * * @param bitfield Bitfield to set the bit in * @param pos Index of the bit within the bitfield, counting from 0 */ void bit_set(unsigned long *bitfield, usize pos); /** * @brief Clear a single bit in a bitfield. * * @param bitfield Bitfield to clear the bit in * @param pos Index of the bit within the bitfield, counting from 0 */ void bit_clr(unsigned long *bitfield, usize pos); /** * @brief Set a range of bits in a bitfield. * * @param bitfield Bitfield to set bits in * @param first Index of the first bit to set in the bitfield, counting from 0 * @param count Number of bits to set, starting from index `first` */ void bit_set_range(unsigned long *bitfield, usize first, usize count); /** * @brief Clear a range of bits in a bitfield. * * @param bitfield Bitfield to clear bits in * @param first Index of the first bit to clear in the bitfield, counting from 0 * @param count Number of bits to clear, starting from index `first` */ void bit_clr_range(unsigned long *bitfield, usize first, usize count);