[Python-checkins] cpython (2.7): issue #9090 : Take the same approach for socketmodule as daytimemodule
kristjan.jonsson
python-checkins at python.org
Tue Mar 19 21:57:21 CET 2013
http://hg.python.org/cpython/rev/0f5e1e642dc3
changeset: 82776:0f5e1e642dc3
branch: 2.7
parent: 82772:58980d0084cc
user: Kristján Valur Jónsson <sweskman at gmail.com>
date: Tue Mar 19 13:53:56 2013 -0700
summary:
issue #9090 : Take the same approach for socketmodule as daytimemodule
when it needs support from timemodule (which is a .so on linux):
link in timemodule.c for the required functions.
files:
Include/timefuncs.h | 3 +++
Modules/socketmodule.c | 27 ++++-----------------------
Modules/timemodule.c | 2 +-
setup.py | 5 +++--
4 files changed, 11 insertions(+), 26 deletions(-)
diff --git a/Include/timefuncs.h b/Include/timefuncs.h
--- a/Include/timefuncs.h
+++ b/Include/timefuncs.h
@@ -16,6 +16,9 @@
*/
PyAPI_FUNC(time_t) _PyTime_DoubleToTimet(double x);
+/* Get the current time since the epoch in seconds */
+PyAPI_FUNC(double) _PyTime_FloatTime(void);
+
#ifdef __cplusplus
}
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -92,6 +92,7 @@
#include "Python.h"
#include "structmember.h"
+#include "timefuncs.h"
#undef MAX
#define MAX(x, y) ((x) < (y) ? (y) : (x))
@@ -751,43 +752,23 @@
}
END_SELECT_LOOP(s)
*/
-#ifdef _WIN32
-/* _PyTime_floattime is exported from timemodule.c which is a builtin on windows
- * but not on linux. The problem we are fixing is mostly a windows problem so
- * we leave it at that.
- */
-#define HAVE_PYTIME_FLOATTIME
-#endif
-#ifdef HAVE_PYTIME_FLOATTIME
-PyAPI_FUNC(double) _PyTime_floattime(void); /* defined in timemodule.c */
#define BEGIN_SELECT_LOOP(s) \
{ \
double deadline, interval = s->sock_timeout; \
int has_timeout = s->sock_timeout > 0.0; \
if (has_timeout) { \
- deadline = _PyTime_floattime() + s->sock_timeout; \
+ deadline = _PyTime_FloatTime() + s->sock_timeout; \
} \
while (1) { \
- errno = 0; \
+ errno = 0;
#define END_SELECT_LOOP(s) \
if (!has_timeout || \
(!CHECK_ERRNO(EWOULDBLOCK) && !CHECK_ERRNO(EAGAIN))) \
break; \
- interval = deadline - _PyTime_floattime(); \
+ interval = deadline - _PyTime_FloatTime(); \
} \
}
-#else
-#define BEGIN_SELECT_LOOP(s) \
- { \
- double interval = s->sock_timeout; \
- do { \
- errno = 0; \
-
-#define END_SELECT_LOOP(s) \
- } while(0); \
- }
-#endif
/* Initialize a new socket object. */
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -1058,7 +1058,7 @@
/* export floattime to socketmodule.c */
PyAPI_FUNC(double)
-_PyTime_floattime(void)
+_PyTime_FloatTime(void)
{
return floattime();
}
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -777,8 +777,9 @@
exts.append( Extension('_csv', ['_csv.c']) )
# socket(2)
- exts.append( Extension('_socket', ['socketmodule.c'],
- depends = ['socketmodule.h']) )
+ exts.append( Extension('_socket', ['socketmodule.c', 'timemodule.c'],
+ depends=['socketmodule.h'],
+ libraries=math_libs) )
# Detect SSL support for the socket module (via _ssl)
search_for_ssl_incs_in = [
'/usr/local/ssl/include',
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list