[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bogus prototype for setitimer
From: |
Martin Buchholz |
Subject: |
Bogus prototype for setitimer |
Date: |
Mon, 11 Jun 2001 17:20:19 +0900 |
glibc setitimer has a non-standard prototype (in sys/time.h) if
__USE_GNU is defined (the default).
This causes valid programs that use setitimer() to fail, e.g.
(address@hidden) ~/src $ cat setitimer.c
#include <sys/time.h>
int my_setitimer (int which, const struct itimerval *n, struct itimerval *o)
{
return setitimer (which, n, o);
}
(address@hidden) ~/src $ g++ -v -c -Wall setitimer.c
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/specs
gcc version 2.95.3 20010315 (release)
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/cpp0 -lang-c++ -v -D__GNUC__=2
-D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -D__ELF__ -Dunix -D__i386__
-Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux
-Asystem(posix) -D__EXCEPTIONS -Wall -Acpu(i386) -Amachine(i386) -Di386
-D__i386 -D__i386__ -Di686 -Dpentiumpro -D__i686 -D__i686__ -D__pentiumpro
-D__pentiumpro__ setitimer.c /tmp/ccVAPnL5.ii
GNU CPP version 2.95.3 20010315 (release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/../../../../include/g++-3
/usr/local/include
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/../../../../i686-pc-linux-gnu/include
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/include
/usr/include
End of search list.
The following default directories have been omitted from the search path:
End of omitted list.
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.3/cc1plus /tmp/ccVAPnL5.ii
-quiet -dumpbase setitimer.cc -Wall -version -o /tmp/ccehc6Y8.s
GNU C++ version 2.95.3 20010315 (release) (i686-pc-linux-gnu) compiled by GNU C
version 2.95.3 20010315 (release).
setitimer.c: In function `int my_setitimer(int, const itimerval *, itimerval
*)':
setitimer.c:5: conversion from `int' to `enum __itimer_which'
setitimer.c:6: warning: control reaches end of non-void function
`my_setitimer(int, const itimerval *, itimerval *)'
I understand the motivation for doing this (better compile-time
argument range checking), but this only works if setitimer is invoked
with a constant argument. But to be Unix98-standard-compliant, glibc
must reverse this change. The patch (to sys/time.h) is obvious, but I
can supply it if you wish.
If glibc wants to keep the (admittedly valuable) compile-time checking
of constant arguments, then glibc may have to work with the gcc folks
to add function-specific compile-time type-checking, as currently
happens with printf, for example.
/* imaginary syntax */
int setitimer (int, const struct itimerval *, struct itimerval);
#ifdef GCC_HAS_CONSTANT_INTEGRAL_ARG_CHECKING
#pragma gcc CONSTANT_INTEGRAL_ARG_CHECKING (setitimer, 1, (ITIMER_REAL,
ITIMER_VIRTUAL, ITIMER_PROF))
#endif
- Bogus prototype for setitimer,
Martin Buchholz <=