chsnprintf thread safe

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

chsnprintf thread safe

Post by Tabulous »

Am i right to assume chsnprintf is not thread safe ?
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: chsnprintf thread safe

Post by Giovanni »

Hi,

Why not?

Giovanni
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: chsnprintf thread safe

Post by Tabulous »

Let me re-phase the question, is chsnprintf thread safe ?

I use it alot in different threads and im trying to locate a weird issue.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: chsnprintf thread safe

Post by Giovanni »

Hi,

It is meant to be thread safe IF the stream is thread safe as well.

Giovanni
Tabulous
Posts: 518
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 7 times
Been thanked: 18 times

Re: chsnprintf thread safe

Post by Tabulous »

Hi
this is what ive got

Code: Select all


#define DBGIO   &SD6

void debugInit( void )
{
    sdStart( DBGIO, &debugconfig );
    stream = (BaseSequentialStream *)DBGIO;
}

void debugOut( uint32_t mask, const char *fmt, ... )
{
va_list args;


    if( stream != NULL )
    {
            va_start( args, fmt );
            chvprintf( stream, fmt, args );
            va_end( args );
    }
}



debugOut is called everywhere all over the application/different threads to spit out debug messages.

But i also use chsnprintf alot to format other things, these normally use static buffers declared in each software module.


both debug and chsnprintf use chvprintf the differential is the stream.
Post Reply