xref: /aosp_15_r20/external/lzma/CPP/Common/Random.cpp (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1*f6dc9357SAndroid Build Coastguard Worker // Common/Random.cpp
2*f6dc9357SAndroid Build Coastguard Worker 
3*f6dc9357SAndroid Build Coastguard Worker #include "StdAfx.h"
4*f6dc9357SAndroid Build Coastguard Worker 
5*f6dc9357SAndroid Build Coastguard Worker #include <stdlib.h>
6*f6dc9357SAndroid Build Coastguard Worker 
7*f6dc9357SAndroid Build Coastguard Worker #ifndef _WIN32
8*f6dc9357SAndroid Build Coastguard Worker #include <time.h>
9*f6dc9357SAndroid Build Coastguard Worker #else
10*f6dc9357SAndroid Build Coastguard Worker #include "MyWindows.h"
11*f6dc9357SAndroid Build Coastguard Worker #endif
12*f6dc9357SAndroid Build Coastguard Worker 
13*f6dc9357SAndroid Build Coastguard Worker #include "Random.h"
14*f6dc9357SAndroid Build Coastguard Worker 
Init(unsigned seed)15*f6dc9357SAndroid Build Coastguard Worker void CRandom::Init(unsigned seed) { srand(seed); }
16*f6dc9357SAndroid Build Coastguard Worker 
Init()17*f6dc9357SAndroid Build Coastguard Worker void CRandom::Init()
18*f6dc9357SAndroid Build Coastguard Worker {
19*f6dc9357SAndroid Build Coastguard Worker   Init((unsigned)
20*f6dc9357SAndroid Build Coastguard Worker     #ifdef _WIN32
21*f6dc9357SAndroid Build Coastguard Worker     GetTickCount()
22*f6dc9357SAndroid Build Coastguard Worker     #else
23*f6dc9357SAndroid Build Coastguard Worker     time(NULL)
24*f6dc9357SAndroid Build Coastguard Worker     #endif
25*f6dc9357SAndroid Build Coastguard Worker     );
26*f6dc9357SAndroid Build Coastguard Worker }
27*f6dc9357SAndroid Build Coastguard Worker 
Generate() const28*f6dc9357SAndroid Build Coastguard Worker int CRandom::Generate() const { return rand(); }
29