From 1c22ef17053e096c18ed34e9772073c57ad3a7b5 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 8 Aug 2008 08:03:19 +0000 Subject: * configure.in (shutdown, sched_yield, pthread_attr_setinheritsched): check for Haiku. * eval_intern.h, io.c, thread_pthread.c: use autoconfisticated results. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- configure.in | 29 +++++++++++++++++++++-------- eval_intern.h | 2 +- io.c | 13 +++++-------- thread_pthread.c | 8 ++++---- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/configure.in b/configure.in index 173e593b76..47dadcac36 100644 --- a/configure.in +++ b/configure.in @@ -512,11 +512,14 @@ hpux*) LIBS="-lm $LIBS" human*) ac_cv_func_getpgrp_void=yes ac_cv_func_setitimer=no ;; -beos*) ac_cv_func_link=no - LIBS="$LIBS" # m lib is include in root under BeOS - ;; -haiku*) ac_cv_func_link=no - LIBS="$LIBS" # m lib is include in root under Haiku +beos*|haiku*) ac_cv_func_link=no + ac_cv_func_sched_yield=no + ac_cv_func_pthread_attr_setinheritsched=no + case "$target_os" in + beos*) ac_cv_header_net_socket_h=yes;; + haiku*) ac_cv_func_shutdown=no;; + esac + LIBS="$LIBS" # m lib is include in root under BeOS/Haiku ;; cygwin*) ;; mingw*) LIBS="-lshell32 -lws2_32 $LIBS" @@ -529,6 +532,7 @@ mingw*) LIBS="-lshell32 -lws2_32 $LIBS" ac_cv_header_sys_select_h=no ac_cv_header_sys_time_h=no ac_cv_header_sys_times_h=no + ac_cv_header_sys_socket_h=no ac_cv_func_times=yes ac_cv_func_waitpid=yes ac_cv_func_fsync=yes @@ -560,6 +564,7 @@ msdosdjgpp*) LIBS="-lm $LIBS" ac_cv_sizeof_rlim_t=4 ac_cv_func_fork=no ac_cv_func_setrlimit=no + ac_cv_header_sys_socket_h=no ;; bsdi*) LIBS="-lm $LIBS" AC_DEFINE(BROKEN_SETREUID, 1) @@ -603,6 +608,13 @@ alpha*) case "$target_os"::"$GCC" in esac ;; esac +ac_cv_header_net_socket_h=${ac_cv_header_net_socket_h=no} +if test "$ac_cv_header_net_socket_h" = yes; then + ac_cv_header_sys_socket_h=${ac_cv_header_sys_socket_h=no} +else + ac_cv_header_sys_socket_h=${ac_cv_header_sys_socket_h=yes} +fi + dnl Checks for header files. AC_HEADER_DIRENT AC_HEADER_STDC @@ -611,7 +623,8 @@ AC_CHECK_HEADERS(stdlib.h string.h unistd.h limits.h sys/file.h sys/ioctl.h sys/ fcntl.h sys/fcntl.h sys/select.h sys/time.h sys/times.h sys/param.h\ syscall.h pwd.h grp.h a.out.h utime.h memory.h direct.h sys/resource.h \ sys/mkdev.h sys/utime.h xti.h netinet/in_systm.h float.h ieeefp.h pthread.h \ - ucontext.h intrinsics.h langinfo.h locale.h sys/sendfile.h time.h) + ucontext.h intrinsics.h langinfo.h locale.h sys/sendfile.h time.h \ + net/socket.h sys/socket.h) dnl Check additional types. AC_CHECK_SIZEOF(rlim_t, 0, [ @@ -751,7 +764,7 @@ AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall chroot fsync getcwd setsid telldir seekdir fchmod cosh sinh tanh log2 round signbit\ setuid setgid daemon select_large_fdset setenv unsetenv\ mktime timegm clock_gettime gettimeofday\ - pread sendfile) + pread sendfile shutdown) AC_CACHE_CHECK(for __builtin_setjmp, ac_cv_func___builtin_setjmp, [AC_TRY_LINK([@%:@include @@ -1127,7 +1140,7 @@ if test x"$enable_pthread" = xyes; then else AC_MSG_WARN("Don't know how to find pthread library on your system -- thread support disabled") fi - AC_CHECK_FUNCS(nanosleep) + AC_CHECK_FUNCS(nanosleep sched_yield pthread_attr_setinheritsched) if test x"$ac_cv_func_nanosleep" = xno; then AC_CHECK_LIB(rt, nanosleep) if test x"$ac_cv_lib_rt_nanosleep" = xyes; then diff --git a/eval_intern.h b/eval_intern.h index 6fc0aecb3e..201604a5b9 100644 --- a/eval_intern.h +++ b/eval_intern.h @@ -75,7 +75,7 @@ char *strrchr(const char *, const char); #include #endif -#if defined(__BEOS__) && !defined(__HAIKU__) +#ifdef HAVE_NET_SOCKET_H #include #endif diff --git a/io.c b/io.c index ed3023b190..380755a599 100644 --- a/io.c +++ b/io.c @@ -25,12 +25,10 @@ #endif #include -#if !defined(_WIN32) && !defined(__DJGPP__) -#if defined(__BEOS__) && !defined(__HAIKU__) -# include -# else -# include -# endif +#if defined HAVE_NET_SOCKET_H +# include +#elif defined HAVE_SYS_SOCKET_H +# include #endif #if defined(MSDOS) || defined(__BOW__) || defined(__CYGWIN__) || defined(_WIN32) || defined(__human68k__) || defined(__EMX__) || defined(__BEOS__) @@ -201,7 +199,7 @@ static int max_file_descriptor = NOFILE; # endif #endif -#if defined(__HAIKU__) +#ifndef HAVE_SHUTDOWN #define shutdown(a,b) 0 #endif @@ -209,7 +207,6 @@ static int max_file_descriptor = NOFILE; #define is_socket(fd, path) rb_w32_is_socket(fd) #elif !defined(S_ISSOCK) #define is_socket(fd, path) 0 -#define shutdown(a,b) 0 #else static int is_socket(int fd, const char *path) diff --git a/thread_pthread.c b/thread_pthread.c index e9d94e7780..bf3dd96bad 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -119,10 +119,10 @@ native_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) #define native_cleanup_push pthread_cleanup_push #define native_cleanup_pop pthread_cleanup_pop -#ifdef __HAIKU__ -#define native_thread_yield() /* not available under Haiku */ +#ifdef HAVE_SCHED_YIELD +#define native_thread_yield() (void)sched_yield() #else -#define native_thread_yield() sched_yield() +#define native_thread_yield() ((void)0) #endif #ifndef __CYGWIN__ @@ -413,7 +413,7 @@ native_thread_create(rb_thread_t *th) CHECK_ERR(pthread_attr_setstacksize(&attr, stack_size)); #endif -#ifndef __HAIKU__ /* not yet available under Haiku */ +#ifdef HAVE_PTHREAD_ATTR_SETINHERITSCHED CHECK_ERR(pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED)); #endif CHECK_ERR(pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)); -- cgit v1.2.3