CloverBootloader/Library/CppMemLib/memory.cpp

51 lines
1.0 KiB
C++
Raw Normal View History

2020-11-02 14:45:11 +01:00
//
// memory.cpp
//
// Created by Jief on 30/10/2020.
//
extern "C" {
#include <Uefi/UefiBaseType.h>
2020-11-02 14:45:11 +01:00
#include <Library/BaseMemoryLib.h>
/*
* memset and memcpy has to be provided for clang
*/
// Jief : I think __attribute__ ((used)) was needed for older version of GCC, can't remember.
// If you want to put it back, do it only for the compiler version that really needs it.
// Nov 2020 : With Gcc 10.2, defining it for memset is ok, but not needed. Defining it for memcpy generates an error in GenFW.
//#ifdef __GNUC__
// void* memset(void* dst, int ch, UINTN count) __attribute__ ((used));
// void* memcpy(void* dst, const void* src, UINTN count) __attribute__ ((used));
//#endif
2020-11-02 14:45:11 +01:00
void* memset(void* dst, int ch, UINTN count)
{
SetMem(dst, count, (UINT8)(ch));
return dst;
}
void* memcpy(void* dst, const void* src, UINTN count)
{
CopyMem(dst, src, count);
return dst;
}
#if defined(__clang__)
void __bzero(void *dst, UINTN n)
{
SetMem(dst, n, (UINT8)(0));
}
#endif
2020-11-02 14:45:11 +01:00
} // extern "C"