1 | /** @file
|
---|
2 | * innotek Portable Runtime - Random Numbers and Byte Streams.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2007 innotek GmbH
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License as published by the Free Software Foundation,
|
---|
12 | * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
|
---|
13 | * distribution. VirtualBox OSE is distributed in the hope that it will
|
---|
14 | * be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | */
|
---|
16 |
|
---|
17 | #ifndef ___iprt_rand_h
|
---|
18 | #define ___iprt_rand_h
|
---|
19 |
|
---|
20 | #include <iprt/cdefs.h>
|
---|
21 | #include <iprt/types.h>
|
---|
22 |
|
---|
23 | __BEGIN_DECLS
|
---|
24 |
|
---|
25 | /** @defgroup grp_rt_rand RTRand - Random Numbers and Byte Streams
|
---|
26 | * @ingroup grp_rt
|
---|
27 | * @{
|
---|
28 | */
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * Fills a buffer with random bytes.
|
---|
32 | *
|
---|
33 | * @param pv Where to store the random bytes.
|
---|
34 | * @param cb Number of bytes to generate.
|
---|
35 | */
|
---|
36 | RTDECL(void) RTRandBytes(void *pv, size_t cb);
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * Generate a 32-bit signed random number in the set [i32First..i32Last].
|
---|
40 | *
|
---|
41 | * @returns The random number.
|
---|
42 | * @param i32First First number in the set.
|
---|
43 | * @param i32Last Last number in the set.
|
---|
44 | */
|
---|
45 | RTDECL(int32_t) RTRandS32Ex(int32_t i32First, int32_t i32Last);
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Generate a 32-bit signed random number.
|
---|
49 | *
|
---|
50 | * @returns The random number.
|
---|
51 | */
|
---|
52 | RTDECL(int32_t) RTRandS32(void);
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * Generate a 32-bit unsigned random number in the set [u32First..u32Last].
|
---|
56 | *
|
---|
57 | * @returns The random number.
|
---|
58 | * @param u32First First number in the set.
|
---|
59 | * @param u32Last Last number in the set.
|
---|
60 | */
|
---|
61 | RTDECL(uint32_t) RTRandU32Ex(uint32_t u32First, uint32_t u32Last);
|
---|
62 |
|
---|
63 | /**
|
---|
64 | * Generate a 32-bit unsigned random number.
|
---|
65 | *
|
---|
66 | * @returns The random number.
|
---|
67 | */
|
---|
68 | RTDECL(uint32_t) RTRandU32(void);
|
---|
69 |
|
---|
70 | /**
|
---|
71 | * Generate a 32-bit signed random number in the set [i32First..i32Last].
|
---|
72 | *
|
---|
73 | * @returns The random number.
|
---|
74 | * @param i32First First number in the set.
|
---|
75 | * @param i32Last Last number in the set.
|
---|
76 | */
|
---|
77 | RTDECL(int64_t) RTRandS64Ex(int64_t i64First, int64_t i64Last);
|
---|
78 |
|
---|
79 | /**
|
---|
80 | * Generate a 64-bit signed random number.
|
---|
81 | *
|
---|
82 | * @returns The random number.
|
---|
83 | */
|
---|
84 | RTDECL(int64_t) RTRandS64(void);
|
---|
85 |
|
---|
86 | /**
|
---|
87 | * Generate a 64-bit unsigned random number in the set [u64First..u64Last].
|
---|
88 | *
|
---|
89 | * @returns The random number.
|
---|
90 | * @param u64First First number in the set.
|
---|
91 | * @param u64Last Last number in the set.
|
---|
92 | */
|
---|
93 | RTDECL(uint64_t) RTRandU64Ex(uint64_t u64First, uint64_t u64Last);
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * Generate a 64-bit unsigned random number.
|
---|
97 | *
|
---|
98 | * @returns The random number.
|
---|
99 | */
|
---|
100 | RTDECL(uint64_t) RTRandU64(void);
|
---|
101 |
|
---|
102 | /** @} */
|
---|
103 |
|
---|
104 | __END_DECLS
|
---|
105 |
|
---|
106 |
|
---|
107 | #endif
|
---|
108 |
|
---|