diff options
author | Guido van Rossum <guido@python.org> | 1993-01-04 09:09:59 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1993-01-04 09:09:59 (GMT) |
commit | a2b7f40513ba5d75a2063c3fabe47377cd8c0416 (patch) | |
tree | a49810320cbb0291ed16424b8d7ca980b5c2b1b1 /Modules/timemodule.c | |
parent | 349f2b516b89c46f915a57029ed2bd33f85ff363 (diff) | |
download | cpython-a2b7f40513ba5d75a2063c3fabe47377cd8c0416.zip cpython-a2b7f40513ba5d75a2063c3fabe47377cd8c0416.tar.gz cpython-a2b7f40513ba5d75a2063c3fabe47377cd8c0416.tar.bz2 |
* Configure.py: use #!/usr/local/bin/python
* posixmodule.c: move extern function declarations to top
* listobject.c: cmp() arguments must be void* if __STDC__
* Makefile, allobjects.h, panelmodule.c, modsupport.c: get rid of
strdup() -- it is a portability risk
* Makefile: enclosed ranlib command in parentheses for Sequent Make
which aborts if the command is not found even if '-' is present
* timemodule.c: time() returns a floating point number, in microsecond
precision if BSD_TIME is defined.
Diffstat (limited to 'Modules/timemodule.c')
-rw-r--r-- | Modules/timemodule.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/Modules/timemodule.c b/Modules/timemodule.c index 69a0c88..17dff19 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -33,6 +33,10 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include <signal.h> #include <setjmp.h> +#ifdef BSD_TIME +#define HAVE_GETTIMEOFDAY +#endif + #ifdef macintosh #define NO_UNISTD #endif @@ -79,6 +83,17 @@ time_time(self, args) object *self; object *args; { +#ifdef HAVE_GETTIMEOFDAY + struct timeval t; + struct timezone tz; + if (!getnoarg(args)) + return NULL; + if (gettimeofday(&t, &tz) != 0) { + err_errno(IOError); + return NULL; + } + return newfloatobject(t.tv_sec*1.0 + t.tv_usec*0.000001); +#else /* !HAVE_GETTIMEOFDAY */ time_t secs; if (!getnoarg(args)) return NULL; @@ -90,7 +105,8 @@ time_time(self, args) (((1970-1904)*365L + (1970-1904)/4) * 24 * 3600)) secs -= TIMEDIFF; #endif - return newintobject((long)secs); + return newfloatobject((double)secs); +#endif /* !HAVE_GETTIMEOFDAY */ } static jmp_buf sleep_intr; |