From 69b1ac09c26238cfdf615d1689413b7e22ad254b Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Tue, 19 Sep 2023 20:14:20 +0300 Subject: [PATCH] syscalls: support identifiers lookup --- src/openpower/syscalls/__init__.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/openpower/syscalls/__init__.py b/src/openpower/syscalls/__init__.py index 9f3e8474..053e45f3 100644 --- a/src/openpower/syscalls/__init__.py +++ b/src/openpower/syscalls/__init__.py @@ -54,6 +54,15 @@ class Dispatcher: return super().__init__() + def __getitem__(self, identifier): + if not isinstance(identifier, int): + raise ValueError(identifier) + + identifier = str(identifier) + entry = self.__guest[identifier][1][0] + + return getattr(self, entry) + def __getattr__(self, entry): if entry.startswith("compat_sys_"): identifier = entry[len("compat_sys_"):] @@ -98,11 +107,6 @@ class Dispatcher: return syscall def __call__(self, identifier, *arguments): - if not isinstance(identifier, int): - raise ValueError(identifier) - - identifier = str(identifier) - entry = self.__guest[identifier][1][0] - syscall = getattr(self, entry) + syscall = self[identifier] return syscall(*arguments) -- 2.30.2