Bug 11771 - pthread_mutex_trylock is not weakly defined in glibc-2.1.3-15
Summary: pthread_mutex_trylock is not weakly defined in glibc-2.1.3-15
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 8.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-05-31 04:05 UTC by Daphne Shaw
Modified: 2016-11-24 15:09 UTC (History)
1 user (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2003-04-22 00:14:14 UTC
Embargoed:


Attachments (Terms of Use)

Description Daphne Shaw 2000-05-31 04:05:19 UTC
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 23:43:45 UTC
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-22 00:14:14 UTC
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.