From 8d4b47298b6c9eeb9a3f79a5b80d894f80ed4a45 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sat, 27 Dec 2025 03:05:05 +0000 Subject: Do away with memcpy/memset/memcmp Now everything is either explicitly a rep thing, or explicitly some other small run of reasonably efficient instructions. No library calls or function call overhead of any kind. Code size remains nice and small. Ban a few other bad libc functions while we're at it. More can be added later if we decide that's a useful idea. This will require some discipline and workarounds to cope with Clang's tendency to shove mem* calls in places you don't want them even when you tell it not to. Well, c'est la vie. I'm a little nervous that the __builtin_memmove() usage in shuntvars() could still one day emit actual library calls. It appears we're not importing memmove() from anywhere at the moment, though. So I guess it's good enough for now. Also I had to get rid of alloca() in con_.c but that was kind of bad anyway, so that's fine. --- src/fixes.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/fixes.c') diff --git a/src/fixes.c b/src/fixes.c index ac21722..b7e3bcd 100644 --- a/src/fixes.c +++ b/src/fixes.c @@ -15,8 +15,6 @@ * PERFORMANCE OF THIS SOFTWARE. */ -#include - #ifdef _WIN32 #include #endif @@ -216,7 +214,7 @@ static inline void portal1specific() { void *EyeAngles = mem_offset(clientlib, 0x19D1B0); // in C_PortalPlayer static const char match[] = HEXBYTES(56, 8B, F1, E8, 48, 50, EA, FF, 84, C0, 74, 25); - if (!memcmp(EyeAngles, match, sizeof(match))) { + if (!mem_cmp(EyeAngles, match, sizeof(match))) { char *patch = mem_offset(EyeAngles, 39); if (patch[0] == 0x75 && patch[1] == 0x08) { if_hot (os_mprot(patch, 2, PAGE_EXECUTE_READWRITE)) { -- cgit v1.2.3-54-g00ecf