You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
2.0 KiB
C
66 lines
2.0 KiB
C
/* See the end of this file for copyright and license terms. */
|
|
|
|
#pragma once
|
|
|
|
#include <gay/cdefs.h>
|
|
#include <gay/types.h>
|
|
|
|
#include <limits.h>
|
|
|
|
/**
|
|
* @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);
|
|
|
|
/*
|
|
* This file is part of GayBSD.
|
|
* Copyright (c) 2021 fef <owo@fef.moe>.
|
|
*
|
|
* GayBSD is nonviolent software: you may only use, redistribute, and/or
|
|
* modify it under the terms of the Cooperative Nonviolent Public License
|
|
* (CNPL) as found in the LICENSE file in the source code root directory
|
|
* or at <https://git.pixie.town/thufie/npl-builder>; either version 7
|
|
* of the license, or (at your option) any later version.
|
|
*
|
|
* GayBSD comes with ABSOLUTELY NO WARRANTY, to the extent
|
|
* permitted by applicable law. See the CNPL for details.
|
|
*/
|