diff options
| author | Richard M. Stallman | 1998-04-27 20:54:19 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-04-27 20:54:19 +0000 |
| commit | f4b50f66eeaf4de7844f8decfdfff7e3fe57fda0 (patch) | |
| tree | f13f6f94c776a8660b8b034f02c5407d011d3e05 | |
| parent | b1ee4bd14704ff747677160e37372371498e07dc (diff) | |
| download | emacs-f4b50f66eeaf4de7844f8decfdfff7e3fe57fda0.tar.gz emacs-f4b50f66eeaf4de7844f8decfdfff7e3fe57fda0.zip | |
(Fload_average): New arg USE_FLOATS.
| -rw-r--r-- | src/fns.c | 19 |
1 files changed, 13 insertions, 6 deletions
| @@ -2494,24 +2494,31 @@ and can edit it until it has been confirmed.") | |||
| 2494 | } | 2494 | } |
| 2495 | } | 2495 | } |
| 2496 | 2496 | ||
| 2497 | DEFUN ("load-average", Fload_average, Sload_average, 0, 0, 0, | 2497 | DEFUN ("load-average", Fload_average, Sload_average, 0, 1, 0, |
| 2498 | "Return list of 1 minute, 5 minute and 15 minute load averages.\n\ | 2498 | "Return list of 1 minute, 5 minute and 15 minute load averages.\n\ |
| 2499 | Each of the three load averages is multiplied by 100,\n\ | 2499 | Each of the three load averages is multiplied by 100,\n\ |
| 2500 | then converted to integer.\n\ | 2500 | then converted to integer.\n\ |
| 2501 | When USE-FLOATS is non-nil, floats will be used instead of integers.\n\ | ||
| 2502 | These floats are not multiplied by 100.\n\n\ | ||
| 2501 | If the 5-minute or 15-minute load averages are not available, return a\n\ | 2503 | If the 5-minute or 15-minute load averages are not available, return a\n\ |
| 2502 | shortened list, containing only those averages which are available.") | 2504 | shortened list, containing only those averages which are available.") |
| 2503 | () | 2505 | (use_floats) |
| 2506 | Lisp_Object use_floats; | ||
| 2504 | { | 2507 | { |
| 2505 | double load_ave[3]; | 2508 | double load_ave[3]; |
| 2506 | int loads = getloadavg (load_ave, 3); | 2509 | int loads = getloadavg (load_ave, 3); |
| 2507 | Lisp_Object ret; | 2510 | Lisp_Object ret = Qnil; |
| 2508 | 2511 | ||
| 2509 | if (loads < 0) | 2512 | if (loads < 0) |
| 2510 | error ("load-average not implemented for this operating system"); | 2513 | error ("load-average not implemented for this operating system"); |
| 2511 | 2514 | ||
| 2512 | ret = Qnil; | 2515 | while (loads-- > 0) |
| 2513 | while (loads > 0) | 2516 | { |
| 2514 | ret = Fcons (make_number ((int) (load_ave[--loads] * 100.0)), ret); | 2517 | Lisp_Object load = (NILP (use_floats) ? |
| 2518 | make_number ((int) (100.0 * load_ave[loads])) | ||
| 2519 | : make_float (load_ave[loads])); | ||
| 2520 | ret = Fcons (load, ret); | ||
| 2521 | } | ||
| 2515 | 2522 | ||
| 2516 | return ret; | 2523 | return ret; |
| 2517 | } | 2524 | } |