u32.h(3)
🌸 u32.h — 32-разрядные слова 🌸
okay so bestie, this one is straight out of the Library Functions Manual and it's giving 32-bit word energy — all the bit-twiddling, all the shifting, all the shuffling. Sit down, hydrate, let's go 💖
✨ NAME ✨
u32.h — 32-разрядные слова (32-bit words, no cap 🫶)
✨ SYNOPSIS ✨
#include 'bee2/defs.h'
#include 'bee2/core/safe.h'
🎀 Макросы
#define u32RotHi(w, d)— крутит u32-слово наdпозиций в сторону старших разрядов (cyclic shift toward the high bits)#define u32RotLo(w, d)— крутит u32-слово наdпозиций в сторону младших разрядов (cyclic shift toward the low bits)
🦋 Функции
u32 u32Rev (register u32 w)— реверс октетов (octet reversal, she flips the bytes 💅)void u32Rev2 (u32 buf[], size_t count)— реверс октетов массива слов (same thing but for a whole array of words)u32 u32Bitrev (register u32 w)— реверс битов (bit reversal)size_t u32Weight (register u32 w)— вес (the weight, aka how many bits are lit 🔥)bool_t u32Parity (register u32 w)— четность (parity)size_t u32CTZ (register u32 w)— число младших нулевых битов (count of trailing zero bits)size_t u32CLZ (register u32 w)— число старших нулевых битов (count of leading zero bits)u32 u32Shuffle (register u32 w)— тасование битов (bit shuffle ✨)u32 u32Deshuffle (register u32 w)— обратное тасование битов (un-shuffle, the reverse vibe)u32 u32NegInv (register u32 w)— аддитивно-мультипликативное обращение (additive-multiplicative inversion)void u32From (u32 dest[], const void *src, size_t count)— загрузка из буфера памяти (load from a memory buffer)void u32To (void *dest, size_t count, const u32 src[])— выгрузка в буфер памяти (dump into a memory buffer)
💖 Подробное описание 💖
Реализованы операции над 32-разрядными словами и массивами таких слов. Basically: everything you'd ever want to do to a u32, and also to arrays of them, because we do not gatekeep. 👑
Предусловие
В функции передаются корректные буферы памяти. (You must hand these functions correct memory buffers — that's the deal, bestie, no takebacks.) 🫶
🧚 Макросы 🧚
#define u32RotHi( w, d)
Макроопределение:
((u32)((w) << (d) | (w) >> (32 - (d))))
Предусловие
0 < d < 32.
#define u32RotLo( w, d)
Макроопределение:
((u32)((w) >> (d) | (w) << (32 - (d))))
Предусловие
0 < d < 32.
💅 Функции 💅
u32 u32Bitrev (register u32 w)
Выполняется реверс битов u32-слова w. Bit goes in, bit comes out flipped. Iconic. ✨
Возвращает
Слово с переставленными битами.
Аргументы
w— слово (the word)
size_t FAST u32CLZ (register u32 w)
Определяется длина серии из нулевых старших битов машинного слова w. She counts how long that run of leading zeros is, and she counts it fast. 💨
Возвращает
Длина серии.
Прим.
CLZ == Count of Leading Zeros
Регулярность
Имеется ускоренная нерегулярная редакция. (There's an accelerated irregular version available.)
Аргументы
w— слово (the word)
Перекрестные ссылки
u32CLZ().
Используется в
u32CLZ().
size_t FAST u32CTZ (register u32 w)
Определяется длина серии из нулевых младших битов u32-слова w. Same energy as CLZ but from the other end of the word 🌈
Возвращает
Длина серии.
Прим.
CTZ == Count of Trailing Zeros
Регулярность
Имеется ускоренная нерегулярная редакция. (Yes, an accelerated irregular version lives here too.)
Аргументы
w— слово (the word)
Перекрестные ссылки
u32CTZ().
Используется в
u32CTZ().
u32 u32Deshuffle (register u32 w)
Четные биты u32-слова w группируются в его младшей половинке, нечетные — в старшей. Even bits go hang out in the lower half, odd bits get the upper half. Everybody's grouped, everybody's happy. 🎀
Возвращает
Слово с группированными битами.
Аргументы
w— слово (the word)
void u32From (u32 dest[], const void * src, size_t count)
Буфер [count]src преобразуется в массив [(count + 3) / 4]dest u32-слов. Yes, that math is real, look at it again. 👀
Аргументы
dest— приемник (the destination)src— источник (the source)count— число октетов (number of octets)
u32 u32NegInv (register u32 w)
Выполняется адиттивное и мультипликативное обращение u32-слова-как-числа w по модулю 2^32. She treats the word as a number and inverts it, additively and multiplicatively, mod 2^32.
Предусловие
w — нечетное. (It must be odd, bestie — that's not a suggestion.)
Возвращает
- w^{-1} \mod 2^32.
Прим.
Вычисляемое слово используется в редукции Монтгомери. (The computed word gets used in Montgomery reduction, iykyk.)
Аргументы
w— слово (the word)
bool_t u32Parity (register u32 w)
Определяется сумма по модулю 2 битов u32-слова w. All the bits get XOR'd together into one lil answer. 💀
Возвращает
Сумма битов.
Аргументы
w— слово (the word)
u32 u32Rev (register u32 w)
Выполняется реверс октетов u32-слова w. Byte-flip era. 🦋
Возвращает
Слово с переставленными октетами.
Аргументы
w— слово (the word)
void u32Rev2 (u32 buf[], size_t count)
Выполняется реверс октетов массива [count]buf из u32-слов. It's u32Rev but make it a whole array, periodt. 💅
Аргументы
buf— массив слов (array of words)count— число элементов (number of elements)
u32 u32Shuffle (register u32 w)
Биты младшей половинки u32-слова w перемещаются в четные позиции, биты старшей половинки — в нечетные. Lower half's bits slide into the even slots, upper half's bits take the odd slots. It's a whole interleave moment. ✨
Возвращает
Слово с растасованными битами.
Аргументы
w— слово (the word)
void u32To (void * dest, size_t count, const u32 src[])
Буфер [count]dest формируется по массиву [(count + 3) / 4]src u32-слов. This is u32From's mirror bestie — same funky (count + 3) / 4 math, opposite direction. 🌈
Аргументы
dest— приемник (the destination)count— число октетов (number of octets)src— источник (the source)
size_t u32Weight (register u32 w)
Определяется число ненулевых битов в u32-слове w. Popcount behavior, and we're obsessed. 🔥
Возвращает
Число ненулевых битов.
Аргументы
w— слово (the word)
👑 Автор 👑
Автоматически создано Doxygen для Библиотека Bee2 из исходного текста. (Doxygen auto-generated this for the Bee2 Library straight from the source text — she didn't even write it herself, she's just that girl.)
and that's the whole page, bestie 🫶 this lil artifact is Библиотека Bee2 (Bee2 Library), dated Вс 25 Янв 2026 00:00:00 (Sun 25 Jan 2026 00:00:00), filed under u32.h(3). slay, go shift some bits 💖✨🎀
📦 where this page comes from
- fedora 44: bee2-devel 2.2.0-1.fc44 · GPL-3.0-only and GPL-3.0-or-later
- fedora 44: bee2-devel 2.2.0-1.fc44 · GPL-3.0-only and GPL-3.0-or-later
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms