Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / native_client_sdk / src / libraries / third_party / pthreads-win32 / pthread_mutexattr_getrobust.c
blobbe004837bc1dd114b076e9119ca41850618f7a45
1 /*
2 * pthread_mutexattr_getrobust.c
4 * Description:
5 * This translation unit implements mutual exclusion (mutex) primitives.
7 * --------------------------------------------------------------------------
9 * Pthreads-win32 - POSIX Threads Library for Win32
10 * Copyright(C) 1998 John E. Bossom
11 * Copyright(C) 1999,2005 Pthreads-win32 contributors
13 * Contact Email: rpj@callisto.canberra.edu.au
15 * The current list of contributors is contained
16 * in the file CONTRIBUTORS included with the source
17 * code distribution. The list can also be seen at the
18 * following World Wide Web location:
19 * http://sources.redhat.com/pthreads-win32/contributors.html
21 * This library is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU Lesser General Public
23 * License as published by the Free Software Foundation; either
24 * version 2 of the License, or (at your option) any later version.
26 * This library is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 * Lesser General Public License for more details.
31 * You should have received a copy of the GNU Lesser General Public
32 * License along with this library in the file COPYING.LIB;
33 * if not, write to the Free Software Foundation, Inc.,
34 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
37 #include "pthread.h"
38 #include "implement.h"
41 int
42 pthread_mutexattr_getrobust (const pthread_mutexattr_t * attr, int * robust)
44 * ------------------------------------------------------
46 * DOCPUBLIC
47 * The pthread_mutexattr_setrobust() and
48 * pthread_mutexattr_getrobust() functions respectively set and
49 * get the mutex robust attribute. This attribute is set in the
50 * robust parameter to these functions.
52 * PARAMETERS
53 * attr
54 * pointer to an instance of pthread_mutexattr_t
56 * robust
57 * must be one of:
59 * PTHREAD_MUTEX_STALLED
61 * PTHREAD_MUTEX_ROBUST
63 * DESCRIPTION
64 * The pthread_mutexattr_setrobust() and
65 * pthread_mutexattr_getrobust() functions respectively set and
66 * get the mutex robust attribute. This attribute is set in the
67 * robust parameter to these functions. The default value of the
68 * robust attribute is PTHREAD_MUTEX_STALLED.
70 * The robustness of mutex is contained in the robustness attribute
71 * of the mutex attributes. Valid mutex robustness values are:
73 * PTHREAD_MUTEX_STALLED
74 * No special actions are taken if the owner of the mutex is
75 * terminated while holding the mutex lock. This can lead to
76 * deadlocks if no other thread can unlock the mutex.
77 * This is the default value.
79 * PTHREAD_MUTEX_ROBUST
80 * If the process containing the owning thread of a robust mutex
81 * terminates while holding the mutex lock, the next thread that
82 * acquires the mutex shall be notified about the termination by
83 * the return value [EOWNERDEAD] from the locking function. If the
84 * owning thread of a robust mutex terminates while holding the mutex
85 * lock, the next thread that acquires the mutex may be notified
86 * about the termination by the return value [EOWNERDEAD]. The
87 * notified thread can then attempt to mark the state protected by
88 * the mutex as consistent again by a call to
89 * pthread_mutex_consistent(). After a subsequent successful call to
90 * pthread_mutex_unlock(), the mutex lock shall be released and can
91 * be used normally by other threads. If the mutex is unlocked without
92 * a call to pthread_mutex_consistent(), it shall be in a permanently
93 * unusable state and all attempts to lock the mutex shall fail with
94 * the error [ENOTRECOVERABLE]. The only permissible operation on such
95 * a mutex is pthread_mutex_destroy().
97 * RESULTS
98 * 0 successfully set attribute,
99 * EINVAL 'attr' or 'robust' is invalid,
101 * ------------------------------------------------------
104 int result = EINVAL;
106 if ((attr != NULL && *attr != NULL && robust != NULL))
108 *robust = (*attr)->robustness;
109 result = 0;
112 return (result);
113 } /* pthread_mutexattr_getrobust */