aboutsummaryrefslogtreecommitdiff
path: root/pthreads/pthread_mutex_init.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-07-18 10:51:09 +0200
committermarha <marha@users.sourceforge.net>2011-07-18 10:51:09 +0200
commit3c0d2312573b81e3067bea610a58b1940c075e05 (patch)
tree3f025a27d813374f225957801226aa8ee829a33a /pthreads/pthread_mutex_init.c
parentba033884541714680fd7552ab9d6c8817650f7d8 (diff)
parent88101146f2ec7d53ffb793e365f05097ffd35fd3 (diff)
downloadvcxsrv-3c0d2312573b81e3067bea610a58b1940c075e05.tar.gz
vcxsrv-3c0d2312573b81e3067bea610a58b1940c075e05.tar.bz2
vcxsrv-3c0d2312573b81e3067bea610a58b1940c075e05.zip
Merge remote-tracking branch 'origin/released'
Conflicts: X11/Xfuncproto.h.in X11/configure.ac X11/keysymdef.h freetype/include/freetype/internal/pcftypes.h freetype/src/cache/ftcbasic.c freetype/src/cache/ftccmap.c mesalib/src/glsl/ir.h mesalib/src/glsl/link_functions.cpp mesalib/src/mesa/main/dlist.c mesalib/src/mesa/program/prog_optimize.c mesalib/src/mesa/state_tracker/st_program.c pthreads/Makefile
Diffstat (limited to 'pthreads/pthread_mutex_init.c')
-rw-r--r--pthreads/pthread_mutex_init.c52
1 files changed, 39 insertions, 13 deletions
diff --git a/pthreads/pthread_mutex_init.c b/pthreads/pthread_mutex_init.c
index cff8e5054..daf805e5b 100644
--- a/pthreads/pthread_mutex_init.c
+++ b/pthreads/pthread_mutex_init.c
@@ -49,27 +49,28 @@ pthread_mutex_init (pthread_mutex_t * mutex, const pthread_mutexattr_t * attr)
return EINVAL;
}
- if (attr != NULL
- && *attr != NULL && (*attr)->pshared == PTHREAD_PROCESS_SHARED)
+ if (attr != NULL && *attr != NULL)
{
- /*
- * Creating mutex that can be shared between
- * processes.
- */
+ if ((*attr)->pshared == PTHREAD_PROCESS_SHARED)
+ {
+ /*
+ * Creating mutex that can be shared between
+ * processes.
+ */
#if _POSIX_THREAD_PROCESS_SHARED >= 0
- /*
- * Not implemented yet.
- */
+ /*
+ * Not implemented yet.
+ */
#error ERROR [__FILE__, line __LINE__]: Process shared mutexes are not supported yet.
#else
- return ENOSYS;
+ return ENOSYS;
#endif /* _POSIX_THREAD_PROCESS_SHARED */
-
+ }
}
mx = (pthread_mutex_t) calloc (1, sizeof (*mx));
@@ -82,8 +83,33 @@ pthread_mutex_init (pthread_mutex_t * mutex, const pthread_mutexattr_t * attr)
{
mx->lock_idx = 0;
mx->recursive_count = 0;
- mx->kind = (attr == NULL || *attr == NULL
- ? PTHREAD_MUTEX_DEFAULT : (*attr)->kind);
+ mx->robustNode = NULL;
+ if (attr == NULL || *attr == NULL)
+ {
+ mx->kind = PTHREAD_MUTEX_DEFAULT;
+ }
+ else
+ {
+ mx->kind = (*attr)->kind;
+ if ((*attr)->robustness == PTHREAD_MUTEX_ROBUST)
+ {
+ /*
+ * Use the negative range to represent robust types.
+ * Replaces a memory fetch with a register negate and incr
+ * in pthread_mutex_lock etc.
+ *
+ * Map 0,1,..,n to -1,-2,..,(-n)-1
+ */
+ mx->kind = -mx->kind - 1;
+
+ mx->robustNode = (ptw32_robust_node_t*) malloc(sizeof(ptw32_robust_node_t));
+ mx->robustNode->stateInconsistent = PTW32_ROBUST_CONSISTENT;
+ mx->robustNode->mx = mx;
+ mx->robustNode->next = NULL;
+ mx->robustNode->prev = NULL;
+ }
+ }
+
mx->ownerThread.p = NULL;
mx->event = CreateEvent (NULL, PTW32_FALSE, /* manual reset = No */