1 message in org.python.python-bugs-list[ python-Bugs-923315 ] AIX POLLNVAL d...
FromSent OnAttachments
SourceForge.netMar 25, 2004 1:06 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:[ python-Bugs-923315 ] AIX POLLNVAL definition causes problemsActions...
From:SourceForge.net (nore@sourceforge.net)
Date:Mar 25, 2004 1:06:33 pm
List:org.python.python-bugs-list

Bugs item #923315, was opened at 2004-03-25 13:06 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=923315&group_id=5470

Category: Python Library Group: Python 2.3 Status: Open Resolution: None Priority: 5 Submitted By: John Marshall (john_marshall) Assigned to: Nobody/Anonymous (nobody) Summary: AIX POLLNVAL definition causes problems

Initial Comment: Under AIX (5.1 at least), POLLNVAL (from sys/poll.h) is 0x8000. This causes a problem because it is stored in a (signed) short (e.g., revents):

----- struct pollfd { int fd; /* file descriptor or file ptr */ short events; /* requested events */ short revents; /* returned events */ }; -----

As such, the following tests and results are given: ----- ashort (%hx) = 8000, ashort (%x) = ffff8000 POLLNVAL (%hx) = 8000, POLLNVAL (%x) = 8000

ashort == POLLNVAL => 0 ashort == (short)POLLNVAL => 1 -----

Note that the 'ashort == POLLNVAL' test is 0 rather than 1 because (I believe) POLLNVAL is treated as a signed integer, the ashort value is then promoted to signed integer thus giving 0xffff8000, not 0x8000.

The problem arises because IBM has chosen to use a negative short value (0x8000) in a signed short variable. Neither Linux or IRIX have this problem because they use POLLNVAL=0x20 which promotes to 0x20.

This situation will cause the test_poll to fail and will certainly be a gotcha for AIX users.

I have added the following code to the selectmodule.c to address the problem (mask out the upper 32 bits):

-----~ line 513:selectmodule.c num = PyInt_FromLong(self->ufds[i].revents & 0xffff); -----

John

----------------------------------------------------------------------