Fwd: [U-Boot-Users] u-boot 1.1.2 and atoi in exports not working

---------- Forwarded message ---------- From: John Davis davisjf@gmail.com Date: Nov 24, 2005 9:37 AM Subject: Re: [U-Boot-Users] u-boot 1.1.2 and atoi in exports not working To: Wolfgang Denk wd@denx.de
Hello Wolfgang,
On 11/24/05, Wolfgang Denk wd@denx.de wrote:
In message 6a7ac2300511240623t31e9e96bp9b48e224527e2d2@mail.gmail.com you wrote:
I am trying to use atoi in my code. I can not get the image to link properly when i try to add it. Here is my setup.
What makes you think atoi() is available in U-Boot?
I see all these other routines using it. I figured I could use it as well. ie.
common/hush.c:104:#include <stdlib.h> /* getenv, atoi */ common/hush.c:606: exit (atoi(child->argv[1])); common/hush.c:803: n=atoi(child->argv[1]); common/hush.c:2667: num=atoi(o->data); disk/part_amiga.c:153: limit = atoi(s); disk/part_amiga.c:194: limit = atoi(s); tools/mpc86x_clk.c:205: xin = atoi(argv[1]); tools/mpc86x_clk.c:206: want_gclk2 = atoi(argv[2]); tools/mpc86x_clk.c:208: ppm = atoi(argv[3]); tools/ncb.c:14: port = atoi (argv[1]); board/MAI/AmigaOneG3SE/enet.c:450: unsigned long base = atoi(s); board/MAI/AmigaOneG3SE/enet.c:510: ret = pci_write_config_byte(devno, PCI_LATENCY_TIMER, (unsigned ch ar)atoi(s)); board/MAI/AmigaOneG3SE/usb_uhci.c:607: temp = atoi(s); board/MAI/AmigaOneG3SE/usb_uhci.c:618: temp2 = atoi(s); board/MAI/AmigaOneG3SE/video.c:81: attr = atoi(s); board/MAI/AmigaOneG3SE/video.c:87: attr |= atoi(s)<<4; board/MAI/AmigaOneG3SE/video.c:505: maxdev = atoi(s) * 2; board/MAI/bios_emulator/x86interface.c:56:int atoi(char *string) board/MAI/bios_emulator/x86interface.c:490: more_strap[3] = atoi(m); board/MAI/menu/menu.c:37: if (s) normal_attr = atoi(s); board/MAI/menu/menu.c:40: if (s) select_attr = atoi(s); board/MAI/menu/menu.c:43: if (s) disabled_attr = atoi(s); board/xilinx/xilinx_iic/iic_adapter.c:146:atoi(uchar * string) board/xilinx/xilinx_iic/iic_adapter.c:300: sprintf(temp, "%02x", atoi(s));
JD
Best regards,
Wolfgang Denk
-- Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de I don't see any direct evidence ... but, then, my crystal ball is in dire need of an ectoplasmic upgrade. :-) -- Howard Smith

Just some thoughts:
common/hush.c:104:#include <stdlib.h> /* getenv, atoi */
This looks suspicious for a bootloader! I would examine this a little bit closer. Where's stdlib.h? Is this line really compiled into u-boot? I think not, look inside the code, there's an "#ifndef __U_BOOT__" right in front of it.
[...] board/MAI/bios_emulator/x86interface.c:56:int atoi(char *string) [...] board/xilinx/xilinx_iic/iic_adapter.c:146:atoi(uchar * string)
In these two places, someone seems to define an atoi(). It doesn't look like a normal place to do it if it was meant to be available to everyone. These obviously are "local" patches to be able to run copied code. Anyway, atoi is a pretty simple function, I'd just do the same as these two guys, and paste a sample implementation into my code....
Greetings,

In message 200511241716.51670.david.jander@protonic.nl you wrote:
Anyway, atoi is a pretty simple function, I'd just do the same as these two guys, and paste a sample implementation into my code....
That's twenty lashes with an Ethernet cable on your back ;-)
Do *NOT* do this. Instead, look what everybody else is doing, and you will see that simple_strtoul() should be used instead.
Best regards,
Wolfgang Denk

Hello Wolfgang,
Thanks for the explanation on Thursday. Sorry I didn't get back to you earlier. I'll convert stuff to simple_stroul(). I was not aware that it existed.
JD
On 11/24/05, Wolfgang Denk wd@denx.de wrote:
In message 200511241716.51670.david.jander@protonic.nl you wrote:
Anyway, atoi is a pretty simple function, I'd just do the same as these two guys, and paste a sample implementation into my code....
That's twenty lashes with an Ethernet cable on your back ;-)
Do *NOT* do this. Instead, look what everybody else is doing, and you will see that simple_strtoul() should be used instead.
Best regards,
Wolfgang Denk
-- Software Engineering: Embedded and Realtime Systems, Embedded Linux Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de Life would be so much easier if everyone read the manual.
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_idv37&alloc_id%16865&opclick _______________________________________________ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users
participants (3)
-
David Jander
-
John Davis
-
Wolfgang Denk