[Python-checkins] cpython: struct timeval.tv_usec is 4 bytes on 64-bit OS X as it should be, but

brett.cannon python-checkins at python.org
Sat Apr 7 20:59:39 CEST 2012


http://hg.python.org/cpython/rev/3028c8d46c00
changeset: 76156:3028c8d46c00
user: Brett Cannon <brett at python.org>
date: Sat Apr 07 14:59:29 2012 -0400
summary:
 struct timeval.tv_usec is 4 bytes on 64-bit OS X as it should be, but
is defined as an int while everyone else expects a long regardless of
length.
files:
 Modules/selectmodule.c | 6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -237,8 +237,12 @@
 #endif
 tv.tv_sec = (long)sec;
 #else
- if (_PyTime_ObjectToTimeval(tout, &tv.tv_sec, &tv.tv_usec) == -1)
+ /* 64-bit OS X has struct timeval.tv_usec as an int (and thus still 4
+ bytes as required), but no longer defined by a long. */
+ long tv_usec = tv.tv_usec;
+ if (_PyTime_ObjectToTimeval(tout, &tv.tv_sec, &tv_usec) == -1)
 return NULL;
+ tv.tv_usec = tv_usec;
 #endif
 if (tv.tv_sec < 0) {
 PyErr_SetString(PyExc_ValueError, "timeout must be non-negative");
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /