[glib] Protect call to pthread_condattr_setclock with define.



commit decac50c1598f75ce781a3c6a68a85c0defe38ac
Author: Patrick Welche <prlw1 cam ac uk>
Date:   Thu Jan 12 15:38:15 2012 +0000

    Protect call to pthread_condattr_setclock with define.
    
    While here update pthread_attr_setstacksize test to use AC_LINK_IFELSE
    and avoid an unused variable in glib/tests/thread.c.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=667790

 configure.ac         |   22 +++++++++++++++++-----
 glib/gthread-posix.c |    2 +-
 glib/tests/thread.c  |    2 +-
 3 files changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4b13eac..d3628e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2238,11 +2238,23 @@ if test x"$have_threads" = xposix; then
         # This is not AC_CHECK_FUNC to also work with function
         # name mangling in header files.
         AC_MSG_CHECKING(for pthread_attr_setstacksize)
-        AC_TRY_LINK([#include <pthread.h>],
-                    [pthread_attr_t t; pthread_attr_setstacksize(&t,0)],
-                    [AC_MSG_RESULT(yes)
-                     AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACKSIZE,1,[Have function pthread_attr_setstacksize])],
-                    [AC_MSG_RESULT(no)])
+        AC_LINK_IFELSE(
+            [AC_LANG_PROGRAM(
+                [#include <pthread.h>],
+                [pthread_attr_t t; pthread_attr_setstacksize(&t,0)])],
+            [AC_MSG_RESULT(yes)
+             AC_DEFINE(HAVE_PTHREAD_ATTR_SETSTACKSIZE,1,
+                [Have function pthread_attr_setstacksize])],
+            [AC_MSG_RESULT(no)])
+        AC_MSG_CHECKING(for pthread_condattr_setclock)
+        AC_LINK_IFELSE(
+            [AC_LANG_PROGRAM(
+                [#include <pthread.h>],
+                [pthread_condattr_t a; pthread_condattr_setclock(&a,0)])],
+            [AC_MSG_RESULT(yes)
+             AC_DEFINE(HAVE_PTHREAD_CONDATTR_SETCLOCK,1,
+                [Have function pthread_condattr_setclock])],
+            [AC_MSG_RESULT(no)])
         CPPFLAGS="$glib_save_CPPFLAGS"
 fi
 
diff --git a/glib/gthread-posix.c b/glib/gthread-posix.c
index faa6004..5d1344d 100644
--- a/glib/gthread-posix.c
+++ b/glib/gthread-posix.c
@@ -636,7 +636,7 @@ g_cond_impl_new (void)
   gint status;
 
   pthread_condattr_init (&attr);
-#ifdef CLOCK_MONOTONIC
+#if defined (HAVE_PTHREAD_CONDATTR_SETCLOCK) && defined (CLOCK_MONOTONIC)
   pthread_condattr_setclock (&attr, CLOCK_MONOTONIC);
 #endif
 
diff --git a/glib/tests/thread.c b/glib/tests/thread.c
index b6bb5a9..29b3850 100644
--- a/glib/tests/thread.c
+++ b/glib/tests/thread.c
@@ -167,9 +167,9 @@ test_thread5 (void)
 static gpointer
 thread6_func (gpointer data)
 {
+#ifdef HAVE_SYS_PRCTL_H
   const gchar name[16];
 
-#ifdef HAVE_SYS_PRCTL_H
   prctl (PR_GET_NAME, name, 0, 0, 0, 0);
 
   g_assert_cmpstr (name, ==, (gchar*)data);



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