[PATCH] Define CLOCKS_PER_SEC type to the type clock_t

H.J. Lu hjl.tools@gmail.com
Mon Jan 5 23:25:00 GMT 2015


On Mon, Jan 5, 2015 at 2:51 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, Jan 5, 2015 at 2:45 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Mon, Jan 5, 2015 at 2:32 PM, Paul Eggert <eggert@cs.ucla.edu> wrote:
>>> On 01/05/2015 12:46 PM, H.J. Lu wrote:
>>>>
>>>> C99 specifies that CLOCKS_PER_SEC is a constant expression
>>>
>>>
>>> A minor point (mostly for comments): CLOCKS_PER_SEC needn't be a constant
>>> expression.  Even POSIX doesn't require that: on the contrary, it explicitly
>>> warns you that it might not be a constant expression, even though it must
>>> evaluate to 1000000.
>>>
>>>> +       * bits/time2.h: New file.
>>>> +       * sysdeps/unix/sysv/linux/x86/bits/time2.h: Likewise.
>>>
>>>
>>> Wouldn't it be simpler and clearer to replace "# define CLOCKS_PER_SEC
>>> 1000000l" with "# define CLOCKS_PER_SEC ((clock_t) 1000000)"?  That way, one
>>> wouldn't need all these other little files running around.
>>
>> My copy of C99 has
>>
>> ---
>>       CLOCKS_PER_SEC
>>
>> which expands to a constant expression with type clock_t (described below)
>> that is the number per second of the value returned by the clock function.
>> ---
>>
>> Has it been changed?
>
> Yes, it does:
>
> http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_281.htm
>
> I will update my patch.

This is the updated patch.  OK to install?

Thanks.

-- 
H.J.
----
[BZ #17797]
* bits/time.h (CLOCKS_PER_SEC): Changed to ((clock_t) 1000000).
* sysdeps/unix/sysv/linux/bits/time.h (CLOCKS_PER_SEC): Likewise.
* time/clocktest.c (main): Replace %ld with %jd and cast to
intmax_t.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Define-CLOCKS_PER_SEC-type-to-the-type-clock_t.patch
Type: text/x-patch
Size: 3726 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20150105/9103edf1/attachment.bin>


More information about the Libc-alpha mailing list