From 01ff501326d4c03049ad45e22d14812d75ce1984 Mon Sep 17 00:00:00 2001 From: Wouter van Oortmerssen Date: Mon, 4 Oct 2021 16:41:23 -0700 Subject: [PATCH] [Memory64] pthread rwlock libc changes for 64-bit --- .../lib/libc/musl/src/thread/pthread_rwlock_timedwrlock.c | 8 ++++---- .../lib/libc/musl/src/thread/pthread_rwlock_trywrlock.c | 2 +- system/lib/libc/musl/src/thread/pthread_rwlock_unlock.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/system/lib/libc/musl/src/thread/pthread_rwlock_timedwrlock.c b/system/lib/libc/musl/src/thread/pthread_rwlock_timedwrlock.c index e1d6162f3b1d6..15a8acc1cacf1 100644 --- a/system/lib/libc/musl/src/thread/pthread_rwlock_timedwrlock.c +++ b/system/lib/libc/musl/src/thread/pthread_rwlock_timedwrlock.c @@ -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(); @@ -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; } diff --git a/system/lib/libc/musl/src/thread/pthread_rwlock_trywrlock.c b/system/lib/libc/musl/src/thread/pthread_rwlock_trywrlock.c index fdd08d39dbcc4..cf0f2c648e386 100644 --- a/system/lib/libc/musl/src/thread/pthread_rwlock_trywrlock.c +++ b/system/lib/libc/musl/src/thread/pthread_rwlock_trywrlock.c @@ -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; } diff --git a/system/lib/libc/musl/src/thread/pthread_rwlock_unlock.c b/system/lib/libc/musl/src/thread/pthread_rwlock_unlock.c index 61d5e38646255..15b363dcafc41 100644 --- a/system/lib/libc/musl/src/thread/pthread_rwlock_unlock.c +++ b/system/lib/libc/musl/src/thread/pthread_rwlock_unlock.c @@ -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 {