Q_SIGNSHFT(3)
π Q_SIGNSHFT(3) β Library Functions Manual, bestie
okay so this is Q_SIGNSHFT(3) from the library functions manual, and honestly? it's giving low-level bit-fiddling royalty. β¨ these are the fixed-point math girlies that mess with the control bits and the sign bit, and i need you to stay with me because it's actually so good once it clicks.
πΈ NAME πΈ
Q_SIGNSHFT, Q_SSIGN, Q_CRAWMASK, Q_SRAWMASK, Q_GCRAW, Q_GCVAL, Q_SCVAL β fixed-point math functions which manipulate the control/sign data bits
like yes, that's the whole squad. seven functions, one job: touching the control bits and the sign bit. no cap. π
β¨ SYNOPSIS β¨
#include <sys/qmath.h>
uint32_t
Q_SIGNSHFT(QTYPE q);
QTYPE
Q_SSIGN(QTYPE q, bool isneg);
ITYPE
Q_CRAWMASK(QTYPE q);
ITYPE
Q_SRAWMASK(QTYPE q);
ITYPE
Q_GCRAW(QTYPE q);
ITYPE
Q_GCVAL(QTYPE q);
QTYPE
Q_SCVAL(QTYPE q, ITYPE cv);
copy it exactly, don't be weird about it π«Ά
π DESCRIPTION π
okay so, function by function, here's the vibe:
Q_SIGNSHFT()β gets the bit position ofq's sign bit relative to bit zero. so basically "where does the sign bit live," as a number. iconic. πQ_SSIGN()β sets the sign bit ofqbased on the booleanisneg.truemeans negative energy,falsemeans positive energy. πQ_CRAWMASK()andQ_SRAWMASK()β returnq-specific bit masks forq's control bits and sign bit respectively. masks! for the control bits and the sign bit! matching set, slay. πQ_GCRAW()andQ_GCVAL()β get the raw masked control bits and value ofq's control bits respectively. one's the raw masked version, one's the value. don't mix them up bestie. πQ_SCVAL()β setsq's control bits to the valuecv. boom. done. β¨
and here's the thing β all of those functions operate on the following data types: s8q_t, u8q_t, s16q_t, u16q_t, s32q_t, u32q_t, s64q_t, and u64q_t, which are referred to generically as QTYPE. so like, that's the whole QTYPE family, all eight of them, signed and unsigned, 8 through 64. the ITYPE refers to the stdint(7) integer types. π¦
For more details, see qmath(3). (go read it, it's the main character.)
π¦ RETURN VALUES π¦
what comes back out, per function:
Q_SIGNSHFT()returns the sign bit's position as an integer.Q_SSIGN()returns the value ofqpost change. so you get yourqback, but changed. glow-up returned. πQ_CRAWMASK(),Q_SRAWMASK(),Q_GCRAW()andQ_GCVAL()return their respective values as integers of the same underlyingITYPEasq. same underlying type asq, always. matching energy. π§Q_SCVAL()returns the value ofqpost change.
β SEE ALSO β
the friend group. go say hi. π
π HISTORY π
The qmath(3) functions first appeared in FreeBSD 13.0. so like, they're not ancient, they're just established. periodt.
π AUTHORS π
The qmath(3) functions and this manual page were written by Lawrence Stewart <lstewart@FreeBSD.org> and sponsored by Netflix, Inc. β yes, that Netflix. sponsoring bit-level fixed-point math. main character behavior fr fr. π¬π₯
ok that's the whole page bestie, every flag-free function, every type, every return value, nothing skipped π
and finally, the cute little sign-off the manpage came with: this one's from Debian, dated July 8, 2018. π bye bestie, go manipulate some control bits responsibly! π«Άβ¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2018 Netflix, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms