Warning: That file was not part of the compilation database. It may have many parsing errors.

1/* Transfer ownership of a mutex. Generic version.
2 Copyright (C) 2008-2019 Free Software Foundation, Inc.
3 Written by Neal H. Walfield <neal@gnu.org>.
4
5 This file is part of the GNU Hurd.
6
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.
11
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.
16
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/>. */
20
21#include <pthread.h>
22#include <assert.h>
23
24#include <pt-internal.h>
25
26int
27__pthread_mutex_transfer_np (struct __pthread_mutex *mutex, pthread_t tid)
28{
29 assert (mutex->__owner == _pthread_self ());
30
31 struct __pthread *thread = __pthread_getid (tid);
32 const struct __pthread_mutexattr *attr = mutex->__attr;
33
34 if (thread == NULL)
35 return ESRCH;
36
37 if (thread == _pthread_self ())
38 return 0;
39
40 if (attr == __PTHREAD_ERRORCHECK_MUTEXATTR)
41 attr = &__pthread_errorcheck_mutexattr;
42 if (attr == __PTHREAD_RECURSIVE_MUTEXATTR)
43 attr = &__pthread_recursive_mutexattr;
44
45 if (attr != NULL && attr->__mutex_type == PTHREAD_MUTEX_ERRORCHECK)
46 {
47
48 if (mutex->__owner != _pthread_self ())
49 return EPERM;
50
51 mutex->__owner = thread;
52 }
53
54#ifndef NDEBUG
55# if !defined(ALWAYS_TRACK_MUTEX_OWNER)
56 if (attr != NULL && attr->__mutex_type != PTHREAD_MUTEX_NORMAL)
57# endif
58 {
59 mutex->__owner = thread;
60 }
61#endif
62
63 return 0;
64}
65
66strong_alias (__pthread_mutex_transfer_np, pthread_mutex_transfer_np)
67

Warning: That file was not part of the compilation database. It may have many parsing errors.