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/democustom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/democustom.c') diff --git a/src/democustom.c b/src/democustom.c index 05c1d41..5c2ab55 100644 --- a/src/democustom.c +++ b/src/democustom.c @@ -72,13 +72,13 @@ static WriteMessages_func WriteMessages = 0; void democustom_write(const void *buf, int len) { for (; len > CHUNKSZ; len -= CHUNKSZ) { createhdr(&bb, CHUNKSZ, false); - memcpy(bb.buf + (bb.nbits >> 3), buf, CHUNKSZ); + mem_copy(bb.buf + (bb.nbits >> 3), buf, CHUNKSZ); bb.nbits += CHUNKSZ << 3; WriteMessages(demorecorder, &bb); bitbuf_reset(&bb); } createhdr(&bb, len, true); - memcpy(bb.buf + (bb.nbits >> 3), buf, len); + mem_copy(bb.buf + (bb.nbits >> 3), buf, len); bb.nbits += len << 3; WriteMessages(demorecorder, &bb); bitbuf_reset(&bb); -- cgit v1.2.3-54-g00ecf