From 82a58e1c66438f0f475d81c6a7bd8b51d85e34e1 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Tue, 12 Aug 2025 23:58:26 +0200 Subject: [PATCH] Update libc memcpy. --- lib/std/libc/libc.c3 | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/lib/std/libc/libc.c3 b/lib/std/libc/libc.c3 index 0874d6464..8ad3842e3 100644 --- a/lib/std/libc/libc.c3 +++ b/lib/std/libc/libc.c3 @@ -259,6 +259,8 @@ macro CFile stdout() { return (CFile*)(uptr)STDOUT_FD; } macro CFile stderr() { return (CFile*)(uptr)STDERR_FD; } module libc @if(!env::LIBC); +import std::core::mem; + fn void longjmp(JmpBuf* buffer, CInt value) @weak @extern("longjmp") @nostrip { @@ -288,22 +290,9 @@ fn void* realloc(void* ptr, usz size) @weak @extern("realloc") @nostrip unreachable("realloc unavailable"); } -fn void* memcpy(void* dest, void* src, usz n) @weak @extern("memcpy") @nostrip -{ - for (usz i = 0; i < n; i++) ((char*)dest)[i] = ((char*)src)[i]; - return dest; -} - -fn void* memmove(void* dest, void* src, usz n) @weak @extern("memmove") @nostrip -{ - return memcpy(dest, src, n) @inline; -} - -fn void* memset(void* dest, CInt value, usz n) @weak @extern("memset") @nostrip -{ - for (usz i = 0; i < n; i++) ((char*)dest)[i] = (char)value; - return dest; -} +alias memcpy = mem::__memcpy; +alias memmove = mem::__memcpy; +alias memset = mem::__memset; fn int fseek(CFile stream, SeekIndex offset, int whence) @weak @extern("fseek") @nostrip {