[core] Detect pthread_getname* availability #2111
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Extracted
pthread_getname_np()
related changes from PR Fix Build for MacOS, FreeBSD, GCC earlier than 4.7, and Clang earlier… #2104 (by @jlsantiago0).pthread_getname_np()
andpthread_setname_np()
functions in CMake.pthread_getname_np()
andpthread_setname_np()
functions if available inThreadName
class.Additional minor change in the second commit: put
ThreadName
class insidesrt
namespace.Original Description by Jose
This fixes MacOS builds for MacOS <10.6 as
pthread_getname_np()
andpthread_setname_np()
was introduced in MacOS 10.6 and is not available in MacOS 10.5 and earlier.The rework of the
pthread_getname_np()
andpthread_setname_np()
allows other operating systems that support the API to use it. For instance, these functions are available in many of the BSD variants, but maybe in a different header file or may have a slightly different name. I also fixed the handling of the different function call parameters of the Apple and non-Apple implementations ofpthread_setname_np()
. Apple takes one parameter and most implementations take 2. This was tested withFreeBSD-11.3
andOpenBSD-6.4
.TODO
ThreadName
class insidesrt
namespace.