summaryrefslogtreecommitdiffstats
path: root/MdePkg/Library/BaseMemoryLib/SetMem.c
diff options
context:
space:
mode:
Diffstat (limited to 'MdePkg/Library/BaseMemoryLib/SetMem.c')
-rw-r--r--MdePkg/Library/BaseMemoryLib/SetMem.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/MdePkg/Library/BaseMemoryLib/SetMem.c b/MdePkg/Library/BaseMemoryLib/SetMem.c
index d42abb1287..c079d75a18 100644
--- a/MdePkg/Library/BaseMemoryLib/SetMem.c
+++ b/MdePkg/Library/BaseMemoryLib/SetMem.c
@@ -12,9 +12,6 @@
**/
-
-
-
#include "MemLibInternals.h"
/**
@@ -30,9 +27,9 @@
VOID *
EFIAPI
InternalMemSetMem (
- OUT VOID *Buffer,
- IN UINTN Length,
- IN UINT8 Value
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT8 Value
)
{
//
@@ -40,42 +37,44 @@ InternalMemSetMem (
// volatile to prevent the optimizer from replacing this function with
// the intrinsic memset()
//
- volatile UINT8 *Pointer8;
- volatile UINT32 *Pointer32;
- volatile UINT64 *Pointer64;
- UINT32 Value32;
- UINT64 Value64;
+ volatile UINT8 *Pointer8;
+ volatile UINT32 *Pointer32;
+ volatile UINT64 *Pointer64;
+ UINT32 Value32;
+ UINT64 Value64;
if ((((UINTN)Buffer & 0x7) == 0) && (Length >= 8)) {
// Generate the 64bit value
Value32 = (Value << 24) | (Value << 16) | (Value << 8) | Value;
Value64 = LShiftU64 (Value32, 32) | Value32;
- Pointer64 = (UINT64*)Buffer;
+ Pointer64 = (UINT64 *)Buffer;
while (Length >= 8) {
*(Pointer64++) = Value64;
- Length -= 8;
+ Length -= 8;
}
// Finish with bytes if needed
- Pointer8 = (UINT8*)Pointer64;
+ Pointer8 = (UINT8 *)Pointer64;
} else if ((((UINTN)Buffer & 0x3) == 0) && (Length >= 4)) {
// Generate the 32bit value
Value32 = (Value << 24) | (Value << 16) | (Value << 8) | Value;
- Pointer32 = (UINT32*)Buffer;
+ Pointer32 = (UINT32 *)Buffer;
while (Length >= 4) {
*(Pointer32++) = Value32;
- Length -= 4;
+ Length -= 4;
}
// Finish with bytes if needed
- Pointer8 = (UINT8*)Pointer32;
+ Pointer8 = (UINT8 *)Pointer32;
} else {
- Pointer8 = (UINT8*)Buffer;
+ Pointer8 = (UINT8 *)Buffer;
}
+
while (Length-- > 0) {
*(Pointer8++) = Value;
}
+
return Buffer;
}