From a9f44f3a6cccdf147376f8bf010a85b334ed4c72 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sat, 21 Jun 2025 15:13:42 +0100 Subject: Add memset to wincrt.c The code I'm about to commit appears to generate a call to this. Funny we never needed it until now... --- src/wincrt.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/wincrt.c') diff --git a/src/wincrt.c b/src/wincrt.c index ced1203..d8111ba 100644 --- a/src/wincrt.c +++ b/src/wincrt.c @@ -48,6 +48,23 @@ void *memcpy(void *restrict x, const void *restrict y, unsigned int sz) { #endif } +void *memset(void *x, int c, unsigned int sz) { +#if defined(__GNUC__) || defined(__clang__) + void *r = x; + __asm__ volatile ( + "rep stosb\n" + : "+D" (x), "+c" (sz) + : "a"(c) + : "memory" + ); + return r; +#else + const unsigned char *xb = x; + for (unsigned int i = 0; i < len; ++i) xb[i] = (unsigned char)c; + return x; +#endif +} + int __stdcall _DllMainCRTStartup(void *inst, unsigned int reason, void *reserved) { return 1; -- cgit v1.2.3-54-g00ecf