syslog: Change g_syslog_default_sem to static function variable

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-01-31 16:36:24 +08:00 committed by Petro Karashchenko
parent 49b15e3577
commit 8391ad2721
1 changed files with 3 additions and 6 deletions

View File

@ -115,10 +115,6 @@ static struct syslog_channel_s g_rtt_channel =
#endif
#if defined(CONFIG_SYSLOG_DEFAULT)
# if defined(CONFIG_ARCH_LOWPUTC)
static sem_t g_syslog_default_sem = SEM_INITIALIZER(1);
# endif
static const struct syslog_channel_ops_s g_default_channel_ops =
{
syslog_default_putc,
@ -184,15 +180,16 @@ static ssize_t syslog_default_write(FAR struct syslog_channel_s *channel,
FAR const char *buffer, size_t buflen)
{
#if defined(CONFIG_ARCH_LOWPUTC)
static sem_t sem = SEM_INITIALIZER(1);
size_t nwritten;
nxsem_wait(&g_syslog_default_sem);
nxsem_wait(&sem);
for (nwritten = 0; nwritten < buflen; nwritten++)
{
up_putc(buffer[nwritten]);
}
nxsem_post(&g_syslog_default_sem);
nxsem_post(&sem);
#endif
return buflen;