diff options
| author | 2026-11-11 22:24:54 +0000 | |
|---|---|---|
| committer | 2026-11-11 23:15:15 +0000 | |
| commit | e281c39d24793ea5793b0eabdd684c5e12ea77fe (patch) | |
| tree | 1f1debed802fcc1764d33b05d21d7935bead3d19 /src/mem.h | |
| parent | de8db70103b5ba472fa6e3992e4c7ebb6dcae153 (diff) | |
| download | sst-e281c39d24793ea5793b0eabdd684c5e12ea77fe.tar.gz sst-e281c39d24793ea5793b0eabdd684c5e12ea77fe.zip | |
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.
Diffstat (limited to 'src/mem.h')
| -rw-r--r-- | src/mem.h | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -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 |
