This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: sprintf question


Hi,
at least for sbrk, this function is required by malloc, which in turn
is used to build up your final string for printf type of calls. (In
your case sbrk will not be either called however.).

As for the rest of the calls, these are in your case not actually
called either (verified just a minute ago). The code will end up In
sprintf where you have the following:

f._file = -1; /* No file. */

I.e. in your case you'd get away with stubs, which are required by the linker.

I'm not certain, but I'm guessing the dependency towards these
functions are there because the code is generically written. Since
fp's are involved, so would also their IO functions ( i.e. the rest of
the syscalls in your example).

Best
/Michael

P.S. Robin, sorry for the multiple mails. I reply to ML's way to
seldom to remeber the quirks involved when using gmail. D.S.

On 2/28/07, Robin Getz <rgetz@blackfin.uclinux.org> wrote:
All:

I was trying to use something like:

================
int i=0;
char buff[100];

sprintf(buff,"%i\n", i);
==========

It seems that sprintf, in libc/stdio/sprintf.c calls _vfprintf_r, which needs
<<close>>, <<fstat>>, <<isatty>>, <<lseek>>, <<read>>, <<sbrk>>, <<write>>.

I thought it strange, that operations purely on a buffer, would require
supporting OS file subroutines. I can understand why these are necessary for
printf, fprintf, but why sprintf?

Can someone explain?

Thanks
-Robin



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]