1*43beb913STimo Kreuzer #include <stdlib.h> 2*43beb913STimo Kreuzer 3*43beb913STimo Kreuzer #if defined(__GNUC__) 4*43beb913STimo Kreuzer static unsigned long long next = 0; 5*43beb913STimo Kreuzer #else 6*43beb913STimo Kreuzer static unsigned __int64 next = 0; 7*43beb913STimo Kreuzer #endif 8*43beb913STimo Kreuzer 9*43beb913STimo Kreuzer /* 10*43beb913STimo Kreuzer * @implemented 11*43beb913STimo Kreuzer */ rand(void)12*43beb913STimo Kreuzerint __cdecl rand(void) 13*43beb913STimo Kreuzer { 14*43beb913STimo Kreuzer #if defined(__GNUC__) 15*43beb913STimo Kreuzer next = next * 0x5deece66dLL + 11; 16*43beb913STimo Kreuzer #else 17*43beb913STimo Kreuzer next = next * 0x5deece66di64 + 11; 18*43beb913STimo Kreuzer #endif 19*43beb913STimo Kreuzer return (int)((next >> 16) & RAND_MAX); 20*43beb913STimo Kreuzer } 21*43beb913STimo Kreuzer 22*43beb913STimo Kreuzer 23*43beb913STimo Kreuzer /* 24*43beb913STimo Kreuzer * @implemented 25*43beb913STimo Kreuzer */ srand(unsigned seed)26*43beb913STimo Kreuzervoid __cdecl srand(unsigned seed) 27*43beb913STimo Kreuzer { 28*43beb913STimo Kreuzer next = seed; 29*43beb913STimo Kreuzer } 30