poll() implementation

Rich Felker dalias at aerifal.cx
Fri Jul 28 12:46:27 PDT 2006


On Fri, Jul 28, 2006 at 01:30:56PM -0600, Erik Andersen wrote:
> On Fri Jul 28, 2006 at 07:26:35PM +0200, Richard Braun wrote:
> > Hello,
> > 
> > I have an application using poll() (latest uClibc snapshot). The system
> > is i486-linux-uclibc. Considering the source code, poll() is implemented
> > this way :
> > 
> > _syscall3(int, poll, struct pollfd *, fds,
> >         unsigned long int, nfds, int, timeout);
> > 
> > Does such a declaration prevent poll() from setting errno ?
> 
> See uClibc/libc/sysdeps/linux/i386/bits/syscalls.h where
> _syscall3 is defined (for x86).  If the actual syscall return is
> negative, the _syscallX ensures errno is set accordingly.  So no,
> this does not prevent poll from setting errno on failure.

The original poster seems to have a buggy program that is declaring
"extern int errno;" instead of including errno.h, at least in some
modules. BTW is there any good reason not to _remove_ this extern from
uclibc so that programs that try to use it will give link errors
rather than strange behavior at runtime? My understanding is that
glibc kept the old "errno" 10 years ago to aid in building ancient
applications that expect "extern int errno;" to work, but IMO in this
modern time it leads to horrible bugs whenever non-threaded library
code gets used in a threaded application.

Rich



More information about the uClibc mailing list