1 // Public random number operations.
7 #include "cln/modules.h"
13 struct { uint32 hi; uint32 lo; } seed;
18 // random32(randomstate) liefert eine neue Zufallszahl.
19 // > randomstate: ein Random-State, wird verändert
20 // < ergebnis: eine 32-Bit-Zufallszahl
21 extern uint32 random32 (random_state& randomstate);
23 #if defined(HAVE_FAST_LONGLONG)
24 // random64(randomstate) liefert eine neue Zufallszahl.
25 // > randomstate: ein Random-State, wird verändert
26 // < ergebnis: eine 64-Bit-Zufallszahl
27 inline uint64 random64 (random_state& randomstate)
29 return ((uint64)random32(randomstate) << 32)
30 | (uint64)random32(randomstate);
34 // Ein globaler Zufallszahlengenerator.
35 extern random_state default_random_state;
36 class cl_random_def_init_helper
40 cl_random_def_init_helper();
41 ~cl_random_def_init_helper();
43 static cl_random_def_init_helper cl_random_def_init_helper_instance;
45 // Das ist der Default-Generator.
46 inline uint32 random32 (void)
47 { return random32(default_random_state); }
48 #if defined(HAVE_FAST_LONGLONG)
49 inline uint64 random64 (void)
50 { return random64(default_random_state); }
55 #endif /* _CL_RANDOM_H */