Browse Source

add getloadavg() function that has been running in production on rs1.php.net

for a couple of years.
PHP-5.1
Wez Furlong 21 years ago
parent
commit
a8be85ce7e
  1. 1
      configure.in
  2. 21
      ext/standard/basic_functions.c
  3. 3
      ext/standard/basic_functions.h

1
configure.in

@ -466,6 +466,7 @@ ftok \
funopen \
gai_strerror \
gcvt \
getloadavg \
getlogin \
getprotobyname \
getprotobynumber \

21
ext/standard/basic_functions.c

@ -425,7 +425,9 @@ zend_function_entry basic_functions[] = {
#ifdef HAVE_GETOPT
PHP_FE(getopt, NULL)
#endif
#ifdef HAVE_GETLOADAVG
PHP_FE(getloadavg, NULL)
#endif
#ifdef HAVE_GETTIMEOFDAY
PHP_FE(microtime, NULL)
PHP_FE(gettimeofday, NULL)
@ -3344,6 +3346,23 @@ PHP_FUNCTION(import_request_variables)
}
/* }}} */
#ifdef HAVE_GETLOADAVG
PHP_FUNCTION(getloadavg)
{
double load[3];
if (getloadavg(load, 3) == -1) {
RETURN_FALSE;
} else {
array_init(return_value);
add_index_double(return_value, 0, load[0]);
add_index_double(return_value, 1, load[1]);
add_index_double(return_value, 2, load[2]);
}
}
#endif
/*
* Local variables:
* tab-width: 4

3
ext/standard/basic_functions.h

@ -116,6 +116,9 @@ PHP_NAMED_FUNCTION(php_if_crc32);
PHP_FUNCTION(register_tick_function);
PHP_FUNCTION(unregister_tick_function);
#ifdef HAVE_GETLOADAVG
PHP_FUNCTION(getloadavg);
#endif
PHP_FUNCTION(is_uploaded_file);
PHP_FUNCTION(move_uploaded_file);

Loading…
Cancel
Save