aboutsummaryrefslogtreecommitdiff
path: root/src/arm
diff options
context:
space:
mode:
authorWojtek Kosior <kwojtus@protonmail.com>2020-01-17 18:21:37 +0100
committerWojtek Kosior <kwojtus@protonmail.com>2020-01-17 18:21:37 +0100
commitd08f2e452ef83abf9ec49a40d376a9d681070838 (patch)
tree5ade12769ae06bdbc7530011e061f6144e9ab4e5 /src/arm
parentb2bd2a8c11eacc0a7fffb177e7f556892f4ead61 (diff)
downloadrpi-MMU-example-d08f2e452ef83abf9ec49a40d376a9d681070838.tar.gz
rpi-MMU-example-d08f2e452ef83abf9ec49a40d376a9d681070838.zip
move string operations from ramfs.c to strings.c
Diffstat (limited to 'src/arm')
-rw-r--r--src/arm/PL1/kernel/ramfs.c27
-rw-r--r--src/arm/common/strings.c36
-rw-r--r--src/arm/common/strings.h6
3 files changed, 32 insertions, 37 deletions
diff --git a/src/arm/PL1/kernel/ramfs.c b/src/arm/PL1/kernel/ramfs.c
index cc66b4c..ed3ff73 100644
--- a/src/arm/PL1/kernel/ramfs.c
+++ b/src/arm/PL1/kernel/ramfs.c
@@ -3,32 +3,7 @@
#include <stdint.h>
#include "ramfs.h"
-
-static int strcmp(char const *str1, char const *str2)
-{
- while (1)
- {
- int c1 = (unsigned char) *str1, c2 = (unsigned char) *str2;
-
- if (!c1 && !c2)
- return 0;
-
- if (c1 != c2)
- return c1 - c2;
-
- str1++; str2++;
- }
-}
-
-static uint32_t strlen(char const *str1)
-{
- uint32_t len = 0;
-
- while (str1[len])
- len++;
-
- return len;
-}
+#include "strings.h"
static inline char *align4(char *addr)
{
diff --git a/src/arm/common/strings.c b/src/arm/common/strings.c
index 368d7dc..0c7a73b 100644
--- a/src/arm/common/strings.c
+++ b/src/arm/common/strings.c
@@ -69,15 +69,6 @@ void uint32_to_hexstringt(uint32_t number, char buf[9])
trim_0s(buf);
}
-size_t strlen(char string[])
-{
- size_t len;
-
- for (len = 0; string[len]; len++);
-
- return len;
-}
-
void memcpy(void *dst, void *src, size_t nbytes)
{
size_t iter;
@@ -117,3 +108,30 @@ char *strcat(char *dst, const char *src)
return dst;
}
+
+int strcmp(char const *str1, char const *str2)
+{
+ while (1)
+ {
+ int c1 = (unsigned char) *str1, c2 = (unsigned char) *str2;
+
+ if (!c1 && !c2)
+ return 0;
+
+ if (c1 != c2)
+ return c1 - c2;
+
+ str1++; str2++;
+ }
+}
+
+size_t strlen(char const *str1)
+{
+ size_t len = 0;
+
+ while (str1[len])
+ len++;
+
+ return len;
+}
+
diff --git a/src/arm/common/strings.h b/src/arm/common/strings.h
index aff0533..67c1ab7 100644
--- a/src/arm/common/strings.h
+++ b/src/arm/common/strings.h
@@ -22,12 +22,14 @@ void uint32_to_decstringt(uint32_t number, char buf[11]);
void uint32_to_hexstringt(uint32_t number, char buf[9]);
-size_t strlen(char string[]);
-
void memcpy(void *dst, void *src, size_t nbytes);
void *memset(void *s, int c, size_t n);
char *strcat(char *dst, const char *src);
+int strcmp(char const *str1, char const *str2);
+
+size_t strlen(char const *str1);
+
#endif // STRINGS_H