-
Notifications
You must be signed in to change notification settings - Fork 235
Conversation
"I don't know enough about musl / glibc pthreads differences to know if there is a possible common solution." Please can you do some quick searches, and see whether this is intentionally NOT supported in musl? Or maybe some other API variant is supported, and we could switch to that? If we know this isn't possible in musl then I'm happy to make that change, but we need to do a little due-diligence before committing this change. Thanks! |
http://man7.org/linux/man-pages/man7/pthreads.7.html
These are not currently implemented in musl as far as I can tell, e.g. |
The alternative in the code is to log the thread name in a global variable, rather than attaching it to the thread itself.
The |
N.B. musl refuses to define |
Good principle, except "as they are POSIX compliant" is not true in at least this case! Want to change this PR so these two functions use a thread-local global as per your comment above? So pre-processor conditionals would stay the same but the code would change in a way which would work for GLIBC and musl. |
#if defined(__GLIBC__) | ||
pthread_setname_np(pthread_self(), _n.c_str()); | ||
#elif defined(__APPLE__) | ||
#if defined(__APPLE__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean like this? Or shall I just cut the pthread naming entirely for all platforms?
You mean have glibc / musl do the same thread-local thing? Shall I just cut the pthread naming entirely for all platforms? |
Yeah - let's do this for now and keep this code for OS X. Please could you squash and update the comment and I will merge. Thanks! |
Motivation is that pthread_(set|get)name_np are not implemented in musl. This is the only non musl compliant feature across the codebase. This commit gives consistent linux logging, regardless of glibc / musl.
There might be a better way of doing this. I don't know enough about musl / glibc pthreads differences to know if there is a possible common solution.
The problem is that when compiling with musl (i.e. non glibc) on linux, the changed code gives an error. Checking whether we are using glibc (rather than just linux) lets us get past this problem.