summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2006-02-16 22:49:13 +0000
committerWez Furlong <wez@php.net>2006-02-16 22:49:13 +0000
commita8be85ce7eecc3d36cb0249671d16d2cbd9ee8eb (patch)
treeeba4dd01c5b854f54352d0595843e35fece1a8ba
parent1e8aad5075ff3cdc063fbcbd238f2dce41f6d92a (diff)
downloadphp-git-a8be85ce7eecc3d36cb0249671d16d2cbd9ee8eb.tar.gz
add getloadavg() function that has been running in production on rs1.php.net
for a couple of years.
-rw-r--r--configure.in1
-rw-r--r--ext/standard/basic_functions.c21
-rw-r--r--ext/standard/basic_functions.h3
3 files changed, 24 insertions, 1 deletions
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);