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.
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.
I think this is potentially lossy compared to the previous version if
SIZEOF_PTHREAD_T > SIZEOF_LONG. Previously we would cast directly to aPyThread_ident_t(anunsigned long long), whereas we now cast through anunsigned long.Uh oh!
There was an error while loading. Please reload this page.
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.
I think I understand your concern.
This was an edge case in
PyThread_start_new_thread, my guess is that it was there for the situations wherepthread_twas not a ulong and was, instead, a pointer or struct.It's probably fine to drop the condition in
_pthread_t_to_identand let the caller here truncate it since this API is specifically returning a ULONG and not aPyThread_ident_t.Looking at the history:
2565bff
635f6fb
The cast through ulong* was for Alpha OSF which was dropped from PEP 11 a few years ago (CPython 3.3) https://bugs.python.org/issue8606. My guess is it was also defined as a pointer or struct type and this was a way to work around it by returning at least
longbytes.I think if we find other platforms where we need to support this workaround, they can be chained to the MUSL
#ifdefI think. The only time it would maybe be a problem is ifsizeof(uintptr_t)<sizeof(ulong).If others agree, I can drop the condition so the function looks like so:
I do not suggest this as a long term solution; I do think we need to work towards making this opaque. I'm just trying to find something that is a stop-gap that can be ported back with relative ease that doesn't cause a regression.