uloop: fix build using C++ compilers
authorFelix Fietkau <nbd@nbd.name>
Tue, 28 Nov 2023 09:54:53 +0000 (10:54 +0100)
committerFelix Fietkau <nbd@nbd.name>
Tue, 28 Nov 2023 09:54:54 +0000 (10:54 +0100)
Rename the 'private' field to 'priv' in order to avoid using a C++ keyword

Signed-off-by: Felix Fietkau <nbd@nbd.name>
uloop-epoll.c
uloop-kqueue.c
uloop.h

index cf5733fa973b3ec40723f268c12f0c32bdea4443..d7b3acf095c467edbed832007e708617ef99108c 100644 (file)
@@ -115,7 +115,7 @@ static void dispatch_timer(struct uloop_fd *u, unsigned int events)
        if (read(u->fd, &fired, sizeof(fired)) != sizeof(fired))
                return;
 
-       struct uloop_interval *tm = container_of(u, struct uloop_interval, private.ufd);
+       struct uloop_interval *tm = container_of(u, struct uloop_interval, priv.ufd);
 
        tm->expirations += fired;
        tm->cb(tm);
@@ -123,14 +123,14 @@ static void dispatch_timer(struct uloop_fd *u, unsigned int events)
 
 static int timer_register(struct uloop_interval *tm, unsigned int msecs)
 {
-       if (!tm->private.ufd.registered) {
+       if (!tm->priv.ufd.registered) {
                int fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC|TFD_NONBLOCK);
 
                if (fd == -1)
                        return -1;
 
-               tm->private.ufd.fd = fd;
-               tm->private.ufd.cb = dispatch_timer;
+               tm->priv.ufd.fd = fd;
+               tm->priv.ufd.cb = dispatch_timer;
        }
 
        struct itimerspec spec = {
@@ -144,29 +144,29 @@ static int timer_register(struct uloop_interval *tm, unsigned int msecs)
                }
        };
 
-       if (timerfd_settime(tm->private.ufd.fd, 0, &spec, NULL) == -1)
+       if (timerfd_settime(tm->priv.ufd.fd, 0, &spec, NULL) == -1)
                goto err;
 
-       if (uloop_fd_add(&tm->private.ufd, ULOOP_READ) == -1)
+       if (uloop_fd_add(&tm->priv.ufd, ULOOP_READ) == -1)
                goto err;
 
        return 0;
 
 err:
-       uloop_fd_delete(&tm->private.ufd);
-       close(tm->private.ufd.fd);
-       memset(&tm->private.ufd, 0, sizeof(tm->private.ufd));
+       uloop_fd_delete(&tm->priv.ufd);
+       close(tm->priv.ufd.fd);
+       memset(&tm->priv.ufd, 0, sizeof(tm->priv.ufd));
 
        return -1;
 }
 
 static int timer_remove(struct uloop_interval *tm)
 {
-       int ret = __uloop_fd_delete(&tm->private.ufd);
+       int ret = __uloop_fd_delete(&tm->priv.ufd);
 
        if (ret == 0) {
-               close(tm->private.ufd.fd);
-               memset(&tm->private.ufd, 0, sizeof(tm->private.ufd));
+               close(tm->priv.ufd.fd);
+               memset(&tm->priv.ufd, 0, sizeof(tm->priv.ufd));
        }
 
        return ret;
@@ -176,10 +176,10 @@ static int64_t timer_next(struct uloop_interval *tm)
 {
        struct itimerspec spec;
 
-       if (!tm->private.ufd.registered)
+       if (!tm->priv.ufd.registered)
                return -1;
 
-       if (timerfd_gettime(tm->private.ufd.fd, &spec) == -1)
+       if (timerfd_gettime(tm->priv.ufd.fd, &spec) == -1)
                return -1;
 
        return spec.it_value.tv_sec * 1000 + spec.it_value.tv_nsec / 1000000;
index a48cca0725d04e7410c7e0dab74ec50cae177eec..c81f815969d259df25fdf521a51eb1e21707fd47 100644 (file)
@@ -135,7 +135,7 @@ static int uloop_fetch_events(int timeout)
                if (events[n].filter == EVFILT_TIMER) {
                        struct uloop_interval *tm = events[n].udata;
 
-                       tm->private.time.fired = get_timestamp_us();
+                       tm->priv.time.fired = get_timestamp_us();
                        tm->expirations += events[n].data;
                        tm->cb(tm);
 
@@ -180,8 +180,8 @@ static int timer_register(struct uloop_interval *tm, unsigned int msecs)
 {
        struct kevent ev;
 
-       tm->private.time.msecs = msecs;
-       tm->private.time.fired = get_timestamp_us();
+       tm->priv.time.msecs = msecs;
+       tm->priv.time.fired = get_timestamp_us();
 
        EV_SET(&ev, (uintptr_t)tm, EVFILT_TIMER, EV_ADD, NOTE_USECONDS, msecs * 1000, tm);
 
@@ -199,11 +199,11 @@ static int timer_remove(struct uloop_interval *tm)
 
 static int64_t timer_next(struct uloop_interval *tm)
 {
-       int64_t t1 = tm->private.time.fired;
+       int64_t t1 = tm->priv.time.fired;
        int64_t t2 = get_timestamp_us();
 
        while (t1 < t2)
-               t1 += tm->private.time.msecs * 1000;
+               t1 += tm->priv.time.msecs * 1000;
 
        return (t1 - t2) / 1000;
 }
diff --git a/uloop.h b/uloop.h
index 5edeb7012a7a08543f90ffe0673f2b30fd275dc9..4313dfea1f3f8d74408c7294b71ef710aa6d2ccf 100644 (file)
--- a/uloop.h
+++ b/uloop.h
@@ -98,7 +98,7 @@ struct uloop_interval
                        int64_t fired;
                        unsigned int msecs;
                } time;
-       } private;
+       } priv;
 };
 
 struct uloop_signal