portable random unsigned int added by dieggsy on Wed Mar 13 20:22:30 2019

(import (only miscmacros repeat)
        (only chicken.blob make-blob)
        (only chicken.random random-bytes pseudo-random-integer)
        srfi-4
        chicken.foreign)

(foreign-declare "#include <limits.h>")

(define (random-long)
  (let ((bytes (random-bytes (make-blob 8))))
    ((foreign-lambda* unsigned-long ((c-pointer l))
       "C_return(*(unsigned long*)l);")
     (location bytes))))

(define (random-long*)
  (pseudo-random-integer (foreign-value "LONG_MAX" long)))