test: localrtl.c Source File

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

# localrtl.c

Go to the documentation of this file.

    00001 /*++
    00002
    00003 Copyright (c) 1993  Digital Equipment Corporation
    00004
    00005 Module Name:
    00006
    00007     localrtl.c
    00008
    00009 Abstract:
    00010
    00011     This module contains alternate implementations of each of the Rtl Memory
    00012     functions and other common functions required by the Rtl Memory test
    00013     programs.
    00014
    00015 Author:
    00016
    00017     Thomas Van Baak (tvb) 11-Jan-1993
    00018
    00019 Revision History:
    00020
    00021 --*/
    00022
    00023 #include <nt.h>
    00024 #include "localrtl.h"
    00025
    00026 //
    00027 // Simple pattern generator.
    00028 //
    00029
    00030 #define PATTERN "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
    00031 #define PATTERN_SIZE (sizeof(PATTERN) - 1)
    00032 UCHAR Pattern[] = PATTERN;
    00033
    00034 VOID
    00035 FillPattern(PUCHAR To, ULONG Length)
    00036 {
    00037     ULONG Index;
    00038     ULONG Rotor = 0;
    00039
    00040     for (Index = 0; Index < Length; Index += 1) {
    00041         To[Index] = Pattern[Rotor];
    00042         Rotor += 1;
    00043         if (Rotor == PATTERN_SIZE) {
    00044             Rotor = 0;
    00045         }
    00046     }
    00047 }
    00048
    00049 //
    00050 // The following functions are simple, non-optimized, (and thus maybe even
    00051 // bug-proof) implementations of each of the Rtl Memory functions.
    00052 //
    00053
    00054 ULONG
    00055 LocalCompareMemory (
    00056     PVOID Source1,
    00057     PVOID Source2,
    00058     ULONG Length
    00059     )
    00060 {
    00061     ULONG Index;
    00062     PUCHAR Left = Source1;
    00063     ULONG Match;
    00064     PUCHAR Right = Source2;
    00065
    00066     Match = 0;
    00067     for (Index = 0; Index < Length; Index += 1) {
    00068         if (Left[Index] != Right[Index]) {
    00069             break;
    00070         }
    00071         Match += 1;
    00072     }
    00073     return Match;
    00074 }
    00075
    00076 ULONG
    00077 LocalCompareMemoryUlong (
    00078     PVOID Source,
    00079     ULONG Length,
    00080     ULONG Pattern
    00081     )
    00082 {
    00083     PULONG From = Source;
    00084     ULONG Index;
    00085     ULONG Match;
    00086
    00087     Match = 0;
    00088     for (Index = 0; Index < Length / sizeof(ULONG); Index += 1) {
    00089         if (From[Index] != Pattern) {
    00090             break;
    00091         }
    00092         Match += sizeof(ULONG);
    00093     }
    00094     return Match;
    00095 }
    00096
    00097 VOID
    00098 LocalMoveMemory (
    00099    PVOID Destination,
    00100    PVOID Source,
    00101    ULONG Length
    00102    )
    00103 {
    00104     PUCHAR From = Source;
    00105     ULONG Index;
    00106     PUCHAR To = Destination;
    00107
    00108     for (Index = 0; Index < Length; Index += 1) {
    00109         if (To <= From) {
    00110             To[Index] = From[Index];
    00111
    00112         } else {
    00113             To[Length - 1 - Index] = From[Length - 1 - Index];
    00114         }
    00115     }
    00116 }
    00117
    00118 VOID
    00119 LocalFillMemory (
    00120    PVOID Destination,
    00121    ULONG Length,
    00122    UCHAR Fill
    00123    )
    00124 {
    00125     ULONG Index;
    00126     PUCHAR To = Destination;
    00127
    00128     for (Index = 0; Index < Length; Index += 1) {
    00129         To[Index] = Fill;
    00130     }
    00131 }
    00132
    00133 VOID
    00134 LocalFillMemoryUlong (
    00135    PVOID Destination,
    00136    ULONG Length,
    00137    ULONG Pattern
    00138    )
    00139 {
    00140     ULONG Index;
    00141     PULONG To = Destination;
    00142
    00143     for (Index = 0; Index < Length / sizeof(ULONG); Index += 1) {
    00144         To[Index] = Pattern;
    00145     }
    00146 }
    00147
    00148 VOID
    00149 LocalZeroMemory (
    00150    PVOID Destination,
    00151    ULONG Length
    00152    )
    00153 {
    00154     ULONG Index;
    00155     PUCHAR To = Destination;
    00156
    00157     for (Index = 0; Index < Length; Index += 1) {
    00158         To[Index] = 0;
    00159     }
    00160 }