make qsort and bsearch type safe

This introduces wrappers around qsort and bsearch to make them type
safe.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Liu Yuan <tailai.ly@taobao.com>