]> xenbits.xensource.com Git - unikraft/libs/newlib.git/commitdiff
syslog.c: Bring back setlogmask() from musl
authorCostin Lupu <costin.lupu@cs.pub.ro>
Mon, 2 Sep 2019 15:06:45 +0000 (18:06 +0300)
committerCostin Lupu <costin.lupu@cs.pub.ro>
Mon, 2 Sep 2019 20:51:02 +0000 (23:51 +0300)
The OSv implementation, where we took this from, dropped the setlogmask()
function. We bring it back from the musl implementation because it is needed by
Python 3.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Vlad-Andrei Badoiu<vlad_andrei.badoiu@stud.acs.upb.ro>
musl-imported/src/syslog.c

index 179224165be12bcb163b8ea0f25bb718245a7844..ee109f56f1006de8f6e99d3e98cc7314a2da2182 100644 (file)
@@ -70,6 +70,7 @@
 static struct uk_mutex lock = UK_MUTEX_INITIALIZER(lock);
 static char log_ident[32];
 static int log_opt;
+static int log_mask = 0xff;
 static int log_facility = LOG_USER;
 
 void openlog(const char *ident, int opt, int facility)
@@ -95,6 +96,18 @@ void closelog(void)
 {
 }
 
+int setlogmask(int maskpri)
+{
+       int ret;
+
+       LOCK(lock);
+       ret = log_mask;
+       if (maskpri)
+               log_mask = maskpri;
+       UNLOCK(lock);
+       return ret;
+}
+
 void syslog(int priority, const char *message, ...)
 {
        va_list ap;
@@ -105,6 +118,9 @@ void syslog(int priority, const char *message, ...)
        int pid;
        int l, l2;
 
+       if (!(log_mask & LOG_MASK(priority & 7)) || (priority & ~0x3ff))
+               return;
+
        LOCK(lock);
 
        va_start(ap, message);