History log of /freebsd-current/sys/sys/qmath.h
Revision Date Author Comments
# 743d4b7c 01-Apr-2024 Lawrence Stewart <lstewart@FreeBSD.org>

Fix the logic which determines if the destination Q variable can represent the source Q variable's value with full accuracy.

The new logic is mostly self explanatory except for the value fit checks.

If b has fewer integer bits than a, 0 == (Q_GIABSVAL(a) & (~Q_TC(a, 0) << Q_NIBITS(b))) is checking that a's integer value does not have high-order bits set above what b is capable of storing.

If b has fewer fractional bits than a, 0 == (Q_GFABSVAL(a) & ~(~Q_TC(a, 0) << (Q_NFBITS(a) - Q_NFBITS(b))))) is checking that a's fractional value does not have low-order bits set below what b is capable of storing.

Obtained from: Netflix, Inc.
MFC afer: 1 week


# 95ee2897 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# f1f98706 18-Apr-2021 Warner Losh <imp@FreeBSD.org>

Minor style cleanup

We prefer 'while (0)' to 'while(0)' according to grep and stlye(9)'s
space after keyword rule. Remove a few stragglers of the latter.
Many of these usages were inconsistent within the file.

MFC After: 3 days
Sponsored by: Netflix


# 2c7cf9a3 09-Oct-2019 Edward Tomasz Napierala <trasz@FreeBSD.org>

Fix the compilation workaround so it's not entirely dead code - clang
also defines __GNUC__.

Submitted by: cem
Sponsored by: Klara Inc, Netflix


# a9afc57c 28-Sep-2019 Edward Tomasz Napierala <trasz@FreeBSD.org>

Fix Q_TOSTR(3) with GCC when it's called with first parameter being const.

Discussed with: cem
MFC after: 2 weeks
Sponsored by: Klara Inc, Netflix
Differential Revision: https://reviews.freebsd.org/D21766


# 3dd61c21 29-Aug-2019 Edward Tomasz Napierala <trasz@FreeBSD.org>

Fix qmath(3) build problems with GCC 8.

Discussed with: asomers
Sponsored by: Klara Systems
Differential Revision: https://reviews.freebsd.org/D21442


# 5a38af1f 27-Aug-2019 Edward Tomasz Napierala <trasz@FreeBSD.org>

Introduce <sys/qmath.h>, a fixed-point math library from Netflix.

This makes it possible to perform mathematical operations
on
fractional values without using floating point. It operates on Q
numbers, which are integer-sized, opaque structures initialized
to hold a chosen number of integer and fractional
bits.


For a general description of the Q number system, see the "Fixed Point
Representation & Fractional Math" whitepaper[1]; for the actual
API see the qmath(3) man page.

This is one of dependencies for the upcoming stats(3) framework[2]
that will be applied to the TCP stack in a later commit.

1. https://www.superkits.net/whitepapers/Fixed%20Point%20Representation%20&%20Fractional%20Math.pdf
2. https://reviews.freebsd.org/D20477

Reviewed by: bcr (man pages, earlier version), sef (earlier version)
Discussed with: cem, dteske, imp, lstewart
Sponsored By: Klara Inc, Netflix
Obtained from: Netflix
Differential Revision: https://reviews.freebsd.org/D20116