On RISC-V 64-bit, GCC complains about undefined reference to 'ffs' via __builtin_ffs(). So implement a brute force way to do it. Once the toolchain has __builtin_ffs(), this can be reverted. Signed-off-by: Daniel Leung <daniel.leung@intel.com>