Skip to content

Commit

Permalink
chore(mutex): Update name to match Haiku
Browse files Browse the repository at this point in the history
Update `mutex_unlock` to `mutex_unblock` to match changes in
haiku/haiku@6f3f29c7.

The actual fixes have not been applied yet, see #12.
  • Loading branch information
trungnt2910 committed Jun 10, 2023
1 parent 2c265cb commit f590514
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions haiku_loader/loader_mutex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static int32_t atomic_or(int32_t *a, int32_t b);
static int32_t atomic_and(int32_t *a, int32_t b);
static int loader_mutex_lock_locked(int32_t *mutex, const char *name, uint32_t flags, int64_t timeout,
std::unique_lock<std::mutex> &lock);
static void loader_mutex_unlock_locked(int32_t *mutex, uint32_t flags);
static void loader_mutex_unblock_locked(int32_t *mutex, uint32_t flags);
static int loader_mutex_wait_locked(int32_t *mutex, const char *name, uint32_t flags, int64_t timeout,
std::unique_lock<std::mutex> &lock, bool &lastWaiter);
static void add_loader_mutex_info(int32_t *mutex, std::shared_ptr<mutex_info> info);
Expand All @@ -60,7 +60,7 @@ int loader_mutex_lock(int32_t *mutex, const char *name, uint32_t flags, int64_t
return error;
}

int loader_mutex_unlock(int32_t *mutex, uint32 flags)
int loader_mutex_unblock(int32_t *mutex, uint32 flags)
{
if (mutex == NULL || ((intptr_t)mutex) % 4 != 0)
{
Expand All @@ -70,7 +70,7 @@ int loader_mutex_unlock(int32_t *mutex, uint32 flags)
{
auto lock = std::unique_lock<std::mutex>(sMutexTableLock);

loader_mutex_unlock_locked(mutex, flags);
loader_mutex_unblock_locked(mutex, flags);
}

return B_OK;
Expand All @@ -94,7 +94,7 @@ int loader_mutex_switch_lock(int32_t *fromMutex, int32_t *toMutex,
// unlock the first mutex and lock the second one
{
auto lock = std::unique_lock<std::mutex>(sMutexTableLock);
loader_mutex_unlock_locked(fromMutex, flags);
loader_mutex_unblock_locked(fromMutex, flags);

error = loader_mutex_lock_locked(toMutex, name, flags, timeout, lock);
}
Expand Down Expand Up @@ -125,7 +125,7 @@ static int loader_mutex_lock_locked(int32_t *mutex, const char *name, uint32_t f
return error;
}

static void loader_mutex_unlock_locked(int32_t *mutex, uint32_t flags)
static void loader_mutex_unblock_locked(int32_t *mutex, uint32_t flags)
{
auto it = sMutexTable.find(mutex);
if (it == sMutexTable.end() || !it->second || it->second->empty())
Expand Down
2 changes: 1 addition & 1 deletion haiku_loader/loader_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <cstdint>

int loader_mutex_lock(int32_t* mutex, const char* name, uint32_t flags, int64_t timeout);
int loader_mutex_unlock(int32_t* mutex, uint32_t flags);
int loader_mutex_unblock(int32_t* mutex, uint32_t flags);
// Unlocks "from" and locks "to" such that unlocking and starting to wait
// for the lock is atomic. I.e. if "from" guards the object "to" belongs
// to, the operation is safe as long as "from" is held while destroying
Expand Down
2 changes: 1 addition & 1 deletion haiku_loader/sys/linux/loader_commpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void* loader_allocate_commpage()
hostcalls_ptr->wait_for_thread = loader_wait_for_thread;

hostcalls_ptr->mutex_lock = loader_mutex_lock;
hostcalls_ptr->mutex_unlock = loader_mutex_unlock;
hostcalls_ptr->mutex_unblock = loader_mutex_unblock;
hostcalls_ptr->mutex_switch_lock = loader_mutex_switch_lock;

hostcalls_ptr->realtime_sem_open = loader_realtime_sem_open;
Expand Down
4 changes: 2 additions & 2 deletions monika/linux/threading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ status_t _moni_mutex_lock(int32* mutex, const char* name,
return GET_HOSTCALLS()->mutex_lock(mutex, name, flags, timeout);
}

status_t _moni_mutex_unlock(int32* mutex, uint32 flags)
status_t _moni_mutex_unblock(int32* mutex, uint32 flags)
{
return GET_HOSTCALLS()->mutex_unlock(mutex, flags);
return GET_HOSTCALLS()->mutex_unblock(mutex, flags);
}

status_t _moni_mutex_switch_lock(int32* fromMutex, int32* toMutex,
Expand Down
2 changes: 1 addition & 1 deletion shared_headers/extended_commpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct hostcalls

// Mutex
int (*mutex_lock)(int32_t* mutex, const char* name, uint32_t flags, int64_t timeout);
int (*mutex_unlock)(int32_t* mutex, uint32_t flags);
int (*mutex_unblock)(int32_t* mutex, uint32_t flags);
int (*mutex_switch_lock)(int32_t* fromMutex, int32_t* toMutex, const char* name, uint32_t flags, int64_t timeout);

// Semaphore
Expand Down
2 changes: 1 addition & 1 deletion shared_headers/user_mutex_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef _SYSTEM_USER_MUTEX_DEFS_H
#define _SYSTEM_USER_MUTEX_DEFS_H

// user mutex specific flags passed to _kern_user_mutex_unlock()
// user mutex specific flags passed to _kern_user_mutex_unblock()
#define B_USER_MUTEX_UNBLOCK_ALL 0x80000000
// All threads currently waiting on the mutex will be unblocked. The mutex
// state will be locked.
Expand Down

0 comments on commit f590514

Please sign in to comment.