[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/editfns.c [emacs-unicode-2]
From: |
Miles Bader |
Subject: |
[Emacs-diffs] Changes to emacs/src/editfns.c [emacs-unicode-2] |
Date: |
Thu, 11 Nov 2004 22:18:50 -0500 |
Index: emacs/src/editfns.c
diff -c emacs/src/editfns.c:1.359.2.14 emacs/src/editfns.c:1.359.2.15
*** emacs/src/editfns.c:1.359.2.14 Thu Nov 4 08:55:32 2004
--- emacs/src/editfns.c Fri Nov 12 02:52:56 2004
***************
*** 22,27 ****
--- 22,28 ----
#include <config.h>
#include <sys/types.h>
+ #include <stdio.h>
#ifdef VMS
#include "vms-pwd.h"
***************
*** 33,42 ****
#include <unistd.h>
#endif
! /* Without this, sprintf on Mac OS Classic will produce wrong
! result. */
! #ifdef MAC_OS8
! #include <stdio.h>
#endif
#include <ctype.h>
--- 34,46 ----
#include <unistd.h>
#endif
! /* systime.h includes <sys/time.h> which, on some systems, is required
! for <sys/resource.h>; thus systime.h must be included before
! <sys/resource.h> */
! #include "systime.h"
!
! #if defined HAVE_SYS_RESOURCE_H
! #include <sys/resource.h>
#endif
#include <ctype.h>
***************
*** 49,56 ****
#include "frame.h"
#include "window.h"
- #include "systime.h"
-
#ifdef STDC_HEADERS
#include <float.h>
#define MAX_10_EXP DBL_MAX_10_EXP
--- 53,58 ----
***************
*** 1370,1375 ****
--- 1372,1418 ----
return Flist (3, result);
}
+
+ DEFUN ("get-internal-run-time", Fget_internal_run_time,
Sget_internal_run_time,
+ 0, 0, 0,
+ doc: /* Return the current run time used by Emacs.
+ The time is returned as a list of three integers. The first has the
+ most significant 16 bits of the seconds, while the second has the
+ least significant 16 bits. The third integer gives the microsecond
+ count.
+
+ On systems that can't determine the run time, get-internal-run-time
+ does the same thing as current-time. The microsecond count is zero on
+ systems that do not provide resolution finer than a second. */)
+ ()
+ {
+ #ifdef HAVE_GETRUSAGE
+ struct rusage usage;
+ Lisp_Object result[3];
+ int secs, usecs;
+
+ if (getrusage (RUSAGE_SELF, &usage) < 0)
+ /* This shouldn't happen. What action is appropriate? */
+ Fsignal (Qerror, Qnil);
+
+ /* Sum up user time and system time. */
+ secs = usage.ru_utime.tv_sec + usage.ru_stime.tv_sec;
+ usecs = usage.ru_utime.tv_usec + usage.ru_stime.tv_usec;
+ if (usecs >= 1000000)
+ {
+ usecs -= 1000000;
+ secs++;
+ }
+
+ XSETINT (result[0], (secs >> 16) & 0xffff);
+ XSETINT (result[1], (secs >> 0) & 0xffff);
+ XSETINT (result[2], usecs);
+
+ return Flist (3, result);
+ #else
+ return Fcurrent_time ();
+ #endif
+ }
int
***************
*** 4447,4452 ****
--- 4490,4496 ----
defsubr (&Suser_full_name);
defsubr (&Semacs_pid);
defsubr (&Scurrent_time);
+ defsubr (&Sget_internal_run_time);
defsubr (&Sformat_time_string);
defsubr (&Sfloat_time);
defsubr (&Sdecode_time);