* [U-Boot-Users] u-boot 1.1.2 and atoi in exports not working
@ 2005-11-24 14:23 John Davis
2005-11-24 14:35 ` Wolfgang Denk
0 siblings, 1 reply; 7+ messages in thread
From: John Davis @ 2005-11-24 14:23 UTC (permalink / raw)
To: u-boot
Hello
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.
Addded to include/_exports.h
EXPORT_FUNC(atoi)
Added to include/exports.h
int atoi(const char *);
Added to common/exports.c
gd->jt[XF_atoi] = (void *)atoi;
But when I do the make of u-boot, I get :
/gcc-lib/ppc-linux/3.3.3/pic -lgcc --end-group \
-Map u-boot.map -o u-boot
common/libcommon.a(exports.o)(.got2+0x20): In function `jumptable_init':
/home/davis/progs/c/u-boot-1.1.2/common/exports.c:14: undefined
reference to `atoi'
make: *** [u-boot] Error 1
However, I did the same thing for get_dcr and set_dcr and it worked.
Please advise,
JD
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot-Users] u-boot 1.1.2 and atoi in exports not working
2005-11-24 14:23 [U-Boot-Users] u-boot 1.1.2 and atoi in exports not working John Davis
@ 2005-11-24 14:35 ` Wolfgang Denk
[not found] ` <6a7ac2300511240637p1b281106k2849ac3bb5a96715@mail.gmail.com>
0 siblings, 1 reply; 7+ messages in thread
From: Wolfgang Denk @ 2005-11-24 14:35 UTC (permalink / raw)
To: u-boot
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?
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I don't see any direct evidence ... but, then, my crystal ball is in
dire need of an ectoplasmic upgrade. :-) -- Howard Smith
^ permalink raw reply [flat|nested] 7+ messages in thread
* Fwd: [U-Boot-Users] u-boot 1.1.2 and atoi in exports not working
[not found] ` <6a7ac2300511240637p1b281106k2849ac3bb5a96715@mail.gmail.com>
@ 2005-11-24 14:52 ` John Davis
2005-11-24 16:16 ` David Jander
2005-11-24 15:53 ` Wolfgang Denk
1 sibling, 1 reply; 7+ messages in thread
From: John Davis @ 2005-11-24 14:52 UTC (permalink / raw)
To: u-boot
---------- 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 at denx.de
> I don't see any direct evidence ... but, then, my crystal ball is in
> dire need of an ectoplasmic upgrade. :-) -- Howard Smith
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot-Users] u-boot 1.1.2 and atoi in exports not working
[not found] ` <6a7ac2300511240637p1b281106k2849ac3bb5a96715@mail.gmail.com>
2005-11-24 14:52 ` Fwd: " John Davis
@ 2005-11-24 15:53 ` Wolfgang Denk
1 sibling, 0 replies; 7+ messages in thread
From: Wolfgang Denk @ 2005-11-24 15:53 UTC (permalink / raw)
To: u-boot
Dear John,
in message <6a7ac2300511240637p1b281106k2849ac3bb5a96715@mail.gmail.com> you wrote:
>
> > 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.
Be careful! Just running "grep" does not mean anything. You have to
check on which #ifdef's these lines depend.
> 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);
For example, the hush shell is a port from the busybox project, and
was changed only in the minimal necessary way. And if you look for
example at
common/hush.c:104:#include <stdlib.h> /* getenv, atoi */
you should check the context:
...
100 #ifdef CFG_HUSH_PARSER
101 #ifndef __U_BOOT__
102 #include <ctype.h> /* isalpha, isdigit */
103 #include <unistd.h> /* getpid */
104 #include <stdlib.h> /* getenv, atoi */
...
Note the "#ifndef __U_BOOT__" part!
> 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]);
Also, tools/ are tools that are running on the host system - they
don't have anything in common with U-Boot code.
Summary: there is no atoi() in U-Boot.
Best regards,
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
In an organization, each person rises to the level of his own incom-
petency - The Peter Principle
^ permalink raw reply [flat|nested] 7+ messages in thread
* Fwd: [U-Boot-Users] u-boot 1.1.2 and atoi in exports not working
2005-11-24 14:52 ` Fwd: " John Davis
@ 2005-11-24 16:16 ` David Jander
2005-11-24 16:42 ` Wolfgang Denk
0 siblings, 1 reply; 7+ messages in thread
From: David Jander @ 2005-11-24 16:16 UTC (permalink / raw)
To: u-boot
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,
--
David Jander
Protonic Holland.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Fwd: [U-Boot-Users] u-boot 1.1.2 and atoi in exports not working
2005-11-24 16:16 ` David Jander
@ 2005-11-24 16:42 ` Wolfgang Denk
2005-11-28 15:30 ` John Davis
0 siblings, 1 reply; 7+ messages in thread
From: Wolfgang Denk @ 2005-11-24 16:42 UTC (permalink / raw)
To: u-boot
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 at denx.de
Life would be so much easier if everyone read the manual.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Fwd: [U-Boot-Users] u-boot 1.1.2 and atoi in exports not working
2005-11-24 16:42 ` Wolfgang Denk
@ 2005-11-28 15:30 ` John Davis
0 siblings, 0 replies; 7+ messages in thread
From: John Davis @ 2005-11-28 15:30 UTC (permalink / raw)
To: u-boot
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 at 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\x16865&opclick
> _______________________________________________
> U-Boot-Users mailing list
> U-Boot-Users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/u-boot-users
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-11-28 15:30 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-24 14:23 [U-Boot-Users] u-boot 1.1.2 and atoi in exports not working John Davis
2005-11-24 14:35 ` Wolfgang Denk
[not found] ` <6a7ac2300511240637p1b281106k2849ac3bb5a96715@mail.gmail.com>
2005-11-24 14:52 ` Fwd: " John Davis
2005-11-24 16:16 ` David Jander
2005-11-24 16:42 ` Wolfgang Denk
2005-11-28 15:30 ` John Davis
2005-11-24 15:53 ` Wolfgang Denk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox