mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-27 15:52:28 +00:00
Make improvements
- Improve compatibility with Blink virtual machine - Add non-POSIX APIs for joining threads and signal masks - Never ever use anything except 32-bit integers for atomics - Add some `#undef` statements to workaround `ctags` problems
This commit is contained in:
parent
b46ac13504
commit
f2af97711b
114 changed files with 902 additions and 363 deletions
|
@ -18,6 +18,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/cp.internal.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/atomic.h"
|
||||
|
@ -37,9 +38,10 @@
|
|||
*
|
||||
* @return 0 on success, or errno on error
|
||||
* @raise ECANCELED if calling thread was cancelled in masked mode
|
||||
* @raise EBUSY if `abstime` was specified and deadline expired
|
||||
* @cancellationpoint
|
||||
*/
|
||||
errno_t _wait0(const atomic_int *ctid) {
|
||||
errno_t _wait0(const atomic_int *ctid, struct timespec *abstime) {
|
||||
int x, rc = 0;
|
||||
// "The behavior is undefined if the value specified by the thread
|
||||
// argument to pthread_join() refers to the calling thread."
|
||||
|
@ -50,9 +52,13 @@ errno_t _wait0(const atomic_int *ctid) {
|
|||
if (!(rc = pthread_testcancel_np())) {
|
||||
BEGIN_CANCELLATION_POINT;
|
||||
while ((x = atomic_load_explicit(ctid, memory_order_acquire))) {
|
||||
if (nsync_futex_wait_(ctid, x, !IsWindows(), 0) == -ECANCELED) {
|
||||
rc = nsync_futex_wait_(ctid, x, !IsWindows(), abstime);
|
||||
if (rc == -ECANCELED) {
|
||||
rc = ECANCELED;
|
||||
break;
|
||||
} else if (rc == -ETIMEDOUT) {
|
||||
rc = EBUSY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
END_CANCELLATION_POINT;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue