]> git.karo-electronics.de Git - linux-beck.git/blobdiff - include/linux/bitops.h
bitops.h: add sign_extend64()
[linux-beck.git] / include / linux / bitops.h
index 5629923a87015dc95ef1c41fa00facd9d20ce8fc..2b8ed123ad36b26bc26956293452937d3ac1b90e 100644 (file)
@@ -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)