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/con_.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/con_.h') diff --git a/src/con_.h b/src/con_.h index eb03642..5de5608 100644 --- a/src/con_.h +++ b/src/con_.h @@ -19,6 +19,7 @@ #define INC_CON_H #include "intdefs.h" +#include "mem.h" #if defined(__GNUC__) || defined(__clang__) #define _CON_PRINTF(x, y) __attribute((format(printf, (x), (y)))) @@ -417,10 +418,10 @@ extern struct _con_vtab_iconvar_wrap { and back to avoid confusing side effects for the caller. */ \ /* XXX: not bothering with the null term here; should we be? */ \ const char *_orig_argv[80]; \ - memcpy(_orig_argv, _con_argv, _orig_argc * sizeof(*argv)); \ - memcpy(_con_argv, argv, argc * sizeof(*argv)); \ + mem_copy(_orig_argv, _con_argv, _orig_argc * sizeof(*argv)); \ + mem_copy(_con_argv, argv, argc * sizeof(*argv)); \ _orig_##name##_cb.v1(); \ - memcpy(_con_argv, _orig_argv, _orig_argc * sizeof(*argv)); \ + mem_copy(_con_argv, _orig_argv, _orig_argc * sizeof(*argv)); \ } \ else { \ _orig_##name##_cb.v1(); \ -- cgit v1.2.3-54-g00ecf