Just doing an emerge -ve world to find out atftp uses an old CLK_TCK macro. Attached find a patch to fix this. It should be backwards compatible, I only compiled it with atftp-0.7 however
Created attachment 82361 [details, diff] replace CLK_TCK with CLOCKS_PER_SEC just add this epatch and all should be well again. I think it's backwards compatible with somewhat older glibc's as this has been obsoleted a while ago.
Created attachment 82371 [details, diff] Patch that uses sysconf(_SC_CLK_TCK) as a replacement
Comment on attachment 82371 [details, diff] Patch that uses sysconf(_SC_CLK_TCK) as a replacement CLOCKS_PER_SEC is not the same as CLK_TCK I think. The man pages recommands using sysconf(_SC_CLK_TCK) instead of CLK_TCK and that's what this patch does
I don't know where that came from. But from http://www.chemie.fu-berlin.de/chemnet/use/info/libc/libc_17.html it says: Macro: int CLK_TCK This is an obsolete name for CLOCKS_PER_SEC.
And god forbid: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_clocks_per_sec.2c_.clk_tck.asp even tells us: The time in seconds is the value returned by the clock function, divided by CLOCKS_PER_SEC. CLK_TCK is equivalent, but considered obsolete. And even time.h (the old glibc version one) has CLK_TCK defined as # if defined __USE_POSIX && !defined __USE_XOPEN2K # ifndef CLK_TCK # define CLK_TCK CLOCKS_PER_SEC # endif # endif So I don't know what the sysconf(_SC_CLK_TCK) does, but I'm fairly confident that it should be CLOCKS_PER_SEC.
Well, that comes from the man pages : man 2 times tells us : times() returns the number of clock ticks that have elapsed since an arbitrary point in the past. ... The number of clock ticks per second can be obtained using sysconf(_SC_CLK_TCK); In POSIX-1996 the symbol CLK_TCK (defined in <time.h>) is mentioned as obsolescent. It is obsolete now. ... Note that clock(3) returns values of type clock_t that are not measured in clock ticks but in CLOCKS_PER_SEC. and a 'man clock' confirms that. So if the info comes from the function times, use sysconf(...), if the info comes from clock, use CLOCKS_PER_SEC And theses two values are quite different : tnt@hitomi ~ $ cat test.c #include <stdio.h> #include <unistd.h> #include <sys/times.h> #include <time.h> int main(int argc, char *argv[]) { printf("%d %d\n", sysconf(_SC_CLK_TCK), CLOCKS_PER_SEC); } tnt@hitomi ~ $ ./test 100 1000000
Well until someone stops bye that knows this thing exactly: as I mentioned, the pre 2.4 glibc has: # if defined __USE_POSIX && !defined __USE_XOPEN2K # ifndef CLK_TCK # define CLK_TCK CLOCKS_PER_SEC # endif # endif so changing CLK_TCK to CLOCKS_PER_SEC you should have a identical binary. with _CLK_TCK you obvisouly won't. Again, I don't know what it should be, I haven't studied the code, but this seemed the most sensible to me, as you don't want binary un-identical (is that a word?) code, when only replasing an obsolete macro.
I just tried the following test on a glibc 2.3.5 machine (see below) and that shows that sysconf(_SC_CLK_TCK) = 100 CLOCKS_PER_SEC = 1000000 CLK_TCK = 100 Yes, the binary will be different that's because there is no longer any static/compile time value for CLK_TCK ... now you have to make a function call to get it ... Try the little apps below by yourself on a pre-2.4 machine ... tnt@ritsuko ~ $ /lib/libc.so.6 GNU C Library stable release version 2.3.5, by Roland McGrath et al. Copyright (C) 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Compiled by GNU CC version 3.4.4 (Gentoo 3.4.4-r1, ssp-3.4.4-1.0, pie-8.7.8). Compiled on a Linux 2.6.11 system on 2005-12-31. Available extensions: GNU libio by Per Bothner crypt add-on version 2.1 by Michael Glad and others linuxthreads-0.10 by Xavier Leroy The C stubs add-on version 2.1.2. GNU Libidn by Simon Josefsson BIND-8.2.3-T5B libthread_db work sponsored by Alpha Processor Inc NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk Thread-local storage support included. For bug reporting instructions, please see: <http://www.gnu.org/software/libc/bugs.html>. tnt@ritsuko ~ $ cat test.c #include <stdio.h> #include <unistd.h> #include <sys/times.h> #include <time.h> int main(int argc, char *argv[]) { printf("%d %d %d\n", sysconf(_SC_CLK_TCK), CLOCKS_PER_SEC, CLK_TCK); } tnt@ritsuko ~ $ ./test 100 1000000 100
I agree with the results of the test program. I just wonder why even the MSDN site (which is google's first hit on CLK_TCK) claims to use CLOCKS_PER_SEC. Even time.h says defines it as so. Weird. Well as long as it's fixed, it's all good right? All we need is an updated ebuild to get merged in and we can mark it as closed.
Could you please modify the patch to have only one sysconf call and cache the result - this should be safe, but correct me if I'm wrong.
Ok, I implemented it myself, and stuck it in.