plan 9 kernel history: overview | file list | diff list

1992/0312/port/devcons.c (diff list | history)

1992/0310/sys/src/9/port/devcons.c:889,9071992/0312/sys/src/9/port/devcons.c:889,900 (short | long | prev | next)
1991/1206    
 *  Rand is huge and not worth it here.  Be small. 
 *  Borrowed from the white book. 
1991/1127    
 */ 
ulong	randn; 
void 
srand(char *s) 
{ 
	randn = MACHP(0)->ticks * boottime; 
	while(s && *s) 
		randn = (randn << 1) ^ *s++; 
} 
                 
int 
nrand(int n) 
{ 
	randn = randn*1103515245 + 12345; 
1992/0312    
	static ulong randn; 
 
	randn = randn*1103515245 + 12345 + MACHP(0)->ticks; 
1991/1127    
	return (randn>>16) % n; 
1990/0227    
} 
1991/1102    
 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)