From a8be85ce7eecc3d36cb0249671d16d2cbd9ee8eb Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 16 Feb 2006 22:49:13 +0000 Subject: [PATCH] add getloadavg() function that has been running in production on rs1.php.net for a couple of years. --- configure.in | 1 + ext/standard/basic_functions.c | 21 ++++++++++++++++++++- ext/standard/basic_functions.h | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index 09223279ef..569a6362ec 100644 --- a/configure.in +++ b/configure.in @@ -466,6 +466,7 @@ ftok \ funopen \ gai_strerror \ gcvt \ +getloadavg \ getlogin \ getprotobyname \ getprotobynumber \ diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 90e52db813..e3abf68155 100644 --- a/ext/standard/basic_functions.c +++ b/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 diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h index e58f20213e..63bcea432d 100644 --- a/ext/standard/basic_functions.h +++ b/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); -- 2.40.0