Closed HoKim98 closed 9 months ago
Do we know why libc::pthread_t is void* on Alpine ? Is it a general musl thing ?
I have cross-checked the musl source code, and it turns out that their pthread_t definition is made of as much insanity as the rest of their threading support...
#ifdef __cplusplus
TYPEDEF unsigned long pthread_t;
#else
TYPEDEF struct __pthread * pthread_t;
#endif
...so I guess I'll just redefine ThreadId to be c_ulong on musl and call it a day. :shrug:
Wow, musl is so amazing. I've never seen such an inconvenient and insane implementation.
Try to update to the freshly released hwlocality-sys v0.4.1 and you should hopefully be good to go.
Sorry for necrobumping, but there is one remaining error
error[E0308]: mismatched types
--> src/lib.rs:266:14
|
264 | pub fn current_thread_id() -> ThreadId {
| -------- expected `u64` because of return type
265 | // SAFETY: Should be always safe to call
266 | unsafe { libc::pthread_self() }
| ^^^^^^^^^^^^^^^^^^^^ expected `u64`, found `*mut c_void`
|
= note: expected type `u64`
found raw pointer `*mut c_void`
For more information about this error, try `rustc --explain E0308`.
error: could not compile `hwlocality` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...
This should be resolved by #116, and the hwlocality 1.0.0-alpha.2 release that I'll push which integrates it.
Long-term, I should set up a musl build in CI to avoid this sort of issues, but I do not have the time for this right now.
Should be good now.
On Alpine Linux,
pthread_t
type is mismatched betweenlibc
andstd
.ThreadId
=libc::pthread_t
's type is*mut libc::c_void
!std::os::unix::thread::JoinHandleExt::as_pthread_t
's return type isRawPthread
=u64
.Error reconstruction
Logs
Expected Solution
If we cast the type
ThreadId
to*mut libc::c_void
, then all examples would be failed becauseThreadId
is not thread-safe.So I think the plausible option is:
type ThreadId = u64
.