Re: Clarify drand48() return values
Theo de Raadt wrote: > Alexander Nasonov wrote: > > > Ingo Schwarze wrote: > > > Looking at our code in lib/libc/stdlib/drand48.c, i conclude that > > > drand48(3) does return 0.0 with a probability of 2^-48. > > > > I looked at the code too and I have some comments. > > > > > More generally, the function returns a uniform distribution of > > > numbers from the set {2^-48 * n | n integer and 0 <= n < 2^48}. > > > > You don't need three ldexp calls to compose 2^-48 * n: > > > > uint64_t n = (uint64_t)xseed[2] << 32 | xseed[1] << 16 | xseed[0]; > > return ldexp((double)n, -48); > > xseed? s/xseed/rseed/g -- Alex
Re: Clarify drand48() return values
Ingo Schwarze wrote: > Looking at our code in lib/libc/stdlib/drand48.c, i conclude that > drand48(3) does return 0.0 with a probability of 2^-48. I looked at the code too and I have some comments. > More generally, the function returns a uniform distribution of > numbers from the set {2^-48 * n | n integer and 0 <= n < 2^48}. You don't need three ldexp calls to compose 2^-48 * n: uint64_t n = (uint64_t)xseed[2] << 32 | xseed[1] << 16 | xseed[0]; return ldexp((double)n, -48); > Talking about loading bits into the mantissa and adjusting the > exponent feels mildly confusing, given that the distribution is > simply uniform over a fixed finite set. I'm not sending a patch > because i never looked at how floating point representation works > internally, so i would likely only make matters worse. Not sure if you wanted to patch the man page or the code. If the latter, take a binary representation of 1.0 and replace 52 least significant bits with (pseudo)random bits then subtract 1.0. double d = 1.0; uint64_t u = 0; memcpy(, , sizeof(d)); u |= n << 4; /* scale 48 bits to 52 bits, n is from the previous snippet */ memcpy(, , sizeof(u)); return d - 1.0; It will only work with IEEE 754 compliant doubles, though. -- Alex
Re: Clarify drand48() return values
j...@bitminer.ca wrote: > > Clarify that drand48 returns values not including 1.0. It's not clear from the documentation whether drand48 can generate a denormal number. If it can't, you can exclude 0.0 because it's a denormal ;-) -- Alex
Re: syscall call-from verification
Theo de Raadt wrote: > The following change only permits system calls from address-ranges > in the process which system calls are expected from. Just curious if some approximation of pledge can be reimplemented in userspace with more granular libc.so's text segments? -- Alex
Re: [EXTERNAL] Re: Removing PF
Eichert, Diana wrote: > I wrote a vax BPF jit as a simple exercize some time ago, so all > you really need now is to implement vax-to-${ARCH} jit on an MD > basis. This should be very easy to do as long as BPF does not get > extended to use floating-point values. I'm afraid you have to rewrite it to risv-to-${ARCH} and vectorise along the way. -- Alex