summaryrefslogtreecommitdiff
path: root/bsp/AE210P/libc/string/strcmp.c
diff options
context:
space:
mode:
Diffstat (limited to 'bsp/AE210P/libc/string/strcmp.c')
-rw-r--r--bsp/AE210P/libc/string/strcmp.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/bsp/AE210P/libc/string/strcmp.c b/bsp/AE210P/libc/string/strcmp.c
new file mode 100644
index 0000000000..277bafaaaf
--- /dev/null
+++ b/bsp/AE210P/libc/string/strcmp.c
@@ -0,0 +1,30 @@
+#include <string.h>
+
+__attribute__((used))
+int strcmp(const char *s1, const char *s2)
+{
+ while (*s1 == *s2) {
+
+ if (!*s1)
+ return 0;
+ ++s1;
+ ++s2;
+ }
+
+ return *(unsigned char *)s1 - *(unsigned char *)s2;
+}
+
+__attribute__((used))
+int strncmp(const char *s1, const char *s2, size_t n)
+{
+ while (*s1 == *s2 && --n) {
+
+ if (!*s1)
+ return 0;
+ ++s1;
+ ++s2;
+ }
+
+ return *(unsigned char *)s1 - *(unsigned char *)s2;
+}
+