Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature-vt/sys/src/libc/9sys/truerand.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
 
4
ulong
5
truerand(void)
6
{
7
	ulong x;
8
	static int randfd = -1;
9
 
10
	if(randfd < 0)
11
		randfd = open("/dev/random", OREAD|OCEXEC);
12
	if(randfd < 0)
13
		sysfatal("can't open /dev/random");
14
	if(read(randfd, &x, sizeof(x)) != sizeof(x))
15
		sysfatal("can't read /dev/random");
16
	return x;
17
}