Bug 11771 - pthread_mutex_trylock is not weakly defined in glibc-2.1.3-15
pthread_mutex_trylock is not weakly defined in glibc-2.1.3-15
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
8.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-05-31 00:05 EDT by David Shaw
Modified: 2007-04-18 12:27 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-04-21 20:14:14 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description David Shaw 2000-05-31 00:05:19 EDT
glibc defines all of the pthread_* functions weakly within glibc itself so
a program that uses them but does not link with libpthreads will still
function.  The functions are weakly defined to return a "no error" code.

Unfortunately, for some reason pthread_mutex_trylock was left out.

For example, this code works fine whether you link to libpthread or not:
  #include <pthread.h>
  
  int main(int argc,char *argv[])
  {
    pthread_mutex_t mymutex=PTHREAD_MUTEX_INITIALIZER;
  
    pthread_mutex_lock(&mymutex);
  }

On the other hand, this does not work (but should):

  #include <pthread.h>

  int main(int argc,char *argv[])
  {
    pthread_mutex_t mymutex=PTHREAD_MUTEX_INITIALIZER;

    pthread_mutex_trylock(&mymutex);
  }
Comment 1 Alan Cox 2002-12-14 18:43:45 EST
Still the same in 8.0 if this is actually a bug its still there

Alan the bugzilla womble
Comment 2 Ulrich Drepper 2003-04-21 20:14:14 EDT
If pthread_mutex_trylock isn't used, why should it have been defined?  The
definitions are not meant for programmers to rely on.

RHL9 changed all that code, calling thread functions from libc works completely
different now, even in the LinuxThreads code.  I close the bug.

Note You need to log in before you can comment on or make changes to this bug.