diff options
author | stefan <stefan@s00.xyz> | 2023-04-21 21:56:45 -0400 |
---|---|---|
committer | stefan <stefan@s00.xyz> | 2023-04-21 21:56:45 -0400 |
commit | 386ad4f82955d389ae347bc50f7efca5edb9d9a8 (patch) | |
tree | c18143b0a593e80145f003707a4eb29fa25d0f33 /lib | |
parent | eff82c45c589b42061344039d5f2efc8ad7c52df (diff) | |
download | sv-386ad4f82955d389ae347bc50f7efca5edb9d9a8.tar.gz |
actually got libfdt working
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/Makefile | 2 | ||||
-rw-r--r-- | lib/libc/string/strchr.c | 3 | ||||
-rw-r--r-- | lib/libc/string/strlen.c | 19 | ||||
-rw-r--r-- | lib/libfdt/Makefile | 2 | ||||
-rw-r--r-- | lib/libfdt/fdt.c | 1 |
5 files changed, 24 insertions, 3 deletions
diff --git a/lib/libc/Makefile b/lib/libc/Makefile index b2aea30..ab68ab0 100644 --- a/lib/libc/Makefile +++ b/lib/libc/Makefile @@ -13,6 +13,8 @@ SRC=\ string/memset.c \ string/memcmp.c \ string/memchr.c \ + string/strlen.c \ + string/strchr.c ${BUILDDIR}/libc.a: ${SRC} diff --git a/lib/libc/string/strchr.c b/lib/libc/string/strchr.c index 09b4d43..f8b3339 100644 --- a/lib/libc/string/strchr.c +++ b/lib/libc/string/strchr.c @@ -2,9 +2,8 @@ char *strchr(const char *s, int c) { do { - if ((char)c == *s) { + if ((char)c == *s) return (char*)s; - } } while (*s++ != '\0'); return NULL; } diff --git a/lib/libc/string/strlen.c b/lib/libc/string/strlen.c new file mode 100644 index 0000000..a1a73b6 --- /dev/null +++ b/lib/libc/string/strlen.c @@ -0,0 +1,19 @@ +#include <string.h> + +size_t +strlen(const char *s) +{ + int n; + for (n = 0; s[n]; n++) + ; + return n; +} + +size_t +strnlen(const char *s, size_t max) +{ + int n; + for (n = 0; s[n] && n < max; n++) + ; + return n; +} diff --git a/lib/libfdt/Makefile b/lib/libfdt/Makefile index b9c7223..a3de4b6 100644 --- a/lib/libfdt/Makefile +++ b/lib/libfdt/Makefile @@ -13,7 +13,7 @@ SRC=fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c fdt_empty_tree.c \ ${BUILDDIR}/libfdt.a: ${SRC} mkdir -p ${BUILDDIR} - cd ${BUILDDIR} && ${CROSS_COMPILE}gcc -c ${CFLAGS} -nostdlib ${SRC:%=../../%} + cd ${BUILDDIR} && ${CROSS_COMPILE}gcc -c ${CFLAGS} -L ../libc/${BUILDDIR} -l:libc.a -nostdlib -nostdinc -I../../include/ ${SRC:%=../../%} cd ${BUILDDIR} && ${CROSS_COMPILE}ar -rcs ${@:T} ${SRC:T:%.c=%.o} diff --git a/lib/libfdt/fdt.c b/lib/libfdt/fdt.c index 20c6415..96955c7 100644 --- a/lib/libfdt/fdt.c +++ b/lib/libfdt/fdt.c @@ -9,6 +9,7 @@ #include <libfdt.h> #include "libfdt_internal.h" +#include <string.h> /* * Minimal sanity check for a read-only tree. fdt_ro_probe_() checks |