]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseMemoryLib/CopyMemWrapper.c
Split wrapper functions into separate source files to reduce image code size
[mirror_edk2.git] / MdePkg / Library / BaseMemoryLib / CopyMemWrapper.c
CommitLineData
608fd3fd 1/** @file\r
2 CopyMem() implementation.\r
3\r
4 Copyright (c) 2006, Intel Corporation<BR>\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13 Module Name: CopyMemWrapper.c\r
14\r
15 The following BaseMemoryLib instances share the same version of this file:\r
16\r
17 BaseMemoryLib\r
18 BaseMemoryLibMmx\r
19 BaseMemoryLibSse2\r
20 BaseMemoryLibRepStr\r
21 PeiMemoryLib\r
22 UefiMemoryLib\r
23\r
24**/\r
25\r
24de7645 26#include "MemLibInternals.h"\r
608fd3fd 27\r
28/**\r
29 Copy Length bytes from Source to Destination.\r
30\r
31 This function copies Length bytes from SourceBuffer to DestinationBuffer, and\r
32 returns DestinationBuffer. The implementation must be reentrant, and it must\r
33 handle the case where SourceBuffer overlaps DestinationBuffer.\r
34\r
35 If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then\r
36 ASSERT().\r
37 If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().\r
38\r
39 @param Destination Target of copy\r
40 @param Source Place to copy from\r
41 @param Length Number of bytes to copy\r
42\r
43 @return Destination\r
44\r
45**/\r
46VOID *\r
47EFIAPI\r
48CopyMem (\r
49 OUT VOID *Destination,\r
50 IN CONST VOID *Source,\r
51 IN UINTN Length\r
52 )\r
53{\r
24de7645 54 ASSERT (\r
55 Destination == NULL ||\r
56 Length <= MAX_ADDRESS - (UINTN)Destination + 1\r
57 );\r
58 ASSERT (\r
59 Source == NULL ||\r
60 Length <= MAX_ADDRESS - (UINTN)Source + 1\r
61 );\r
608fd3fd 62 if (Destination == Source || Length == 0) {\r
63 return Destination;\r
64 }\r
65 return InternalMemCopyMem (Destination, Source, Length);\r
66}\r