diff options
| author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-01-31 21:16:22 -0800 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2011-01-31 21:16:22 -0800 |
| commit | a1f3d4bba8ea395a39d34ade6017afee8be16031 (patch) | |
| tree | 874d843d35622f17aa6c3e048e42cf0d679bcb75 /include/linux/bitops.h | |
| parent | 723d928417bffff6467da155d8ebbbe016464012 (diff) | |
| parent | ebf53826e105f488f4f628703a108e98940d1dc5 (diff) | |
Merge commit 'v2.6.38-rc3' into next
Diffstat (limited to 'include/linux/bitops.h')
| -rw-r--r-- | include/linux/bitops.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 827cc95711ef..2184c6b97aeb 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -109,6 +109,17 @@ static inline __u8 ror8(__u8 word, unsigned int shift) return (word >> shift) | (word << (8 - shift)); } +/** + * sign_extend32 - sign extend a 32-bit value using specified bit as sign-bit + * @value: value to sign extend + * @index: 0 based bit index (0<=index<32) to sign bit + */ +static inline __s32 sign_extend32(__u32 value, int index) +{ + __u8 shift = 31 - index; + return (__s32)(value << shift) >> shift; +} + static inline unsigned fls_long(unsigned long l) { if (sizeof(l) == 4) |
