fix memcpy&memset alignment (#37)

This commit is contained in:
Camel Coder 2024-07-15 05:44:36 +02:00 committed by GitHub
parent 5b34ea9384
commit 28c275b0ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -53,7 +53,7 @@ void* memset(void* v,int c,size_t n){
if (n >= threshold) {
// first let dst aligned by 8 bytes
int pad = (uintptr_t)dst % 8;
int pad = (8 - (uintptr_t)dst % 8) % 8;
n -= pad;
while (pad --) { *dst ++ = c; }
@ -102,7 +102,7 @@ void* memcpy(void* out, const void* in, size_t n) {
if (n >= threshold && is_align8) {
// first let dst aligned by 8 bytes
int pad = (uintptr_t)dst % 8;
int pad = (8 - (uintptr_t)dst % 8) % 8;
n -= pad;
while (pad --) { *dst ++ = *src ++; }
@ -131,7 +131,7 @@ void* memcpy(void* out, const void* in, size_t n) {
if (n >= threshold && is_align4) {
// first let dst aligned by 4 bytes
int pad = (uintptr_t)dst % 4;
int pad = (4 - (uintptr_t)dst % 4) % 4;
n -= pad;
while (pad --) { *dst ++ = *src ++; }