]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/mach/hurd/htl/pt-mutex-lock.c
a7f153775611b98e16bac9f3df5aa9ccf2a8043a
1 /* pthread_mutex_lock. Hurd version.
2 Copyright (C) 2016-2018 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
22 #include <pt-internal.h>
27 __pthread_mutex_lock (pthread_mutex_t
*mtxp
)
29 struct __pthread
*self
;
30 int flags
= mtxp
->__flags
& GSYNC_SHARED
;
33 switch (MTX_TYPE (mtxp
))
36 lll_lock (&mtxp
->__lock
, flags
);
39 case PT_MTX_RECURSIVE
:
40 self
= _pthread_self ();
41 if (mtx_owned_p (mtxp
, self
, flags
))
43 if (__glibc_unlikely (mtxp
->__cnt
+ 1 == 0))
50 lll_lock (&mtxp
->__lock
, flags
);
51 mtx_set_owner (mtxp
, self
, flags
);
55 case PT_MTX_ERRORCHECK
:
56 self
= _pthread_self ();
57 if (mtx_owned_p (mtxp
, self
, flags
))
60 lll_lock (&mtxp
->__lock
, flags
);
61 mtx_set_owner (mtxp
, self
, flags
);
64 case PT_MTX_NORMAL
| PTHREAD_MUTEX_ROBUST
:
65 case PT_MTX_RECURSIVE
| PTHREAD_MUTEX_ROBUST
:
66 case PT_MTX_ERRORCHECK
| PTHREAD_MUTEX_ROBUST
:
67 self
= _pthread_self ();
68 ROBUST_LOCK (self
, mtxp
, __lll_robust_lock
, flags
);
79 strong_alias (__pthread_mutex_lock
, _pthread_mutex_lock
)
80 strong_alias (__pthread_mutex_lock
, pthread_mutex_lock
)