Bug#47035: setitimer lacks feature
Package: libc0.2
Version: N/A
Hello,
(this is a repost, to get it in the BTS.)
(want to get binutils off my plate by fixing the hertz.c code for us.)
Ok, sysdeps/mach/hurd/setitimer.c is unfinished code (ITIMER_PROF and
ITIMER_VIRTUAL are not implemented at all), however, there is also a small
feature missing that would be extremely useful for binutils/gprof:
Something like the following code is used to measure the hertz value:
====================================================================
#include <sys/time.h>
#include <unistd.h>
int
hertz (int timer)
{
struct itimerval tim;
tim.it_interval.tv_sec = 0;
tim.it_interval.tv_usec = 1;
tim.it_value.tv_sec = 0;
tim.it_value.tv_usec = 0;
setitimer (timer, &tim, 0);
setitimer (timer, 0, &tim);
printf("tim.it_interval.tv_sec = %i\n", tim.it_interval.tv_sec);
printf("tim.it_interval.tv_usec = %i\n", tim.it_interval.tv_usec);
printf("tim.it_value.tv_sec = %i\n", tim.it_value.tv_sec);
printf("tim.it_value.tv_usec = %i\n", tim.it_value.tv_usec);
if (tim.it_interval.tv_usec < 2)
{
return -1;
}
return 1000000 / tim.it_interval.tv_usec;
}
main() {
printf("ITIMER_REAL: %i, _SC_CLK_TCK: %i\n",
hertz(ITIMER_REAL), sysconf (_SC_CLK_TCK));
}
====================================================================
Under Linux, I get the following output:
tim.it_interval.tv_sec = 0
tim.it_interval.tv_usec = 10000
tim.it_value.tv_sec = 0
tim.it_value.tv_usec = 0
ITIMER_REAL: 100, _SC_CLK_TCK: 100
Under the Hurd, I get the following:
tim.it_interval.tv_sec = 0
tim.it_interval.tv_usec = 1
tim.it_value.tv_sec = 0
tim.it_value.tv_usec = 0
ITIMER_REAL: -1, _SC_CLK_TCK: 100
The code in binutils/gprof/hertz.c does only try _SC_CLK_TCK if setitimer is
not available. Do you think this code should be rearranged? Can you fix the
glibc code to support the above use of setitimer?
Thanks,
Marcus
--
`Rhubarb is no Egyptian god.' Debian http://www.debian.org Check Key server
Marcus Brinkmann GNU http://www.gnu.org for public PGP Key
Marcus.Brinkmann@ruhr-uni-bochum.de, marcus@gnu.org PGP Key ID 36E7CD09
http://homepage.ruhr-uni-bochum.de/Marcus.Brinkmann/ brinkmd@debian.org
Reply to: