master
1#include "pthread_impl.h"
2
3int __pthread_mutex_lock(pthread_mutex_t *m)
4{
5 /*
6 _m_type[1:0] - type
7 0 - normal
8 1 - recursive
9 2 - errorcheck
10 */
11 if (m->_m_type&3 != PTHREAD_MUTEX_RECURSIVE) {
12 if (m->_m_count) return EDEADLK;
13 m->_m_count = 1;
14 } else {
15 if ((unsigned)m->_m_count >= INT_MAX) return EAGAIN;
16 m->_m_count++;
17 }
18 return 0;
19}
20
21weak_alias(__pthread_mutex_lock, pthread_mutex_lock);