[glib] meson: Always define _GNU_SOURCE for pthread checks



commit 4c46869081ceb156fd7555b6fa67954dc0ca1bca
Author: Nirbheek Chauhan <nirbheek centricular com>
Date:   Mon Aug 14 00:05:52 2017 +0530

    meson: Always define _GNU_SOURCE for pthread checks
    
    Without this, GNU-specific symbols won't be defined and the compiler
    check will pass because GCC will assume that you know what you're
    doing since it doesn't know what the symbol prototype is and compiler
    checks aren't built with -Wall -Werror.
    
    This will then cause a build failure because the wrong prototype will
    be used.

 meson.build |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/meson.build b/meson.build
index 9340735..ff3ccaa 100644
--- a/meson.build
+++ b/meson.build
@@ -1272,12 +1272,17 @@ else
   if cc.has_header_symbol('pthread.h', 'pthread_cond_timedwait_relative_np')
     glib_conf.set('HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP', 1)
   endif
-  if cc.links('''#include <pthread.h>
+  # Assume that pthread_setname_np is available in some form; same as configure
+  if cc.links('''#ifndef _GNU_SOURCE
+              # define _GNU_SOURCE
+              #endif
+              #include <pthread.h>
               int main() {
                 pthread_setname_np("example");
               }''',
               name : 'pthread_setname_np(const char*)',
               dependencies : thread_dep)
+    # macOS and iOS
     glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID', 1)
   elif cc.links('''#ifndef _GNU_SOURCE
                 # define _GNU_SOURCE
@@ -1288,6 +1293,7 @@ else
                 }''',
                 name : 'pthread_setname_np(pthread_t, const char*)',
                 dependencies : thread_dep)
+    # Linux, Solaris, etc.
     glib_conf.set('HAVE_PTHREAD_SETNAME_NP_WITH_TID', 1)
   endif
 endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]