[RFC 1/1] Optimizing the rand function on arm64 platforms

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Mon Jul 24 18:14:54 GMT 2023



On 24/07/23 15:03, Xi Ruoyao wrote:
> On Mon, 2023-07-24 at 09:59 -0300, Adhemerval Zanella Netto wrote:
>>
>> The rand family functions (including the rand48 ones) is *really* a bad
>> interface and it seems that future POSIX realized it and plan to obsolete 
>> it in next revision [1].
>>
>> [1] https://lists.gnu.org/archive/html/bug-gnulib/2023-07/msg00104.html
> 
> Hmm, what is the problem with the rand48 ones?  This link does not
> mention the rand48 functions anyway.
> 
> AFAIK rand_r is broken because the state space is too small and rand48
> functions do not share the issue.

lrand48 and nrand48 only returns over an interval of [0, 2^31), which is
tricky to work with unsigned results, sizes larger than long (either
int128 or int64 for 32 bits), or buffers.   And it is still a linear 
congruential formula, so might be not suitable for all scenarios.  


More information about the Libc-alpha mailing list