Add support for setting thread name on FreeBSD, DragonFlyBSD, OpenBSD, and NetBSD. Fixes GNOME/glib#1761