Define XTABS to TAB3 on alpha to match Linux 4.16.
[glibc.git] / sysdeps / htl / pt-mutex-transfer-np.c
blobe208ac1b58fd82b1b5fe22af7798bcb0386a749b
1 /* Transfer ownership of a mutex. Generic version.
2 Copyright (C) 2008-2018 Free Software Foundation, Inc.
3 Written by Neal H. Walfield <neal@gnu.org>.
5 This file is part of the GNU Hurd.
7 The GNU Hurd is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public License
9 as published by the Free Software Foundation; either version 3 of
10 the License, or (at your option) any later version.
12 The GNU Hurd is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with this program. If not, see
19 <http://www.gnu.org/licenses/>. */
21 #include <pthread.h>
22 #include <assert.h>
24 #include <pt-internal.h>
26 int
27 __pthread_mutex_transfer_np (struct __pthread_mutex *mutex, pthread_t tid)
29 assert (mutex->__owner == _pthread_self ());
31 struct __pthread *thread = __pthread_getid (tid);
32 const struct __pthread_mutexattr *attr = mutex->__attr;
34 if (thread == NULL)
35 return ESRCH;
37 if (thread == _pthread_self ())
38 return 0;
40 if (attr == __PTHREAD_ERRORCHECK_MUTEXATTR)
41 attr = &__pthread_errorcheck_mutexattr;
42 if (attr == __PTHREAD_RECURSIVE_MUTEXATTR)
43 attr = &__pthread_recursive_mutexattr;
45 if (attr != NULL && attr->__mutex_type == PTHREAD_MUTEX_ERRORCHECK)
48 if (mutex->__owner != _pthread_self ())
49 return EPERM;
51 mutex->__owner = thread;
54 #ifndef NDEBUG
55 # if !defined(ALWAYS_TRACK_MUTEX_OWNER)
56 if (attr != NULL && attr->__mutex_type != PTHREAD_MUTEX_NORMAL)
57 # endif
59 mutex->__owner = thread;
61 #endif
63 return 0;
66 strong_alias (__pthread_mutex_transfer_np, pthread_mutex_transfer_np)