summaryrefslogtreecommitdiffstats
path: root/tools/net
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2024-10-03 20:54:41 +0200
committerChuck Lever <chuck.lever@oracle.com>2024-11-11 19:42:04 +0100
commit2852c92ba1305fd2d85fd69f73bb4b43a3c58146 (patch)
tree292eaf513779cfb52cfa0bc537a948faf7e47654 /tools/net
parentxdrgen: XDR width for optional_data type (diff)
downloadlinux-2852c92ba1305fd2d85fd69f73bb4b43a3c58146.tar.xz
linux-2852c92ba1305fd2d85fd69f73bb4b43a3c58146.zip
xdrgen: XDR width for typedef
The XDR width of a typedef is the same as the width of the base type. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'tools/net')
-rw-r--r--tools/net/sunrpc/xdrgen/xdr_ast.py34
1 files changed, 27 insertions, 7 deletions
diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py
index f2ef78654e36..8996f26cbd55 100644
--- a/tools/net/sunrpc/xdrgen/xdr_ast.py
+++ b/tools/net/sunrpc/xdrgen/xdr_ast.py
@@ -268,6 +268,18 @@ class _XdrBasic(_XdrDeclaration):
spec: _XdrTypeSpecifier
template: str = "basic"
+ def max_width(self) -> int:
+ """Return width of type in XDR_UNITS"""
+ return max_widths[self.spec.type_name]
+
+ def symbolic_width(self) -> List:
+ """Return list containing XDR width of type's components"""
+ return symbolic_widths[self.spec.type_name]
+
+ def __post_init__(self):
+ max_widths[self.name] = self.max_width()
+ symbolic_widths[self.name] = self.symbolic_width()
+
@dataclass
class _XdrVoid(_XdrDeclaration):
@@ -361,14 +373,22 @@ class _XdrTypedef(_XdrAst):
declaration: _XdrDeclaration
- def __post_init__(self):
- if not isinstance(self.declaration, _XdrBasic):
- return
+ def max_width(self) -> int:
+ """Return width of type in XDR_UNITS"""
+ return self.declaration.max_width()
- new_type = self.declaration
- if isinstance(new_type.spec, _XdrDefinedType):
- if new_type.spec.type_name in pass_by_reference:
- pass_by_reference.add(new_type.name)
+ def symbolic_width(self) -> List:
+ """Return list containing XDR width of type's components"""
+ return self.declaration.symbolic_width()
+
+ def __post_init__(self):
+ if isinstance(self.declaration, _XdrBasic):
+ new_type = self.declaration
+ if isinstance(new_type.spec, _XdrDefinedType):
+ if new_type.spec.type_name in pass_by_reference:
+ pass_by_reference.add(new_type.name)
+ max_widths[new_type.name] = self.max_width()
+ symbolic_widths[new_type.name] = self.symbolic_width()
@dataclass