From f209dc3a24987419c3f7ad9fbe3fe2b4dfb16427 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Fri, 25 Aug 2017 10:26:21 +0200 Subject: implements pio.h functions and makefile update to optimize size - remove syscall.h, unused and not implemented - bug fix for memcmp() in string.c other changes are still partially unfinished and might not work --- sw/z80/libc/string.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'sw/z80/libc') diff --git a/sw/z80/libc/string.c b/sw/z80/libc/string.c index 9dd56cc..57b3a7f 100644 --- a/sw/z80/libc/string.c +++ b/sw/z80/libc/string.c @@ -1,11 +1,11 @@ #include "string.h" -void * memset(void *dest, const int8_t src, size_t n) { +void *memset(void *dest, const int8_t src, size_t n) { - void *dp = dest; + char *dp = (char *) dest; while (n--) - *dp++ = src; + *(dp++) = src; return dest; } @@ -22,16 +22,14 @@ 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++) { +int8_t memcmp(void *s1, void *s2, size_t n) +{ + char *u1 = (char *) s1; + char *u2 = (char *) s2; - u1 = *s1; - u2 = *s2; + for ( ; n--; u1++, u2++) { - if (u1 != u2) + if (*u1 != *u2) return u1 - u2; } -- cgit v1.2.1