This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos 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: Implementation of sprintf ....


On Mon, Feb 03, 2003 at 11:19:11AM +0100, Thomas BINDER wrote:
> 
> Hi folks!
> 

> Ich have a short question concerning the implementation of the
> (libc) sprintf function.

> A quick look into the sources reveals that an instance of
> Cyg_StdioStream is used, which in turn uses a mutex to lock critical
> sections (e.g. in write).

> Since there is another implementation of sprintf (diag_sprintf)
> which does not need a mutex, I wonder what the actual differences
> between the two implementations are (apart from the mutex).  Why are
> streams used in sprintf ???

For consistence, sprintf maps down to vfnprintf, which implements the
whole printf family. diag_sprintf is used for the debug output. Its
not as feature rich as vfnprintf. diag_sprintf is part of the infra
package so will always be available, where as sprintf is part of libc
and so is optional.

The libc function is slow, because of all the stream and mutex
stuff. It would be nice to optimize this, but it does not look easy.

       Andrew

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss


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