This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] nptl: Avoid using PTHREAD_MUTEX_DEFAULT in macro definition [BZ #25271]


Commit 1c3f9acf1f1f75faa7a28bf39af64afd ("nptl: Add struct_mutex.h")
replaced a zero constant with the identifier PTHREAD_MUTEX_DEFAULT
in the macro PTHREAD_MUTEX_INITIALIZER.  However, that constant
is not available in ISO C11 mode:

In file included from /usr/include/bits/thread-shared-types.h:74,
                 from /usr/include/bits/pthreadtypes.h:23,
                 from /usr/include/pthread.h:26,
                 from bug25271.c:1:
bug25271.c:3:21: error: ‘PTHREAD_MUTEX_DEFAULT’ undeclared here (not in a function)
    3 | pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~

This commit change the constant to the equivalent
PTHREAD_MUTEX_TIMED_NP, which is in the POSIX extension namespace
and thus always available.

Tested on x86_64-linux-gnu and i686-linux-gnu.  Verified that a
minimal example now builds in -std=c11 mode.

-----
 sysdeps/nptl/pthread.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sysdeps/nptl/pthread.h b/sysdeps/nptl/pthread.h
index 7825737840..44dd707896 100644
--- a/sysdeps/nptl/pthread.h
+++ b/sysdeps/nptl/pthread.h
@@ -84,7 +84,7 @@ enum
 
 
 #define PTHREAD_MUTEX_INITIALIZER \
- { {  __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_DEFAULT) } }
+ { {  __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_TIMED_NP) } }
 #ifdef __USE_GNU
 # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \
  { {  __PTHREAD_MUTEX_INITIALIZER (PTHREAD_MUTEX_RECURSIVE_NP) } }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]