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.
This commit is contained in:
2025-12-23 13:10:27 +01:00
parent dd590b9f42
commit 0538a0a634
3 changed files with 22 additions and 0 deletions

4
src/atrb.h Normal file
View File

@@ -0,0 +1,4 @@
#pragma once
#if defined(__cplusplus)
#define restrict __restrict__
#endif

10
src/string.c Normal file
View File

@@ -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) { }

8
src/string.h Normal file
View File

@@ -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);