From b77f2a4ce9034d4341668bb61ca55fc177ee7729 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 28 Nov 2023 10:54:53 +0100 Subject: uloop: fix build using C++ compilers Rename the 'private' field to 'priv' in order to avoid using a C++ keyword Signed-off-by: Felix Fietkau --- uloop-epoll.c | 28 ++++++++++++++-------------- uloop-kqueue.c | 10 +++++----- uloop.h | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/uloop-epoll.c b/uloop-epoll.c index cf5733f..d7b3acf 100644 --- a/uloop-epoll.c +++ b/uloop-epoll.c @@ -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; diff --git a/uloop-kqueue.c b/uloop-kqueue.c index a48cca0..c81f815 100644 --- a/uloop-kqueue.c +++ b/uloop-kqueue.c @@ -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 5edeb70..4313dfe 100644 --- 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 -- cgit v1.2.3