diff options
| author | Louis Burda <quent.burda@gmail.com> | 2022-06-02 15:28:40 +0200 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2022-06-02 15:28:40 +0200 |
| commit | 5bc16063c29aa4d3d287ebd163ccdbcbf54c4f9f (patch) | |
| tree | c131f947a37b3af2d14d41e9eda098bdec2d061c /gbdk/gbdk-lib/libc/string.c | |
| parent | 78a5f810b22f0d8cafa05f638b0cb2e889824859 (diff) | |
| download | cscg2022-gearboy-master.tar.gz cscg2022-gearboy-master.zip | |
Diffstat (limited to 'gbdk/gbdk-lib/libc/string.c')
| -rw-r--r-- | gbdk/gbdk-lib/libc/string.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gbdk/gbdk-lib/libc/string.c b/gbdk/gbdk-lib/libc/string.c new file mode 100644 index 00000000..c1f8198a --- /dev/null +++ b/gbdk/gbdk-lib/libc/string.c @@ -0,0 +1,36 @@ +/** Dumb strings hack. +*/ +#include <string.h> +#include <gbdk/gbdk-lib.h> + +#if USE_C_STRCPY +char *strcpy(char *dest, const char *source) NONBANKED +{ + char *d = dest; + const char *s = source; + while (*d = *s) d++, s++; + return dest; +} +#endif + +#if USE_C_MEMCPY +void *memcpy(void *dest, const void *source, size_t count) NONBANKED +{ + char *d = dest; + const char *s = source; + while (count--) { + *d = *s; + d++; + s++; + } + return dest; +} +#endif + +#if USE_C_STRCMP +int strcmp(const char *s1, const char *s2) { + char ret = 0; + while (!(ret = *s1 - *s2) && *s2) ++s1, ++s2; + return (ret < 0) ? -1 : ((ret > 0) ? 1 : 0); +} +#endif |
