]> granicus.if.org Git - php/commitdiff
add getloadavg() function that has been running in production on rs1.php.net
authorWez Furlong <wez@php.net>
Thu, 16 Feb 2006 22:49:13 +0000 (22:49 +0000)
committerWez Furlong <wez@php.net>
Thu, 16 Feb 2006 22:49:13 +0000 (22:49 +0000)
for a couple of years.

configure.in
ext/standard/basic_functions.c
ext/standard/basic_functions.h

index 09223279effe52176675e07bea74e0edb1d3d265..569a6362ec4a2fbe7dc13fc05f9d53f282e19437 100644 (file)
@@ -466,6 +466,7 @@ ftok \
 funopen \
 gai_strerror \
 gcvt \
+getloadavg \
 getlogin \
 getprotobyname \
 getprotobynumber \
index 90e52db813f8c72f5be18ecee3df2bd3b3c8ce93..e3abf681550fac8c97296b4b5c3ccb4ef369ca48 100644 (file)
@@ -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
index e58f20213e7911902fec2df9436fa15ae7bf510e..63bcea432daf5cd9dfb10a3231765c7f8d34fe04 100644 (file)
@@ -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);