There's a patch I'd like to get reviewed at

http://trac.sagemath.org/sage_trac/ticket/9041

which, excluding

 * Comments
 * A few lines in spkg-install to apply the patch

consists of just 3 changed lines in one large Python source file.

So it is small, but because I've had to copy one of the large Python
source fles, and make a diff from that, the attached patch file is 143
KB. I think it looks intimidating myself, but it is in fact quite
simple. A few hundred bytes of code changes make a patch file that is
probably 20x to 50x bigger than the changes. (This is one downside of
the Sage policy of not using patch files).

Basically it boils down to the original python code assumed that if
the header file netpacket/packet.h existed, then it could compile
loads of stuff making use of PACKET_LOOPBACK, SIOCGIFINDEX and
PACKET_FASTROUTE.

OpenSolaris has the header file netpacket/packet.h but that does not
define PACKET_LOOPBACK, SIOCGIFINDEX or PACKET_FASTROUTE. As such,
those bits of code fail to compile. That results in one module
(_socket) not building on OpenSolaris.

The changes consist of replacing three occurrences of the line

#if defined(HAVE_NETPACKET_PACKET_H)

with 3 lines which actually check that PACKET_LOOPBACK, SIOCGIFINDEX
and PACKET_FASTROUTE and also defined before trying to compile the
code. So each of the following 3 lines gets added in the source code,
and the simpler


1) #if defined(HAVE_NETPACKET_PACKET_H) && defined(PACKET_LOOPBACK) &&
defined(PACKET_FASTROUTE)
2) #if defined(HAVE_NETPACKET_PACKET_H) && defined(SIOCGIFNAME)
3) #if defined(HAVE_NETPACKET_PACKET_H) && defined(SIOCGIFINDEX)

and simpler, but more error prone

#if defined(HAVE_NETPACKET_PACKET_H)

removed.

It's much easier to explain than the 143 KB patch file would suggest!

I've not made the patch Solaris specific, as clearly these are safe
and desirable that you check obscure things are defined before trying
to make code compile with them.

I've placed extensive test results, having checked on Linux, OS X,
Solaris 10 and OpenSolaris.

Any takers?

Dave

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to