Name threads on Linux properly

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.

This second incarnation now implements a proper configure check to ensure we are using the capabilities of the library on various platforms (esp. when using glibc < 1.12).
Merge pull request #2323 from dagwieers/pthread_setname

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