# HG changeset patch # User Paul Boddie # Date 1676680237 -3600 # Node ID 914dbfb7bcaaa67299838054b79eefa0e13c4e4a # Parent f8f29bf0e4d7546dba491ae258291b5ec414f4b9 Introduced values to the notify operation and notification mechanisms. diff -r f8f29bf0e4d7 -r 914dbfb7bcaa libexec/lib/src/external_pager.cc --- a/libexec/lib/src/external_pager.cc Fri Feb 17 18:41:18 2023 +0100 +++ b/libexec/lib/src/external_pager.cc Sat Feb 18 01:30:37 2023 +0100 @@ -164,7 +164,7 @@ long ExternalPager::signal(unsigned long sig, unsigned long val) { if (_notifier != NULL) - _notifier->notify(NOTIFY_TASK_SIGNAL); + _notifier->notify(NOTIFY_TASK_SIGNAL, (notify_values_t) {sig, val}); return L4_EOK; } diff -r f8f29bf0e4d7 -r 914dbfb7bcaa libfsclient/include/fsclient/notifier.h --- a/libfsclient/include/fsclient/notifier.h Fri Feb 17 18:41:18 2023 +0100 +++ b/libfsclient/include/fsclient/notifier.h Sat Feb 18 01:30:37 2023 +0100 @@ -43,7 +43,8 @@ /* Pending notifications for monitored objects. */ - notify_flags_t pending = 0; + notify_flags_t pending_notifications = 0; + notify_values_t pending_values = NOTIFY_VALUES_NULL; /* Endpoints associated with monitored objects. */ @@ -89,7 +90,8 @@ /* Helper methods. */ - virtual void _notify(notifiable_t *object, notify_flags_t flags) = 0; + virtual void _notify(notifiable_t *object, notify_flags_t flags, + notify_values_t values) = 0; virtual bool _transfer(ObjectNotificationState &state, notifiable_t *object); @@ -131,7 +133,8 @@ /* Helper methods. */ - virtual void _notify(notifiable_t *object, notify_flags_t flags); + virtual void _notify(notifiable_t *object, notify_flags_t flags, + notify_values_t values); virtual bool _retrieve(notifiable_t **object); @@ -150,7 +153,8 @@ protected: /* Helper methods. */ - virtual void _notify(notifiable_t *object, notify_flags_t flags); + virtual void _notify(notifiable_t *object, notify_flags_t flags, + notify_values_t values); public: virtual long wait_object(notifiable_t *object); diff -r f8f29bf0e4d7 -r 914dbfb7bcaa libfsclient/lib/src/Makefile --- a/libfsclient/lib/src/Makefile Fri Feb 17 18:41:18 2023 +0100 +++ b/libfsclient/lib/src/Makefile Sat Feb 18 01:30:37 2023 +0100 @@ -16,7 +16,7 @@ # Individual interfaces. CLIENT_INTERFACES_CC = dataspace directory file filesystem flush \ - mapped_file notification opener \ + mapped_file notifier notification opener \ opener_context pipe pipe_opener # Generated and plain source files. diff -r f8f29bf0e4d7 -r 914dbfb7bcaa libfsclient/lib/src/notifier.cc --- a/libfsclient/lib/src/notifier.cc Fri Feb 17 18:41:18 2023 +0100 +++ b/libfsclient/lib/src/notifier.cc Sat Feb 18 01:30:37 2023 +0100 @@ -30,6 +30,7 @@ #include "notification_client.h" #include "notifier.h" +#include "notifier_interface.h" @@ -124,7 +125,7 @@ ipc_message_open(&msg); - notify_flags_t flags = ipc_message_get_word(&msg, 0); + struct in_words_Notifier_notify *in_words = (struct in_words_Notifier_notify *) ipc_message_get_word_address(&msg, 0); /* Reply to notifications. */ @@ -133,7 +134,7 @@ /* Register the notification. */ - _notify(object, flags); + _notify(object, in_words->flags, in_words->values); } ipc_message_free(&msg); @@ -256,7 +257,8 @@ the generic server dispatch mechanism, with the gate label being interpreted and provided as the first parameter. */ -void GeneralObjectNotifier::_notify(notifiable_t *object, notify_flags_t flags) +void GeneralObjectNotifier::_notify(notifiable_t *object, notify_flags_t flags, + notify_values_t values) { /* Enter critical section for the notifier (affecting all objects). */ @@ -275,11 +277,12 @@ std::unique_lock object_guard(state.lock); - /* Record flags and return previous flags. */ + /* Record flags and note previous flags. */ - notify_flags_t recorded = state.pending; + notify_flags_t recorded = state.pending_notifications; - state.pending |= flags; + state.pending_notifications |= flags; + state.pending_values = values; /* Add an object queue entry for any objects without previous notifications. */ @@ -291,7 +294,8 @@ _general_condition.notify_one(); } -void SpecificObjectNotifier::_notify(notifiable_t *object, notify_flags_t flags) +void SpecificObjectNotifier::_notify(notifiable_t *object, notify_flags_t flags, + notify_values_t values) { /* Acquire the lock for state lookup. */ @@ -306,7 +310,8 @@ std::unique_lock object_guard(state.lock); - state.pending |= flags; + state.pending_notifications |= flags; + state.pending_values = values; /* Notify any waiting caller. */ @@ -320,12 +325,13 @@ bool ObjectNotifier::_transfer(ObjectNotificationState &state, notifiable_t *object) { - notify_flags_t recorded = state.pending; + notify_flags_t recorded = state.pending_notifications; if (recorded) { object->notifications = recorded; - state.pending = 0; + object->values = state.pending_values; + state.pending_notifications = 0; return true; } diff -r f8f29bf0e4d7 -r 914dbfb7bcaa libfsserver/lib/generic/notification.cc --- a/libfsserver/lib/generic/notification.cc Fri Feb 17 18:41:18 2023 +0100 +++ b/libfsserver/lib/generic/notification.cc Sat Feb 18 01:30:37 2023 +0100 @@ -1,7 +1,7 @@ /* * Notification support. * - * Copyright (C) 2021, 2022 Paul Boddie + * Copyright (C) 2021, 2022, 2023 Paul Boddie * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -177,7 +177,7 @@ { client_Notifier notifier(*it); - notifier.notify(flags & ep.flags); + notifier.notify(flags & ep.flags, (notify_values_t) NOTIFY_VALUES_NULL); } } } diff -r f8f29bf0e4d7 -r 914dbfb7bcaa libsystypes/idl/notifier.idl --- a/libsystypes/idl/notifier.idl Fri Feb 17 18:41:18 2023 +0100 +++ b/libsystypes/idl/notifier.idl Sat Feb 18 01:30:37 2023 +0100 @@ -1,8 +1,8 @@ -#include /* notify_flags_t */ +#include /* notify_flags_t, notify_values_t */ interface Notifier { /* Send notification events. */ - [opcode(25)] void notify(in notify_flags_t flags); + [opcode(25)] void notify(in notify_flags_t flags, in notify_values_t values); }; diff -r f8f29bf0e4d7 -r 914dbfb7bcaa libsystypes/include/systypes/base.h --- a/libsystypes/include/systypes/base.h Fri Feb 17 18:41:18 2023 +0100 +++ b/libsystypes/include/systypes/base.h Sat Feb 18 01:30:37 2023 +0100 @@ -47,6 +47,14 @@ typedef l4_uint64_t notify_flags_t; +typedef struct +{ + unsigned long sig, val; /* signal-specific values */ + +} notify_values_t; + +#define NOTIFY_VALUES_NULL ((notify_values_t) {0, 0}) + enum notify_flags { NOTIFY_CONTENT_AVAILABLE = 0x001, /* reading files and pipes */ @@ -67,7 +75,8 @@ typedef struct { notifiable_base_t *base; /* access to the specific object */ - notify_flags_t notifications; + notify_flags_t notifications; /* essential notifications */ + notify_values_t values; /* signal-specific values */ } notifiable_t; diff -r f8f29bf0e4d7 -r 914dbfb7bcaa tests/dstest_exec.cc --- a/tests/dstest_exec.cc Fri Feb 17 18:41:18 2023 +0100 +++ b/tests/dstest_exec.cc Sat Feb 18 01:30:37 2023 +0100 @@ -34,9 +34,10 @@ class local_Notifier : public Notifier { public: - long notify(notify_flags_t flags) + long notify(notify_flags_t flags, notify_values_t values) { printf("Notified with flags: %" pFMTnotify_flags "x\n", flags); + printf("Notified with values: %ld, %ld\n", values.sig, values.val); return L4_EOK; }