[m-rev.] For review: implement time.c_clk_tck/0 for Java

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Feb 12 10:36:49 AEDT 2004


On 11-Feb-2004, James Goddard <goddardjames at yahoo.com> wrote:
> Index: ../java/runtime/Native.c
...
> +#if defined(MR_HAVE_SYSCONF) && defined(_SC_CLK_TCK)
> +	return (MR_Integer) sysconf(_SC_CLK_TCK);
> +#elif defined(CLK_TCK)
> +	/*
> +	** If sysconf is not available, try using the (obsolete) macro CLK_TCK.
> +	*/
> +	return (MR_Integer) CLK_TCK;
> +#else
> +	return -1;
> +#endif

The code there duplicates some code in time.m.
It would be a good idea to at least put a comment in both places saying
that the code is duplicated in the other place.
Or alternatively, to define the code in a macro in the Mercury
runtime, so that it can be shared between both places.
This is important in case this code needs to be modified during
later maintenance.

Oh, wait, there already _is_ a macro in the Mercury runtime for this:
it's called MR_CLOCK_TICKS_PER_SECOND, and it is defined in mercury_timing.h.
That one is defined slightly differently -- it uses "HZ" if that is defined --
but it seems to be intended to do exactly the same thing.

So it would be better to replace this code with

	#if defined(MR_CLOCK_TICKS_PER_SECOND)
	  return MR_CLOCK_TICKS_PER_SECOND;
	#else
	  return -1;
	#endif

(both here and in time.m).

Otherwise that looks fine.

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