From 5ac36bcefb6dda98ddf052d8faf6d9d781cec7b1 Mon Sep 17 00:00:00 2001 From: Adrian Danis Date: Mon, 9 Apr 2018 16:01:10 +1000 Subject: [PATCH] riscv: Move strcmp to util --- include/util.h | 1 + src/plat/spike/machine/fdt.c | 12 ------------ src/util.c | 13 +++++++++++++ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/include/util.h b/include/util.h index 08b3eab55..734e1b1b1 100644 --- a/include/util.h +++ b/include/util.h @@ -89,6 +89,7 @@ void memzero(void *s, unsigned long n); void *memset(void *s, unsigned long c, unsigned long n) VISIBLE; void *memcpy(void* ptr_dst, const void* ptr_src, unsigned long n) VISIBLE; int PURE strncmp(const char *s1, const char *s2, int n); +int strcmp(const char *s1, const char *s2); unsigned long strlen(const char *s); long CONST char_to_long(char c); long PURE str_to_long(const char* str); diff --git a/src/plat/spike/machine/fdt.c b/src/plat/spike/machine/fdt.c index fe8f2d5c2..0c46f8c27 100644 --- a/src/plat/spike/machine/fdt.c +++ b/src/plat/spike/machine/fdt.c @@ -78,18 +78,6 @@ const char fdt_memory[] = {'m', 'e', 'm', 'o', 'r', 'y', 0}; // RVTODO: this code needs to updated to not have function pointers or string literals "like this" // and any of these appropriate string functions should be moved to common utils -static int strcmp(const char* s1, const char* s2) -{ - unsigned char c1, c2; - - do { - c1 = *s1++; - c2 = *s2++; - } while (c1 != 0 && c1 == c2); - - return c1 - c2; -} - static inline uint32_t bswap(uint32_t x) { uint32_t y = (x & 0x00FF00FF) << 8 | (x & 0xFF00FF00) >> 8; diff --git a/src/util.c b/src/util.c index 28a038b4f..85bce3b59 100644 --- a/src/util.c +++ b/src/util.c @@ -95,6 +95,19 @@ strncmp(const char* s1, const char* s2, int n) return 0; } +int +strcmp(const char* s1, const char* s2) +{ + unsigned char c1, c2; + + do { + c1 = *s1++; + c2 = *s2++; + } while (c1 != 0 && c1 == c2); + + return c1 - c2; +} + unsigned long strlen(const char *s) {