Skip to content

Commit d9a4cf9

Browse files
authored
Check against thread id instead. NFC. (#15606)
1 parent 8b6cc91 commit d9a4cf9

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

system/lib/libc/musl/src/internal/pthread_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ enum {
131131
// XXX Emscripten: The spec allows detecting when multiple write locks would deadlock, so use an extra field
132132
// _rw_wr_owner to record which thread owns the write lock in order to avoid hangs.
133133
// Points to the pthread that currently has the write lock.
134-
#define _rw_wr_owner __u.__p[3]
134+
#define _rw_wr_owner __u.__vi[3]
135135
#endif
136136
#define _b_lock __u.__vi[0]
137137
#define _b_waiters __u.__vi[1]

system/lib/libc/musl/src/thread/pthread_rwlock_timedwrlock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ int __pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict rw, const struct tim
55
#ifdef __EMSCRIPTEN__
66
/// XXX Emscripten: The spec allows detecting when multiple write locks would deadlock, which we do here to avoid hangs.
77
/// If attempting to lock the write lock that we already own, error out.
8-
if (rw->_rw_wr_owner == (void *)pthread_self()) return EDEADLK;
8+
if (rw->_rw_wr_owner == __pthread_self()->tid) return EDEADLK;
99
#endif
1010
int r, t;
1111

@@ -27,7 +27,7 @@ int __pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict rw, const struct tim
2727
#ifdef __EMSCRIPTEN__
2828
/// XXX Emscripten: The spec allows detecting when multiple write locks would deadlock, which we do here to avoid hangs.
2929
/// Mark this thread as the owner of this write lock.
30-
rw->_rw_wr_owner = (void *)pthread_self();
30+
rw->_rw_wr_owner = __pthread_self()->tid;
3131
#endif
3232
return r;
3333
}

system/lib/libc/musl/src/thread/pthread_rwlock_trywrlock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ int __pthread_rwlock_trywrlock(pthread_rwlock_t *rw)
66
#ifdef __EMSCRIPTEN__
77
/// XXX Emscripten: The spec allows detecting when multiple write locks would deadlock, which we do here to avoid hangs.
88
/// Mark this thread to own the write lock, to ignore multiple attempts to lock.
9-
rw->_rw_wr_owner = (void *)pthread_self();
9+
rw->_rw_wr_owner = __pthread_self()->tid;
1010
#endif
1111
return 0;
1212
}

system/lib/libc/musl/src/thread/pthread_rwlock_unlock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ int __pthread_rwlock_unlock(pthread_rwlock_t *rw)
77
#ifdef __EMSCRIPTEN__
88
/// XXX Emscripten: The spec allows detecting when multiple write locks would deadlock, which we do here to avoid hangs.
99
/// Mark this thread to not own the write lock anymore.
10-
if (rw->_rw_wr_owner == (void *)pthread_self()) rw->_rw_wr_owner = 0;
10+
if (rw->_rw_wr_owner == __pthread_self()->tid) rw->_rw_wr_owner = 0;
1111
#endif
1212

1313
do {

0 commit comments

Comments
 (0)