mbox series

[0/6] Continued work on xdrgen

Message ID 20240930005016.13374-1-cel@kernel.org (mailing list archive)
Headers show
Series Continued work on xdrgen | expand

Message

Chuck Lever Sept. 30, 2024, 12:50 a.m. UTC
From: Chuck Lever <chuck.lever@oracle.com>

This series (intended for v6.13) contains some clean-ups and new
features for the xdrgen tool.

The "Exit status should be zero ..." patch is needed so that "make"
co-operates properly with xdrgen. I've prototyped some Makefile
stanzas that can generate encoder and decoder functions to ensure
this is working correctly (to appear in a later series).

"enum" types are now generated as C typedefs, without the "enum"
classifier. This is to enable the same type name to be used to
represent either an enum (CPU-endian) or a __be32 (network-endian).

So, instead of generating, say, "enum nfsstat3 {};" xdrgen now
generates "nfsstat3" which can be either an enum or a __be32,
depending on a new pragma directive. The goal is to handle the
special case where the upper layer prefers to use __be32
discriminant values for XDR union types.

Comments are welcome.


Chuck Lever (6):
  xdrgen: Exit status should be zero on success
  xdrgen: Clean up type_specifier
  xdrgen: Rename "variable-length strings"
  xdrgen: Rename enum's declaration Jinja2 template
  xdrgen: Rename "enum yada" types as just "yada"
  xdrgen: Implement big-endian enums

 include/linux/sunrpc/xdr.h                    | 21 ++++++++++++
 tools/net/sunrpc/xdrgen/README                | 17 ++++++++++
 tools/net/sunrpc/xdrgen/generators/enum.py    | 19 ++++++++---
 tools/net/sunrpc/xdrgen/generators/pointer.py |  8 ++---
 tools/net/sunrpc/xdrgen/generators/struct.py  |  8 ++---
 tools/net/sunrpc/xdrgen/generators/typedef.py | 10 +++---
 tools/net/sunrpc/xdrgen/generators/union.py   | 34 ++++++++++++++-----
 tools/net/sunrpc/xdrgen/grammars/xdr.lark     |  6 ++--
 .../templates/C/enum/declaration/close.j2     |  4 ---
 .../templates/C/enum/declaration/enum.j2      |  4 +++
 .../xdrgen/templates/C/enum/decoder/enum.j2   |  2 +-
 .../{encoder/enum.j2 => decoder/enum_be.j2}   |  6 ++--
 .../templates/C/enum/definition/close.j2      |  1 +
 .../enum/definition/{close.j2 => close_be.j2} |  1 +
 .../xdrgen/templates/C/enum/encoder/enum.j2   |  2 +-
 .../C/enum/encoder/{enum.j2 => enum_be.j2}    |  6 ++--
 .../{variable_length_string.j2 => string.j2}  |  0
 .../{variable_length_string.j2 => string.j2}  |  0
 .../{variable_length_string.j2 => string.j2}  |  0
 .../{variable_length_string.j2 => string.j2}  |  0
 .../{variable_length_string.j2 => string.j2}  |  0
 .../{variable_length_string.j2 => string.j2}  |  0
 .../{variable_length_string.j2 => string.j2}  |  0
 .../{variable_length_string.j2 => string.j2}  |  0
 .../{variable_length_string.j2 => string.j2}  |  0
 .../{variable_length_string.j2 => string.j2}  |  0
 .../templates/C/union/decoder/case_spec_be.j2 |  2 ++
 .../{variable_length_string.j2 => string.j2}  |  0
 .../templates/C/union/encoder/case_spec_be.j2 |  2 ++
 tools/net/sunrpc/xdrgen/xdr_ast.py            | 21 ++++++------
 tools/net/sunrpc/xdrgen/xdrgen                |  4 ++-
 31 files changed, 125 insertions(+), 53 deletions(-)
 delete mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/declaration/close.j2
 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/declaration/enum.j2
 copy tools/net/sunrpc/xdrgen/templates/C/enum/{encoder/enum.j2 => decoder/enum_be.j2} (51%)
 copy tools/net/sunrpc/xdrgen/templates/C/enum/definition/{close.j2 => close_be.j2} (60%)
 copy tools/net/sunrpc/xdrgen/templates/C/enum/encoder/{enum.j2 => enum_be.j2} (50%)
 rename tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/{variable_length_string.j2 => string.j2} (100%)
 rename tools/net/sunrpc/xdrgen/templates/C/pointer/definition/{variable_length_string.j2 => string.j2} (100%)
 rename tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/{variable_length_string.j2 => string.j2} (100%)
 rename tools/net/sunrpc/xdrgen/templates/C/struct/decoder/{variable_length_string.j2 => string.j2} (100%)
 rename tools/net/sunrpc/xdrgen/templates/C/struct/definition/{variable_length_string.j2 => string.j2} (100%)
 rename tools/net/sunrpc/xdrgen/templates/C/struct/encoder/{variable_length_string.j2 => string.j2} (100%)
 rename tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/{variable_length_string.j2 => string.j2} (100%)
 rename tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/{variable_length_string.j2 => string.j2} (100%)
 rename tools/net/sunrpc/xdrgen/templates/C/typedef/definition/{variable_length_string.j2 => string.j2} (100%)
 rename tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/{variable_length_string.j2 => string.j2} (100%)
 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/case_spec_be.j2
 rename tools/net/sunrpc/xdrgen/templates/C/union/decoder/{variable_length_string.j2 => string.j2} (100%)
 create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/case_spec_be.j2