Mercurial > hg > xemacs-beta
comparison src/fns.c @ 278:90d73dddcdc4 r21-0b37
Import from CVS: tag r21-0b37
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:31:29 +0200 |
parents | 6330739388db |
children | 558f606b08ae |
comparison
equal
deleted
inserted
replaced
277:cfdf3ff11843 | 278:90d73dddcdc4 |
---|---|
37 #include "lisp.h" | 37 #include "lisp.h" |
38 | 38 |
39 #ifdef HAVE_UNISTD_H | 39 #ifdef HAVE_UNISTD_H |
40 #include <unistd.h> | 40 #include <unistd.h> |
41 #endif | 41 #endif |
42 #include <errno.h> | |
42 | 43 |
43 #include "buffer.h" | 44 #include "buffer.h" |
44 #include "bytecode.h" | 45 #include "bytecode.h" |
45 #include "commands.h" | 46 #include "commands.h" |
46 #include "device.h" | 47 #include "device.h" |
3320 } | 3321 } |
3321 | 3322 |
3322 | 3323 |
3323 /* #### this function doesn't belong in this file! */ | 3324 /* #### this function doesn't belong in this file! */ |
3324 | 3325 |
3325 DEFUN ("load-average", Fload_average, 0, 0, 0, /* | 3326 DEFUN ("load-average", Fload_average, 0, 1, 0, /* |
3326 Return list of 1 minute, 5 minute and 15 minute load averages. | 3327 Return list of 1 minute, 5 minute and 15 minute load averages. |
3327 Each of the three load averages is multiplied by 100, | 3328 Each of the three load averages is multiplied by 100, |
3328 then converted to integer. | 3329 then converted to integer. |
3329 | 3330 |
3331 When USE-FLOATS is non-nil, floats will be used instead of integers. | |
3332 These floats are not multiplied by 100. | |
3333 | |
3330 If the 5-minute or 15-minute load averages are not available, return a | 3334 If the 5-minute or 15-minute load averages are not available, return a |
3331 shortened list, containing only those averages which are available. | 3335 shortened list, containing only those averages which are available. |
3332 | 3336 |
3333 On some systems, this won't work due to permissions on /dev/kmem, | 3337 On some systems, this won't work due to permissions on /dev/kmem, |
3334 in which case you can't use this. | 3338 in which case you can't use this. |
3335 */ | 3339 */ |
3336 ()) | 3340 (use_floats)) |
3337 { | 3341 { |
3338 double load_ave[3]; | 3342 double load_ave[3]; |
3339 int loads = getloadavg (load_ave, countof (load_ave)); | 3343 int loads = getloadavg (load_ave, countof (load_ave)); |
3344 Lisp_Object ret = Qnil; | |
3340 | 3345 |
3341 if (loads == -2) | 3346 if (loads == -2) |
3342 error ("load-average not implemented for this operating system."); | 3347 error ("load-average not implemented for this operating system"); |
3343 else if (loads < 0) | 3348 else if (loads < 0) |
3344 error ("could not get load-average; check permissions."); | 3349 signal_simple_error ("Could not get load-average", |
3345 | 3350 lisp_strerror (errno)); |
3346 { | 3351 |
3347 Lisp_Object ret = Qnil; | 3352 while (loads-- > 0) |
3348 while (loads > 0) | 3353 { |
3349 ret = Fcons (make_int ((int) (load_ave[--loads] * 100.0)), ret); | 3354 Lisp_Object load = (NILP (use_floats) ? |
3350 return ret; | 3355 make_int ((int) (100.0 * load_ave[loads])) |
3351 } | 3356 : make_float (load_ave[loads])); |
3357 ret = Fcons (load, ret); | |
3358 } | |
3359 return ret; | |
3352 } | 3360 } |
3353 | 3361 |
3354 | 3362 |
3355 Lisp_Object Vfeatures; | 3363 Lisp_Object Vfeatures; |
3356 | 3364 |