Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: fusl/src/thread/pthread_mutex_timedlock.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fusl/src/thread/pthread_mutex_setprioceiling.c ('k') | fusl/src/thread/pthread_mutex_trylock.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include "pthread_impl.h"
2
3 int __pthread_mutex_timedlock(pthread_mutex_t *restrict m, const struct timespec *restrict at)
4 {
5 if ((m->_m_type&15) == PTHREAD_MUTEX_NORMAL
6 && !a_cas(&m->_m_lock, 0, EBUSY))
7 return 0;
8
9 int r, t, priv = (m->_m_type & 128) ^ 128;
10
11 r = pthread_mutex_trylock(m);
12 if (r != EBUSY) return r;
13
14 int spins = 100;
15 while (spins-- && m->_m_lock && !m->_m_waiters) a_spin();
16
17 while ((r=pthread_mutex_trylock(m)) == EBUSY) {
18 if (!(r=m->_m_lock) || ((r&0x40000000) && (m->_m_type&4)))
19 continue;
20 if ((m->_m_type&3) == PTHREAD_MUTEX_ERRORCHECK
21 && (r&0x7fffffff) == __pthread_self()->tid)
22 return EDEADLK;
23
24 a_inc(&m->_m_waiters);
25 t = r | 0x80000000;
26 a_cas(&m->_m_lock, r, t);
27 r = __timedwait(&m->_m_lock, t, CLOCK_REALTIME, at, priv);
28 a_dec(&m->_m_waiters);
29 if (r && r != EINTR) break;
30 }
31 return r;
32 }
33
34 weak_alias(__pthread_mutex_timedlock, pthread_mutex_timedlock);
OLDNEW
« no previous file with comments | « fusl/src/thread/pthread_mutex_setprioceiling.c ('k') | fusl/src/thread/pthread_mutex_trylock.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698