File: rand.c

package info (click to toggle)
tra 20020816-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 1,696 kB
  • ctags: 2,623
  • sloc: ansic: 22,519; makefile: 406; asm: 269
file content (18 lines) | stat: -rw-r--r-- 279 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "os.h"
#include <time.h>

ulong
fastrand(void)
{
	ulong seed;
	struct timeval tv;
	static int first = 1;

	if(first){
		gettimeofday(&tv, nil);
		seed = tv.tv_sec ^ tv.tv_usec ^ (getpid()<<8);
		srandom(seed);
		first = 0;
	}
	return (random()&0xFFFF)|(random()<<16);
}