We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2752

Summary: broken recursive mutexes checks in configury
Product: SDL Reporter: Ozkan Sezer <sezeroz>
Component: buildAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: icculus
Version: HG 2.0Keywords: triage-2.0.4
Hardware: All   
OS: Linux   
Attachments: configury fix for recursive mutex checks
recursive mutex patch for SDL-1.2 branch

Description Ozkan Sezer 2014-10-17 07:41:50 UTC
Created attachment 1899 [details]
configury fix for recursive mutex checks

The configury checks for pthread_mutexattr_settype/PTHREAD_MUTEX_RECURSIVE
without defining _GNU_SOURCE so the check would fail even if it is present.
(The corresponding *.c file does define _GNU_SOURCE, so that side is just
fine.) Besides, the check is done using _TRY_COMPILE instead of _TRY_LINK,
so the result is not safe enough either.

The attached small patch fixes these issues.
Comment 1 Ozkan Sezer 2014-10-17 07:51:56 UTC
Additional note: The configure.in part of the patch also applies to SDL-1.2
branch.  It _is_ needed there too, because the SDL-1.2 branch of hg removed
the _GNU_SOURCE definition from its common CFLAGS.
Comment 2 Ozkan Sezer 2014-10-17 08:20:02 UTC
Created attachment 1900 [details]
recursive mutex patch for SDL-1.2 branch

Went ahead and attached a patch for the SDL-1.2 branch.

I also suggest that the _GNU_SOURCE definition removal (commit
7b87c1773b3e: http://hg.libsdl.org/SDL/rev/7b87c1773b3e) to be
reverted from the SDL-1.2 branch.
Comment 3 Ryan C. Gordon 2015-02-19 05:22:20 UTC
Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry if you got a lot of email from this. This is to help me sort through some bugs in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4, though!
Comment 4 Ryan C. Gordon 2015-02-19 18:26:41 UTC
On my Linux system (Ubuntu 14.04), this is working without this patch. Can you see what the error you get in your config.log without this patch?

--ryan.
Comment 5 Ozkan Sezer 2015-02-19 18:50:17 UTC
(In reply to Ryan C. Gordon from comment #4)
> On my Linux system (Ubuntu 14.04), this is working without this patch. Can
> you see what the error you get in your config.log without this patch?
> 
> --ryan.

configure:21912: checking for recursive mutexes
configure:21932: gcc -c -g -O2 -Iinclude -I/home/ozzie/Download/SDL2/include   -D_REENTRANT  -Iinclude -I/home/ozzie/Download/SDL2/include  conftest.c >&5
conftest.c: In function 'main':
conftest.c:149: error: 'PTHREAD_MUTEX_RECURSIVE' undeclared (first use in this function)
conftest.c:149: error: (Each undeclared identifier is reported only once
conftest.c:149: error: for each function it appears in.)
configure:21932: $? = 1
configure: failed program was:
[...snip...]
| 
|                   #include <pthread.h>
| 
| int
| main ()
| {
| 
|                   pthread_mutexattr_t attr;
|                   pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
| 
|   ;
|   return 0;
| }
configure:21959: gcc -c -g -O2 -Iinclude -I/home/ozzie/Download/SDL2/include   -D_REENTRANT  -Iinclude -I/home/ozzie/Download/SDL2/include  conftest.c >&5
configure:21959: $? = 0
configure:21969: result: yes

In the generated SDL_config.h, I have:
/* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX */
#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP 1

This is with glibc-2.8.
Comment 6 Ryan C. Gordon 2015-03-24 00:13:32 UTC
The SDL2 patch is now https://hg.libsdl.org/SDL/rev/a3344156e514, thanks!

SDL-1.2: https://hg.libsdl.org/SDL/rev/d2bc9b3760fb and https://hg.libsdl.org/SDL/rev/c238763e1228

--ryan.