From 95ba13d7af5a6e08dab0a3855dd3ca97041b83f1 Mon Sep 17 00:00:00 2001 From: David Chisnall Date: Fri, 17 Jan 2025 14:49:23 +0000 Subject: [PATCH] Fix multiwaiter public header. (#419) It had a load of left-over things in it from when the scheduler knew about event groups. --------- Co-authored-by: Nathaniel Wesley Filardo --- sdk/include/multiwaiter.h | 44 +++++++-------------------------------- tests/multiwaiter-test.cc | 12 +++++------ 2 files changed, 13 insertions(+), 43 deletions(-) diff --git a/sdk/include/multiwaiter.h b/sdk/include/multiwaiter.h index 9032a723..8b22817f 100644 --- a/sdk/include/multiwaiter.h +++ b/sdk/include/multiwaiter.h @@ -33,25 +33,6 @@ #include #include -/** - * The kind of event source to wait for in a multiwaiter. - */ -enum EventWaiterKind -{ - /// Event source is an event channel. - EventWaiterEventChannel, - /// Event source is a futex. - EventWaiterFutex -}; - -enum [[clang::flag_enum]] EventWaiterEventChannelFlags -{ - /// Automatically clear the bits we waited on. - EventWaiterEventChannelClearOnExit = (1 << 24), - /// Notify when all bits were set. - EventWaiterEventChannelWaitAll = (1 << 26) -}; - /** * Structure describing a change to the set of managed event sources for an * event waiter. @@ -59,29 +40,18 @@ enum [[clang::flag_enum]] EventWaiterEventChannelFlags struct EventWaiterSource { /** - * A pointer to the event source. For a futex, this should be the memory - * address. For other sources, it should be a pointer to an object of the - * corresponding type. + * A pointer to the event source. This is the futex that is monitored for + * the multiwaiter. */ void *eventSource; /** - * The kind of the event source. This must match the pointer type. - */ - enum EventWaiterKind kind; - /** - * Event-specific configuration. This field is modified during the wait - * call. The interpretation of this depends on `kind`: + * Event value. This field is modified during the wait + * call. * - * - `EventWaiterEventChannel`: The low 24 bits contain the bits to - * monitor, the top bit indicates whether this event is triggered if all - * of the bits are set (true) or some of them (false). On return, this - * contains the bits that have been set during the call. - * - `EventWaiterFutex`: This indicates the value to compare the futex word - * against. If they mismatch, the event fires immediately. + * This indicates the value to compare the futex word against. If they + * mismatch, the event fires immediately. * - * If waiting for a futex, signal the event immediately if the value - * does not match. On return, this is set to 1 if the futex is - * signaled, 0 otherwise. + * On return, this is set to 1 if the futex is signaled, 0 otherwise. */ uint32_t value; }; diff --git a/tests/multiwaiter-test.cc b/tests/multiwaiter-test.cc index 16cbc047..6cc0249a 100644 --- a/tests/multiwaiter-test.cc +++ b/tests/multiwaiter-test.cc @@ -32,12 +32,12 @@ int test_multiwaiter() EventWaiterSource events[4]; debug_log("Testing error case: Invalid values"); - events[0] = {nullptr, static_cast(5), 0}; + events[0] = {nullptr, 0}; ret = multiwaiter_wait(&t, mw, events, 1); TEST(ret == -EINVAL, "multiwaiter returned {}, expected {}", ret, -EINVAL); debug_log("Testing one futex, already ready"); - events[0] = {&futex, EventWaiterFutex, 1}; + events[0] = {&futex, 1}; t.remaining = 5; ret = multiwaiter_wait(&t, mw, events, 1); TEST(ret == 0, "multiwaiter returned {}, expected 0", ret); @@ -53,7 +53,7 @@ int test_multiwaiter() debug_log("Testing one futex, not yet ready"); setFutex(&futex, 1); - events[0] = {&futex, EventWaiterFutex, 0}; + events[0] = {&futex, 0}; t.remaining = 6; ret = multiwaiter_wait(&t, mw, events, 1); TEST(ret == 0, "multiwaiter returned {}, expected 0", ret); @@ -62,8 +62,8 @@ int test_multiwaiter() futex = 0; futex2 = 2; setFutex(&futex2, 3); - events[0] = {&futex, EventWaiterFutex, 0}; - events[1] = {&futex2, EventWaiterFutex, 2}; + events[0] = {&futex, 0}; + events[1] = {&futex2, 2}; t.remaining = 6; ret = multiwaiter_wait(&t, mw, events, 2); TEST(ret == 0, "multiwaiter returned {}, expected 0", ret); @@ -118,7 +118,7 @@ int test_multiwaiter() futex = 0; setFutex(&futex, 1); multiwaiter_queue_receive_init(&events[0], queue); - events[1] = {&futex, EventWaiterFutex, 0}; + events[1] = {&futex, 0}; t.remaining = 6; ret = multiwaiter_wait(&t, mw, events, 2); TEST(ret == 0, "multiwait on futex and queue returned {}", ret);