diff options
author | Nao Pross <naopross@thearcway.org> | 2017-07-04 09:16:59 +0200 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2017-07-04 09:16:59 +0200 |
commit | a86838ead76c76e62369d461d5f4ff6ea6b07433 (patch) | |
tree | a2a5131ce8a4fb06c6cefceaa5fb9857a42ce553 /sw/z80/libc/string.c | |
parent | new components list and cpld test unit (diff) | |
parent | Order and update of the struct (diff) | |
download | z80uPC-a86838ead76c76e62369d461d5f4ff6ea6b07433.tar.gz z80uPC-a86838ead76c76e62369d461d5f4ff6ea6b07433.zip |
merge branch 'atlas' into naopross
Diffstat (limited to '')
-rw-r--r-- | sw/z80/libc/string.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sw/z80/libc/string.c b/sw/z80/libc/string.c index fd6a7ff..9dd56cc 100644 --- a/sw/z80/libc/string.c +++ b/sw/z80/libc/string.c @@ -1,5 +1,15 @@ #include "string.h" +void * memset(void *dest, const int8_t src, size_t n) { + + void *dp = dest; + + while (n--) + *dp++ = src; + + return dest; +} + void *memcpy(void *dest, void *src, size_t n) { char *dp = dest; @@ -11,3 +21,19 @@ void *memcpy(void *dest, void *src, size_t n) return dest; } + +int8_t memcmp(const void *s1, const void *s2, size_t n) { + + uint8_t u1, u2; + + for ( ; n--; s1++, s2++) { + + u1 = *s1; + u2 = *s2; + + if (u1 != u2) + return u1 - u2; + } + + return 0; +}
\ No newline at end of file |