freebsd-dev/sys
Hans Petter Selasky d97ecf714e time(3): Increase precision of time conversion functions by using gcd.
When converting times to and from units which have many leading zeros,
it pays off to compute the greatest common divisor first, and then do the
scaling product. This way all time unit conversion comes down to scaling a
signed or unsigned 64-bit value by a fraction represented by two signed
or unsigned 32-bit integers.

SBT_1S is defined as 2^32 . When scaling using powers of 10 above 1,
the gcd of SBT_1S and 10^N is always greater than or equal to 4,
when N is greater or equal to 2.

Scaling a sbt value to milliseconds is then done by multiplying by
(1000 / 8) and dividing by (2^32 / 8).

This trick allows for higher precision at very little additional CPU cost.

It shall also be noted that the Xtosbt() functions prior to this patch,
sometimes were off-by-one:

For example when converting 1 / 8 of a second to sbt as 125ms the old sbt
conversion function would compute 0x20000001 while the new function computes
0x20000000 which multiplied by 8 becomes SBT_1S, which is the correct value.

Reviewed by:	kib@
Differential Revision:	https://reviews.freebsd.org/D36857
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-10-04 13:51:06 +02:00
..
amd64 amd64/db_trace.c: remove stray prototype 2022-10-04 01:50:30 +03:00
arm Teach the GICv3 driver to translate memory ranges 2022-09-23 15:28:45 +01:00
arm64 Set denominator to 1 if it is 0 in the init phase. 2022-10-01 02:01:59 +00:00
bsm
cam cam: Provide compatibility for CAMGETPASSTHRU for periph drivers 2022-09-29 13:14:57 -04:00
cddl opensolaris: Delete unused sources 2022-09-29 08:34:29 -04:00
compat linuxolator: add netlink support 2022-10-01 14:16:45 +00:00
conf arm64: coresight: fix the build without FDT 2022-09-29 14:33:33 -05:00
contrib zlib crc32: Add prototypes for recently-added static functions. 2022-09-28 14:00:27 -07:00
crypto Fix the IV length in the armv8 AES GCM code 2022-09-06 13:11:04 +01:00
ddb db_sym.c: restore sys/systm.h include 2022-10-03 14:51:22 -03:00
dev powerpc_nvram: Fix a bug in the adler32 checksum. 2022-10-03 16:10:41 -07:00
dts sys/dts: Remove MIPS files 2022-05-20 17:11:27 +01:00
fs cuse(3): Cosmetic change about testing boolean values. 2022-10-04 13:51:06 +02:00
gdb ddb: use _FLAGS command macros where appropriate 2022-07-05 11:56:55 -03:00
geom Adjust g_waitidle() visibility and definition 2022-08-02 21:11:10 +03:00
gnu
i386 ddb: de-duplicate decode_syscall() 2022-10-03 13:49:54 -03:00
isa Adjust function definition in isa's pnp.c to avoid clang 15 warning 2022-07-27 21:13:59 +02:00
kern time(3): Align fast clock times to avoid firing multiple timers. 2022-10-03 17:53:17 +02:00
kgssapi
libkern qdivrem: Predict division by zero as false. 2022-10-04 13:51:06 +02:00
modules linuxolator: add netlink support 2022-10-01 14:16:45 +00:00
net bpf: obtain timestamps from controller via pkthdr if available 2022-10-03 18:53:40 -04:00
net80211 net80211: move IEEE80211_F_WME check to vap for consistency 2022-09-29 12:54:23 +00:00
netgraph Alter the prototype of qsort_r(3) to match POSIX, which adopted the 2022-09-30 15:26:30 -07:00
netinet tcp idle reduce does not work for a server. 2022-10-04 07:09:01 -04:00
netinet6 netinet*: remove PRC_ constants and streamline ICMP processing 2022-10-03 20:53:04 -07:00
netipsec netinet*: remove PRC_ constants and streamline ICMP processing 2022-10-03 20:53:04 -07:00
netlink netlink: fix non-default builds (no INET, INET6, ROUTE_MPATH). 2022-10-02 13:12:52 +00:00
netpfil ipfilter: Cast uintmax_t values to size_t when adding to a pointer. 2022-09-28 13:58:34 -07:00
netsmb
nfs nfs: skip bootpc when vfs.root.mountfrom is other than nfs 2022-05-31 16:07:27 -03:00
nfsclient
nfsserver
nlm
ofed ibcore: The use of IN_LOOPBACK() now requires a valid VNET context. 2022-09-23 13:42:03 +02:00
opencrypto opencrypto: mark INVARIANTS variables as __diagused 2022-08-10 15:35:29 -04:00
powerpc powerpc: slb_alloc_user_cache: fix missing uma_zalloc wait flag 2022-10-03 20:56:41 -03:00
riscv riscv: move GEOM_PART_GPT option to DEFAULTS 2022-10-03 13:49:54 -03:00
rpc nfsd: Allow multiple instances of rpc.tlsservd 2022-08-22 13:54:24 -07:00
security vfs: introduce V_PCATCH to stop abusing PCATCH 2022-09-17 15:41:37 +00:00
sys time(3): Increase precision of time conversion functions by using gcd. 2022-10-04 13:51:06 +02:00
teken
tests
tools sound(4): Fix order of parameters for custom equalizer band pass filter. 2022-08-22 10:04:26 +02:00
ufs Updates to UFS/FFS superblock integrity checks when reading a superblock. 2022-10-03 05:53:10 -07:00
vm Fix various places which cast a pointer to a vm_paddr_t or vice versa. 2022-10-03 16:10:41 -07:00
x86 Fix various places which cast a pointer to a vm_paddr_t or vice versa. 2022-10-03 16:10:41 -07:00
xdr
xen xenbus: improve device tracking 2022-06-07 12:29:53 +02:00
Makefile