[Patches] [ python-Patches-1471925 ] Weak linking support for OSX

SourceForge.net noreply at sourceforge.net
Tue Apr 18 21:29:51 CEST 2006


Patches item #1471925, was opened at 2006-04-17 21:49
Message generated for change (Comment added) made by ronaldoussoren
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1471925&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Ronald Oussoren (ronaldoussoren)
Assigned to: Nobody/Anonymous (nobody)
Summary: Weak linking support for OSX

Initial Comment:
The "itch" that is scratched by this patch is the wish to be able to use a 
python binary that was build on OSX 10.4 on OSX 10.3 systems. At the 
same time the binary should offer full access to OSX 10.4 API's when 
running on that system.

This patch weakly links a number of functions in the posix, time and 
socket modules.

I'm not quite happy with code duplication in the time and socket modules, 
but don't quite know how to fix that.

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

>Comment By: Ronald Oussoren (ronaldoussoren)
Date: 2006-04-18 21:29

Message:
Logged In: YES 
user_id=580910

Version 3 solves the ftime issue the other (IMO more correct) way: it ignores the 
returnvalue of gettimeofday and conditionalizes the floattime code in such way 
that either gettimeofday or ftime is used, but never both.

 

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

Comment By: Ronald Oussoren (ronaldoussoren)
Date: 2006-04-18 21:27

Message:
Logged In: YES 
user_id=580910

Good points. I was clearing errors because it seemed better to ignore errors. 
But you're right, if this does fail somethings is seriously wrong. I've replaced 
error-checking by return statements (but have not replaced the patch).

The change to time is interesting, I added those changes because the binary 
wouldn't run without the patch, without realizing that configure/timemodule 
is picking up the wrong function for finding the current time.  That seems to 
be caused by a bug in the preprocessor code that selects the right section of 
code. OSX 10.4 has both gettimeofday and ftime, and with the current set of 
#if statements this means both the gettimeofday and ftime blocks get 
compiled in. The ftime-bit is dead code, but present nonetheless.

I tried to rearange the #if-statements to make sure just one block gets 
included, but then get compiler warnings because floattime checks for an 
error-return of gettimeofday.  IMHO the error-return check is rather lame, 
the only reason this could fail is when the first argument of gettimeofday is 
invalid (and SUS says this function will always return 0, although manpage on 
darwin and linux claim otherwise), And time(2) can also return -1 to indicate 
failure ;-)

If uploaded a new patch (version 2) that removes error clearing for the DelAttr 
calls in posixmodule and chickens out on the ftime issue by #undef-ing 
HAVE_FTIME for OSX systems that HAVE_GETTIMEOFDAY.

SUS: http://www.opengroup.org/onlinepubs/007908799/xsh/
gettimeofday.html

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

Comment By: Martin v. Löwis (loewis)
Date: 2006-04-18 00:18

Message:
Logged In: YES 
user_id=21627

The patch looks fine to me. I wonder why you are clearing
the errors from PyObject_DelAttrString, though: There
shouldn't be any errors (right?), so if that fails,
something is seriously wrong.

As for the time changes: are you saying OSX doesn't have
gettimeofday? I can find a manual page on

http://developer.apple.com/documentation/Darwin/Reference/ManPages/man2/gettimeofday.2.html

This has higher resolution than ftime, and also takes higher
precedence in timemodule.c: Why is it not used?

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

Comment By: Ronald Oussoren (ronaldoussoren)
Date: 2006-04-17 21:50

Message:
Logged In: YES 
user_id=580910

I should not that I haven't checked this patch on other platforms than osx 10.4/
intel. 

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1471925&group_id=5470


More information about the Patches mailing list