test: rtl/random.c File Reference

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# random.c File Reference

`#include <ntrtlp.h>`

Go to the source code of this file.

## Defines

#define | Multiplier ((ULONG)(0x80000000ul - 19))
#define | Increment ((ULONG)(0x80000000ul - 61))
#define | Modulus ((ULONG)(0x80000000ul - 1))
#define | UniformMacro(Seed)

## Functions

ULONG | RtlUniform (IN OUT PULONG Seed)
ULONG | RtlRandom (IN OUT PULONG Seed)

## Variables

ULONG | RtlpRandomConstantVector []

## Define Documentation

#define Increment ((ULONG)(0x80000000ul - 61))

| Definition at line 32 of file rtl/random.c. Referenced by Ke386VdmInsertQueueApc(), KeBoostPriorityThread(), KeI386GetLid(), KeInsertQueueApc(), KePulseEvent(), KeQueryBasePriorityThread(), KeReleaseMutant(), KeReleaseSemaphore(), KeSetBasePriorityThread(), KeSetEvent(), KeSetEventBoostPriority(), KeSetProcess(), KeTerminateThread(), KeUpdateSystemTime(), KiInsertQueueApc(), KiUnwaitThread(), KiWaitTest(), RtlUniform(), VerifierSetEvent(), and ViReservePoolAllocation().

#define Modulus ((ULONG)(0x80000000ul - 1))

| Definition at line 33 of file rtl/random.c. Referenced by RtlUniform().

#define Multiplier ((ULONG)(0x80000000ul - 19))

| Definition at line 31 of file rtl/random.c. Referenced by RtlExtendedIntegerMultiply(), and RtlUniform().

#define UniformMacro | ( | Seed |  | ) |

Value:

    (                                 \
        *Seed = (((Multiplier * (*Seed)) + Increment) % Modulus) \
        )

Definition at line 64 of file rtl/random.c.

Referenced by RtlRandom().

## Function Documentation

ULONG RtlRandom | ( | IN OUT PULONG | Seed | ) |

Definition at line 72 of file rtl/random.c.

References RTL_PAGED_CODE, RtlpRandomConstantVector, Seed, and UniformMacro.

Referenced by AnotherPrefix(), main(), MmCreateProcessAddressSpace(), and RtlpDphShouldAllocateInPageHeap().

    00078                    :
    00079
    00080     An every better random number generator based on MacLaren and Marsaglia.
    00081
    00082 Arguments:
    00083
    00084     Seed - Supplies a pointer to the random number generator seed.
    00085
    00086 Return Value:
    00087
    00088     ULONG - returns a random number uniformly distributed over [0..MAXLONG]
    00089
    00090 --*/
    00091
    00092 {
    00093     ULONG X;
    00094     ULONG Y;
    00095     ULONG j;
    00096     ULONG Result;
    00097
    00098     RTL_PAGED_CODE();
    00099
    00100     X = UniformMacro(Seed);
    00101     Y = UniformMacro(Seed);
    00102
    00103     j = Y % 128;
    00104
    00105     Result = RtlpRandomConstantVector[j];
    00106
    00107     RtlpRandomConstantVector[j] = X;
    00108
    00109     return Result;
    00110
    00111 }
    }

ULONG RtlUniform | ( | IN OUT PULONG | Seed | ) |

Definition at line 37 of file rtl/random.c.

References Increment, Modulus, Multiplier, and Seed.

Referenced by main().

    00043                    :
    00044
    00045     A simple uniform random number generator, based on D.H. Lehmer's 1948
    00046     alrogithm.
    00047
    00048 Arguments:
    00049
    00050     Seed - Supplies a pointer to the random number generator seed.
    00051
    00052 Return Value:
    00053
    00054     ULONG - returns a random number uniformly distributed over [0..MAXLONG]
    00055
    00056 --*/
    00057
    00058 {
    00059     *Seed = ((Multiplier * (*Seed)) + Increment) % Modulus;
    00060     return *Seed;
    00061 }
    #endif

## Variable Documentation

ULONG RtlpRandomConstantVector[]

| Definition at line 69 of file rtl/random.c. Referenced by RtlRandom().