include/intrin: Implement `_rot{l,r}{8,16}` functions

They are declared in 'intrin.h' but were not defined anywhere.

The implementations might be imperfect: If the second argument is <= zero
or is >= the width of the first parameter, one of the shift counts will be
out of range and cause undefined behavior. Some bitwise arithmetic may be
involved to prevent this (like in 'ia32intrin.h' from GCC 8), which is
unfortunately not recognized by GCC 7 and earlier versions as bitwise
rotation and results in rather complex code.

Signed-off-by: Liu Hao <>
1 file changed