[commit: ghc] master: Fix FP_CHECK_TIMER_CREATE when cross-compiling (c0017bd)

Ian Lynagh <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/c0017bd23db0255bc401867abac16725de18bdaa

>---------------------------------------------------------------

commit c0017bd23db0255bc401867abac16725de18bdaa
Author: Ian Lynagh <[email protected]>
Date:   Tue Nov 13 23:13:13 2012 +0000

    Fix FP_CHECK_TIMER_CREATE when cross-compiling
    
    If we are cross-compiling, we assume that if timer_create exists then
    it works.

>---------------------------------------------------------------

 aclocal.m4 |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index 9de541b..d014b3a 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1452,9 +1452,18 @@ AC_SUBST([ProjectPatchLevel])
 # here, because there exist partially-working implementations of
 # timer_create() in certain versions of Linux (see bug #1933).
 #
-AC_DEFUN([FP_CHECK_TIMER_CREATE],
-if test "$cross_compiling" = "no" ; then
-  [AC_CACHE_CHECK([for a working timer_create(CLOCK_REALTIME)], 
+AC_DEFUN([FP_CHECK_TIMER_CREATE],[
+AC_CHECK_FUNC([timer_create],[HAVE_timer_create=yes],[HAVE_timer_create=no])
+
+if test "$HAVE_timer_create" = "yes"
+then
+  if test "$cross_compiling" = "yes"
+  then
+    # We can't test timer_create when we're cross-compiling, so we
+    # optimistiaclly assume that it actually works properly.
+    AC_DEFINE([USE_TIMER_CREATE], 1,  [Define to 1 if we can use timer_create(CLOCK_PROCESS_CPUTIME_ID,...)])
+  else
+  AC_CACHE_CHECK([for a working timer_create(CLOCK_REALTIME)], 
     [fptools_cv_timer_create_works],
     [AC_TRY_RUN([
 #include <stdio.h>
@@ -1577,6 +1586,7 @@ case $fptools_cv_timer_create_works in
     yes) AC_DEFINE([USE_TIMER_CREATE], 1, 
                    [Define to 1 if we can use timer_create(CLOCK_PROCESS_CPUTIME_ID,...)]);;
 esac
+  fi
 fi
 ])
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.