Fix the devicetree parser for stdout-path
Subsystems (4)
cover Fix the devicetree parser for stdout-path
This set of patches fixes the way we parse the stdout-path which is used to set up the console. Prior to this, the code ignored the fact that stdout-path is made of the path to the uart node as well as parameters and as a result it would fail to find the relevant DT node. In addition to minor fixes in the device tree code, this series pulls a new version of libfdt from upstream.
Thanks,
Nikos
Nikos Nikoleris (4):
lib/string: add strnlen and strrchr
libfdt: Pull v1.6.0
Makefile: Avoid double definition of libfdt_clean
devicetree: Parse correctly the stdout-path
lib/libfdt/README | 3 +- Makefile | 12 +- lib/libfdt/Makefile.libfdt | 10 +- lib/libfdt/version.lds | 24 +- lib/libfdt/fdt.h | 53 +-- lib/libfdt/libfdt.h | 766 +++++++++++++++++++++++++----- lib/libfdt/libfdt_env.h | 109 ++--- lib/libfdt/libfdt_internal.h | 206 +++++--- lib/string.h | 5 +- lib/devicetree.c | 15 +- lib/libfdt/fdt.c | 200 +++++--- lib/libfdt/fdt_addresses.c | 101 ++++ lib/libfdt/fdt_check.c | 74 +++ lib/libfdt/fdt_empty_tree.c | 48 +- lib/libfdt/fdt_overlay.c | 881 +++++++++++++++++++++++++++++++++++ lib/libfdt/fdt_ro.c | 512 +++++++++++++++----- lib/libfdt/fdt_rw.c | 231 +++++---- lib/libfdt/fdt_strerror.c | 53 +-- lib/libfdt/fdt_sw.c | 297 ++++++++---- lib/libfdt/fdt_wip.c | 90 ++-- lib/string.c | 30 +- 21 files changed, 2890 insertions(+), 830 deletions(-) create mode 100644 lib/libfdt/fdt_addresses.c create mode 100644 lib/libfdt/fdt_check.c create mode 100644 lib/libfdt/fdt_overlay.c
Signature · 1 line
2.25.1
PATCH 1/4 lib/string: add strnlen and strrchr
This change adds two functions from <string.h> in preparation for an update in the libfdt.
--- lib/string.h | 4 +++- lib/string.c | 23 +++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-)
lib/string.h +3 -1
@@ -7,12 +7,14 @@#ifndef __STRING_H#define __STRING_H -extern unsigned long strlen (const char *buf); +extern size_t strlen (const char *buf); +extern size_t strnlen (const char *buf,size_t maxlen);extern char *strcat (char *dest,const char *src);extern char *strcpy (char *dest,const char *src);extern int strcmp (const char *a,const char *b);extern int strncmp (const char *a,const char *b,size_t n);extern char *strchr (const char *s,int c); +extern char *strrchr (const char *s,int c);extern char *strstr (const char *haystack,const char *needle);extern void *memset (void *s,int c,size_t n);extern void *memcpy (void *dest,const void *src,size_t n);
lib/string.c +21 -2
@@ -7,15 +7,24 @@#include "libcflat.h" -unsigned long strlen (const char *buf) +size_t strlen (const char *buf) { -unsigned long len =0 ; +size_t len =0 ;while (*buf++) ++len;return len; } +size_t strnlen (const char *buf,size_t maxlen) +{ +const char *sc; + +for (sc = buf; maxlen-- && *sc !='\0' ; ++sc) +/* nothing */ ; +return sc - buf; +} +char *strcat (char *dest,const char *src) {char *p = dest;
@@ -55,6 +64,16 @@ char *strchr(const char *s, int c)return (char *)s; } +char *strrchr (const char *s,int c) +{ +const char *last =NULL ; +do { +if (*s != (char )c) + last = s; + }while (*s++); +return (char *)last; +} +char *strstr (const char *s1,const char *s2) {size_t l1, l2;
Signature · 1 line
2.25.1
Re: [kvm-unit-tests PATCH 1/4] lib/string: add strnlen and strrchr
Quoted 61 lines · Nikos Nikoleris
This change adds two functions from <
string.h> in preparation for an update in the libfdt.Signed-off-by Nikos Nikoleris <[email protected]>--- lib/string.h | 4 +++- lib/string.c | 23 +++++++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-)lib/string.h +3
-1@@ -7,12 +7,14 @@#ifndef __STRING_H#define __STRING_H -extern unsigned long strlen (const char *buf); +extern size_t strlen (const char *buf); +extern size_t strnlen (const char *buf,size_t maxlen);extern char *strcat (char *dest,const char *src);extern char *strcpy (char *dest,const char *src);extern int strcmp (const char *a,const char *b);extern int strncmp (const char *a,const char *b,size_t n);extern char *strchr (const char *s,int c); +extern char *strrchr (const char *s,int c);extern char *strstr (const char *haystack,const char *needle);extern void *memset (void *s,int c,size_t n);extern void *memcpy (void *dest,const void *src,size_t n);lib/string.c +11
-2@@ -7,15 +7,24 @@#include "libcflat.h" -unsigned long strlen (const char *buf) +size_t strlen (const char *buf) { -unsigned long len =0 ; +size_t len =0 ;while (*buf++) ++len;return len; } +size_t strnlen (const char *buf,size_t maxlen) +{ +const char *sc; + +for (sc = buf; maxlen-- && *sc !='\0' ; ++sc) +/* nothing */ ; +return sc - buf; +} +char *strcat (char *dest,const char *src) {char *p = dest;
lib/string.c char *strchr(const char *s, int c) · line 71
Quoted 8 lines
lib/string.c +5
-0@@ -55,6 +64,16 @@ char *strchr(const char *s, int c)return (char *)s; } +char *strrchr (const char *s,int c) +{ +const char *last =NULL ; + do { + if (*s != (char)c)
This should be ==
Quoted 11 lines
lib/string.c +5
-0+ last = s; + }while (*s++); +return (char *)last; +} +char *strstr (const char *s1,const char *s2) {size_t l1, l2;Signature · 1 line
2.25.1
Thanks,
drew
PATCH 3/4 Makefile: Avoid double definition of libfdt_clean
In reply to Nikos Nikolerislibfdt_clean is now defined in the libfdt Makefile and as a result, we don't need to redefine it in the top Makefile. In addition we define some variables for the remaining libfdt_clean rule.
--- Makefile | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
Makefile +5 -7
@@ -40,8 +40,6 @@ cflatobjs := \ LIBFDT_objdir = lib/libfdt LIBFDT_srcdir = $(SRCDIR)/lib/libfdt LIBFDT_archive = $(LIBFDT_objdir)/libfdt.a -LIBFDT_include = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_INCLUDES)) -LIBFDT_version = $(addprefix $(LIBFDT_srcdir)/,$(LIBFDT_VERSION)) OBJDIRS += $(LIBFDT_objdir)
@@ -90,6 +88,10 @@ $(LIBFDT_archive): CFLAGS += -ffreestanding -I $(SRCDIR)/lib -I $(SRCDIR)/lib/li $(LIBFDT_archive): $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS)) $(AR) rcs $@ $^ +libfdt_clean: VECHO = echo " " +libfdt_clean: STD_CLEANFILES = *.o *.d +libfdt_clean: LIBFDT_dir = $(LIBFDT_objdir) +libfdt_clean: SHAREDLIB_EXT = so # Build directory target .PHONY: directories
@@ -113,12 +115,8 @@ install: standalone clean: arch_clean $(RM) lib/.*.d $(libcflat) $(cflatobjs) -libfdt_clean: - $(RM) $(LIBFDT_archive) \ - $(addprefix $(LIBFDT_objdir)/,$(LIBFDT_OBJS)) \ - $(LIBFDT_objdir)/.*.d - distclean: clean libfdt_clean + $(RM) $(LIBFDT_archive) $(RM) lib/asm lib/config.h config.mak $(TEST_DIR)-run msr.out cscope.* build-head $(RM) -r tests logs logs.old
Signature · 1 line
2.25.1
PATCH 4/4 devicetree: Parse correctly the stdout-path
In reply to Nikos NikolerisThe stdout-path property in the device tree is a string of the form
"UART_NODE:OPTS"
Where UART_NODE is a compatible serial port and OPTS specify parameters such as the baud. Fix the way we parse the node and, at least for now, ignore options as we don't act on them.
--- lib/string.h | 1 + lib/devicetree.c | 15 +++++++++------ lib/string.c | 7 +++++++ 3 files changed, 17 insertions(+), 6 deletions(-)
lib/string.h +1 -0
@@ -15,6 +15,7 @@ extern int strcmp(const char *a, const char *b);extern int strncmp (const char *a,const char *b,size_t n);extern char *strchr (const char *s,int c);extern char *strrchr (const char *s,int c); +extern char *strchrnul (const char *s,int c);extern char *strstr (const char *haystack,const char *needle);extern void *memset (void *s,int c,size_t n);extern void *memcpy (void *dest,const void *src,size_t n);
lib/devicetree.c +9 -6
@@ -265,21 +265,24 @@ int dt_get_bootargs(const char **bootargs)int dt_get_default_console_node (void ) { -const struct fdt_property *prop; +const char *p, *q;int node, len; node =fdt_path_offset (fdt,"/chosen" );if (node <0 )return node; - prop =fdt_get_property (fdt, node,"stdout-path" , &len); -if (!prop) { - prop =fdt_get_property (fdt, node,"linux,stdout-path" , &len); -if (!prop) + p =fdt_getprop (fdt, node,"stdout-path" , &len); +if (!p) { + p =fdt_getprop (fdt, node,"linux,stdout-path" , &len); +if (!p)return len; } -return fdt_path_offset (fdt, prop->data); + q =strchrnul (p,':' ); + len = q - p; + +return fdt_path_offset_namelen (fdt, p, len); }int dt_get_initrd (const char **initrd,u32 *size)
lib/string.c +7 -0
@@ -74,6 +74,13 @@ char *strrchr(const char *s, int c)return (char *)last; } +char *strchrnul (const char *s,int c) +{ +while (*s && *s != (char )c) + s++; +return (char *)s; +} +char *strstr (const char *s1,const char *s2) {size_t l1, l2;
Signature · 1 line
2.25.1
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [kvm-unit-tests PATCH 2/4] libfdt: Pull v1.6.0
Quoted 32 lines · Nikos Nikoleris
This change updates the libfdt source files to v1.6.0 from
git://git.kernel.org/pub/scm/utils/dtc/dtc.gitSigned-off-by Nikos Nikoleris <[email protected]>--- lib/libfdt/README | 3 +- lib/libfdt/Makefile.libfdt | 10 +- lib/libfdt/version.lds | 24 +- lib/libfdt/fdt.h | 53 +-- lib/libfdt/libfdt.h | 766 +++++++++++++++++++++++++----- lib/libfdt/libfdt_env.h | 109 ++--- lib/libfdt/libfdt_internal.h | 206 +++++--- lib/libfdt/fdt.c | 200 +++++--- lib/libfdt/fdt_addresses.c | 101 ++++ lib/libfdt/fdt_check.c | 74 +++ lib/libfdt/fdt_empty_tree.c | 48 +- lib/libfdt/fdt_overlay.c | 881 +++++++++++++++++++++++++++++++++++ lib/libfdt/fdt_ro.c | 512 +++++++++++++++----- lib/libfdt/fdt_rw.c | 231 +++++---- lib/libfdt/fdt_strerror.c | 53 +-- lib/libfdt/fdt_sw.c | 297 ++++++++---- lib/libfdt/fdt_wip.c | 90 ++-- 17 files changed, 2844 insertions(+), 814 deletions(-) create mode 100644 lib/libfdt/fdt_addresses.c create mode 100644 lib/libfdt/fdt_check.c create mode 100644 lib/libfdt/fdt_overlay.clib/libfdt/README +0
-0
lib/libfdt/README line 2
Quoted 2 lines
lib/libfdt/README +0
-0@@ -1,4 +1,5 @@ The code in this directory is originally imported from the libfdt
^^ says originally, so we should
replace the whole paragraph with something like
The code in this directory has been imported from the libfdt directory of git://git.kernel.org/pub/scm/utils/dtc/dtc.git - version 1.6.0.
lib/libfdt/README line 5
Quoted 4 lines
lib/libfdt/README +2
-1-directory of git://git.jdl.com/software/dtc.git - version 1.4.0. +directory of git://git.kernel.org/pub/scm/utils/dtc/dtc.git - +version 1.60
Thanks,
drew
Quoted 34 lines · Nikos Nikoleris
This set of patches fixes the way we parse the stdout-path which is used to set up the console. Prior to this, the code ignored the fact that stdout-path is made of the path to the uart node as well as parameters and as a result it would fail to find the relevant DT node. In addition to minor fixes in the device tree code, this series pulls a new version of libfdt from upstream.
Thanks,
Nikos
Nikos Nikoleris (4):
lib/string: add strnlen and strrchr
libfdt: Pull v1.6.0
Makefile: Avoid double definition oflibfdt_clean
devicetree: Parse correctly the stdout-pathlib/libfdt/README | 3 +- Makefile | 12 +- lib/libfdt/Makefile.libfdt | 10 +- lib/libfdt/version.lds | 24 +- lib/libfdt/fdt.h | 53 +-- lib/libfdt/libfdt.h | 766 +++++++++++++++++++++++++----- lib/libfdt/libfdt_env.h | 109 ++--- lib/libfdt/libfdt_internal.h | 206 +++++--- lib/string.h | 5 +- lib/devicetree.c | 15 +- lib/libfdt/fdt.c | 200 +++++--- lib/libfdt/fdt_addresses.c | 101 ++++ lib/libfdt/fdt_check.c | 74 +++ lib/libfdt/fdt_empty_tree.c | 48 +- lib/libfdt/fdt_overlay.c | 881 +++++++++++++++++++++++++++++++++++ lib/libfdt/fdt_ro.c | 512 +++++++++++++++----- lib/libfdt/fdt_rw.c | 231 +++++----
Quoted 12 lines
lib/libfdt/fdt_strerror.c | 53 +-- lib/libfdt/fdt_sw.c | 297 ++++++++---- lib/libfdt/fdt_wip.c | 90 ++-- lib/string.c | 30 +- 21 files changed, 2890 insertions(+), 830 deletions(-) create mode 100644 lib/libfdt/fdt_addresses.c create mode 100644 lib/libfdt/fdt_check.c create mode 100644 lib/libfdt/fdt_overlay.cSignature · 1 line
2.25.1
Just tried to give this a test run, but I couldn't compile it on my x86 Fedora machine with my cross compiler:
gcc-aarch64-linux-gnu-9.2.1-3.fc32.1.x86_64
Every file that includes libfdt_env.h gives me a message like this
In file included from lib/libfdt/fdt_overlay.c:7:lib/libfdt/libfdt_env.h:13:10: fatal error: stdlib.h: No such file or directory
13 | #include <stdlib.h>
| ^~~~~~~~~~
compilation terminated
So I commented out the #include line to see why it was there. We need strtoul(). I quick hacked an incomplete one (below) and was able to compile and run tests. However I see that 'make clean' is leaving behind several libfdt files
$ git clean -ndx Would remove lib/libfdt/.fdt.d Would remove lib/libfdt/.fdt_addresses.d Would remove lib/libfdt/.fdt_check.d Would remove lib/libfdt/.fdt_empty_tree.d Would remove lib/libfdt/.fdt_overlay.d Would remove lib/libfdt/.fdt_ro.d Would remove lib/libfdt/.fdt_rw.d Would remove lib/libfdt/.fdt_strerror.d Would remove lib/libfdt/.fdt_sw.d Would remove lib/libfdt/.fdt_wip.d
Thanks,
drew
lib/stdlib.h new file +4 -0
@@ -0,0 +1,4 @@ +#ifndef _STDLIB_H_ +#define _STDLIB_H_ +unsigned long int strtoul (const char *nptr,char **endptr,int base); +#endif
lib/string.c +16 -1
@@ -6,6 +6,7 @@*/ #include "libcflat.h" +#include "stdlib.h" size_t strlen (const char *buf) {
@@ -161,7 +162,7 @@ void *memchr(const void *s, int c, size_t n)return NULL ; } -long atol (const char *ptr) +static long __atol (const char *ptr,char **endptr) {long acc =0 ;const char *s = ptr;
@@ -189,9 +190,23 @@ long atol(const char *ptr)if (neg) acc = -acc; +if (endptr) + *endptr = (char *)s; +return acc; } +long atol (const char *ptr) +{ +return __atol (ptr,NULL ); +} + +unsigned long int strtoul (const char *nptr,char **endptr,int base) +{ +assert (base ==10 ); +return __atol (nptr, endptr); +} +extern char **environ;char *getenv (const char *name)
Hey Drew,
Quoted 57 lines · Andrew Jones
Quoted 39 lines · Nikos Nikoleris
This set of patches fixes the way we parse the stdout-path which is used to set up the console. Prior to this, the code ignored the fact that stdout-path is made of the path to the uart node as well as parameters and as a result it would fail to find the relevant DT node. In addition to minor fixes in the device tree code, this series pulls a new version of libfdt from upstream.
Thanks,
Nikos
Nikos Nikoleris (4):
lib/string: add strnlen and strrchr
libfdt: Pull v1.6.0
Makefile: Avoid double definition oflibfdt_clean
devicetree: Parse correctly the stdout-pathlib/libfdt/README | 3 +- Makefile | 12 +- lib/libfdt/Makefile.libfdt | 10 +- lib/libfdt/version.lds | 24 +- lib/libfdt/fdt.h | 53 +-- lib/libfdt/libfdt.h | 766 +++++++++++++++++++++++++----- lib/libfdt/libfdt_env.h | 109 ++--- lib/libfdt/libfdt_internal.h | 206 +++++--- lib/string.h | 5 +- lib/devicetree.c | 15 +- lib/libfdt/fdt.c | 200 +++++--- lib/libfdt/fdt_addresses.c | 101 ++++ lib/libfdt/fdt_check.c | 74 +++ lib/libfdt/fdt_empty_tree.c | 48 +- lib/libfdt/fdt_overlay.c | 881 +++++++++++++++++++++++++++++++++++ lib/libfdt/fdt_ro.c | 512 +++++++++++++++----- lib/libfdt/fdt_rw.c | 231 +++++---- lib/libfdt/fdt_strerror.c | 53 +-- lib/libfdt/fdt_sw.c | 297 ++++++++---- lib/libfdt/fdt_wip.c | 90 ++-- lib/string.c | 30 +- 21 files changed, 2890 insertions(+), 830 deletions(-)Quoted 7 lines
create mode 100644
lib/libfdt/fdt_addresses.c
create mode 100644lib/libfdt/fdt_check.c
create mode 100644lib/libfdt/fdt_overlay.c--
2.25.1Just tried to give this a test run, but I couldn't compile it on my x86 Fedora machine with my cross compiler:
gcc-aarch64-linux-gnu-9.2.1-3.fc32.1.x86_64Every file that includes
libfdt_env.hgives me a message like thisIn file included from
lib/libfdt/fdt_overlay.c:7:lib/libfdt/libfdt_env.h:13:10: fatal error:stdlib.h: No such file or directory
Quoted 9 lines
13 | #include <stdlib.h> | ^~~~~~~~~~compilation terminated
So I commented out the #include line to see why it was there. We need
strtoul(). I quick hacked an incomplete one (below) and was able to compile and run tests. However I see that 'make clean' is leaving behind several libfdt files
Thanks for testing and for the fixes!
For some reason this isn't causing problems in my setup. gcc is eliminating unused symbols and it doesn't need to link with strtoul(). I see how this is a problem though and I will include your fix in the next version.
Quoted 12 lines
$ git clean -ndx Would remove lib/libfdt/.fdt.d Would remove lib/libfdt/.fdt_addresses.d Would remove lib/libfdt/.fdt_check.d Would remove lib/libfdt/.fdt_empty_tree.d Would remove lib/libfdt/.fdt_overlay.d Would remove lib/libfdt/.fdt_ro.d Would remove lib/libfdt/.fdt_rw.d Would remove lib/libfdt/.fdt_strerror.d Would remove lib/libfdt/.fdt_sw.d Would remove lib/libfdt/.fdt_wip.d
Sorry for that, I will fix in the Makefile.
Thanks,
Nikos
Quoted 49 lines
Thanks,
drewlib/stdlib.h new file +4
-0@@ -0,0 +1,4 @@ +#ifndef _STDLIB_H_ +#define _STDLIB_H_ +unsigned long int strtoul (const char *nptr,char **endptr,int base); +#endif lib/string.c +9
-1@@ -6,6 +6,7 @@*/ #include "libcflat.h" +#include "stdlib.h" size_t strlen (const char *buf) {@@ -161,7 +162,7 @@ void *memchr(const void *s, int c, size_t n)return NULL ; } -long atol (const char *ptr) +static long __atol (const char *ptr,char **endptr) {long acc =0 ;const char *s = ptr;@@ -189,9 +190,23 @@ long atol(const char *ptr)if (neg) acc = -acc; +if (endptr) + *endptr = (char *)s; +return acc; } +long atol (const char *ptr) +{ +return __atol (ptr,NULL ); +}
lib/string.c long atol(const char *ptr) · line 212
Quoted 10 lines
lib/string.c +7
-0+ +unsigned long int strtoul (const char *nptr,char **endptr,int base) +{ +assert (base ==10 ); +return __atol (nptr, endptr); +} +extern char **environ;char *getenv (const char *name)
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Quoted 70 lines · Nikos Nikoleris
Hey Drew,
Quoted 57 lines · Andrew Jones
Quoted 39 lines · Nikos Nikoleris
This set of patches fixes the way we parse the stdout-path which is used to set up the console. Prior to this, the code ignored the fact that stdout-path is made of the path to the uart node as well as parameters and as a result it would fail to find the relevant DT node. In addition to minor fixes in the device tree code, this series pulls a new version of libfdt from upstream.
Thanks,
Nikos
Nikos Nikoleris (4):
lib/string: add strnlen and strrchr
libfdt: Pull v1.6.0
Makefile: Avoid double definition oflibfdt_clean
devicetree: Parse correctly the stdout-pathlib/libfdt/README | 3 +- Makefile | 12 +- lib/libfdt/Makefile.libfdt | 10 +- lib/libfdt/version.lds | 24 +- lib/libfdt/fdt.h | 53 +-- lib/libfdt/libfdt.h | 766 +++++++++++++++++++++++++----- lib/libfdt/libfdt_env.h | 109 ++--- lib/libfdt/libfdt_internal.h | 206 +++++--- lib/string.h | 5 +- lib/devicetree.c | 15 +- lib/libfdt/fdt.c | 200 +++++--- lib/libfdt/fdt_addresses.c | 101 ++++ lib/libfdt/fdt_check.c | 74 +++ lib/libfdt/fdt_empty_tree.c | 48 +- lib/libfdt/fdt_overlay.c | 881 +++++++++++++++++++++++++++++++++++ lib/libfdt/fdt_ro.c | 512 +++++++++++++++----- lib/libfdt/fdt_rw.c | 231 +++++---- lib/libfdt/fdt_strerror.c | 53 +-- lib/libfdt/fdt_sw.c | 297 ++++++++---- lib/libfdt/fdt_wip.c | 90 ++-- lib/string.c | 30 +- 21 files changed, 2890 insertions(+), 830 deletions(-)Quoted 7 lines
create mode 100644
lib/libfdt/fdt_addresses.c
create mode 100644lib/libfdt/fdt_check.c
create mode 100644lib/libfdt/fdt_overlay.c--
2.25.1Just tried to give this a test run, but I couldn't compile it on my x86 Fedora machine with my cross compiler:
gcc-aarch64-linux-gnu-9.2.1-3.fc32.1.x86_64Every file that includes
libfdt_env.hgives me a message like thisIn file included from
lib/libfdt/fdt_overlay.c:7:lib/libfdt/libfdt_env.h:13:10: fatal error:stdlib.h: No such file or directoryQuoted 9 lines
13 | #include <stdlib.h> | ^~~~~~~~~~compilation terminated
So I commented out the #include line to see why it was there. We need
strtoul(). I quick hacked an incomplete one (below) and was able to compile and run tests. However I see that 'make clean' is leaving behind several libfdt files
Quoted 6 lines
Thanks for testing and for the fixes!
For some reason this isn't causing problems in my setup. gcc is eliminating unused symbols and it doesn't need to link with
strtoul(). I see how this is a problem though and I will include your fix in the next version.
Please write a proper strtoul(). Mine was just a minimal hack so I could progress and see if there was anything else to comment on.
Thanks,
drew
Quoted 81 lines
Quoted 13 lines
$ git clean -ndx Would remove lib/libfdt/.fdt.d Would remove lib/libfdt/.fdt_addresses.d Would remove lib/libfdt/.fdt_check.d Would remove lib/libfdt/.fdt_empty_tree.d Would remove lib/libfdt/.fdt_overlay.d Would remove lib/libfdt/.fdt_ro.d Would remove lib/libfdt/.fdt_rw.d Would remove lib/libfdt/.fdt_strerror.d Would remove lib/libfdt/.fdt_sw.d Would remove lib/libfdt/.fdt_wip.dSorry for that, I will fix in the
Makefile.Thanks,
Nikos
Quoted 49 lines
Thanks,
drewlib/stdlib.h new file +4
-0@@ -0,0 +1,4 @@ +#ifndef _STDLIB_H_ +#define _STDLIB_H_ +unsigned long int strtoul (const char *nptr,char **endptr,int base); +#endif lib/string.c +9
-1@@ -6,6 +6,7 @@*/ #include "libcflat.h" +#include "stdlib.h" size_t strlen (const char *buf) {@@ -161,7 +162,7 @@ void *memchr(const void *s, int c, size_t n)return NULL ; } -long atol (const char *ptr) +static long __atol (const char *ptr,char **endptr) {long acc =0 ;const char *s = ptr;@@ -189,9 +190,23 @@ long atol(const char *ptr)if (neg) acc = -acc; +if (endptr) + *endptr = (char *)s; +return acc; } +long atol (const char *ptr) +{ +return __atol (ptr,NULL ); +}lib/string.c long atol(const char *ptr) · line 212
Quoted 10 lines
lib/string.c +7
-0+ +unsigned long int strtoul (const char *nptr,char **endptr,int base) +{ +assert (base ==10 ); +return __atol (nptr, endptr); +} +extern char **environ;char *getenv (const char *name)IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.