[m-rev.] for review: Implementation of time library in Java
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Dec 15 14:47:25 AEDT 2003
On 15-Dec-2003, James Goddard <goddardjames at yahoo.com> wrote:
> Implemented some library functions for the time library in java.
...
> +:- pragma foreign_proc("Java", time__clock(Ret::out, _IO0::di, _IO::uo),
> + [will_not_call_mercury, promise_pure, tabled_for_io],
> +"
> + // System.currentTimeMillis() returns a long (64 bit) integer which
> + // represents the number of milliseconds since
> + // January 1, 1970, 00:00:00 GMT.
> + // This is cast to type int, discarding the high order bits, which is
> + // ok since time__clock/3's base time is defined as being arbitrary.
>
> + Ret = (int) System.currentTimeMillis();
time__clock should return processor time, i.e. CPU usage, not wall clock time.
Apparently there is no way of doing this in Java short of using JNI or
the like. So I suggest you leave this unimplemented for now, and just
put an XXX comment explaining the problem. You can come back to this
once everything else is done.
> +:- pragma foreign_proc("Java", time__clk_tck = (Ret::out),
> + [will_not_call_mercury, promise_pure],
> +"
> + // Java only supports millisecond precision.
> + Ret = 1000;
> +").
The time__clk_tck function is only used for interpreting the results of the
time__times procedure, which is unimplemented for the same reason as
time__clock. It doesn't really make sense to implement this without
implementing time__times. So I recommend leaving this unimplemented
for now.
> +:- pragma foreign_proc("Java",
> + time__c_localtime(Time::in, Yr::out, Mnt::out, MD::out, Hrs::out,
> + Min::out, Sec::out, YD::out, WD::out, N::out),
> + [will_not_call_mercury, promise_pure],
> +"
...
> + default:
> + throw new RuntimeException(
> + "DAY_OF_WEEK undefined in time__c_local_time");
s/DAY_OF_WEEK undefined/invalid DAY_OF_WEEK/
As discussed in person, the computation/use of N and DST_OFFSET in
localtime, gmtime, and mktime is not correct.
Please post another diff when you've addressed these review comments.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list