hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/kernel/bpf/tnum.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /* tnum: tracked (or tristate) numbers
23 *
34 * A tnum tracks knowledge about the bits of a value. Each bit can be either
....@@ -193,3 +194,18 @@
193194 str[min(size - 1, (size_t)64)] = 0;
194195 return 64;
195196 }
197
+
198
+struct tnum tnum_subreg(struct tnum a)
199
+{
200
+ return tnum_cast(a, 4);
201
+}
202
+
203
+struct tnum tnum_clear_subreg(struct tnum a)
204
+{
205
+ return tnum_lshift(tnum_rshift(a, 32), 32);
206
+}
207
+
208
+struct tnum tnum_const_subreg(struct tnum a, u32 value)
209
+{
210
+ return tnum_or(tnum_clear_subreg(a), tnum_const(value));
211
+}