Bug 82617 - Build failure when using older pthreads implementations
Summary: Build failure when using older pthreads implementations
Status: RESOLVED FIXED
Alias: None
Product: p11-glue
Classification: Unclassified
Component: p11-kit (show other bugs)
Version: unspecified
Hardware: Other Linux (All)
: medium normal
Assignee: Stef Walter
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-14 13:13 UTC by Baruch Siach
Modified: 2014-08-15 06:07 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Fix build against older pthreads implementations (1.89 KB, text/plain)
2014-08-14 13:13 UTC, Baruch Siach
Details
Fix build against older pthreads implementations (revised) (1.39 KB, patch)
2014-08-14 14:05 UTC, Baruch Siach
Details | Splinter Review

Description Baruch Siach 2014-08-14 13:13:54 UTC
Created attachment 104620 [details]
Fix build against older pthreads implementations

Older pthreads implementations like glibc NPTL prior to version 2.12, and
uClibc linuxthreads (both), need _XOPEN_SOURCE to expose
pthread_mutexattr_settype() and THREAD_MUTEX_DEFAULT.
    
This results in the following build error:
    
  CC       compat.lo
compat.c: In function 'p11_mutex_init':
compat.c:164:2: warning: implicit declaration of function 'pthread_mutexattr_settype' [-Wimplicit-function-declaration]
compat.c:164:2: warning: nested extern declaration of 'pthread_mutexattr_settype' [-Wnested-externs]
compat.c:164:36: error: 'PTHREAD_MUTEX_DEFAULT' undeclared (first use in this function)

The attached patch should fix this.
Comment 1 Stef Walter 2014-08-14 13:16:24 UTC
I'm a bit worried about defining this in a header. Would it work to define it very early in the compat.c file?
Comment 2 Baruch Siach 2014-08-14 13:22:14 UTC
(In reply to comment #1)
> I'm a bit worried about defining this in a header. Would it work to define
> it very early in the compat.c file?

This can only work if you define _XOPEN_SOURCE before '#include "compat.h"'. Is that what you mean?
Comment 3 Stef Walter 2014-08-14 13:27:01 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > I'm a bit worried about defining this in a header. Would it work to define
> > it very early in the compat.c file?
> 
> This can only work if you define _XOPEN_SOURCE before '#include "compat.h"'.
> Is that what you mean?

Yes.
Comment 4 Baruch Siach 2014-08-14 14:05:31 UTC
Created attachment 104621 [details] [review]
Fix build against older pthreads implementations (revised)

Here is a revised patch, build tested.
Comment 5 Stef Walter 2014-08-15 06:07:20 UTC
Thanks. Merged the patch into master.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.