diff mbox

Go patch committed: Update Go library

Message ID yddfwie4mtj.fsf@manam.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth Oct. 27, 2011, 12:54 p.m. UTC
Ian,

> This patch updates the Go library to the most recent weekly release.  I
> think the only potential portability issues here are the use of the
> ipv6_mreq struct.  I'm not entirely sure the new exp/terminal package is
> portable, but it might be.

the only issue I've found on Solaris is the use of pthread_yield, which
doesn't exist even on Solaris 11.  The following patch checks for this,
and falls back to thr_yield if available.

It allowed i386-pc-solaris2.1[01] bootstraps to complete without
regressions.

	Rainer


2011-10-27  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* configure.ac: Check for <thread.h>.
	Check for pthread_yield, thr_yield.
	* configure: Regenerate.
	* config.h.in: Regenerate.
	* runtime/yield.c [HAVE_THREAD_H]: Include <thread.h>.
	(runtime_osyield): Call thr_yield or pthread_yield if available.

Comments

Ian Lance Taylor Oct. 27, 2011, 4:45 p.m. UTC | #1
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> the only issue I've found on Solaris is the use of pthread_yield, which
> doesn't exist even on Solaris 11.  The following patch checks for this,
> and falls back to thr_yield if available.

Thanks--but is sched_yield available?  I realized that I misread the man
page; it looks like sched_yield is more portable than pthread_yield.

Ian
Rainer Orth Oct. 27, 2011, 4:58 p.m. UTC | #2
Ian Lance Taylor <iant@google.com> writes:

> Thanks--but is sched_yield available?  I realized that I misread the man
> page; it looks like sched_yield is more portable than pthread_yield.

It is, but before Solaris 11 it only lives in librt.

	Rainer
diff mbox

Patch

diff --git a/libgo/configure.ac b/libgo/configure.ac
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -442,7 +442,7 @@  no)
   ;;
 esac
 
-AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h)
+AC_CHECK_HEADERS(sys/mman.h syscall.h sys/epoll.h sys/ptrace.h sys/syscall.h sys/user.h sys/utsname.h sys/select.h sys/socket.h net/if.h thread.h)
 
 AC_CHECK_HEADERS([linux/filter.h linux/netlink.h linux/rtnetlink.h], [], [],
 [#ifdef HAVE_SYS_SOCKET_H
@@ -452,7 +452,7 @@  AC_CHECK_HEADERS([linux/filter.h linux/n
 
 AM_CONDITIONAL(HAVE_SYS_MMAN_H, test "$ac_cv_header_sys_mman_h" = yes)
 
-AC_CHECK_FUNCS(srandom random strerror_r strsignal wait4 mincore setenv)
+AC_CHECK_FUNCS(srandom random strerror_r strsignal wait4 mincore setenv pthread_yield thr_yield)
 AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes)
 AM_CONDITIONAL(HAVE_WAIT4, test "$ac_cv_func_wait4" = yes)
 
diff --git a/libgo/runtime/yield.c b/libgo/runtime/yield.c
--- a/libgo/runtime/yield.c
+++ b/libgo/runtime/yield.c
@@ -9,6 +9,9 @@ 
 #include <stddef.h>
 #include <sys/types.h>
 #include <sys/time.h>
+#ifdef HAVE_THREAD_H
+#include <thread.h>
+#endif
 #include <pthread.h>
 #include <unistd.h>
 
@@ -38,7 +41,11 @@  runtime_procyield (uint32 cnt)
 void
 runtime_osyield (void)
 {
+#ifdef HAVE_THR_YIELD
+  thr_yield ();
+#elif defined(HAVE_PTHREAD_YIELD)
   pthread_yield ();
+#endif
 }
 
 /* Sleep for some number of microseconds.  */