FreeBSD patch port

Stolen all the patches from the Ports mysql55-server but also
fixed up the Posix Timers/Threads stuff as that failed to compile
due to relying on types only available in Linux.