Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CLK_TCK or CLOCKS_PER_SEC?

573 views
Skip to first unread message

David Swofford

unread,
Feb 28, 1992, 4:11:02 PM2/28/92
to
Sorry if this is a FAQ but I don't read this group regularly and
I can't find a FAQ list.

I've got a couple of books that claim to describe the ANSI C
headers; both say that CLK_TCK defines the number of clock
ticks per second. But in the RS/6000 (AIX) headers, CLK_TCK
is replaced by CLOCKS_PER_SEC. On some other systems, the
two constants are defined equivalently. Which is the correct
name for this constant/macro in ANSI C?
--
David L. Swofford Phone: (217)244-6959
Illinois Natural History Survey FAX: (217)333-4949
607 E. Peabody Drive BITNET: DAVESWOF@UIUCVMD
Champaign, Illinois 61820 USA Internet: swof...@uxh.cso.uiuc.edu

Eric W. Ziegenfus

unread,
Feb 28, 1992, 7:34:57 PM2/28/92
to

>Sorry if this is a FAQ but I don't read this group regularly and
>I can't find a FAQ list.

>I've got a couple of books that claim to describe the ANSI C
>headers; both say that CLK_TCK defines the number of clock
>ticks per second. But in the RS/6000 (AIX) headers, CLK_TCK
>is replaced by CLOCKS_PER_SEC. On some other systems, the
>two constants are defined equivalently. Which is the correct
>name for this constant/macro in ANSI C?

In section 4.12.1 of the standard it says:

CLOCKS_PER_SEC

which is the number per second of the value returned by the clock
function.

--

/---------------------------------------------\
| INTERNET: zieg...@moravian.edu |
| UUCP: ...!rutgers!lafcol!batman!ziegenfE |
\_____________________________________________/

Stan Brown

unread,
Feb 29, 1992, 11:12:59 PM2/29/92
to
In article <1992Feb28.2...@ux1.cso.uiuc.edu> swof...@uxh.cso.uiuc.edu (David Swofford ) writes:
>Sorry if this is a FAQ but I don't read this group regularly and
>I can't find a FAQ list.
>
>I've got a couple of books that claim to describe the ANSI C
>headers; both say that CLK_TCK defines the number of clock
>ticks per second. But in the RS/6000 (AIX) headers, CLK_TCK
>is replaced by CLOCKS_PER_SEC. On some other systems, the
>two constants are defined equivalently. Which is the correct
>name for this constant/macro in ANSI C?

Sec 4.12.1 of the Standard says CLOCK_PER_SEC.

(diatribe mode on)

I suppose I shouldn't be surprised by the number of persons who think
that looking at books about the standard is a substitute for looking at
the standard, but I am.

For the record, there is not a book out that is 100% accurate in its
description of the standard, not even K&R2 or H&S. At least once a
month, in this group or in comp.lang.c, we see one of the 'gurus' answer
a question by pointing out an error in the questioner's reference book.

Yes, the standard costs a little more than most other books about C.
But in the long run it will save you time because you'll get the right
answers the first time.

To forestall the inevitable, here is an extract from the FAQ list for
comp.lang.c, by Steve Summit:

4.2: How can I get a copy of the Standard?

A: Copies are available from

American National Standards Institute
1430 Broadway
New York, NY 10018 USA
(+1) 212 642 4900
or
Global Engineering Documents
2805 McGaw Avenue
Irvine, CA 92714 USA
(+1) 714 261 1455
(800) 854 7179 (U.S. & Canada)

The cost from ANSI is $50.00, plus $6.00 shipping. Quantity
discounts are available. (Note that ANSI derives revenues to
support its operations from the sale of printed standards, so
electronic copies are _not_ available.)


--
Stan Brown, Oak Road Systems, Cleveland, Ohio, USA br...@ncoast.org
George goes to the You-Bet-Your-Life computer dating service. He asks
for someone who is white, not very talkative, comfortable in fur, yet
disdainful of city life. The computer sends him a polar bear.

Steve Clamage

unread,
Mar 2, 1992, 11:38:44 AM3/2/92
to
swof...@uxh.cso.uiuc.edu (David Swofford ) writes:

>I've got a couple of books that claim to describe the ANSI C
>headers; both say that CLK_TCK defines the number of clock
>ticks per second. But in the RS/6000 (AIX) headers, CLK_TCK
>is replaced by CLOCKS_PER_SEC. On some other systems, the
>two constants are defined equivalently. Which is the correct
>name for this constant/macro in ANSI C?

Early releases of the Draft Standard listed CLK_TCK as the macro
name. The final revision of the Standard changed the name to
CLOCKS_PER_SEC.

Some implementations were written to the earlier draft specification.
When the change was made, some implementations supported both
versions of the macro name so as not to break programs written for
earlier releases. The books you checked either predated the
final version of the Standard, or did not get corrected.

There is a similar situation with "errno". Early Draft Standards
required it to be declared volatile. This was later changed. Some
implementations still declare "errno" (incorrectly) as volatile.
--

Steve Clamage, TauMetric Corp, st...@taumet.com
Vice Chair, ANSI C++ Committee, X3J16

Norman Diamond

unread,
Mar 2, 1992, 11:27:34 PM3/2/92
to
In article <1992Mar2.1...@taumet.com> st...@taumet.com (Steve Clamage) writes:
>There is a similar situation with "errno". Early Draft Standards
>required it to be declared volatile. This was later changed. Some
>implementations still declare "errno" (incorrectly) as volatile.

Why is it incorrect for an implementation to declare errno as volatile?

If it were a type, then it would be incorrect for an implementation to
reject a user's program that added the volatile qualifier to this type
when declaring a user's variable. But errno is not a type, and does not
have this hypothetical potential pitfall.

If it were a macro, then a program would be able to stringize the macro
definition and might be able to find out if the resulting modifiable
lvalue is declared as volatile. In the past, a program similar to this
has been the subject of controversy, concerning whether the program was
strictly conforming or not. However, in the case of errno, it is a moot
point. In fact errno does not have to be a macro, so a strictly conforming
program cannot stringize it.

I do not see how a strictly conforming program would be affected, or would
be able to detect, if the implementation makes errno volatile.
--
Norman Diamond dia...@jit081.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
"Yeah -- bad wiring. That was probably it. Very bad."

Hendrik Boom

unread,
Mar 4, 1992, 9:53:12 AM3/4/92
to
In article <1992Mar1.0...@NCoast.ORG> br...@NCoast.ORG (Stan Brown) writes:
>In article <1992Feb28.2...@ux1.cso.uiuc.edu> swof...@uxh.cso.uiuc.edu (David Swofford ) writes:
> The cost from ANSI is $50.00, plus $6.00 shipping. Quantity
> discounts are available. (Note that ANSI derives revenues to
> support its operations from the sale of printed standards, so
> electronic copies are _not_ available.)

As I heard it, electronic documents are easy to modify,
and they didn't want a lot of near-standards to appear looking
for all the world like the real standard.


--
Try one or more of the following addresses to reply.
hen...@vedge.uucp
iros1!vedge!hendrik

0 new messages