|
3 | 3 |
|
4 | 4 | #include "Python.h"
|
5 | 5 | #include "structseq.h"
|
6 |
| -#include "timefuncs.h" |
| 6 | +#include "_time.h" |
7 | 7 |
|
8 | 8 | #define TZNAME_ENCODING "utf-8"
|
9 | 9 |
|
10 |
| -#ifdef __APPLE__ |
11 |
| -#if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_FTIME) |
12 |
| - /* |
13 |
| - * floattime falls back to ftime when getttimeofday fails because the latter |
14 |
| - * might fail on some platforms. This fallback is unwanted on MacOSX because |
15 |
| - * that makes it impossible to use a binary build on OSX 10.4 on earlier |
16 |
| - * releases of the OS. Therefore claim we don't support ftime. |
17 |
| - */ |
18 |
| -# undef HAVE_FTIME |
19 |
| -#endif |
20 |
| -#endif |
21 |
| - |
22 | 10 | #include <ctype.h>
|
23 | 11 |
|
24 | 12 | #ifdef HAVE_SYS_TYPES_H
|
|
29 | 17 | #include <io.h>
|
30 | 18 | #endif
|
31 | 19 |
|
32 |
| -#ifdef HAVE_FTIME |
33 |
| -#include <sys/timeb.h> |
34 |
| -#if !defined(MS_WINDOWS) && !defined(PYOS_OS2) |
35 |
| -extern int ftime(struct timeb *); |
36 |
| -#endif /* MS_WINDOWS */ |
37 |
| -#endif /* HAVE_FTIME */ |
38 |
| - |
39 | 20 | #if defined(__WATCOMC__) && !defined(__QNX__)
|
40 | 21 | #include <i86.h>
|
41 | 22 | #else
|
@@ -946,44 +927,12 @@ PyInit_time(void)
|
946 | 927 | return m;
|
947 | 928 | }
|
948 | 929 |
|
949 |
| - |
950 |
| -/* Implement floattime() for various platforms */ |
951 |
| - |
952 | 930 | static double
|
953 | 931 | floattime(void)
|
954 | 932 | {
|
955 |
| - /* There are three ways to get the time: |
956 |
| - (1) gettimeofday() -- resolution in microseconds |
957 |
| - (2) ftime() -- resolution in milliseconds |
958 |
| - (3) time() -- resolution in seconds |
959 |
| - In all cases the return value is a float in seconds. |
960 |
| - Since on some systems (e.g. SCO ODT 3.0) gettimeofday() may |
961 |
| - fail, so we fall back on ftime() or time(). |
962 |
| - Note: clock resolution does not imply clock accuracy! */ |
963 |
| -#ifdef HAVE_GETTIMEOFDAY |
964 |
| - { |
965 |
| - struct timeval t; |
966 |
| -#ifdef GETTIMEOFDAY_NO_TZ |
967 |
| - if (gettimeofday(&t) == 0) |
968 |
| - return (double)t.tv_sec + t.tv_usec*0.000001; |
969 |
| -#else /* !GETTIMEOFDAY_NO_TZ */ |
970 |
| - if (gettimeofday(&t, (struct timezone *)NULL) == 0) |
971 |
| - return (double)t.tv_sec + t.tv_usec*0.000001; |
972 |
| -#endif /* !GETTIMEOFDAY_NO_TZ */ |
973 |
| - } |
974 |
| - |
975 |
| -#endif /* !HAVE_GETTIMEOFDAY */ |
976 |
| - { |
977 |
| -#if defined(HAVE_FTIME) |
978 |
| - struct timeb t; |
979 |
| - ftime(&t); |
980 |
| - return (double)t.time + (double)t.millitm * (double)0.001; |
981 |
| -#else /* !HAVE_FTIME */ |
982 |
| - time_t secs; |
983 |
| - time(&secs); |
984 |
| - return (double)secs; |
985 |
| -#endif /* !HAVE_FTIME */ |
986 |
| - } |
| 933 | + _PyTime_timeval t; |
| 934 | + _PyTime_gettimeofday(&t); |
| 935 | + return (double)t.tv_sec + t.tv_usec*0.000001; |
987 | 936 | }
|
988 | 937 |
|
989 | 938 |
|
|
0 commit comments