Commit 48e203e2 authored by Martin Kepplinger's avatar Martin Kepplinger Committed by Linus Torvalds

bitops.h: add sign_extend64()

Months back, this was discussed, see
The result was the 64-bit version being "likely fine", "valuable" and
"correct".  The discussion fell asleep but since there are possible users,
let's add it.
Signed-off-by: default avatarMartin Kepplinger <>
Cc: Peter Zijlstra <>
Cc: Ingo Molnar <>
Cc: Arnaldo Carvalho de Melo <>
Cc: Thomas Gleixner <>
Cc: "H. Peter Anvin" <>
Cc: George Spelvin <>
Cc: Rasmus Villemoes <>
Cc: Maxime Coquelin <>
Cc: Denys Vlasenko <>
Cc: Yury Norov <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent e2eb53aa
......@@ -173,6 +173,17 @@ static inline __s32 sign_extend32(__u32 value, int index)
return (__s32)(value << shift) >> shift;
* 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 inline __s64 sign_extend64(__u64 value, int index)
__u8 shift = 63 - index;
return (__s64)(value << shift) >> shift;
static inline unsigned fls_long(unsigned long l)
if (sizeof(l) == 4)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment