<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>P {MARGIN-TOP: 0mm; MARGIN-BOTTOM: 0mm}</style>
</head>
<body>
<div style="FONT-FAMILY: Arial; FONT-SIZE: 10pt" id="ezFormProc_div">
<div style="FONT-FAMILY: Arial" id="msgbody">
<div>
<div style="LINE-HEIGHT: 15pt">Hello Dave, (and Mohan)</div>
<div style="LINE-HEIGHT: 15pt">Thanks for the nice info. </div>
<div style="LINE-HEIGHT: 15pt"> </div>
<div style="LINE-HEIGHT: 15pt">I've downloaded uClibc code and ran ctags -R and searched down printf.</div>
<div style="LINE-HEIGHT: 15pt">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..)</div>
<div style="LINE-HEIGHT: 15pt">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</div>
<div style="LINE-HEIGHT: 15pt"> </div>
<div style="LINE-HEIGHT: 15pt">in libc/stdio/_stdio.h, the __gcs.wirte is assigned to _cs_write and
<br>
in libc/stdio/_cs_funcs.c, the _cs_write function is defined as below.</div>
<div style="LINE-HEIGHT: 15pt">ssize_t attribute_hidden _cs_write(void *cookie, const char *buf, size_t bufsize)<br>
{<br>
return write(*((int *) cookie), (char *) buf, bufsize);<br>
}<br>
</div>
<div style="LINE-HEIGHT: 15pt">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?
</div>
<div style="LINE-HEIGHT: 15pt">Any hint will be deeply appreciated and if I'm wrong with something, please correct me.</div>
<div style="LINE-HEIGHT: 15pt">Thanks and regards,</div>
<div style="LINE-HEIGHT: 15pt"> </div>
<div style="LINE-HEIGHT: 15pt">Chan</div>
<div style="LINE-HEIGHT: 15pt">
<hr tabindex="-1">
</div>
<div style="LINE-HEIGHT: 15pt"><b>From : </b>"Dave Hylands" <dhylands@gmail.com><br>
<b>Sent : </b>2014-03-12 13:39:11 ( +09:00 )<br>
<b>To : </b>Kim Chan <ckim@etri.re.kr><br>
<b>Cc : </b>kernelnewbies@kernelnewbies.org <kernelnewbies@kernelnewbies.org><br>
<b>Subject : </b>Re: where is the printf source for busybox?<br>
<br>
</div>
<div style="LINE-HEIGHT: 15pt" dir="ltr">
<div>
<div>Hi,<br>
<br>
On Tue, Mar 11, 2014 at 6:44 PM, Kim Chan <<a href="mailto:ckim@etri.re.kr" target="_blank">ckim@etri.re.kr</a>> wrote:<br>
><br>
><br>
> Hi,<br>
> I've had this question for some time past and I would like to know the answer now..<br>
> I wanted to follow a printf in busybox but couldn't find the source of the printf function.<br>
> Then I throught probably the printf is provided by the system library where printf is connected to proper linux system call. (Is it printk?)<br>
<br>
</div>
busybox is typically built using uclibc, which is here:<br>
<a href="http://www.uclibc.org/" target="_blank">http://www.uclibc.org/</a><br>
<br>
</div>
The printf source code within uclibc is here:<br>
<a href="http://git.uclibc.org/uClibc/tree/libc/stdio/printf.c" target="_blank">http://git.uclibc.org/uClibc/tree/libc/stdio/printf.c</a><br>
<div>
<div>
<div><br>
</div>
<div>It eveentually winds up in _vfprintf here:<br>
<a href="http://git.uclibc.org/uClibc/tree/libc/stdio/_vfprintf.c" target="_blank">http://git.uclibc.org/uClibc/tree/libc/stdio/_vfprintf.c</a><br>
</div>
<div><br>
--<br>
Dave Hylands<br>
Shuswap, BC, Canada<br>
<a href="http://www.davehylands.com/" target="_blank">http://www.davehylands.com</a></div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>