summaryrefslogtreecommitdiff
path: root/sysdeps/generic/pt-mutex-trylock.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/generic/pt-mutex-trylock.c')
-rw-r--r--sysdeps/generic/pt-mutex-trylock.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/sysdeps/generic/pt-mutex-trylock.c b/sysdeps/generic/pt-mutex-trylock.c
index b3c3fe3..d56f6e1 100644
--- a/sysdeps/generic/pt-mutex-trylock.c
+++ b/sysdeps/generic/pt-mutex-trylock.c
@@ -1,5 +1,5 @@
/* Try to Lock a mutex. Generic version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -23,7 +23,7 @@
#define LOSE do { * (int *) 0 = 0; } while (1)
-/* Lock MUTEX, block if we can't get it. */
+/* Lock MUTEX, return EBUSY if we can't get it. */
int
__pthread_mutex_trylock (struct __pthread_mutex *mutex)
{
@@ -65,8 +65,9 @@ __pthread_mutex_trylock (struct __pthread_mutex *mutex)
break;
case PTHREAD_MUTEX_ERRORCHECK:
- if (mutex->owner == self)
- err = EDEADLK;
+ /* We could check if MUTEX->OWNER is SELF, however, POSIX
+ does not permit pthread_mutex_trylock to return EDEADLK
+ instead of EBUSY, only pthread_mutex_lock. */
break;
case PTHREAD_MUTEX_RECURSIVE:
@@ -82,8 +83,10 @@ __pthread_mutex_trylock (struct __pthread_mutex *mutex)
}
}
+ __pthread_spin_unlock (&mutex->__lock);
+
return err;
}
-weak_alias (__pthread_mutex_trylock, _pthread_mutex_trylock);
-weak_alias (__pthread_mutex_trylock, pthread_mutex_trylock);
+strong_alias (__pthread_mutex_trylock, _pthread_mutex_trylock);
+strong_alias (__pthread_mutex_trylock, pthread_mutex_trylock);