Author: rfm
Date: Tue Dec  2 07:52:55 2014
New Revision: 38221

URL: http://svn.gna.org/viewcvs/gnustep?rev=38221&view=rev
Log:
change tests for pthread_setname_np

Modified:
    libs/base/trunk/configure
    libs/base/trunk/configure.ac

Modified: libs/base/trunk/configure
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/configure?rev=38221&r1=38220&r2=38221&view=diff
==============================================================================
--- libs/base/trunk/configure   (original)
+++ libs/base/trunk/configure   Tue Dec  2 07:52:55 2014
@@ -13711,9 +13711,13 @@
 #--------------------------------------------------------------------
 
 
-{ $as_echo "$as_me:$LINENO: checking for pthread_setname_np" >&5
-$as_echo_n "checking for pthread_setname_np... " >&6; }
-if test "${ac_cv_func_pthread_setname_np+set}" = set; then
+
+for ac_func in pthread_set_name_np
+do
+as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5
+$as_echo_n "checking for $ac_func... " >&6; }
+if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
   $as_echo_n "(cached) " >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
@@ -13722,12 +13726,12 @@
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-/* Define pthread_setname_np to an innocuous variant, in case <limits.h> 
declares pthread_setname_np.
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares 
$ac_func.
    For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define pthread_setname_np innocuous_pthread_setname_np
+#define $ac_func innocuous_$ac_func
 
 /* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char pthread_setname_np (); below.
+    which can conflict with char $ac_func (); below.
     Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
     <limits.h> exists even on freestanding compilers.  */
 
@@ -13737,7 +13741,7 @@
 # include <assert.h>
 #endif
 
-#undef pthread_setname_np
+#undef $ac_func
 
 /* Override any GCC internal prototype to avoid an error.
    Use char because int might match the return type of a GCC
@@ -13745,18 +13749,18 @@
 #ifdef __cplusplus
 extern "C"
 #endif
-char pthread_setname_np ();
+char $ac_func ();
 /* The GNU C library defines this for functions which it implements
     to always fail with ENOSYS.  Some functions are actually named
     something starting with __ and the normal name is an alias.  */
-#if defined __stub_pthread_setname_np || defined __stub___pthread_setname_np
+#if defined __stub_$ac_func || defined __stub___$ac_func
 choke me
 #endif
 
 int
 main ()
 {
-return pthread_setname_np ();
+return $ac_func ();
   ;
   return 0;
 }
@@ -13782,44 +13786,42 @@
         test "$cross_compiling" = yes ||
         $as_test_x conftest$ac_exeext
        }; then
-  ac_cv_func_pthread_setname_np=yes
+  eval "$as_ac_var=yes"
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cv_func_pthread_setname_np=no
+       eval "$as_ac_var=no"
 fi
 
 rm -rf conftest.dSYM
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_pthread_setname_np" >&5
-$as_echo "$ac_cv_func_pthread_setname_np" >&6; }
-if test "x$ac_cv_func_pthread_setname_np" = x""yes; then
-  pthread_setname_ok=yes
-else
-  pthread_setname_ok=no
-fi
-
-if test $pthread_setname_ok = yes ; then
-  case "$target_os" in
-    darwin*)
+ac_res=`eval 'as_val=${'$as_ac_var'}
+                $as_echo "$as_val"'`
+              { $as_echo "$as_me:$LINENO: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+as_val=`eval 'as_val=${'$as_ac_var'}
+                $as_echo "$as_val"'`
+   if test "x$as_val" = x""yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+if test $ac_cv_func_pthread_set_name_np == yes; then
+
 cat >>confdefs.h <<\_ACEOF
-#define PTHREAD_SETNAME(a,b) pthread_setname_np(b)
-_ACEOF
-;;
-          *)
-cat >>confdefs.h <<\_ACEOF
-#define PTHREAD_SETNAME(a,b) pthread_setname_np(a,b)
-_ACEOF
-;;
-  esac
-fi
-
-{ $as_echo "$as_me:$LINENO: checking for pthread_set_name_np" >&5
-$as_echo_n "checking for pthread_set_name_np... " >&6; }
-if test "${ac_cv_func_pthread_set_name_np+set}" = set; then
+#define PTHREAD_SETNAME(a,b) pthread_set_name_np(b)
+_ACEOF
+
+else
+  { $as_echo "$as_me:$LINENO: checking for pthread_setname_np() variant" >&5
+$as_echo_n "checking for pthread_setname_np() variant... " >&6; }
+if test "${gs_cv_pthread_setname_np+set}" = set; then
   $as_echo_n "(cached) " >&6
 else
   cat >conftest.$ac_ext <<_ACEOF
@@ -13828,41 +13830,11 @@
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-/* Define pthread_set_name_np to an innocuous variant, in case <limits.h> 
declares pthread_set_name_np.
-   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
-#define pthread_set_name_np innocuous_pthread_set_name_np
-
-/* System header to define __stub macros and hopefully few prototypes,
-    which can conflict with char pthread_set_name_np (); below.
-    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-    <limits.h> exists even on freestanding compilers.  */
-
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-
-#undef pthread_set_name_np
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char pthread_set_name_np ();
-/* The GNU C library defines this for functions which it implements
-    to always fail with ENOSYS.  Some functions are actually named
-    something starting with __ and the normal name is an alias.  */
-#if defined __stub_pthread_set_name_np || defined __stub___pthread_set_name_np
-choke me
-#endif
-
+#include <pthread.h>
 int
 main ()
 {
-return pthread_set_name_np ();
+pthread_setname_np(pthread_self(), "name");
   ;
   return 0;
 }
@@ -13888,34 +13860,83 @@
         test "$cross_compiling" = yes ||
         $as_test_x conftest$ac_exeext
        }; then
-  ac_cv_func_pthread_set_name_np=yes
+  gs_cv_pthread_setname_np=glibc
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-       ac_cv_func_pthread_set_name_np=no
+       cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <pthread.h>
+int
+main ()
+{
+pthread_setname_np(pthread_self(), "%s", "name");
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
+$as_echo "$ac_try_echo") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+        test "$cross_compiling" = yes ||
+        $as_test_x conftest$ac_exeext
+       }; then
+  gs_cv_pthread_setname_np=netbsd
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       gs_cv_pthread_setname_np=none
 fi
 
 rm -rf conftest.dSYM
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
 fi
-{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_pthread_set_name_np" >&5
-$as_echo "$ac_cv_func_pthread_set_name_np" >&6; }
-if test "x$ac_cv_func_pthread_set_name_np" = x""yes; then
-  pthread_set_name_ok=yes
-else
-  pthread_set_name_ok=no
-fi
-
-if test $pthread_set_name_ok = yes ; then
+
+rm -rf conftest.dSYM
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:$LINENO: result: $gs_cv_pthread_setname_np" >&5
+$as_echo "$gs_cv_pthread_setname_np" >&6; }
+  case $gs_cv_pthread_setname_np in
+    glibc)
 
 cat >>confdefs.h <<\_ACEOF
-#define PTHREAD_SETNAME(a,b) pthread_set_name_np(a,b)
-_ACEOF
-
-fi
-
+#define PTHREAD_SETNAME(a,b) pthread_setname_np(a,b)
+_ACEOF
+
+      ;;
+    netbsd)
+
+cat >>confdefs.h <<\_ACEOF
+#define PTHREAD_SETNAME(a,b) pthread_setname_np(a,"%s",b)
+_ACEOF
+
+      ;;
+  esac
+fi
 
 #--------------------------------------------------------------------
 # Check whether Objective-C /really/ works

Modified: libs/base/trunk/configure.ac
URL: 
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/configure.ac?rev=38221&r1=38220&r2=38221&view=diff
==============================================================================
--- libs/base/trunk/configure.ac        (original)
+++ libs/base/trunk/configure.ac        Tue Dec  2 07:52:55 2014
@@ -1749,19 +1749,34 @@
 #--------------------------------------------------------------------
 
 
-AC_CHECK_FUNC(pthread_setname_np, pthread_setname_ok=yes, 
pthread_setname_ok=no)
-if test $pthread_setname_ok = yes ; then
-  case "$target_os" in
-    darwin*) AC_DEFINE(PTHREAD_SETNAME(a,b), pthread_setname_np(b), 
[Description: Define set name function for pthread]);;
-          *) AC_DEFINE(PTHREAD_SETNAME(a,b), pthread_setname_np(a,b), 
[Description: Define set name function for pthread]);;
+AC_CHECK_FUNCS(pthread_set_name_np)
+if test $ac_cv_func_pthread_set_name_np == yes; then
+  AC_DEFINE(PTHREAD_SETNAME(a,b), pthread_set_name_np(b),
+    [Description: Define set name function for pthread])
+else
+  AC_CACHE_CHECK(
+    [for pthread_setname_np() variant],
+    [gs_cv_pthread_setname_np],
+    [AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM([#include <pthread.h>],
+        [pthread_setname_np(pthread_self(), "name");])],
+        [gs_cv_pthread_setname_np=glibc],
+        [AC_LINK_IFELSE(
+          [AC_LANG_PROGRAM([#include <pthread.h>],
+            [pthread_setname_np(pthread_self(), "%s", "name");])],
+             [gs_cv_pthread_setname_np=netbsd],
+             [gs_cv_pthread_setname_np=none])])])
+  case $gs_cv_pthread_setname_np in
+    glibc)
+      AC_DEFINE(PTHREAD_SETNAME(a,b), pthread_setname_np(a,b),
+        [Description: Define set name function for pthread])
+      ;;
+    netbsd)
+      AC_DEFINE(PTHREAD_SETNAME(a,b), pthread_setname_np(a,"%s",b),
+        [Description: Define set name function for pthread])
+      ;;
   esac
 fi
-
-AC_CHECK_FUNC(pthread_set_name_np, pthread_set_name_ok=yes, 
pthread_set_name_ok=no)
-if test $pthread_set_name_ok = yes ; then
-  AC_DEFINE(PTHREAD_SETNAME(a,b), pthread_set_name_np(a,b), [Description: 
Define set name function for pthread])
-fi
-
 
 #--------------------------------------------------------------------
 # Check whether Objective-C /really/ works


_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs

Reply via email to