I found this in Hackers Delight, you would need to change it for long long though.

Code:
((x) >> 30) | 1) * x
You could also #define that as a macro.