[kaffe] CVS kaffe (guilhem): Small fix for pthreads (pthread_yield).

Kaffe CVS cvs-commits at kaffe.org
Wed Nov 10 23:57:34 PST 2004


PatchSet 5447 
Date: 2004/11/11 07:40:40
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Small fix for pthreads (pthread_yield).

        * configure, config/config.h.in: Regenerated.

        * configure.ac: Check for pthread_yield, sched_yield and sched.h.

        * kaffe/kaffevm/systems/unix-pthreads/thread-internal.h
        (jthread_yield): Use sched_yield instead of pthread_yield if it has
        not been found and nothing if sched_yield has not been found.

Members: 
	ChangeLog:1.2993->1.2994 
	configure:1.390->1.391 
	configure.ac:1.85->1.86 
	config/config.h.in:1.127->1.128 
	kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.22->1.23 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2993 kaffe/ChangeLog:1.2994
--- kaffe/ChangeLog:1.2993	Thu Nov 11 03:11:23 2004
+++ kaffe/ChangeLog	Thu Nov 11 07:40:40 2004
@@ -1,3 +1,13 @@
+2004-11-11  Guilhem Lavaux  <guilhem at kaffe.org>
+
+	* configure, config/config.h.in: Regenerated.
+
+	* configure.ac: Check for pthread_yield, sched_yield and sched.h.
+
+	* kaffe/kaffevm/systems/unix-pthreads/thread-internal.h
+	(jthread_yield): Use sched_yield instead of pthread_yield if it has
+	not been found and nothing if sched_yield has not been found.
+	
 2004-11-11  Dalibor Topic  <robilad at kaffe.org>
 
 	* libraries/javalib/java/io/File.java:
Index: kaffe/configure
diff -u kaffe/configure:1.390 kaffe/configure:1.391
--- kaffe/configure:1.390	Sun Oct 31 13:36:25 2004
+++ kaffe/configure	Thu Nov 11 07:40:34 2004
@@ -46311,9 +46311,10 @@
 done
 
 
-# pthread_attr_setschedpolicy in not implemented on NetBSD <= 1.6
 
-for ac_func in pthread_attr_setschedpolicy
+
+
+for ac_func in pthread_attr_setschedpolicy pthread_yield sched_yield
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -46412,6 +46413,156 @@
 _ACEOF
 
 fi
+done
+
+
+for ac_header in sched.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+  # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+  (eval $ac_compile) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+  (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null; then
+  if test -s conftest.err; then
+    ac_cpp_err=$ac_c_preproc_warn_flag
+    ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+  else
+    ac_cpp_err=
+  fi
+else
+  ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+    (
+      cat <<\_ASBOX
+## ------------------------------ ##
+## Report this to kaffe at kaffe.org ##
+## ------------------------------ ##
+_ASBOX
+    ) |
+      sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
 done
 
 
Index: kaffe/configure.ac
diff -u kaffe/configure.ac:1.85 kaffe/configure.ac:1.86
--- kaffe/configure.ac:1.85	Sun Oct 31 13:36:28 2004
+++ kaffe/configure.ac	Thu Nov 11 07:40:40 2004
@@ -1245,8 +1245,10 @@
 AC_CHECK_FUNCS([sched_get_priority_max])
 AC_CHECK_FUNCS([sched_get_priority_min])
 
-# pthread_attr_setschedpolicy in not implemented on NetBSD <= 1.6
-AC_CHECK_FUNCS([pthread_attr_setschedpolicy])
+dnl pthread_attr_setschedpolicy in not implemented on NetBSD <= 1.6
+dnl pthread_yield is not implemented on any systems.
+AC_CHECK_FUNCS([pthread_attr_setschedpolicy pthread_yield sched_yield])
+AC_CHECK_HEADERS(sched.h)
 
 dnl getifaddrs replacement for linux
 AC_REPLACE_FUNCS([getifaddrs])
Index: kaffe/config/config.h.in
diff -u kaffe/config/config.h.in:1.127 kaffe/config/config.h.in:1.128
--- kaffe/config/config.h.in:1.127	Sat Oct  9 22:17:58 2004
+++ kaffe/config/config.h.in	Thu Nov 11 07:40:44 2004
@@ -410,6 +410,9 @@
 /* Define to 1 if you have the <pthread.h> header file. */
 #undef HAVE_PTHREAD_H
 
+/* Define to 1 if you have the `pthread_yield' function. */
+#undef HAVE_PTHREAD_YIELD
+
 /* Define to 1 if you have the <pwd.h> header file. */
 #undef HAVE_PWD_H
 
@@ -433,6 +436,12 @@
 
 /* Define to 1 if you have the `sched_get_priority_min' function. */
 #undef HAVE_SCHED_GET_PRIORITY_MIN
+
+/* Define to 1 if you have the <sched.h> header file. */
+#undef HAVE_SCHED_H
+
+/* Define to 1 if you have the `sched_yield' function. */
+#undef HAVE_SCHED_YIELD
 
 /* Define to 1 if you have the `select' function. */
 #undef HAVE_SELECT
Index: kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h
diff -u kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.22 kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.23
--- kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h:1.22	Wed Nov  3 19:25:54 2004
+++ kaffe/kaffe/kaffevm/systems/unix-pthreads/thread-internal.h	Thu Nov 11 07:40:44 2004
@@ -11,11 +11,18 @@
 #ifndef __thread_internal_h
 #define __thread_internal_h
 
+#define __USE_GNU
 #include <pthread.h>
 #if defined(HAVE_SEMAPHORE_H)
 #include <semaphore.h>
 #endif /* defined(HAVE_SEMAPHORE_H) */
 
+#if !defined(HAVE_PTHREAD_YIELD) && defined(HAVE_SCHED_YIELD)
+#if defined(HAVE_SCHED_H)
+#include <sched.h>
+#endif // SCHED_H
+#endif // SCHED_YIELD && !PTHREAD_YIELD
+
 #include "gtypes.h"
 #include "threadData.h"
 #include "debug.h"
@@ -261,7 +268,11 @@
 static inline
 void jthread_yield (void)
 {
+#if defined(HAVE_PTHREAD_YIELD)
   pthread_yield();
+#elif defined(HAVE_SCHED_YIELD)
+  sched_yield();
+#endif
 }
 
 /**




More information about the kaffe mailing list