* k5-thread.h: Only include sched.h if it's available.
(MAYBE_SCHED_YIELD): Only use sched_yield if sched.h and sched_yield are
available; if weak references are supported and sched_yield isn't available by
default, check for it at run time.
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16645
dc483132-0cff-0310-8789-
dd5450dbe970
+2004-08-07 Ken Raeburn <raeburn@mit.edu>
+
+ * configure.in: Look for sched.h and sched_yield.
+ * k5-thread.h: Only include sched.h if it's available.
+ (MAYBE_SCHED_YIELD): Only use sched_yield if sched.h and
+ sched_yield are available; if weak references are supported and
+ sched_yield isn't available by default, check for it at run time.
+
2004-08-05 Ken Raeburn <raeburn@mit.edu>
* k5-thread.h [HAVE_PTHREAD]: Include sched.h if
AC_PROG_AWK
AC_PROG_LEX
AC_C_CONST
-AC_CHECK_FUNCS(strdup setvbuf inet_ntoa inet_aton seteuid setresuid setreuid setegid setresgid setregid setsid flock fchmod chmod strftime strptime geteuid setenv unsetenv getenv gethostbyname2 getifaddrs getpwnam_r getpwuid_r gmtime_r localtime_r pthread_mutex_lock)
+AC_CHECK_FUNCS(strdup setvbuf inet_ntoa inet_aton seteuid setresuid setreuid setegid setresgid setregid setsid flock fchmod chmod strftime strptime geteuid setenv unsetenv getenv gethostbyname2 getifaddrs getpwnam_r getpwuid_r gmtime_r localtime_r pthread_mutex_lock sched_yield)
AC_CHECK_FUNCS( mkstemp)
AC_HEADER_STDARG
-AC_CHECK_HEADERS(unistd.h paths.h regex.h regexp.h regexpr.h fcntl.h memory.h ifaddrs.h sys/filio.h)
+AC_CHECK_HEADERS(unistd.h paths.h regex.h regexp.h regexpr.h fcntl.h memory.h ifaddrs.h sys/filio.h sched.h)
dnl
dnl Check what the return types for gethostbyname_r and getservbyname_r are.
dnl
#define k5_pthread_assert_unlocked(M) (0)
#define k5_pthread_assert_locked(M) (0)
-#ifdef DEBUG_THREADS_SLOW
+#if defined(DEBUG_THREADS_SLOW) && HAVE_SCHED_H && (HAVE_SCHED_YIELD || HAVE_PRAGMA_WEAK_REF)
# include <sched.h>
-# define MAYBE_SCHED_YIELD() ((void)sched_yield())
+# if !HAVE_SCHED_YIELD
+# pragma weak sched_yield
+# define MAYBE_SCHED_YIELD() ((void)((&sched_yield != NULL) ? sched_yield() : 0))
+# else
+# define MAYBE_SCHED_YIELD() ((void)sched_yield())
+# endif
#else
# define MAYBE_SCHED_YIELD() ((void)0)
#endif