[m-rev.] diff: Use gettimeofday() for Mercury's ThreadScope support.

Paul Bone pbone at csse.unimelb.edu.au
Wed Jun 20 23:56:02 AEST 2012


On Wed, Jun 20, 2012 at 11:25:13PM +1000, Julien Fischer wrote:
> 
> On Wed, 20 Jun 2012, Paul Bone wrote:
> 
> >Index: runtime/mercury_threadscope.c
> >===================================================================
> >RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_threadscope.c,v
> >retrieving revision 1.20
> >diff -u -r1.20 mercury_threadscope.c
> >--- runtime/mercury_threadscope.c	19 Jun 2012 11:08:16 -0000	1.20
> >+++ runtime/mercury_threadscope.c	20 Jun 2012 12:59:41 -0000
> 
> >+static Time
> >+gettimeofday_nsecs(void)
> >+{
> >+    struct timeval      tv;
> >+
> >+    if (0 != gettimeofday(&tv, NULL)) {
> >+        perror("gettimeofday()");
> >+        /*
> >+        ** Return a stupid value generating an obviously bad logfile
> >+        ** rather than crashing a program that may otherwise work.
> >+        */
> >+        return 0;
> >    }
> >+    return (Time)tv.tv_sec * 1000000000 +
> >+            (Time)tv.tv_usec * 1000;
> >}
> 
> The body of that function should be protected by
> 
>    #if defined(MR_HAVE_GETTIMEOFDAY)
> 
> (unless that is implied by the surrouding context.)

I'll make another change later to make threadscope depend on gettimeofday.  If
TSCs are unreliable and detecting this is difficult, therefore we use
gettimeofday by default.  then Threadscope doesn't make any sense without
gettimeofday().

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20120620/3bc76762/attachment.sig>


More information about the reviews mailing list