mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-02 20:58:15 +00:00
fix thread_unix for Darwin after pthread corrections in posix package
afed3ceremoved the sys/unix package and moved over to sys/posix, it has new bindings for the pthread APIs but should have been equivalent (not).8fb7182used `CANCEL_ENABLE :: 0`, `CANCEL_DISABLE :: 1`, `CANCEL_DEFERRED :: 0`, `CANCEL_ASYNCHRONOUS :: 1` for Darwin, while the correct values are `1`, `0`, `2` and `0` respectively (same mistake was made for FreeBSD in that commit). What this meant is that the `pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS)` was not actually successful, but because the error wasn't checked it was assumed it was. It also meant `pthread_setcancelstate(PTHREAD_CANCEL_ENABLE)` would actually be setting `PTHREAD_CANCEL_DISABLE`. The code in this PR restores the behaviour by now actually deliberately setting `PTHREAD_CANCEL_DISABLE` and not setting `PTHREAD_CANCEL_ASYNCHRONOUS` which was the previous behaviour that does actually seem to work for some reason. (I also fixed an issue in fmt where `x` would use uppercase if it was a pointer.)
This commit is contained in:
@@ -101,5 +101,29 @@ int main(int argc, char *argv[])
|
||||
printf("timespec %zu %zu\n", sizeof(struct timespec), _Alignof(struct timespec));
|
||||
printf("clock_t %zu %zu\n", sizeof(clock_t), _Alignof(clock_t));
|
||||
|
||||
printf("PTHREAD_CANCEL_ASYNCHRONOUS %d\n", PTHREAD_CANCEL_ASYNCHRONOUS);
|
||||
printf("PTHREAD_CANCEL_DEFERRED %d\n", PTHREAD_CANCEL_DEFERRED);
|
||||
|
||||
printf("PTHREAD_CANCEL_DISABLE %d\n", PTHREAD_CANCEL_DISABLE);
|
||||
printf("PTHREAD_CANCEL_ENABLE %d\n", PTHREAD_CANCEL_ENABLE);
|
||||
|
||||
printf("PTHREAD_CANCELED %p\n", PTHREAD_CANCELED);
|
||||
|
||||
printf("PTHREAD_CREATE_JOINABLE %d\n", PTHREAD_CREATE_JOINABLE);
|
||||
printf("PTHREAD_CREATE_DETACHED %d\n", PTHREAD_CREATE_DETACHED);
|
||||
|
||||
printf("PTHREAD_EXPLICIT_SCHED %d\n", PTHREAD_EXPLICIT_SCHED);
|
||||
printf("PTHREAD_INHERIT_SCHED %d\n", PTHREAD_INHERIT_SCHED);
|
||||
|
||||
printf("PTHREAD_PRIO_INHERIT %d\n", PTHREAD_PRIO_INHERIT);
|
||||
printf("PTHREAD_PRIO_NONE %d\n", PTHREAD_PRIO_NONE);
|
||||
printf("PTHREAD_PRIO_PROTECT %d\n", PTHREAD_PRIO_PROTECT);
|
||||
|
||||
printf("PTHREAD_PROCESS_SHARED %d\n", PTHREAD_PROCESS_SHARED);
|
||||
printf("PTHREAD_PROCESS_PRIVATE %d\n", PTHREAD_PROCESS_PRIVATE);
|
||||
|
||||
printf("PTHREAD_SCOPE_PROCESS %d\n", PTHREAD_SCOPE_PROCESS);
|
||||
printf("PTHREAD_SCOPE_SYSTEM %d\n", PTHREAD_SCOPE_SYSTEM);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user