mirror of
				https://source.denx.de/u-boot/u-boot.git
				synced 2025-10-31 00:11:51 +01:00 
			
		
		
		
	Create a new rand.h header file and move functions into it, to reduce the size of common.h Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
		
			
				
	
	
		
			33 lines
		
	
	
		
			497 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			33 lines
		
	
	
		
			497 B
		
	
	
	
		
			C
		
	
	
	
	
	
| // SPDX-License-Identifier: GPL-2.0+
 | |
| /*
 | |
|  * Simple xorshift PRNG
 | |
|  *   see http://www.jstatsoft.org/v08/i14/paper
 | |
|  *
 | |
|  * Copyright (c) 2012 Michael Walle
 | |
|  * Michael Walle <michael@walle.cc>
 | |
|  */
 | |
| 
 | |
| #include <common.h>
 | |
| #include <rand.h>
 | |
| 
 | |
| static unsigned int y = 1U;
 | |
| 
 | |
| unsigned int rand_r(unsigned int *seedp)
 | |
| {
 | |
| 	*seedp ^= (*seedp << 13);
 | |
| 	*seedp ^= (*seedp >> 17);
 | |
| 	*seedp ^= (*seedp << 5);
 | |
| 
 | |
| 	return *seedp;
 | |
| }
 | |
| 
 | |
| unsigned int rand(void)
 | |
| {
 | |
| 	return rand_r(&y);
 | |
| }
 | |
| 
 | |
| void srand(unsigned int seed)
 | |
| {
 | |
| 	y = seed;
 | |
| }
 |