[boot] Provide memset implementation

Clang needs memset, memcpy, etc to exist even in freestanding situations
because it will emit calls to those functions. This commit adds a simple
weak-linked memset implementation.
This commit is contained in:
Justin C. Miller
2020-05-17 22:00:50 -07:00
parent 42dfa6ccfe
commit c9722a07f3

View File

@@ -17,6 +17,18 @@ void *memcpy(void *dest, const void *src, size_t n)
return dest;
}
/// Basic memset() implementation for clang. Clang requires freestanding code
/// implement memset(), as it may emit references to it. This basic memset is
/// not the most efficient, but will get linked if no other memcpy exists.
__attribute__ ((__weak__))
void *memset(void *dest, int c, size_t n)
{
uint8_t *cdest = reinterpret_cast<uint8_t*>(dest);
for (size_t i = 0; i < n; ++i)
cdest[i] = static_cast<uint8_t>(c);
return dest;
}
int _purecall()
{
::boot::error::raise(uefi::status::unsupported, L"Pure virtual call");