Page 1 of 1

chsnprintf thread safe

Posted: Tue Jun 20, 2017 4:52 pm
by Tabulous
Am i right to assume chsnprintf is not thread safe ?

Re: chsnprintf thread safe

Posted: Tue Jun 20, 2017 5:48 pm
by Giovanni
Hi,

Why not?

Giovanni

Re: chsnprintf thread safe

Posted: Tue Jun 20, 2017 7:30 pm
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.

Re: chsnprintf thread safe

Posted: Tue Jun 20, 2017 8:30 pm
by Giovanni
Hi,

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

Giovanni

Re: chsnprintf thread safe

Posted: Tue Jun 20, 2017 8:45 pm
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.