]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCopyMem.c
1, Use #if defined() to judge the switching macro such as compiler macro.
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EfiCommonLib / EfiCopyMem.c
CommitLineData
3eb9473e 1/*++\r
2\r
3Copyright (c) 2004, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 EfiCopyMem.c\r
15\r
16Abstract:\r
17\r
18 Implementation of the EfiCopyMem routine. This function is broken\r
19 out into its own source file so that it can be excluded from a\r
20 build for a particular platform easily if an optimized version \r
21 is desired.\r
22\r
23--*/\r
24\r
25#include "Tiano.h"\r
26\r
27VOID\r
28EfiCommonLibCopyMem (\r
29 IN VOID *Destination,\r
30 IN VOID *Source,\r
31 IN UINTN Length\r
32 )\r
33/*++\r
34\r
35Routine Description:\r
36\r
37 Copy Length bytes from Source to Destination.\r
38\r
39Arguments:\r
40\r
41 Destination - Target of copy\r
42\r
43 Source - Place to copy from\r
44\r
45 Length - Number of bytes to copy\r
46\r
47Returns:\r
48\r
49 None\r
50\r
51--*/\r
52{\r
53 CHAR8 *Destination8;\r
54 CHAR8 *Source8;\r
55\r
56 if (Source < Destination) {\r
57 Destination8 = (CHAR8 *) Destination + Length - 1;\r
58 Source8 = (CHAR8 *) Source + Length - 1;\r
59 while (Length--) {\r
60 *(Destination8--) = *(Source8--);\r
61 }\r
62 } else {\r
63 Destination8 = (CHAR8 *) Destination;\r
64 Source8 = (CHAR8 *) Source;\r
65 while (Length--) {\r
66 *(Destination8++) = *(Source8++);\r
67 }\r
68 }\r
69}\r