public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* CLK_TCK undefined
@ 2023-10-16 13:15 Andrea Monaco
2023-10-18 9:55 ` Florian Weimer
2023-10-18 11:19 ` Andreas Schwab
0 siblings, 2 replies; 8+ messages in thread
From: Andrea Monaco @ 2023-10-16 13:15 UTC (permalink / raw)
To: glibc-bugs
The constant CLK_TCK seems not defined in my glibc headers, although
it's required by C89 (according to the draft I'm using). Is that
intended?
Andrea Monaco
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: CLK_TCK undefined
2023-10-16 13:15 CLK_TCK undefined Andrea Monaco
@ 2023-10-18 9:55 ` Florian Weimer
2023-10-18 12:45 ` Adhemerval Zanella Netto
2023-10-18 11:19 ` Andreas Schwab
1 sibling, 1 reply; 8+ messages in thread
From: Florian Weimer @ 2023-10-18 9:55 UTC (permalink / raw)
To: Andrea Monaco via Glibc-bugs; +Cc: Andrea Monaco
* Andrea Monaco via Glibc-bugs:
> The constant CLK_TCK seems not defined in my glibc headers, although
> it's required by C89 (according to the draft I'm using). Is that
> intended?
We have a conditional definition in <time.h>:
#if (!defined __STRICT_ANSI__ || defined __USE_POSIX) \
&& !defined __USE_XOPEN2K
/* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK
presents the real value for clock ticks per second for the system. */
extern long int __sysconf (int);
# define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */
#endif
Maybe your choice of feature selection macros suppresses the definition?
Thanks,
Florian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: CLK_TCK undefined
2023-10-16 13:15 CLK_TCK undefined Andrea Monaco
2023-10-18 9:55 ` Florian Weimer
@ 2023-10-18 11:19 ` Andreas Schwab
1 sibling, 0 replies; 8+ messages in thread
From: Andreas Schwab @ 2023-10-18 11:19 UTC (permalink / raw)
To: Andrea Monaco via Glibc-bugs; +Cc: Andrea Monaco
On Okt 16 2023, Andrea Monaco via Glibc-bugs wrote:
> it's required by C89 (according to the draft I'm using).
Where does it say that?
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: CLK_TCK undefined
2023-10-18 9:55 ` Florian Weimer
@ 2023-10-18 12:45 ` Adhemerval Zanella Netto
2023-10-19 7:00 ` Andrea Monaco
0 siblings, 1 reply; 8+ messages in thread
From: Adhemerval Zanella Netto @ 2023-10-18 12:45 UTC (permalink / raw)
To: Florian Weimer, Andrea Monaco via Glibc-bugs; +Cc: Andrea Monaco
On 18/10/23 06:55, Florian Weimer via Glibc-bugs wrote:
> * Andrea Monaco via Glibc-bugs:
>
>> The constant CLK_TCK seems not defined in my glibc headers, although
>> it's required by C89 (according to the draft I'm using). Is that
>> intended?
>
> We have a conditional definition in <time.h>:
>
> #if (!defined __STRICT_ANSI__ || defined __USE_POSIX) \
> && !defined __USE_XOPEN2K
> /* Even though CLOCKS_PER_SEC has such a strange value CLK_TCK
> presents the real value for clock ticks per second for the system. */
> extern long int __sysconf (int);
> # define CLK_TCK ((__clock_t) __sysconf (2)) /* 2 is _SC_CLK_TCK */
> #endif
>
> Maybe your choice of feature selection macros suppresses the definition?
It was removed by POSIX 2001 [1]:
Issue 6
The symbolic name CLK_TCK is removed. Application usage is added describing
how its equivalent functionality can be obtained using sysconf().
You need to specify an old POSIX version to actually use it:
$ cat t.c
#include <time.h>
#include <stdio.h>
#include <stdint.h>
int main (int argc, char *argv[])
{
printf ("%jd\n", (intmax_t) CLK_TCK);
return 0;
}
$ gcc -Wall t.c -o t -D_POSIX_C_SOURCE=200112L
t.c: In function ‘main’:
t.c:7:31: error: ‘CLK_TCK’ undeclared (first use in this function)
7 | printf ("%jd\n", (intmax_t) CLK_TCK);
| ^~~~~~~
t.c:7:31: note: each undeclared identifier is reported only once for each function it appears in
$ gcc -Wall t.c -o t -D_POSIX_C_SOURCE=199506
$ ./t
100
[1] https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: CLK_TCK undefined
2023-10-18 12:45 ` Adhemerval Zanella Netto
@ 2023-10-19 7:00 ` Andrea Monaco
2023-10-19 7:55 ` Andreas Schwab
0 siblings, 1 reply; 8+ messages in thread
From: Andrea Monaco @ 2023-10-19 7:00 UTC (permalink / raw)
To: Adhemerval Zanella Netto; +Cc: fweimer, glibc-bugs, schwab
> It was removed by POSIX 2001 [1]:
I understand. But still, it was just a harmless constant, so removing
it is quite strong in my opinion, since glibc usually doesn't just
follow POSIX blindly.
> Maybe your choice of feature selection macros suppresses the
> definition?
I don't define any feature macros, but I pass the -ansi option. Also, I
don't know if autoconf adds other definitions.
> Where does it say that?
http://jfxpt.com/library/c89-draft.html, search for CLK_TCK.
Andrea Monaco
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: CLK_TCK undefined
2023-10-19 7:00 ` Andrea Monaco
@ 2023-10-19 7:55 ` Andreas Schwab
2023-10-19 9:42 ` Andrea Monaco
0 siblings, 1 reply; 8+ messages in thread
From: Andreas Schwab @ 2023-10-19 7:55 UTC (permalink / raw)
To: Andrea Monaco; +Cc: Adhemerval Zanella Netto, fweimer, glibc-bugs
On Okt 19 2023, Andrea Monaco wrote:
> http://jfxpt.com/library/c89-draft.html, search for CLK_TCK.
In the final standard it has been replaced by CLOCKS_PER_SEC.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: CLK_TCK undefined
2023-10-19 7:55 ` Andreas Schwab
@ 2023-10-19 9:42 ` Andrea Monaco
2023-10-19 18:02 ` Joseph Myers
0 siblings, 1 reply; 8+ messages in thread
From: Andrea Monaco @ 2023-10-19 9:42 UTC (permalink / raw)
To: Andreas Schwab; +Cc: adhemerval.zanella, fweimer, glibc-bugs
> In the final standard it has been replaced by CLOCKS_PER_SEC.
Really? Have you got a source?
Andrea Monaco
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: CLK_TCK undefined
2023-10-19 9:42 ` Andrea Monaco
@ 2023-10-19 18:02 ` Joseph Myers
0 siblings, 0 replies; 8+ messages in thread
From: Joseph Myers @ 2023-10-19 18:02 UTC (permalink / raw)
To: Andrea Monaco; +Cc: Andreas Schwab, fweimer, glibc-bugs
On Thu, 19 Oct 2023, Andrea Monaco via Glibc-bugs wrote:
> > In the final standard it has been replaced by CLOCKS_PER_SEC.
>
> Really? Have you got a source?
https://nvlpubs.nist.gov/nistpubs/Legacy/FIPS/fipspub160.pdf#page=185
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-10-19 18:02 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-16 13:15 CLK_TCK undefined Andrea Monaco
2023-10-18 9:55 ` Florian Weimer
2023-10-18 12:45 ` Adhemerval Zanella Netto
2023-10-19 7:00 ` Andrea Monaco
2023-10-19 7:55 ` Andreas Schwab
2023-10-19 9:42 ` Andrea Monaco
2023-10-19 18:02 ` Joseph Myers
2023-10-18 11:19 ` Andreas Schwab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).