Re: [Python-Dev] [Python-checkins] cpython: Close #20656: Fix select.select() on OpenBSD 64-bit
On Mon, Feb 17, 2014 at 6:36 PM, victor.stinner <python-checkins@python.org> wrote:
http://hg.python.org/cpython/rev/79ccf36b0fd0 changeset: 89239:79ccf36b0fd0 user: Victor Stinner <victor.stinner@gmail.com> date: Tue Feb 18 01:35:40 2014 +0100 summary: Close #20656: Fix select.select() on OpenBSD 64-bit
files: Modules/selectmodule.c | 22 ++++++++++++---------- 1 files changed, 12 insertions(+), 10 deletions(-)
This changeset caused a compile warning on 32-bit Windows: ..\Modules\selectmodule.c(238): warning C4244: '=' : conversion from 'time_t' to 'long', possible loss of data [P:\ath\to\cpython\PCbuild\select.vcxproj]
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -212,11 +212,18 @@ return NULL; } else { -#ifdef MS_WINDOWS + /* On OpenBSD 5.4, timeval.tv_sec is a long. + * Example: long is 64-bit, whereas time_t is 32-bit. */ time_t sec; - if (_PyTime_ObjectToTimeval(tout, &sec, &tv.tv_usec, + /* On OS X 64-bit, timeval.tv_usec is an int (and thus still 4 + bytes as required), but no longer defined by a long. */ + long usec; + if (_PyTime_ObjectToTimeval(tout, &sec, &usec, _PyTime_ROUND_UP) == -1) return NULL; +#ifdef MS_WINDOWS + /* On Windows, timeval.tv_sec is a long (32 bit), + * whereas time_t can be 64-bit. */ assert(sizeof(tv.tv_sec) == sizeof(long)); #if SIZEOF_TIME_T > SIZEOF_LONG if (sec > LONG_MAX) { @@ -225,16 +232,11 @@ return NULL; } #endif - tv.tv_sec = (long)sec; #else - /* 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; - if (_PyTime_ObjectToTimeval(tout, &tv.tv_sec, &tv_usec, - _PyTime_ROUND_UP) == -1) - return NULL; - tv.tv_usec = tv_usec; + assert(sizeof(tv.tv_sec) >= sizeof(sec)); #endif + tv.tv_sec = sec;
This is the offending line. I'm not sure how best to fix it, so I'm just pointing it out :) -- Zach
Hi, 2014-02-18 6:19 GMT+01:00 Zachary Ware <zachary.ware@gmail.com>:
On Mon, Feb 17, 2014 at 6:36 PM, victor.stinner <python-checkins@python.org> wrote:
http://hg.python.org/cpython/rev/79ccf36b0fd0 changeset: 89239:79ccf36b0fd0 user: Victor Stinner <victor.stinner@gmail.com> date: Tue Feb 18 01:35:40 2014 +0100 summary: Close #20656: Fix select.select() on OpenBSD 64-bit
files: Modules/selectmodule.c | 22 ++++++++++++---------- 1 files changed, 12 insertions(+), 10 deletions(-)
This changeset caused a compile warning on 32-bit Windows:
..\Modules\selectmodule.c(238): warning C4244: '=' : conversion from 'time_t' to 'long', possible loss of data [P:\ath\to\cpython\PCbuild\select.vcxproj]
Ah yes, I didn't remember why I wrote the downcast initially. You're right, it is still neeed (on 64-bit Windows). I restored it: --- user: Victor Stinner <victor.stinner@gmail.com> date: Tue Feb 18 09:30:33 2014 +0100 files: Modules/selectmodule.c description: Issue #20656: Restore explicit downcast in select_select(). Cast from time_t (64 bit) to long (32 bit). It should fix a compiler warning. --- Victor
participants (2)
-
Victor Stinner
-
Zachary Ware