ref: fa83d0a67d9c796e60a13c5a7ce8e9d4d9e97871 dir: /libc/lnrand.c/
#include <u.h> #include <libc.h> #define MASK 0x7fffffffL long lnrand(long n) { long slop, v; if(n < 0) return n; slop = MASK % n; do v = lrand(); while(v <= slop); return v % n; }