Wrap qsort_r as xsort

BSD-derived systems have a qsort_r with a different argument order
to glibc's.
FreeBSD needs netinet/in.h to get struct sockaddr_in
On BSDs, endian.h lives under sys/
Build under FreeBSD