Bit Manipulation
More...
#include <fennec/lang/intrinsics.h>
#include <fennec/memory/common.h>
#include <fennec/lang/detail/_bits.h>
Go to the source code of this file.
- Author
- Medusa Slockbower
- Copyright
- Copyright © 2025 Medusa Slockbower (GPLv3)
|
template<typename ToT , typename FromT >
requires (sizeof(ToT) == sizeof(FromT)) |
| constexpr ToT | fennec::bit_cast (const FromT &from) |
| | Perform a bitcast of FromT to ToT.
|
| |
| constexpr void * | fennec::bit_and (void *arr, const void *mask, size_t n) |
| | Perform a bit-wise and over an array of bytes.
|
| |
| constexpr void * | fennec::bit_and_s (void *arr, size_t n0, const void *mask, size_t n1) |
| | Safe version of fennec::bit_and.
|
| |
| constexpr void * | fennec::bit_or (void *arr, const void *mask, size_t n) |
| | Perform a bit-wise or over an array of bytes.
|
| |
| constexpr void * | fennec::bit_or_s (void *arr, size_t n0, const void *mask, size_t n1) |
| | Safe version of fennec::bit_or.
|
| |
| constexpr void * | fennec::bit_xor (void *arr, const void *mask, size_t n) |
| | Perform a bit-wise or over an array of bytes.
|
| |
| constexpr void * | fennec::bit_xor_s (void *arr, size_t n0, const void *mask, size_t n1) |
| | Safe version of fennec::bit_xor.
|
| |
◆ bit_cast()
template<typename ToT , typename FromT >
requires (sizeof(ToT) == sizeof(FromT))
| constexpr ToT fennec::bit_cast |
( |
const FromT & |
from | ) |
|
|
constexpr |
Perform a bitcast of FromT to ToT
- Template Parameters
-
| ToT | Type to cast to |
| FromT | Type of the value |
- Parameters
-
- Returns
- A value containing a bitwise copy of the input
◆ bit_and()
| constexpr void * fennec::bit_and |
( |
void * |
arr, |
|
|
const void * |
mask, |
|
|
size_t |
n |
|
) |
| |
|
constexpr |
Perform a bitcast of FromT to ToT
- Parameters
-
| arr | the array of bytes to modify |
| mask | the mask to and against arr |
| n | the number of bytes |
- Returns
- the pointer \(arr\)
◆ bit_and_s()
| constexpr void * fennec::bit_and_s |
( |
void * |
arr, |
|
|
size_t |
n0, |
|
|
const void * |
mask, |
|
|
size_t |
n1 |
|
) |
| |
|
constexpr |
Safe version of fennec::bit_and
- Parameters
-
| arr | the array of bytes to modify |
| n0 | the size of arr in bytes |
| mask | the mask to and against arr |
| n1 | the size of mask in bytes |
- Returns
- the pointer arr
◆ bit_or()
| constexpr void * fennec::bit_or |
( |
void * |
arr, |
|
|
const void * |
mask, |
|
|
size_t |
n |
|
) |
| |
|
constexpr |
Perform a bit-wise or over an array of bytes
- Parameters
-
| arr | the array of bytes to modify |
| mask | the mask to or against arr |
| n | the number of bytes |
- Returns
- the pointer arr
◆ bit_or_s()
| constexpr void * fennec::bit_or_s |
( |
void * |
arr, |
|
|
size_t |
n0, |
|
|
const void * |
mask, |
|
|
size_t |
n1 |
|
) |
| |
|
constexpr |
Safe version of fennec::bit_or
- Parameters
-
| arr | the array of bytes to modify |
| n0 | the size of arr in bytes |
| mask | the mask to or against arr |
| n1 | the size of mask in bytes |
- Returns
- the pointer arr
◆ bit_xor()
| constexpr void * fennec::bit_xor |
( |
void * |
arr, |
|
|
const void * |
mask, |
|
|
size_t |
n |
|
) |
| |
|
constexpr |
Perform a bit-wise or over an array of bytes
- Parameters
-
| arr | the array of bytes to modify |
| mask | the mask to or against arr |
| n | the number of bytes |
- Returns
- the pointer arr
◆ bit_xor_s()
| constexpr void * fennec::bit_xor_s |
( |
void * |
arr, |
|
|
size_t |
n0, |
|
|
const void * |
mask, |
|
|
size_t |
n1 |
|
) |
| |
|
constexpr |
Safe version of fennec::bit_xor
- Parameters
-
| arr | the array of bytes to modify |
| n0 | the size of arr in bytes |
| mask | the mask to or against arr |
| n1 | the size of mask in bytes |
- Returns
- the pointer arr