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

Julien Fischer juliensf at csse.unimelb.edu.au
Wed Jun 20 23:56:19 AEST 2012




On Wed, 20 Jun 2012, Paul Bone wrote:

> 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.

Could you at least leave things in a state where the runtime will compile
on systems that don't provide gettimeofday.

Julien.

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list