summaryrefslogtreecommitdiff
path: root/tools/include/linux
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2024-03-28 17:24:10 -0700
committerJakub Kicinski <kuba@kernel.org>2024-03-28 17:25:57 -0700
commit5e47fbe5cefe5d25d1fa4481c1b9fbe602b4a69f (patch)
treeb86edc39098cca1d0e53e46dceec6ca856183642 /tools/include/linux
parent2a702c2e57908e7bb5c814afeac577a14815c2f2 (diff)
parent50108c352db70405b3d71d8099d0b3adc3b3352c (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Cross-merge networking fixes after downstream PR. No conflicts, or adjacent changes. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/include/linux')
-rw-r--r--tools/include/linux/bitops.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/include/linux/bitops.h b/tools/include/linux/bitops.h
index f18683b95ea6..7319f6ced108 100644
--- a/tools/include/linux/bitops.h
+++ b/tools/include/linux/bitops.h
@@ -87,4 +87,15 @@ static inline __u32 rol32(__u32 word, unsigned int shift)
return (word << shift) | (word >> ((-shift) & 31));
}
+/**
+ * sign_extend64 - sign extend a 64-bit value using specified bit as sign-bit
+ * @value: value to sign extend
+ * @index: 0 based bit index (0<=index<64) to sign bit
+ */
+static __always_inline __s64 sign_extend64(__u64 value, int index)
+{
+ __u8 shift = 63 - index;
+ return (__s64)(value << shift) >> shift;
+}
+
#endif