Name threads properly on Linux, FreeBSD, OpenBSD, ...

I implemented this as part of the OpenELEC project.

It helps debug issues if we can easily identify the XBMC thread by name. This patch implements just that.