[m-rev.] for review: Uncomment foreign code definition for clock/3.
Sebastian Godelet
sebastian.godelet at outlook.com
Tue May 24 17:38:33 AEST 2016
Hello Paul,
> -----Original Message-----
> From: reviews [mailto:reviews-bounces at lists.mercurylang.org] On Behalf Of
> Paul Bone
> Sent: Tuesday, May 24, 2016 15:11
> To: Mercury Reviews <reviews at lists.mercurylang.org>
> Subject: [m-rev.] for review: Uncomment foreign code definition for clock/3.
>
> While I was working on temprary files I thought I needed this to help
> generate random filenames, but time/3 is better. Anyway I seem to have
Note that with time based file names you lose the security aspect of random file generation,
as this is a highly-predictable element.
> this working on Mono, but cannot test .NET.
>
> For review by Sebastian Godelet.
>
> I was working on something else and thought I needed to use clock/3 from
> time.m, so I tried to get it working
>
> It seems to be working but I cannot test it on .NET.
>
> ---
> Uncomment foreign code definition for clock/3.
>
> I noticed this code commented out in time.m, I guessed it'd be
> straightforward to make work and it seems to be working on mono. I cannot
> test it on .NET though.
>
> library/time.m:
> As above.
> ---
> library/time.m | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/library/time.m b/library/time.m index bf4caad..ea9c569 100644
> --- a/library/time.m
> +++ b/library/time.m
> @@ -264,16 +264,14 @@ time.clock(Result, !IO) :- "
> Ret = (MR_Integer) clock();
> ").
> -/* XXX need to add System.dll to the references list.
> :- pragma foreign_proc("C#",
> time.c_clock(Ret::out, _IO0::di, _IO::uo),
> [will_not_call_mercury, promise_pure, tabled_for_io], "{
> // XXX Ticks is long in .NET!
> - Ret = (int) System.Diagnostics.Process.GetCurrentProcess
> - .UserProcessorTime.Ticks;
> + Ret = (int) System.Diagnostics.Process.GetCurrentProcess().
Well the XXX is not addressed in this issue, the reason why ticks is using 64-bit integers
in .NET is that it is based on 100-nanosecond intervals, which get large pretty fast,
but I guess there is a reason why clock_t is a public alias for int (IMHO it should be an abstract type
depending on the backend).
The code change itself is fine.
> + UserProcessorTime.Ticks;
> }").
> -*/
> :- pragma foreign_proc("Java",
> time.c_clock(Ret::out, _IO0::di, _IO::uo),
> [will_not_call_mercury, promise_pure, tabled_for_io],
> --
> 2.8.1
>
> _______________________________________________
> reviews mailing list
> reviews at lists.mercurylang.org
> https://lists.mercurylang.org/listinfo/reviews
More information about the reviews
mailing list