diff options
Diffstat (limited to 'kernel/bpf/tnum.c')
-rw-r--r-- | kernel/bpf/tnum.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/kernel/bpf/tnum.c b/kernel/bpf/tnum.c index 1f4bf68c12db..938d41211be7 100644 --- a/kernel/bpf/tnum.c +++ b/kernel/bpf/tnum.c | |||
@@ -43,6 +43,16 @@ struct tnum tnum_rshift(struct tnum a, u8 shift) | |||
43 | return TNUM(a.value >> shift, a.mask >> shift); | 43 | return TNUM(a.value >> shift, a.mask >> shift); |
44 | } | 44 | } |
45 | 45 | ||
46 | struct tnum tnum_arshift(struct tnum a, u8 min_shift) | ||
47 | { | ||
48 | /* if a.value is negative, arithmetic shifting by minimum shift | ||
49 | * will have larger negative offset compared to more shifting. | ||
50 | * If a.value is nonnegative, arithmetic shifting by minimum shift | ||
51 | * will have larger positive offset compare to more shifting. | ||
52 | */ | ||
53 | return TNUM((s64)a.value >> min_shift, (s64)a.mask >> min_shift); | ||
54 | } | ||
55 | |||
46 | struct tnum tnum_add(struct tnum a, struct tnum b) | 56 | struct tnum tnum_add(struct tnum a, struct tnum b) |
47 | { | 57 | { |
48 | u64 sm, sv, sigma, chi, mu; | 58 | u64 sm, sv, sigma, chi, mu; |