Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

xdrgen: Implement short (16-bit) integer types

"short" and "unsigned short" types are not defined in RFC 4506, but
are supported by the rpcgen program. An upcoming protocol
specification includes at least one "unsigned short" field, so xdrgen
needs to implement support for these types.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

+70
+60
include/linux/sunrpc/xdrgen/_builtins.h
··· 46 46 return true; 47 47 } 48 48 49 + /* 50 + * De facto (non-standard but commonly implemented) signed short type: 51 + * - Wire sends sign-extended 32-bit value (e.g., 0xFFFFFFFF) 52 + * - be32_to_cpup() returns u32 (0xFFFFFFFF) 53 + * - Explicit (s16) cast truncates to 16 bits (0xFFFF = -1) 54 + */ 55 + static inline bool 56 + xdrgen_decode_short(struct xdr_stream *xdr, s16 *ptr) 57 + { 58 + __be32 *p = xdr_inline_decode(xdr, XDR_UNIT); 59 + 60 + if (unlikely(!p)) 61 + return false; 62 + *ptr = (s16)be32_to_cpup(p); 63 + return true; 64 + } 65 + 66 + /* 67 + * De facto (non-standard but commonly implemented) signed short type: 68 + * - C integer promotion sign-extends s16 val to int before passing to 69 + * cpu_to_be32() 70 + * - This is well-defined: -1 as s16 -1 as int 0xFFFFFFFF on wire 71 + */ 72 + static inline bool 73 + xdrgen_encode_short(struct xdr_stream *xdr, s16 val) 74 + { 75 + __be32 *p = xdr_reserve_space(xdr, XDR_UNIT); 76 + 77 + if (unlikely(!p)) 78 + return false; 79 + *p = cpu_to_be32(val); 80 + return true; 81 + } 82 + 83 + /* 84 + * De facto (non-standard but commonly implemented) unsigned short type: 85 + * 16-bit integer zero-extended to fill one XDR_UNIT. 86 + */ 87 + static inline bool 88 + xdrgen_decode_unsigned_short(struct xdr_stream *xdr, u16 *ptr) 89 + { 90 + __be32 *p = xdr_inline_decode(xdr, XDR_UNIT); 91 + 92 + if (unlikely(!p)) 93 + return false; 94 + *ptr = (u16)be32_to_cpup(p); 95 + return true; 96 + } 97 + 98 + static inline bool 99 + xdrgen_encode_unsigned_short(struct xdr_stream *xdr, u16 val) 100 + { 101 + __be32 *p = xdr_reserve_space(xdr, XDR_UNIT); 102 + 103 + if (unlikely(!p)) 104 + return false; 105 + *p = cpu_to_be32(val); 106 + return true; 107 + } 108 + 49 109 static inline bool 50 110 xdrgen_decode_int(struct xdr_stream *xdr, s32 *ptr) 51 111 {
+2
tools/net/sunrpc/xdrgen/generators/__init__.py
··· 59 59 """Return name of C type""" 60 60 builtin_native_c_type = { 61 61 "bool": "bool", 62 + "short": "s16", 63 + "unsigned_short": "u16", 62 64 "int": "s32", 63 65 "unsigned_int": "u32", 64 66 "long": "s32",
+4
tools/net/sunrpc/xdrgen/grammars/xdr.lark
··· 20 20 type_specifier : unsigned_hyper 21 21 | unsigned_long 22 22 | unsigned_int 23 + | unsigned_short 23 24 | hyper 24 25 | long 25 26 | int 27 + | short 26 28 | float 27 29 | double 28 30 | quadruple ··· 37 35 unsigned_hyper : "unsigned" "hyper" 38 36 unsigned_long : "unsigned" "long" 39 37 unsigned_int : "unsigned" "int" 38 + unsigned_short : "unsigned" "short" 40 39 hyper : "hyper" 41 40 long : "long" 42 41 int : "int" 42 + short : "short" 43 43 float : "float" 44 44 double : "double" 45 45 quadruple : "quadruple"
+4
tools/net/sunrpc/xdrgen/xdr_ast.py
··· 34 34 symbolic_widths = { 35 35 "void": ["XDR_void"], 36 36 "bool": ["XDR_bool"], 37 + "short": ["XDR_short"], 38 + "unsigned_short": ["XDR_unsigned_short"], 37 39 "int": ["XDR_int"], 38 40 "unsigned_int": ["XDR_unsigned_int"], 39 41 "long": ["XDR_long"], ··· 50 48 max_widths = { 51 49 "void": 0, 52 50 "bool": 1, 51 + "short": 1, 52 + "unsigned_short": 1, 53 53 "int": 1, 54 54 "unsigned_int": 1, 55 55 "long": 1,