Skip to content

Commit a70e0f0

Browse files
authored
remove thread_tag references (#705)
devkitA64 r29.1 removes thread_tag from lock struct
1 parent 802c18c commit a70e0f0

3 files changed

Lines changed: 4 additions & 15 deletions

File tree

nx/include/switch/kernel/mutex.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ bool mutexIsLockedByCurrentThread(const Mutex* m);
5757
static inline void rmutexInit(RMutex* m)
5858
{
5959
m->lock = 0;
60-
m->thread_tag = 0;
6160
m->counter = 0;
6261
}
6362

nx/source/kernel/mutex.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,20 +139,15 @@ bool mutexIsLockedByCurrentThread(const Mutex* m) {
139139
}
140140

141141
void rmutexLock(RMutex* m) {
142-
if (m->thread_tag != _GetTag()) {
142+
if (!mutexIsLockedByCurrentThread(&m->lock)) {
143143
mutexLock(&m->lock);
144-
m->thread_tag = _GetTag();
144+
m->counter++;
145145
}
146-
147-
m->counter++;
148146
}
149147

150148
bool rmutexTryLock(RMutex* m) {
151-
if (m->thread_tag != _GetTag()) {
152-
if (!mutexTryLock(&m->lock)) {
153-
return false;
154-
}
155-
m->thread_tag = _GetTag();
149+
if (!mutexIsLockedByCurrentThread(&m->lock)) {
150+
return mutexTryLock(&m->lock);
156151
}
157152

158153
m->counter++;
@@ -161,7 +156,6 @@ bool rmutexTryLock(RMutex* m) {
161156

162157
void rmutexUnlock(RMutex* m) {
163158
if (--m->counter == 0) {
164-
m->thread_tag = 0;
165159
mutexUnlock(&m->lock);
166160
}
167161
}

nx/source/runtime/newlib.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,13 @@ int __syscall_cond_wait(_COND_T *cond, _LOCK_T *lock, uint64_t timeout_ns)
108108

109109
int __syscall_cond_wait_recursive(_COND_T *cond, _LOCK_RECURSIVE_T *lock, uint64_t timeout_ns)
110110
{
111-
uint32_t thread_tag_backup = 0;
112111
if (lock->counter != 1)
113112
return EBADF;
114113

115-
thread_tag_backup = lock->thread_tag;
116-
lock->thread_tag = 0;
117114
lock->counter = 0;
118115

119116
int errcode = errno_from_result(condvarWaitTimeout(cond, &lock->lock, timeout_ns));
120117

121-
lock->thread_tag = thread_tag_backup;
122118
lock->counter = 1;
123119

124120
return errcode;

0 commit comments

Comments
 (0)