Move memcpy/memset definition to global init.c

Following up on previous patch, I think we should move
memcpy/memset definitions to the global init.c, since MSVC does
also inserts calls to memset/memcpy for the x86_32 platform,
even when disabling standard libraries and intrinsics.

All in all, it looks like, for all platforms, we should assume
that a compiler may still insert these calls regardless.

Signed-off-by: Pete Batard <pete@akeo.ie>
Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
This commit is contained in:
Nigel Croxon 2017-11-06 09:38:38 -05:00
parent 787b53a66c
commit b1d426ce67
4 changed files with 40 additions and 94 deletions

View File

@ -24,32 +24,3 @@ InitializeLibPlatform (
)
{
}
#ifndef __SIZE_TYPE__
#define __SIZE_TYPE__ UINTN
#endif
/*
* Calls to these functions may be emitted implicitly by GCC even when
* -ffreestanding is in effect.
*/
void *memset(void *s, int c, __SIZE_TYPE__ n)
{
unsigned char *p = s;
while (n--)
*p++ = c;
return s;
}
void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n)
{
const unsigned char *q = src;
unsigned char *p = dest;
while (n--)
*p++ = *q++;
return dest;
}

View File

@ -25,35 +25,6 @@ InitializeLibPlatform (
{
}
#ifndef __SIZE_TYPE__
#define __SIZE_TYPE__ UINTN
#endif
/*
* Calls to these functions may be emitted implicitly by GCC even when
* -ffreestanding is in effect.
*/
void *memset(void *s, int c, __SIZE_TYPE__ n)
{
unsigned char *p = s;
while (n--)
*p++ = c;
return s;
}
void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n)
{
unsigned char *p = dest;
unsigned char const *q = src;
while (n--)
*p++ = *q++;
return dest;
}
#ifdef __GNUC__
void __div0(void)
{

View File

@ -81,7 +81,6 @@ Returns:
if (!EFI_ERROR(Status)) {
PoolAllocationType = LoadedImage->ImageDataType;
}
EFIDebugVariable ();
}
@ -183,3 +182,33 @@ EFIDebugVariable (
EFIDebug = NewEFIDebug;
}
}
/*
* Calls to memset/memcpy may be emitted implicitly by GCC or MSVC
* even when -ffreestanding or /NODEFAULTLIB are in effect.
*/
#ifndef __SIZE_TYPE__
#define __SIZE_TYPE__ UINTN
#endif
void *memset(void *s, int c, __SIZE_TYPE__ n)
{
unsigned char *p = s;
while (n--)
*p++ = c;
return s;
}
void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n)
{
const unsigned char *q = src;
unsigned char *p = dest;
while (n--)
*p++ = *q++;
return dest;
}

View File

@ -24,28 +24,3 @@ InitializeLibPlatform (
)
{
}
/*
* Calls to these functions may be emitted implicitly by GCC even when
* -ffreestanding is in effect.
*/
void *memset(void *s, int c, __SIZE_TYPE__ n)
{
unsigned char *p = s;
while (n--)
*p++ = c;
return s;
}
void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n)
{
const unsigned char *q = src;
unsigned char *p = dest;
while (n--)
*p++ = *q++;
return dest;
}