From e281c39d24793ea5793b0eabdd684c5e12ea77fe Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Wed, 11 Nov 2026 22:24:54 +0000 Subject: Add a mem_copy_fixed and mem_set_fixed to mem.h Probably self-explanatory. I was finding more use cases for the __builtin_memcpy_inline thing but boy is that ugly. --- src/mem.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/mem.h') diff --git a/src/mem.h b/src/mem.h index ae33092..553d390 100644 --- a/src/mem.h +++ b/src/mem.h @@ -223,6 +223,28 @@ static forceinline int mem_cmp(const void *restrict x, const void *restrict y, #endif } +/* + * Copies a small fixed-size chunk of memory using some appropriate + * compiler-chosen arrangement of move instructions, without calling any + * functions. Length must be a compile-time constant. + */ +#ifdef __clang__ +#define mem_copy_fixed __builtin_memcpy_inline +#else +#define mem_copy_fixed mem_copy // meh +#endif + +/* + * Sets a small fixed-size chunk of memory using some appropriate + * compiler-chosen arrangement of instructions, without calling any + * functions. Length and value must be compile-time constants. + */ +#ifdef __clang__ +#define mem_set_fixed __builtin_memcpy_inline +#else +#define mem_set_fixed mem_set // meh +#endif + #endif // vi: sw=4 ts=4 noet tw=80 cc=80 -- cgit v1.2.3-54-g00ecf