Re: Patch to fix comm_incoming (squid-1.2beta22)

From: David Luyer <luyer@dont-contact.us>
Date: Tue, 09 Jun 1998 11:56:34 +0800

--MimeMultipartBoundary
Content-Type: text/plain; charset=us-ascii

> Chris Wedgwood wrote:
>
> > Poll exists in linux 2.1.34 and later. I think libc will use this,
> > and if its not there will emulate it with select.
>
> Any idea how to detect if it is there or not, preferably in a portable
> way (to be embedded in configure or detected at compile time).

Since you only want to do it on linux, you can just attempt the syscall using
the Linux macros (doing it via the macros means it should work on all Linux
architectures);

#include <errno.h>
#if defined(__linux__) && defined(__NR_poll) && (__GLIBC__ >= 2)
#include <asm/unistd.h>
#define __NR_poll_real __NR_poll
_syscall3(int, poll_real, int *, ufds, int, nfds, int, tmt)
main() { if(poll_real(0, 0, 0) == -1) perror(""); else puts("No error"); }
#else
#error Not Linux with poll syscall
#endif

If __NR_poll is defined as 168 but the function isn't implemented
this prints 'Function not implemented'. It should do something else
when poll is implemented (either give No error or Invalid argument;
I don't have a 2.1.x box handy); if __NR_poll is not known it will just die.

We can't hardcode __NR_poll to 168 since this varies on different
architectures (on i386, it is 168). I haven't put in a check for things
like __NR_SYSV_poll which exist on only one architecture where there's a
__NR_poll anyway in the recent kernels.

David.

--MimeMultipartBoundary--
Received on Tue Jul 29 2003 - 13:15:51 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:11:48 MST