Bug 175355

Summary: Bad: Recursive Mutex in pthread.h
Product: Red Hat Enterprise Linux 4 Reporter: Raghuvamshi <raghuvamshi_thakur>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: 4.0   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-12-09 12:02:12 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Raghuvamshi 2005-12-09 10:16:25 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050921 Red Hat/1.0.7-1.4.1 Firefox/1.0.7

Description of problem:
We are using recursive mutex in my application
	
        pthread_mutexattr_t attr;
	(void)pthread_mutexattr_init(&attr);
	(void)pthread_mutexattr_settype(&attr,PTHREAD_MUTEX_RECURSIVE);
        (void)pthread_mutex_init(mutex,&attr);
	(void)pthread_mutexattr_destroy(&attr);
and are encountering constant problems with compilation due to `PTHREAD_MUTEX_RECURSIVE' undeclared (first use in this function)
warning: implicit declaration of function `pthread_mutexattr_settype'
warning: nested extern declaration of `pthread_mutexattr_settype'

We are not able to comile the application with recursive mutex even when we have included the required pthread.h libarary file

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.Simple program using recursive Mutex
2.Compilation 
3.
  

Actual Results:  Not able to comile, getting repeated error regarding to 
`PTHREAD_MUTEX_RECURSIVE' undeclared (first use in this function)
warning: implicit declaration of function `pthread_mutexattr_settype'
warning: nested extern declaration of `pthread_mutexattr_settype'


Additional info:

Comment 1 Raghuvamshi 2005-12-09 10:17:37 UTC
The problem could be due to the #ifdef in the pThread.h 

Comment 2 Jakub Jelinek 2005-12-09 12:02:12 UTC
Please see
info libc 'Feature Test Macros'
In particular, PTHREAD_MUTEX_RECURSIVE is a Unix98 and newer POSIX macro,
so you need one of
-D_XOPEN_SOURCE=500
-D_XOPEN_SOURCE=600
-D_GNU_SOURCE
on the compiler command line to enable that namespace.