<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">&nbsp;</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&nbsp; (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 -&gt; vfprintf (very complex doing all the format conversions..) -&gt; PUTC -&gt; putc_unlocked -&gt; __FPUTC_UNLOCKED -&gt;(after some macro conversion)&nbsp;__fputc_unlocked -&gt; __stdio_WRITE (sometime write only to buffer) -&gt; __WRITE -&gt;
 __gcs.write -&gt; write</div>
<div style="LINE-HEIGHT: 15pt">&nbsp;</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,&nbsp; 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>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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">&nbsp;</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>&quot;Dave Hylands&quot; &lt;dhylands@gmail.com&gt;<br>
<b>Sent : </b>2014-03-12 13:39:11 ( &#43;09:00 )<br>
<b>To : </b>Kim Chan &lt;ckim@etri.re.kr&gt;<br>
<b>Cc : </b>kernelnewbies@kernelnewbies.org &lt;kernelnewbies@kernelnewbies.org&gt;<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 &lt;<a href="mailto:ckim@etri.re.kr" target="_blank">ckim@etri.re.kr</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt; Hi,<br>
&gt; I've had this question for some time past and I would like to know the answer now..<br>
&gt; I wanted to follow a printf in busybox but couldn't find the source of the printf function.<br>
&gt; 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>