From 0538a0a634546ed508d39bfaf6335039ef105120 Mon Sep 17 00:00:00 2001 From: Quinn Date: Tue, 23 Dec 2025 13:10:27 +0100 Subject: [PATCH] start writing STDC functions that are necessary for correct linking. gcc will optimise calls to these four functions, and requires definitions to these funcitons. It is better to let it make these optimisations, rather than disabling this functionality with the `-nostdc` flag. --- src/atrb.h | 4 ++++ src/string.c | 10 ++++++++++ src/string.h | 8 ++++++++ 3 files changed, 22 insertions(+) create mode 100644 src/atrb.h create mode 100644 src/string.c create mode 100644 src/string.h diff --git a/src/atrb.h b/src/atrb.h new file mode 100644 index 0000000..5b77513 --- /dev/null +++ b/src/atrb.h @@ -0,0 +1,4 @@ +#pragma once +#if defined(__cplusplus) +#define restrict __restrict__ +#endif diff --git a/src/string.c b/src/string.c new file mode 100644 index 0000000..bbbd6b0 --- /dev/null +++ b/src/string.c @@ -0,0 +1,10 @@ +#include "string.h" + +int memcmp(const void *s1, const void *s2, usize n) { +} + +void *memset(void *s, int c, usize n) { } + +void *memcpy(void *restrict dst, const void *restrict src, usize n) { } + +void *memmove(void *dst, const void *src, usize n) { } diff --git a/src/string.h b/src/string.h new file mode 100644 index 0000000..43695a9 --- /dev/null +++ b/src/string.h @@ -0,0 +1,8 @@ +#pragma once +#include "types.h" +#include "atrb.h" + +int memcmp(const void *s1, const void *s2, usize n); +void *memset(void *s, int c, usize n); +void *memcpy(void *restrict dst, const void *restrict src, usize n); +void *memmove(void *dst, const void *src, usize n);