|
Home > Archive > Unix Programming > October 2005 > POLLRDNORM, __USE_XOPEN
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
POLLRDNORM, __USE_XOPEN
|
|
| Daniel C. Bastos 2005-10-24, 3:47 pm |
| On freebsd, I can #include <poll.h> and have constants such as
POLLRDNORM available, but it seems that gnu/linux systems do not let
that happen unless I define __USE_XOPEN.
Reading the man page of poll, I figure I could use POLLIN instead of
POLLRDNORM which raises another question: what is the difference
between high priority data and normal data? Is there another kind?
/usr/include/bits/poll.h
#define POLLIN 0x001 /* There is data to read. */
#define POLLPRI 0x002 /* There is urgent data to read. */
#define POLLOUT 0x004 /* Writing now will not block. */
#ifdef __USE_XOPEN
/* These values are defined in XPG4.2. */
# define POLLRDNORM 0x040 /* Normal data may be read. */
# define POLLRDBAND 0x080 /* Priority data may be read. */
# define POLLWRNORM 0x100 /* Writing now will not block. */
# define POLLWRBAND 0x200 /* Priority data may be written. */
#endif
| |
| Michael Kerrisk 2005-10-24, 3:47 pm |
| Gidday Daniel,
On Sun, 16 Oct 2005 17:01:51 +0000 (UTC), "Daniel C. Bastos"
<dbastos@my.free.dom.to> wrote:
>On freebsd, I can #include <poll.h> and have constants such as
>POLLRDNORM available, but it seems that gnu/linux systems do not let
>that happen unless I define __USE_XOPEN.
Don't define __USE_XOPEN: define _XOPEN_SOURCE. (Read <features.h> ).
>Reading the man page of poll, I figure I could use POLLIN instead of
>POLLRDNORM which raises another question: what is the difference
>between high priority data and normal data? Is there another kind?
As you seem to have deduced, POLLIN is equivalent to POLLRDNORM on
Linux. As far as high priority data is concerned there are two
similar looking bits: POLLPRI and POLLRDBAND.
POLLPRI says that there is "high priority data" available for reading.
There are two usual cases (on Linux) where this bit may be set:
-- urgent data is available on an Internet stream (TCP) socket.
-- a pseudo-terminal master in packet mode detects state
change in the slave (see the tty_ioctl(4) manual page).
POLLRDBAND is actually unused on Linux. POLLRDBAND (and POLLWRBAND)
are meaningful on systems providing System V STREAMS (Linux does not).
Under STREAMS, a message can be assigned a non-zero priority, and
these messages are queued to the receiver in decreasing order of
priority, in a band ahead of normal (priority 0) messages. You can
find out more in the Sun Solaris "STREAMS programming Guide".
Hope this helps,
Michael
| |
| James Antill 2005-10-24, 3:47 pm |
| On Sun, 16 Oct 2005 17:01:51 +0000, Daniel C. Bastos wrote:
> On freebsd, I can #include <poll.h> and have constants such as
> POLLRDNORM available, but it seems that gnu/linux systems do not let
> that happen unless I define __USE_XOPEN.
Never define anything that starts with __. Have a look at
/usr/include/features.h and/or the info documentation.
--
James Antill -- james@and.org
http://www.and.org/and-httpd
| |
| Daniel C. Bastos 2005-10-24, 3:47 pm |
| In article <4nh6l152gimse4rik55398rp00igf8od05@4ax.com>,
Michael Kerrisk wrote:
> Gidday Daniel,
Gidday Michael! Are you australian? :>
> On Sun, 16 Oct 2005 17:01:51 +0000 (UTC), "Daniel C. Bastos"
><dbastos@my.free.dom.to> wrote:
>
>
> Don't define __USE_XOPEN: define _XOPEN_SOURCE. (Read <features.h> ).
I was actually hoping to need not to define anything. Can I just use
POLLIN, POLLOUT, POLLERR for normal operations and ignore _XOPEN_SOURCE?
>
> As you seem to have deduced, POLLIN is equivalent to POLLRDNORM on
> Linux. As far as high priority data is concerned there are two
> similar looking bits: POLLPRI and POLLRDBAND.
I'll assume POLLIN is equivalent to POLLRDNORM on FreeBSD too and see
what happens. Thanks for explaning POLLPRI and POLLRDBAND.
| |
| Daniel C. Bastos 2005-10-24, 3:47 pm |
| Hello James.
In article <pan.2005.10.17.17.05.03.658367@and.org>,
James Antill wrote:
> On Sun, 16 Oct 2005 17:01:51 +0000, Daniel C. Bastos wrote:
>
>
> Never define anything that starts with __. Have a look at
> /usr/include/features.h and/or the info documentation.
I'm thinking that __ constants are not for users, right? On my system,
freebsd, I say
%find /usr/include/ -name "*features.h*"
%
And I hear nothing, so I'm thinking you're telling me to read that on
a gnu/linux system. I already gave it a read and what I see so far is
that the information there isn't really for a user like me... as I
told Michael, I will use POLL{IN,OUT,ERR} and try to live with it
without _XOPEN_SOURCE.
| |
| Michael Kerrisk 2005-10-24, 3:47 pm |
| >In article <pan.2005.10.17.17.05.03.658367@and.org>,
>James Antill wrote:
>
>
>I'm thinking that __ constants are not for users, right?
Right. In <features.h>, the macros that applications should define
are the ones beginning with just a single underscore. And they should
always be defined before *any* header file is included.
> On my system,
>freebsd, I say
>
>%find /usr/include/ -name "*features.h*"
>%
>
>And I hear nothing, so I'm thinking you're telling me to read that on
>a gnu/linux system.
Yep -- each system has its way of dealing with the feature test
macros. Typically things are set up in a header file somewhere. On
FreeBSD, have a look at <sys/cdefs.h>. Other implementations have
similar stuff: Solaris <sys/feature_tests.h>; NetBSD
<sys/featuretest.h>; HP-UX <sys/stdsyms.h>, Irix and Tru54
<standards.h>. An application generally doesn't need to worry about
including any of these headers -- other headers will each include
these header files as required.
> I already gave it a read and what I see so far is
>that the information there isn't really for a user like me...
Actually, it probably is useful for you (some day): sometimes, it
isn't always clear what the precise effects of defining a Feature Test
Macro (or a combination of them) are, and so one must consult
<features.h> or its analogue on other systems.
Cheers,
Michael
|
|
|
|
|