1.1 --- a/docs/wiki/Client_Library Sat Dec 09 01:26:55 2023 +0100 1.2 +++ b/docs/wiki/Client_Library Sat Dec 09 01:27:19 2023 +0100 1.3 @@ -228,39 +228,39 @@ 1.4 a given resource via a notifier object: 1.5 1.6 {{{ 1.7 -long client_subscribe(file_t *file, notify_flags_t flags, file_notifier_t *notifier); 1.8 +long client_subscribe(file_t *file, notify_flags_t flags, notifier_t *notifier); 1.9 }}} 1.10 1.11 A notifier object can be common throughout all threads in a task, being 1.12 obtained using the following function: 1.13 1.14 {{{ 1.15 -file_notifier_t *client_notifier_task(); 1.16 +notifier_t *client_notifier_task(); 1.17 }}} 1.18 1.19 Alternatively, a local notifier can be created for use within a thread: 1.20 1.21 {{{ 1.22 -file_notifier_t *client_notifier_local(); 1.23 +notifier_t *client_notifier_local(); 1.24 }}} 1.25 1.26 Local notifiers must be closed when they are no longer needed: 1.27 1.28 {{{ 1.29 -void client_notifier_close(file_notifier_t *notifier); 1.30 +void client_notifier_close(notifier_t *notifier); 1.31 }}} 1.32 1.33 When notifications are no longer needed, an unsubscribe operation can be 1.34 invoked: 1.35 1.36 {{{ 1.37 -long client_unsubscribe(file_t *file, file_notifier_t *notifier); 1.38 +long client_unsubscribe(file_t *file, notifier_t *notifier); 1.39 }}} 1.40 1.41 ==== Example ==== 1.42 1.43 {{{ 1.44 -file_notifier_t *notifier = client_notifier_local(); 1.45 +notifier_t *notifier = client_notifier_local(); 1.46 file_t *directory = client_open(filename, O_DIRECTORY); 1.47 1.48 if (client_opened(directory))
2.1 --- a/libfsclient/include/fsclient/client.h Sat Dec 09 01:26:55 2023 +0100 2.2 +++ b/libfsclient/include/fsclient/client.h Sat Dec 09 01:27:19 2023 +0100 2.3 @@ -100,14 +100,15 @@ 2.4 2.5 /* More advanced notification operations. */ 2.6 2.7 -void client_notifier_close(file_notifier_t *notifier); 2.8 -file_notifier_t *client_notifier_local(void); 2.9 -file_notifier_t *client_notifier_task(void); 2.10 +void client_notifier_close(notifier_t *notifier); 2.11 +notifier_t *client_notifier_local(void); 2.12 +notifier_t *client_notifier_task(void); 2.13 2.14 -long client_subscribe(file_t *file, notify_flags_t flags, file_notifier_t *notifier); 2.15 -long client_unsubscribe(file_t *file, file_notifier_t *notifier); 2.16 -long client_wait_file(file_t *file, file_notifier_t *notifier); 2.17 -long client_wait_files(file_t **file, file_notifier_t *notifier); 2.18 +long client_subscribe(file_t *file, notify_flags_t flags, notifier_t *notifier); 2.19 +long client_unsubscribe(file_t *file, notifier_t *notifier); 2.20 + 2.21 +long client_wait_file(file_t *file, notifier_t *notifier); 2.22 +long client_wait_files(file_t **file, notifier_t *notifier); 2.23 2.24 EXTERN_C_END 2.25
3.1 --- a/libfsclient/include/fsclient/file.h Sat Dec 09 01:26:55 2023 +0100 3.2 +++ b/libfsclient/include/fsclient/file.h Sat Dec 09 01:27:19 2023 +0100 3.3 @@ -29,13 +29,7 @@ 3.4 #include <systypes/base.h> 3.5 #include <systypes/user.h> 3.6 3.7 - 3.8 - 3.9 -/* C compatibility types (defined in the implementation). */ 3.10 - 3.11 -struct file_notifier; 3.12 - 3.13 -typedef struct file_notifier file_notifier_t; 3.14 +#include <fsclient/notify.h> 3.15 3.16 3.17 3.18 @@ -49,6 +43,10 @@ 3.19 3.20 l4_cap_idx_t ref; 3.21 3.22 + /* Notification structure. */ 3.23 + 3.24 + notifiable_t notifiable; 3.25 + 3.26 /* Mapped memory accessing a file region. */ 3.27 3.28 char *memory; 3.29 @@ -71,10 +69,6 @@ 3.30 3.31 notify_flags_t can_block; 3.32 3.33 - /* Notification structure. */ 3.34 - 3.35 - notifiable_t notifiable; 3.36 - 3.37 /* Flags indicated when opening the file. */ 3.38 3.39 flags_t flags; 3.40 @@ -151,14 +145,8 @@ 3.41 notifiable_t *file_notifiable(file_t *file); 3.42 notify_flags_t file_notifications(file_t *file); 3.43 3.44 -void file_notify_close(file_notifier_t *notifier); 3.45 -file_notifier_t *file_notify_local(void); 3.46 -file_notifier_t *file_notify_task(void); 3.47 - 3.48 -long file_notify_subscribe(file_t *file, notify_flags_t flags, file_notifier_t *notifier); 3.49 -long file_notify_unsubscribe(file_t *file, file_notifier_t *notifier); 3.50 -long file_notify_wait_file(file_t *file, file_notifier_t *notifier); 3.51 -long file_notify_wait_files(file_t **file, file_notifier_t *notifier); 3.52 +long file_notify_wait_file(file_t *file, notifier_t *notifier); 3.53 +long file_notify_wait_files(file_t **file, notifier_t *notifier); 3.54 3.55 3.56
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/libfsclient/include/fsclient/notify.h Sat Dec 09 01:27:19 2023 +0100 4.3 @@ -0,0 +1,55 @@ 4.4 +/* 4.5 + * Notification-related functions and types. 4.6 + * 4.7 + * Copyright (C) 2023 Paul Boddie <paul@boddie.org.uk> 4.8 + * 4.9 + * This program is free software; you can redistribute it and/or 4.10 + * modify it under the terms of the GNU General Public License as 4.11 + * published by the Free Software Foundation; either version 2 of 4.12 + * the License, or (at your option) any later version. 4.13 + * 4.14 + * This program is distributed in the hope that it will be useful, 4.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 4.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 4.17 + * GNU General Public License for more details. 4.18 + * 4.19 + * You should have received a copy of the GNU General Public License 4.20 + * along with this program; if not, write to the Free Software 4.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 4.22 + * Boston, MA 02110-1301, USA 4.23 + */ 4.24 + 4.25 +#pragma once 4.26 + 4.27 +#include <systypes/base.h> 4.28 + 4.29 + 4.30 + 4.31 +/* C compatibility types (defined in the implementation). */ 4.32 + 4.33 +struct notifier; 4.34 + 4.35 +typedef struct notifier notifier_t; 4.36 + 4.37 + 4.38 + 4.39 +EXTERN_C_BEGIN 4.40 + 4.41 +notifiable_t *notify_notifiable(notifiable_base_t *notifiable); 4.42 +notify_flags_t notify_notifications(notifiable_base_t *notifiable); 4.43 +notify_values_t notify_notification_values(notifiable_base_t *notifiable); 4.44 + 4.45 +void notify_close(notifier_t *notifier); 4.46 + 4.47 +notifier_t *notify_get_local(void); 4.48 +notifier_t *notify_get_task(void); 4.49 + 4.50 +long notify_subscribe(notifiable_t *notifiable, notify_flags_t flags, notifier_t *notifier); 4.51 +long notify_unsubscribe(notifiable_t *notifiable, notifier_t *notifier); 4.52 + 4.53 +long notify_wait(notifiable_t *notifiable, notifier_t *notifier); 4.54 +long notify_wait_many(notifiable_t **notifiable, notifier_t *notifier); 4.55 + 4.56 +EXTERN_C_END 4.57 + 4.58 +// vim: tabstop=2 expandtab shiftwidth=2
5.1 --- a/libfsclient/include/fsclient/process.h Sat Dec 09 01:26:55 2023 +0100 5.2 +++ b/libfsclient/include/fsclient/process.h Sat Dec 09 01:27:19 2023 +0100 5.3 @@ -28,14 +28,6 @@ 5.4 5.5 5.6 5.7 -/* C compatibility types (defined in the implementation). */ 5.8 - 5.9 -struct process_notifier; 5.10 - 5.11 -typedef struct process_notifier process_notifier_t; 5.12 - 5.13 - 5.14 - 5.15 EXTERN_C_BEGIN 5.16 5.17 /* File access abstraction compatible with notifiable_base_t. */ 5.18 @@ -67,13 +59,9 @@ 5.19 notifiable_t *process_notifiable(process_t *process); 5.20 notify_flags_t process_notifications(process_t *process); 5.21 notify_values_t process_notification_values(process_t *process); 5.22 -void process_notify_close(process_notifier_t *notifier); 5.23 -process_notifier_t *process_notify_local(); 5.24 -process_notifier_t *process_notify_task(); 5.25 -long process_notify_subscribe(process_t *process, notify_flags_t flags, process_notifier_t *notifier); 5.26 -long process_notify_unsubscribe(process_t *process, process_notifier_t *notifier); 5.27 -long process_notify_wait_process(process_t *process, process_notifier_t *notifier); 5.28 -long process_notify_wait_processes(process_t **process, process_notifier_t *notifier); 5.29 + 5.30 +long process_notify_wait_process(process_t *process, notifier_t *notifier); 5.31 +long process_notify_wait_processes(process_t **process, notifier_t *notifier); 5.32 5.33 EXTERN_C_END 5.34
6.1 --- a/libfsclient/lib/src/Makefile Sat Dec 09 01:26:55 2023 +0100 6.2 +++ b/libfsclient/lib/src/Makefile Sat Dec 09 01:27:19 2023 +0100 6.3 @@ -23,7 +23,7 @@ 6.4 6.5 CLIENT_INTERFACES_SRC_CC = $(call interfaces_to_client_cc,$(CLIENT_INTERFACES_CC)) 6.6 6.7 -PLAIN_SRC_CC = client.cc file.cc process.cc 6.8 +PLAIN_SRC_CC = client.cc file.cc notify.cc process.cc 6.9 6.10 # Normal definitions. 6.11
7.1 --- a/libfsclient/lib/src/client.cc Sat Dec 09 01:26:55 2023 +0100 7.2 +++ b/libfsclient/lib/src/client.cc Sat Dec 09 01:27:19 2023 +0100 7.3 @@ -557,23 +557,23 @@ 7.4 7.5 /* Close a notifier object. */ 7.6 7.7 -void client_notifier_close(file_notifier_t *notifier) 7.8 +void client_notifier_close(notifier_t *notifier) 7.9 { 7.10 - file_notify_close(notifier); 7.11 + notify_close(notifier); 7.12 } 7.13 7.14 /* Obtain a local notifier object. */ 7.15 7.16 -file_notifier_t *client_notifier_local() 7.17 +notifier_t *client_notifier_local() 7.18 { 7.19 - return file_notify_local(); 7.20 + return notify_get_local(); 7.21 } 7.22 7.23 /* Obtain a task-wide notifier object. */ 7.24 7.25 -file_notifier_t *client_notifier_task() 7.26 +notifier_t *client_notifier_task() 7.27 { 7.28 - return file_notify_task(); 7.29 + return notify_get_task(); 7.30 } 7.31 7.32 7.33 @@ -766,7 +766,7 @@ 7.34 /* Since blocking access is used with specific file notifications, the 7.35 per-task notifier is used. */ 7.36 7.37 - file_notifier_t *notifier = client_notifier_task(); 7.38 + notifier_t *notifier = client_notifier_task(); 7.39 7.40 if (flags) 7.41 err = client_subscribe(file, flags, notifier); 7.42 @@ -784,12 +784,12 @@ 7.43 7.44 /* Subscribe from events concerning a file. */ 7.45 7.46 -long client_subscribe(file_t *file, notify_flags_t flags, file_notifier_t *notifier) 7.47 +long client_subscribe(file_t *file, notify_flags_t flags, notifier_t *notifier) 7.48 { 7.49 if (!client_opened(file)) 7.50 return -L4_EINVAL; 7.51 7.52 - return file_notify_subscribe(file, flags, notifier); 7.53 + return notify_subscribe(file_notifiable(file), flags, notifier); 7.54 } 7.55 7.56 7.57 @@ -808,19 +808,19 @@ 7.58 7.59 /* Unsubscribe from events concerning a file. */ 7.60 7.61 -long client_unsubscribe(file_t *file, file_notifier_t *notifier) 7.62 +long client_unsubscribe(file_t *file, notifier_t *notifier) 7.63 { 7.64 if (!client_opened(file)) 7.65 return -L4_EINVAL; 7.66 7.67 - return file_notify_unsubscribe(file, notifier); 7.68 + return notify_unsubscribe(file_notifiable(file), notifier); 7.69 } 7.70 7.71 7.72 7.73 /* Wait for events involving a specific file. */ 7.74 7.75 -long client_wait_file(file_t *file, file_notifier_t *notifier) 7.76 +long client_wait_file(file_t *file, notifier_t *notifier) 7.77 { 7.78 if (!client_opened(file)) 7.79 return -L4_EINVAL; 7.80 @@ -831,7 +831,7 @@ 7.81 /* Wait for events concerning files, referencing a file object if an event is 7.82 delivered. */ 7.83 7.84 -long client_wait_files(file_t **file, file_notifier_t *notifier) 7.85 +long client_wait_files(file_t **file, notifier_t *notifier) 7.86 { 7.87 return file_notify_wait_files(file, notifier); 7.88 }
8.1 --- a/libfsclient/lib/src/file.cc Sat Dec 09 01:26:55 2023 +0100 8.2 +++ b/libfsclient/lib/src/file.cc Sat Dec 09 01:27:19 2023 +0100 8.3 @@ -611,96 +611,47 @@ 8.4 8.5 8.6 8.7 -/* Opaque notifier type for file_notifier_t. */ 8.8 - 8.9 -struct file_notifier 8.10 -{ 8.11 - ObjectNotifier *obj; 8.12 -}; 8.13 - 8.14 /* Conversion to the generic notification types. */ 8.15 8.16 notifiable_t *file_notifiable(file_t *file) 8.17 { 8.18 - return &file->notifiable; 8.19 + return notify_notifiable((notifiable_base_t *) file); 8.20 } 8.21 8.22 /* Return the notification flags for a file. */ 8.23 8.24 notify_flags_t file_notifications(file_t *file) 8.25 { 8.26 - return file->notifiable.notifications; 8.27 -} 8.28 - 8.29 -/* Close a notifier object. */ 8.30 - 8.31 -void file_notify_close(file_notifier_t *notifier) 8.32 -{ 8.33 - delete notifier->obj; 8.34 - delete notifier; 8.35 -} 8.36 - 8.37 -/* Obtain a local notifier object. */ 8.38 - 8.39 -file_notifier_t *file_notify_local() 8.40 -{ 8.41 - file_notifier_t *notifier = new file_notifier_t; 8.42 - 8.43 - notifier->obj = notifier_get_local_notifier(); 8.44 - return notifier; 8.45 -} 8.46 - 8.47 -/* Obtain the task-wide notifier object. */ 8.48 - 8.49 -file_notifier_t *file_notify_task() 8.50 -{ 8.51 - file_notifier_t *notifier = new file_notifier_t; 8.52 - 8.53 - notifier->obj = notifier_get_task_notifier(); 8.54 - return notifier; 8.55 -} 8.56 - 8.57 -/* Subscribe to notification events on a file. */ 8.58 - 8.59 -long file_notify_subscribe(file_t *file, notify_flags_t flags, file_notifier_t *notifier) 8.60 -{ 8.61 - return notifier->obj->subscribe(file_notifiable(file), flags); 8.62 -} 8.63 - 8.64 -/* Unsubscribe from notification events on a file. */ 8.65 - 8.66 -long file_notify_unsubscribe(file_t *file, file_notifier_t *notifier) 8.67 -{ 8.68 - return notifier->obj->unsubscribe(file_notifiable(file)); 8.69 + return notify_notifications((notifiable_base_t *) file); 8.70 } 8.71 8.72 /* Wait for a notification event on a file. */ 8.73 8.74 -long file_notify_wait_file(file_t *file, file_notifier_t *notifier) 8.75 +long file_notify_wait_file(file_t *file, notifier_t *notifier) 8.76 { 8.77 - long err = notifier->obj->wait_object(file_notifiable(file)); 8.78 + long err = notify_wait(file_notifiable(file), notifier); 8.79 8.80 /* Unsubscribe if a closure notification has been received. */ 8.81 8.82 - if (!err && (file->notifiable.notifications & NOTIFY_PEER_CLOSED)) 8.83 - file_notify_unsubscribe(file, notifier); 8.84 + if (!err && (file_notifications(file) & NOTIFY_PEER_CLOSED)) 8.85 + notify_unsubscribe(file_notifiable(file), notifier); 8.86 8.87 return err; 8.88 } 8.89 8.90 /* Wait for notification events on files. */ 8.91 8.92 -long file_notify_wait_files(file_t **file, file_notifier_t *notifier) 8.93 +long file_notify_wait_files(file_t **file, notifier_t *notifier) 8.94 { 8.95 notifiable_t *notifiable; 8.96 - long err = notifier->obj->wait(¬ifiable); 8.97 + long err = notify_wait_many(¬ifiable, notifier); 8.98 8.99 *file = (file_t *) notifiable->base; 8.100 8.101 /* Unsubscribe if a closure notification has been received. */ 8.102 8.103 - if (!err && ((*file)->notifiable.notifications & NOTIFY_PEER_CLOSED)) 8.104 - file_notify_unsubscribe(*file, notifier); 8.105 + if (!err && (notifiable->notifications & NOTIFY_PEER_CLOSED)) 8.106 + notify_unsubscribe(notifiable, notifier); 8.107 8.108 return err; 8.109 }
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/libfsclient/lib/src/notify.cc Sat Dec 09 01:27:19 2023 +0100 9.3 @@ -0,0 +1,112 @@ 9.4 +/* 9.5 + * Notification-related functions. 9.6 + * 9.7 + * Copyright (C) 2023 Paul Boddie <paul@boddie.org.uk> 9.8 + * 9.9 + * This program is free software; you can redistribute it and/or 9.10 + * modify it under the terms of the GNU General Public License as 9.11 + * published by the Free Software Foundation; either version 2 of 9.12 + * the License, or (at your option) any later version. 9.13 + * 9.14 + * This program is distributed in the hope that it will be useful, 9.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 9.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 9.17 + * GNU General Public License for more details. 9.18 + * 9.19 + * You should have received a copy of the GNU General Public License 9.20 + * along with this program; if not, write to the Free Software 9.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 9.22 + * Boston, MA 02110-1301, USA 9.23 + */ 9.24 + 9.25 +#include <notifier/notifier.h> 9.26 + 9.27 +#include "notify.h" 9.28 + 9.29 + 9.30 + 9.31 +/* Opaque notifier type for notifier_t. */ 9.32 + 9.33 +struct notifier 9.34 +{ 9.35 + ObjectNotifier *obj; 9.36 +}; 9.37 + 9.38 +/* Return the notifiable details from a compatible object. */ 9.39 + 9.40 +notifiable_t *notify_notifiable(notifiable_base_t *notifiable) 9.41 +{ 9.42 + return ¬ifiable->notifiable; 9.43 +} 9.44 + 9.45 +/* Return the notification flags for an object. */ 9.46 + 9.47 +notify_flags_t notify_notifications(notifiable_base_t *notifiable) 9.48 +{ 9.49 + return notifiable->notifiable.notifications; 9.50 +} 9.51 + 9.52 +/* Return the notification values for an object. */ 9.53 + 9.54 +notify_values_t notify_notification_values(notifiable_base_t *notifiable) 9.55 +{ 9.56 + return notifiable->notifiable.values; 9.57 +} 9.58 + 9.59 +/* Close a notifier object. */ 9.60 + 9.61 +void notify_close(notifier_t *notifier) 9.62 +{ 9.63 + delete notifier->obj; 9.64 + delete notifier; 9.65 +} 9.66 + 9.67 +/* Obtain a local notifier object. */ 9.68 + 9.69 +notifier_t *notify_get_local() 9.70 +{ 9.71 + notifier_t *notifier = new notifier_t; 9.72 + 9.73 + notifier->obj = notifier_get_local_notifier(); 9.74 + return notifier; 9.75 +} 9.76 + 9.77 +/* Obtain the task-wide notifier object. */ 9.78 + 9.79 +notifier_t *notify_get_task() 9.80 +{ 9.81 + notifier_t *notifier = new notifier_t; 9.82 + 9.83 + notifier->obj = notifier_get_task_notifier(); 9.84 + return notifier; 9.85 +} 9.86 + 9.87 +/* Subscribe to notification events. */ 9.88 + 9.89 +long notify_subscribe(notifiable_t *notifiable, notify_flags_t flags, notifier_t *notifier) 9.90 +{ 9.91 + return notifier->obj->subscribe(notifiable, flags); 9.92 +} 9.93 + 9.94 +/* Unsubscribe from notification events. */ 9.95 + 9.96 +long notify_unsubscribe(notifiable_t *notifiable, notifier_t *notifier) 9.97 +{ 9.98 + return notifier->obj->unsubscribe(notifiable); 9.99 +} 9.100 + 9.101 +/* Wait for a notification event on a single object. */ 9.102 + 9.103 +long notify_wait(notifiable_t *notifiable, notifier_t *notifier) 9.104 +{ 9.105 + return notifier->obj->wait_object(notifiable); 9.106 +} 9.107 + 9.108 +/* Wait for notification events on multiple objects. */ 9.109 + 9.110 +long notify_wait_many(notifiable_t **notifiable, notifier_t *notifier) 9.111 +{ 9.112 + return notifier->obj->wait(notifiable); 9.113 +} 9.114 + 9.115 +// vim: tabstop=2 expandtab shiftwidth=2
10.1 --- a/libfsclient/lib/src/process.cc Sat Dec 09 01:26:55 2023 +0100 10.2 +++ b/libfsclient/lib/src/process.cc Sat Dec 09 01:27:19 2023 +0100 10.3 @@ -36,11 +36,11 @@ 10.4 10.5 /* Utility functions. */ 10.6 10.7 -static bool _process_terminated(process_t *process) 10.8 +static bool _process_terminated(notifiable_t *notifiable) 10.9 { 10.10 - return ((process->notifiable.notifications & NOTIFY_TASK_SIGNAL) && 10.11 - (process->notifiable.values.sig == 0)) || 10.12 - (process->notifiable.notifications & NOTIFY_TASK_ERROR); 10.13 + return ((notifiable->notifications & NOTIFY_TASK_SIGNAL) && 10.14 + (notifiable->values.sig == 0)) || 10.15 + (notifiable->notifications & NOTIFY_TASK_ERROR); 10.16 } 10.17 10.18 10.19 @@ -146,106 +146,54 @@ 10.20 10.21 10.22 10.23 -/* NOTE: Much of the code below could be unified with the file-related 10.24 - notification code. */ 10.25 - 10.26 -/* Opaque notifier type for process_notifier_t. */ 10.27 - 10.28 -struct process_notifier 10.29 -{ 10.30 - ObjectNotifier *obj; 10.31 -}; 10.32 - 10.33 /* Conversion to the generic notification types. */ 10.34 10.35 notifiable_t *process_notifiable(process_t *process) 10.36 { 10.37 - return &process->notifiable; 10.38 + return notify_notifiable((notifiable_base_t *) process); 10.39 } 10.40 10.41 /* Return the notification flags for a process. */ 10.42 10.43 notify_flags_t process_notifications(process_t *process) 10.44 { 10.45 - return process->notifiable.notifications; 10.46 + return notify_notifications((notifiable_base_t *) process); 10.47 } 10.48 10.49 /* Return the notification values for a process. */ 10.50 10.51 notify_values_t process_notification_values(process_t *process) 10.52 { 10.53 - return process->notifiable.values; 10.54 -} 10.55 - 10.56 -/* Close a notifier object. */ 10.57 - 10.58 -void process_notify_close(process_notifier_t *notifier) 10.59 -{ 10.60 - delete notifier->obj; 10.61 - delete notifier; 10.62 -} 10.63 - 10.64 -/* Obtain a local notifier object. */ 10.65 - 10.66 -process_notifier_t *process_notify_local() 10.67 -{ 10.68 - process_notifier_t *notifier = new process_notifier_t; 10.69 - 10.70 - notifier->obj = notifier_get_local_notifier(); 10.71 - return notifier; 10.72 -} 10.73 - 10.74 -/* Obtain the task-wide notifier object. */ 10.75 - 10.76 -process_notifier_t *process_notify_task() 10.77 -{ 10.78 - process_notifier_t *notifier = new process_notifier_t; 10.79 - 10.80 - notifier->obj = notifier_get_task_notifier(); 10.81 - return notifier; 10.82 -} 10.83 - 10.84 -/* Subscribe to notification events on a process. */ 10.85 - 10.86 -long process_notify_subscribe(process_t *process, notify_flags_t flags, process_notifier_t *notifier) 10.87 -{ 10.88 - return notifier->obj->subscribe(process_notifiable(process), flags); 10.89 -} 10.90 - 10.91 -/* Unsubscribe from notification events on a process. */ 10.92 - 10.93 -long process_notify_unsubscribe(process_t *process, process_notifier_t *notifier) 10.94 -{ 10.95 - return notifier->obj->unsubscribe(process_notifiable(process)); 10.96 + return notify_notification_values((notifiable_base_t *) process); 10.97 } 10.98 10.99 /* Wait for a notification event on a process. */ 10.100 10.101 -long process_notify_wait_process(process_t *process, process_notifier_t *notifier) 10.102 +long process_notify_wait_process(process_t *process, notifier_t *notifier) 10.103 { 10.104 - long err = notifier->obj->wait_object(process_notifiable(process)); 10.105 + long err = notify_wait(process_notifiable(process), notifier); 10.106 10.107 /* Unsubscribe if a termination notification has been received. */ 10.108 10.109 - if (!err && _process_terminated(process)) 10.110 - process_notify_unsubscribe(process, notifier); 10.111 + if (!err && _process_terminated(process_notifiable(process))) 10.112 + notify_unsubscribe(process_notifiable(process), notifier); 10.113 10.114 return err; 10.115 } 10.116 10.117 /* Wait for notification events on processes. */ 10.118 10.119 -long process_notify_wait_processes(process_t **process, process_notifier_t *notifier) 10.120 +long process_notify_wait_processes(process_t **process, notifier_t *notifier) 10.121 { 10.122 notifiable_t *notifiable; 10.123 - long err = notifier->obj->wait(¬ifiable); 10.124 + long err = notify_wait_many(¬ifiable, notifier); 10.125 10.126 *process = (process_t *) notifiable->base; 10.127 10.128 /* Unsubscribe if a termination notification has been received. */ 10.129 10.130 - if (!err && _process_terminated(*process)) 10.131 - process_notify_unsubscribe(*process, notifier); 10.132 + if (!err && _process_terminated(notifiable)) 10.133 + notify_unsubscribe(notifiable, notifier); 10.134 10.135 return err; 10.136 }
11.1 --- a/libsystypes/include/systypes/base.h Sat Dec 09 01:26:55 2023 +0100 11.2 +++ b/libsystypes/include/systypes/base.h Sat Dec 09 01:27:19 2023 +0100 11.3 @@ -73,13 +73,13 @@ 11.4 11.5 /* Notifiable object types. */ 11.6 11.7 -typedef struct 11.8 -{ 11.9 - l4_cap_idx_t ref; 11.10 +/* Forward reference. */ 11.11 + 11.12 +typedef struct notifiable_base notifiable_base_t; 11.13 11.14 -} notifiable_base_t; 11.15 +/* Structure maintaining notification state for a specific object. */ 11.16 11.17 -typedef struct 11.18 +typedef struct notifiable 11.19 { 11.20 notifiable_base_t *base; /* access to the specific object */ 11.21 notify_flags_t notifications; /* essential notifications */ 11.22 @@ -90,6 +90,16 @@ 11.23 11.24 } notifiable_t; 11.25 11.26 +/* A base structure extended by notifiable object structures like files and 11.27 + processes. */ 11.28 + 11.29 +typedef struct notifiable_base 11.30 +{ 11.31 + l4_cap_idx_t ref; 11.32 + notifiable_t notifiable; 11.33 + 11.34 +} notifiable_base_t; 11.35 + 11.36 /* Filesystem object properties. */ 11.37 11.38 typedef unsigned long object_flags_t;
12.1 --- a/tests/dstest_exec.cc Sat Dec 09 01:26:55 2023 +0100 12.2 +++ b/tests/dstest_exec.cc Sat Dec 09 01:27:19 2023 +0100 12.3 @@ -32,7 +32,7 @@ 12.4 { 12.5 /* Obtain the common notifier. */ 12.6 12.7 - process_notifier_t *notifier = process_notify_task(); 12.8 + notifier_t *notifier = notify_get_task(); 12.9 12.10 /* Create a new process structure. */ 12.11 12.12 @@ -54,7 +54,7 @@ 12.13 12.14 /* Subscribe to the process for notifications. */ 12.15 12.16 - err = process_notify_subscribe(&process, NOTIFY_TASK_ALL, notifier); 12.17 + err = notify_subscribe(process_notifiable(&process), NOTIFY_TASK_ALL, notifier); 12.18 12.19 if (err) 12.20 { 12.21 @@ -96,7 +96,7 @@ 12.22 12.23 /* Obtain the common notifier. */ 12.24 12.25 - process_notifier_t *notifier = process_notify_task(); 12.26 + notifier_t *notifier = notify_get_task(); 12.27 12.28 /* Start a process for a non-existent program. */ 12.29 12.30 @@ -123,7 +123,7 @@ 12.31 if (err) 12.32 return 1; 12.33 12.34 - process_notify_close(notifier); 12.35 + notify_close(notifier); 12.36 12.37 printf("End of test.\n"); 12.38 return 0;
13.1 --- a/tests/dstest_exec_many.cc Sat Dec 09 01:26:55 2023 +0100 13.2 +++ b/tests/dstest_exec_many.cc Sat Dec 09 01:27:19 2023 +0100 13.3 @@ -43,7 +43,7 @@ 13.4 13.5 /* Obtain the common notifier. */ 13.6 13.7 - process_notifier_t *notifier = process_notify_task(); 13.8 + notifier_t *notifier = notify_get_task(); 13.9 13.10 /* Create a new process structure. */ 13.11 13.12 @@ -69,7 +69,7 @@ 13.13 13.14 /* Subscribe to the process for notifications. */ 13.15 13.16 - err = process_notify_subscribe(&process, NOTIFY_TASK_ALL, notifier); 13.17 + err = notify_subscribe(process_notifiable(&process), NOTIFY_TASK_ALL, notifier); 13.18 13.19 if (err) 13.20 { 13.21 @@ -95,7 +95,7 @@ 13.22 process_close(&process); 13.23 } 13.24 13.25 - process_notify_close(notifier); 13.26 + notify_close(notifier); 13.27 13.28 printf("End of test.\n"); 13.29 return 0;
14.1 --- a/tests/dstest_pipe_client.cc Sat Dec 09 01:26:55 2023 +0100 14.2 +++ b/tests/dstest_pipe_client.cc Sat Dec 09 01:27:19 2023 +0100 14.3 @@ -89,7 +89,7 @@ 14.4 14.5 /* Use a local notifier to wait for pipe events. */ 14.6 14.7 - file_notifier_t *notifier = client_notifier_local(); 14.8 + notifier_t *notifier = client_notifier_local(); 14.9 14.10 /* Register the readers for notification. */ 14.11