Re: [waffle] [PATCH 1/3] third_party/threads: Use PTHREAD_MUTEX_RECURSIVE by default

2015-03-26 Thread Chad Versace
Quoting Emil Velikov (2015-03-19 15:26:11)
> PTHREAD_MUTEX_RECURSIVE_NP was used for compatibility with old glibc.
> Although due to the_GNU_SOURCES define the portable,
> PTHREAD_MUTEX_RECURSIVE will be available for Linuxes since at least
> 1998. Simplify things giving us compatibility with musl which
> apparently does not provide the non-portable define.
> 
> Inspired by almost identical commit in mesa aead7fe2e2b(c11/threads: Use
> PTHREAD_MUTEX_RECURSIVE by default) by Felix Janda.
> 
> Signed-off-by: Emil Velikov 
> ---
>  third_party/threads/threads_posix.c | 10 --
>  1 file changed, 4 insertions(+), 6 deletions(-)

Reviewed-by: Chad Versace 

This patch looks safe to land before the others in the series, so I'll
go ahead and commit it.
___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle


[waffle] [PATCH 1/3] third_party/threads: Use PTHREAD_MUTEX_RECURSIVE by default

2015-03-19 Thread Emil Velikov
PTHREAD_MUTEX_RECURSIVE_NP was used for compatibility with old glibc.
Although due to the_GNU_SOURCES define the portable,
PTHREAD_MUTEX_RECURSIVE will be available for Linuxes since at least
1998. Simplify things giving us compatibility with musl which
apparently does not provide the non-portable define.

Inspired by almost identical commit in mesa aead7fe2e2b(c11/threads: Use
PTHREAD_MUTEX_RECURSIVE by default) by Felix Janda.

Signed-off-by: Emil Velikov 
---
 third_party/threads/threads_posix.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/third_party/threads/threads_posix.c 
b/third_party/threads/threads_posix.c
index 5835e43..e122bf9 100644
--- a/third_party/threads/threads_posix.c
+++ b/third_party/threads/threads_posix.c
@@ -26,6 +26,9 @@
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  */
+
+#define _GNU_SOURCE
+
 #include 
 #ifndef assert
 #include 
@@ -150,13 +153,8 @@ int mtx_init(mtx_t *mtx, int type)
   && type != (mtx_try|mtx_recursive))
 return thrd_error;
 pthread_mutexattr_init(&attr);
-if ((type & mtx_recursive) != 0) {
-#if defined(__linux__) || defined(__linux)
-pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
-#else
+if ((type & mtx_recursive) != 0)
 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-#endif
-}
 pthread_mutex_init(mtx, &attr);
 pthread_mutexattr_destroy(&attr);
 return thrd_success;
-- 
2.3.1

___
waffle mailing list
waffle@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/waffle