HomeFreeBSD

libc: Reimplement the *rand48 family of functions

Description

libc: Reimplement the *rand48 family of functions

Rather than implementing the recurrence using 3 16-bit integers, as was
done in _dorand48() before this patch, provide an equivalent
implementation using 64-bit integers.

For drand48() and erand48(), replace the use of ldexp() with
bit-twiddling assuming IEEE 754 double-precision float layout.

This implementation is significantly faster and requires less code,
while producing identical outputs on supported platforms.

While here, add a STANDARDS section to rand48.3.

Obtained from: https://github.com/apple-oss-distributions/libc
MFC after: 3 weeks
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D52429

(cherry picked from commit 2ba20004ef7649db7654520e8376927c4410d9c3)

Details

Provenance
markjAuthored on Sep 4 2025, 7:34 PM
Differential Revision
D52429: libc: Reimplement the *rand48 family of functions
Parents
rG79fbc4ccb6c6: release: Use PKG_CMD when installing pkgbase packages in vmimage.subr
Branches
Unknown
Tags
Unknown