Ticket #2883: patch-ghc6

File patch-ghc6, 4.0 KB (added by sthibaul, 5 years ago)

Autodetect failing setitimer

Line 
1diff -ur ghc6-6.8.2/configure.ac ghc6-6.8.2-mine/configure.ac
2--- ghc6-6.8.2/configure.ac     2007-12-10 19:11:32.000000000 +0100
3+++ ghc6-6.8.2-mine/configure.ac        2008-12-20 11:53:05.000000000 +0100
4@@ -1078,6 +1078,17 @@
5 dnl ** check for more functions
6 dnl ** The following have been verified to be used in ghc/, but might be used somewhere else, too.
7 AC_CHECK_FUNCS([getclock getrusage gettimeofday setitimer siginterrupt sysconf times ctime_r])
8+AC_TRY_RUN([
9+#include <sys/types.h>
10+#include <sys/time.h>
11+int main(void) {
12+  struct itimerval tval;
13+  tval.it_value.tv_sec = 1;
14+  tval.it_value.tv_usec = 0;
15+  tval.it_interval = tval.it_value;
16+  return setitimer(ITIMER_VIRTUAL, &tval, (void*)0) != 0;
17+}
18+],[AC_DEFINE([HAVE_SETITIMER_VIRTUAL], [1], [Define to 1 if setitimer accepts ITIMER_VIRTUAL, 0 else.])])
19 dnl ** On OS X 10.4 (at least), time.h doesn't declare ctime_r if
20 dnl ** _POSIX_C_SOURCE is defined
21 AC_CHECK_DECLS([ctime_r], , ,
22diff -ur ghc6-6.8.2/configure ghc6-6.8.2-mine/configure
23--- ghc6-6.8.2/configure        2007-12-10 19:27:08.000000000 +0100
24+++ ghc6-6.8.2-mine/configure   2008-12-20 11:53:44.000000000 +0100
25@@ -18129,6 +18129,66 @@
26 fi
27 done
28 
29+if test "$cross_compiling" = yes; then
30+  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
31+See \`config.log' for more details." >&5
32+echo "$as_me: error: cannot run test program while cross compiling
33+See \`config.log' for more details." >&2;}
34+   { (exit 1); exit 1; }; }
35+else
36+  cat >conftest.$ac_ext <<_ACEOF
37+/* confdefs.h.  */
38+_ACEOF
39+cat confdefs.h >>conftest.$ac_ext
40+cat >>conftest.$ac_ext <<_ACEOF
41+/* end confdefs.h.  */
42+
43+#include <sys/types.h>
44+#include <sys/time.h>
45+int main(void) {
46+  struct itimerval tval;
47+  tval.it_value.tv_sec = 1;
48+  tval.it_value.tv_usec = 0;
49+  tval.it_interval = tval.it_value;
50+  return setitimer(ITIMER_VIRTUAL, &tval, (void*)0) != 0;
51+}
52+
53+_ACEOF
54+rm -f conftest$ac_exeext
55+if { (ac_try="$ac_link"
56+case "(($ac_try" in
57+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
58+  *) ac_try_echo=$ac_try;;
59+esac
60+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
61+  (eval "$ac_link") 2>&5
62+  ac_status=$?
63+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
64+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
65+  { (case "(($ac_try" in
66+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
67+  *) ac_try_echo=$ac_try;;
68+esac
69+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
70+  (eval "$ac_try") 2>&5
71+  ac_status=$?
72+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
73+  (exit $ac_status); }; }; then
74+
75+cat >>confdefs.h <<\_ACEOF
76+#define HAVE_SETITIMER_VIRTUAL 1
77+_ACEOF
78+
79+else
80+  echo "$as_me: program exited with status $ac_status" >&5
81+echo "$as_me: failed program was:" >&5
82+sed 's/^/| /' conftest.$ac_ext >&5
83+
84+fi
85+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
86+fi
87+
88+
89 echo "$as_me:$LINENO: checking whether ctime_r is declared" >&5
90 echo $ECHO_N "checking whether ctime_r is declared... $ECHO_C" >&6
91 if test "${ac_cv_have_decl_ctime_r+set}" = set; then
92diff -ur ghc6-6.8.2/mk/config.h.in ghc6-6.8.2-mine/mk/config.h.in
93--- ghc6-6.8.2/mk/config.h.in   2007-12-10 19:27:08.000000000 +0100
94+++ ghc6-6.8.2-mine/mk/config.h.in      2008-12-20 11:12:59.000000000 +0100
95@@ -167,6 +167,9 @@
96 /* Define to 1 if you have the `setitimer' function. */
97 #undef HAVE_SETITIMER
98 
99+/* Define to 1 if setitimer accepts ITIMER_VIRTUAL, 0 else. */
100+#undef HAVE_SETITIMER_VIRTUAL
101+
102 /* Define to 1 if you have the `siginterrupt' function. */
103 #undef HAVE_SIGINTERRUPT
104 
105diff -ur ghc6-6.8.2/rts/posix/Itimer.c ghc6-6.8.2-mine/rts/posix/Itimer.c
106--- ghc6-6.8.2/rts/posix/Itimer.c       2007-12-10 19:11:32.000000000 +0100
107+++ ghc6-6.8.2-mine/rts/posix/Itimer.c  2008-12-20 11:31:53.000000000 +0100
108@@ -80,7 +80,7 @@
109 
110 #elif defined(HAVE_SETITIMER)
111 
112-#  ifdef THREADED_RTS
113+#  if defined(THREADED_RTS) || !defined(HAVE_SETITIMER_VIRTUAL)
114 //   Oh dear, we have to use SIGALRM if there's no timer_create and
115 //   we're using the THREADED_RTS.  This leads to problems, see bug #850.
116 #    define ITIMER_SIGNAL  SIGALRM