mirror of
https://github.com/fluencelabs/musl
synced 2025-05-25 13:41:32 +00:00
eliminate atomics in syslog setlogmask function
This commit is contained in:
parent
7a81fe3710
commit
6de071a0be
@ -10,19 +10,21 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "libc.h"
|
#include "libc.h"
|
||||||
#include "atomic.h"
|
|
||||||
|
|
||||||
static volatile int lock[2];
|
static volatile int lock[2];
|
||||||
static char log_ident[32];
|
static char log_ident[32];
|
||||||
static int log_opt;
|
static int log_opt;
|
||||||
static int log_facility = LOG_USER;
|
static int log_facility = LOG_USER;
|
||||||
static volatile int log_mask = 0xff;
|
static int log_mask = 0xff;
|
||||||
static int log_fd = -1;
|
static int log_fd = -1;
|
||||||
|
|
||||||
int setlogmask(int maskpri)
|
int setlogmask(int maskpri)
|
||||||
{
|
{
|
||||||
if (maskpri) return a_swap(&log_mask, maskpri);
|
LOCK(lock);
|
||||||
else return log_mask;
|
int ret = log_mask;
|
||||||
|
if (maskpri) log_mask = maskpri;
|
||||||
|
UNLOCK(lock);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user