LibC: Make memcpy and memset not optimized

GCC does some weird optimizations and breaks these functions
This commit is contained in:
Bananymous 2023-12-19 10:28:40 +02:00
parent 5edbb1d5c4
commit 637397dd2f
1 changed files with 3 additions and 1 deletions

View File

@ -17,7 +17,8 @@ int memcmp(const void* s1, const void* s2, size_t n)
return 0; return 0;
} }
void* memcpy(void* dstp, const void* srcp, size_t n) __attribute__((optimize("-O0")))
void* memcpy(void* __restrict__ dstp, const void* __restrict__ srcp, size_t n)
{ {
unsigned char* dst = static_cast<unsigned char*>(dstp); unsigned char* dst = static_cast<unsigned char*>(dstp);
const unsigned char* src = static_cast<const unsigned char*>(srcp); const unsigned char* src = static_cast<const unsigned char*>(srcp);
@ -45,6 +46,7 @@ void* memmove(void* destp, const void* srcp, size_t n)
return destp; return destp;
} }
__attribute__((optimize("-O0")))
void* memset(void* s, int c, size_t n) void* memset(void* s, int c, size_t n)
{ {
unsigned char* p = static_cast<unsigned char*>(s); unsigned char* p = static_cast<unsigned char*>(s);