diff options
Diffstat (limited to 'src/editfns.c')
| -rw-r--r-- | src/editfns.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/editfns.c b/src/editfns.c index e83e53e9d24..2e8134d4495 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -39,6 +39,10 @@ Boston, MA 02111-1307, USA. */ | |||
| 39 | #include <stdio.h> | 39 | #include <stdio.h> |
| 40 | #endif | 40 | #endif |
| 41 | 41 | ||
| 42 | #if defined HAVE_SYS_RESOURCE_H | ||
| 43 | #include <sys/resource.h> | ||
| 44 | #endif | ||
| 45 | |||
| 42 | #include <ctype.h> | 46 | #include <ctype.h> |
| 43 | 47 | ||
| 44 | #include "lisp.h" | 48 | #include "lisp.h" |
| @@ -1375,6 +1379,47 @@ resolution finer than a second. */) | |||
| 1375 | 1379 | ||
| 1376 | return Flist (3, result); | 1380 | return Flist (3, result); |
| 1377 | } | 1381 | } |
| 1382 | |||
| 1383 | DEFUN ("get-internal-run-time", Fget_internal_run_time, Sget_internal_run_time, | ||
| 1384 | 0, 0, 0, | ||
| 1385 | doc: /* Return the current run time used by Emacs. | ||
| 1386 | The time is returned as a list of three integers. The first has the | ||
| 1387 | most significant 16 bits of the seconds, while the second has the | ||
| 1388 | least significant 16 bits. The third integer gives the microsecond | ||
| 1389 | count. | ||
| 1390 | |||
| 1391 | On systems that can't determine the run time, get-internal-run-time | ||
| 1392 | does the same thing as current-time. The microsecond count is zero on | ||
| 1393 | systems that do not provide resolution finer than a second. */) | ||
| 1394 | () | ||
| 1395 | { | ||
| 1396 | #ifdef HAVE_GETRUSAGE | ||
| 1397 | struct rusage usage; | ||
| 1398 | Lisp_Object result[3]; | ||
| 1399 | int secs, usecs; | ||
| 1400 | |||
| 1401 | if (getrusage (RUSAGE_SELF, &usage) < 0) | ||
| 1402 | /* This shouldn't happen. What action is appropriate? */ | ||
| 1403 | Fsignal (Qerror, Qnil); | ||
| 1404 | |||
| 1405 | /* Sum up user time and system time. */ | ||
| 1406 | secs = usage.ru_utime.tv_sec + usage.ru_stime.tv_sec; | ||
| 1407 | usecs = usage.ru_utime.tv_usec + usage.ru_stime.tv_usec; | ||
| 1408 | if (usecs >= 1000000) | ||
| 1409 | { | ||
| 1410 | usecs -= 1000000; | ||
| 1411 | secs++; | ||
| 1412 | } | ||
| 1413 | |||
| 1414 | XSETINT (result[0], (secs >> 16) & 0xffff); | ||
| 1415 | XSETINT (result[1], (secs >> 0) & 0xffff); | ||
| 1416 | XSETINT (result[2], usecs); | ||
| 1417 | |||
| 1418 | return Flist (3, result); | ||
| 1419 | #else | ||
| 1420 | return Fcurrent_time (); | ||
| 1421 | #endif | ||
| 1422 | } | ||
| 1378 | 1423 | ||
| 1379 | 1424 | ||
| 1380 | int | 1425 | int |
| @@ -4315,6 +4360,7 @@ functions if all the text being accessed has this property. */); | |||
| 4315 | defsubr (&Suser_full_name); | 4360 | defsubr (&Suser_full_name); |
| 4316 | defsubr (&Semacs_pid); | 4361 | defsubr (&Semacs_pid); |
| 4317 | defsubr (&Scurrent_time); | 4362 | defsubr (&Scurrent_time); |
| 4363 | defsubr (&Sget_internal_run_time); | ||
| 4318 | defsubr (&Sformat_time_string); | 4364 | defsubr (&Sformat_time_string); |
| 4319 | defsubr (&Sfloat_time); | 4365 | defsubr (&Sfloat_time); |
| 4320 | defsubr (&Sdecode_time); | 4366 | defsubr (&Sdecode_time); |