[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/src/editfns.c
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] Changes to emacs/src/editfns.c |
Date: |
Sat, 06 Nov 2004 16:12:08 -0500 |
Index: emacs/src/editfns.c
diff -c emacs/src/editfns.c:1.382 emacs/src/editfns.c:1.383
*** emacs/src/editfns.c:1.382 Wed Oct 27 11:02:06 2004
--- emacs/src/editfns.c Sat Nov 6 17:00:37 2004
***************
*** 39,44 ****
--- 39,48 ----
#include <stdio.h>
#endif
+ #if defined HAVE_SYS_RESOURCE_H
+ #include <sys/resource.h>
+ #endif
+
#include <ctype.h>
#include "lisp.h"
***************
*** 1375,1380 ****
--- 1379,1425 ----
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
***************
*** 4315,4320 ****
--- 4360,4366 ----
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);
- [Emacs-diffs] Changes to emacs/src/editfns.c,
Eli Zaretskii <=