Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions system/lib/libc/musl/src/thread/pthread_rwlock_timedwrlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ int pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict rw, const struct times
#ifdef __EMSCRIPTEN__
/// XXX Emscripten: The spec allows detecting when multiple write locks would deadlock, which we do here to avoid hangs.
/// If attempting to lock the write lock that we already own, error out.
if (rw->_rw_wr_owner == (int)pthread_self()) return EDEADLK;
if (rw->_rw_wr_owner == (void *)pthread_self()) return EDEADLK;
#endif
int r, t;

r = pthread_rwlock_trywrlock(rw);
if (r != EBUSY) return r;

int spins = 100;
while (spins-- && rw->_rw_lock && !rw->_rw_waiters) a_spin();

Expand All @@ -27,7 +27,7 @@ int pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict rw, const struct times
#ifdef __EMSCRIPTEN__
/// XXX Emscripten: The spec allows detecting when multiple write locks would deadlock, which we do here to avoid hangs.
/// Mark this thread as the owner of this write lock.
rw->_rw_wr_owner = (int)pthread_self();
rw->_rw_wr_owner = (void *)pthread_self();
#endif
return r;
}
2 changes: 1 addition & 1 deletion system/lib/libc/musl/src/thread/pthread_rwlock_trywrlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ int pthread_rwlock_trywrlock(pthread_rwlock_t *rw)
#ifdef __EMSCRIPTEN__
/// XXX Emscripten: The spec allows detecting when multiple write locks would deadlock, which we do here to avoid hangs.
/// Mark this thread to own the write lock, to ignore multiple attempts to lock.
rw->_rw_wr_owner = (int)pthread_self();
rw->_rw_wr_owner = (void *)pthread_self();
#endif
return 0;
}
2 changes: 1 addition & 1 deletion system/lib/libc/musl/src/thread/pthread_rwlock_unlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int pthread_rwlock_unlock(pthread_rwlock_t *rw)
#ifdef __EMSCRIPTEN__
/// XXX Emscripten: The spec allows detecting when multiple write locks would deadlock, which we do here to avoid hangs.
/// Mark this thread to not own the write lock anymore.
if (rw->_rw_wr_owner == (int)pthread_self()) rw->_rw_wr_owner = 0;
if (rw->_rw_wr_owner == (void *)pthread_self()) rw->_rw_wr_owner = 0;
#endif

do {
Expand Down