Skip to content
Snippets Groups Projects
Commit 3cb49127 authored by Avi Kivity's avatar Avi Kivity
Browse files

pthread: implement mutex_lock, unlock, trylock()

parent 0d0a82b1
No related branches found
No related tags found
No related merge requests found
......@@ -54,3 +54,26 @@ int pthread_mutex_init(pthread_mutex_t* __restrict m,
new (m) mutex;
return 0;
}
int pthread_mutex_lock(pthread_mutex_t *m)
{
mutex* mm = reinterpret_cast<mutex*>(m);
mm->lock();
return 0;
}
int pthread_mutex_trylock(pthread_mutex_t *m)
{
mutex* mm = reinterpret_cast<mutex*>(m);
if (!mm->try_lock()) {
return -EBUSY;
}
return 0;
}
int pthread_mutex_unlock(pthread_mutex_t *m)
{
mutex* mm = reinterpret_cast<mutex*>(m);
mm->unlock();
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment