where is the printf source for busybox?

Kim Chan ckim at etri.re.kr
Wed Mar 12 01:58:02 EDT 2014


Hello Dave, (and Mohan)
Thanks for the nice info.

I've downloaded uClibc code and ran ctags -R and searched down printf.
It looks like the main print path is  (assuming __STDIO_BUFFERS : I guess user level buffer for stdin, stdout, stderr) and assuming STDIO_GETC/PUTC_MACRO defined. without the macro, it seems to directly go to __fputc_unlocked..)
printf -> vfprintf (very complex doing all the format conversions..) -> PUTC -> putc_unlocked -> __FPUTC_UNLOCKED ->(after some macro conversion) __fputc_unlocked -> __stdio_WRITE (sometime write only to buffer) -> __WRITE -> __gcs.write -> write

in libc/stdio/_stdio.h, the __gcs.wirte is assigned to _cs_write and
in libc/stdio/_cs_funcs.c,  the _cs_write function is defined as below.
ssize_t attribute_hidden _cs_write(void *cookie, const char *buf, size_t bufsize)
{
        return write(*((int *) cookie), (char *) buf, bufsize);
}
what does cs stand for here? (Hm.. seems like custom streams..in the code) and I couldn't follow past write above. Where is the function write defined?
Any hint will be deeply appreciated and if I'm wrong with something, please correct me.
Thanks and regards,

Chan
________________________________
From : "Dave Hylands" <dhylands at gmail.com>
Sent : 2014-03-12 13:39:11 ( +09:00 )
To : Kim Chan <ckim at etri.re.kr>
Cc : kernelnewbies at kernelnewbies.org <kernelnewbies at kernelnewbies.org>
Subject : Re: where is the printf source for busybox?

Hi,

On Tue, Mar 11, 2014 at 6:44 PM, Kim Chan <ckim at etri.re.kr<mailto:ckim at etri.re.kr>> wrote:
>
>
> Hi,
> I've had this question for some time past and I would like to know the answer now..
> I wanted to follow a printf in busybox but couldn't find the source of the printf function.
> Then I throught probably the printf is provided by the system library where printf is connected to proper linux system call. (Is it printk?)

busybox is typically built using uclibc, which is here:
http://www.uclibc.org/

The printf source code within uclibc is here:
http://git.uclibc.org/uClibc/tree/libc/stdio/printf.c

It eveentually winds up in _vfprintf here:
http://git.uclibc.org/uClibc/tree/libc/stdio/_vfprintf.c

--
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com<http://www.davehylands.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140312/1fb1bdfb/attachment.html 


More information about the Kernelnewbies mailing list