Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/drm2/linux wait_on_bit
details: https://anonhg.NetBSD.org/src/rev/4b2dd11bf03f
branches: trunk
changeset: 1028035:4b2dd11bf03f
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Dec 19 01:42:01 2021 +0000
description:
wait_on_bit
diffstat:
sys/external/bsd/drm2/include/linux/wait_bit.h | 4 ++-
sys/external/bsd/drm2/linux/linux_wait_bit.c | 36 ++++++++++++++++++++++++-
2 files changed, 37 insertions(+), 3 deletions(-)
diffs (82 lines):
diff -r 9a5ccb3972e1 -r 4b2dd11bf03f sys/external/bsd/drm2/include/linux/wait_bit.h
--- a/sys/external/bsd/drm2/include/linux/wait_bit.h Sun Dec 19 01:41:54 2021 +0000
+++ b/sys/external/bsd/drm2/include/linux/wait_bit.h Sun Dec 19 01:42:01 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wait_bit.h,v 1.1 2021/12/19 01:22:15 riastradh Exp $ */
+/* $NetBSD: wait_bit.h,v 1.2 2021/12/19 01:42:01 riastradh Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,6 +32,7 @@
#ifndef _LINUX_WAIT_BIT_H_
#define _LINUX_WAIT_BIT_H_
+#define wait_on_bit linux_wait_on_bit
#define wait_on_bit_timeout linux_wait_on_bit_timeout
#define wake_up_bit linux_wake_up_bit
@@ -39,6 +40,7 @@
void linux_wait_bit_fini(void);
void wake_up_bit(const volatile unsigned long *, unsigned);
+int wait_on_bit(const volatile unsigned long *, unsigned, int);
int wait_on_bit_timeout(const volatile unsigned long *, unsigned, int,
unsigned long);
diff -r 9a5ccb3972e1 -r 4b2dd11bf03f sys/external/bsd/drm2/linux/linux_wait_bit.c
--- a/sys/external/bsd/drm2/linux/linux_wait_bit.c Sun Dec 19 01:41:54 2021 +0000
+++ b/sys/external/bsd/drm2/linux/linux_wait_bit.c Sun Dec 19 01:42:01 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_wait_bit.c,v 1.2 2021/12/19 01:41:54 riastradh Exp $ */
+/* $NetBSD: linux_wait_bit.c,v 1.3 2021/12/19 01:42:02 riastradh Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_wait_bit.c,v 1.2 2021/12/19 01:41:54 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_wait_bit.c,v 1.3 2021/12/19 01:42:02 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -115,6 +115,38 @@
}
int
+wait_on_bit(const volatile unsigned long *bitmap, unsigned bit, int flags)
+{
+ struct waitbitentry *wbe;
+ int error, ret;
+
+ if (test_bit(bit, bitmap))
+ return 0;
+
+ wbe = wait_bit_enter(bitmap, bit);
+
+ while (!test_bit(bit, bitmap)) {
+ if (flags & TASK_UNINTERRUPTIBLE) {
+ cv_wait(&wbe->cv, &wbe->lock);
+ } else {
+ error = cv_wait_sig(&wbe->cv, &wbe->lock);
+ if (error == EINTR || error == ERESTART)
+ ret = -ERESTARTSYS;
+ else if (error != 0)
+ ret = -error;
+ if (ret)
+ goto out;
+ }
+ }
+
+ /* Bit is set. Return zero on success. */
+ ret = 0;
+
+out: wait_bit_exit(wbe);
+ return ret;
+}
+
+int
wait_on_bit_timeout(const volatile unsigned long *bitmap, unsigned bit,
int flags, unsigned long timeout)
{
Home |
Main Index |
Thread Index |
Old Index