Hey Wez,

We should stick to coding standards for new functions.
How about sys_getloadavg()?

Andi

At 02:49 PM 2/16/2006, Wez Furlong wrote:
wez             Thu Feb 16 22:49:13 2006 UTC

  Modified files:              (Branch: PHP_5_1)
    /php-src    configure.in
    /php-src/ext/standard       basic_functions.c basic_functions.h
  Log:
add getloadavg() function that has been running in production on rs1.php.net
  for a couple of years.



http://cvs.php.net/viewcvs.cgi/php-src/configure.in?r1=1.579.2.36&r2=1.579.2.37&diff_format=u
Index: php-src/configure.in
diff -u php-src/configure.in:1.579.2.36 php-src/configure.in:1.579.2.37
--- php-src/configure.in:1.579.2.36     Thu Jan 12 15:24:10 2006
+++ php-src/configure.in        Thu Feb 16 22:49:13 2006
@@ -1,4 +1,4 @@
- ## $Id: configure.in,v 1.579.2.36 2006/01/12 15:24:10 iliaa Exp $ -*- autoconf -*- + ## $Id: configure.in,v 1.579.2.37 2006/02/16 22:49:13 wez Exp $ -*- autoconf -*-
 dnl ## Process this file with autoconf to produce a configure script.

 divert(1)
@@ -466,6 +466,7 @@
 funopen \
 gai_strerror \
 gcvt \
+getloadavg \
 getlogin \
 getprotobyname \
 getprotobynumber \
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/basic_functions.c?r1=1.725.2.20&r2=1.725.2.21&diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.725.2.20 php-src/ext/standard/basic_functions.c:1.725.2.21 --- php-src/ext/standard/basic_functions.c:1.725.2.20 Thu Feb 16 10:13:52 2006
+++ php-src/ext/standard/basic_functions.c      Thu Feb 16 22:49:13 2006
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */

-/* $Id: basic_functions.c,v 1.725.2.20 2006/02/16 10:13:52 tony2001 Exp $ */
+/* $Id: basic_functions.c,v 1.725.2.21 2006/02/16 22:49:13 wez Exp $ */

 #include "php.h"
 #include "php_streams.h"
@@ -425,7 +425,9 @@
 #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 @@
 }
 /* }}} */

+#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
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/basic_functions.h?r1=1.139.2.2&r2=1.139.2.3&diff_format=u
Index: php-src/ext/standard/basic_functions.h
diff -u php-src/ext/standard/basic_functions.h:1.139.2.2 php-src/ext/standard/basic_functions.h:1.139.2.3 --- php-src/ext/standard/basic_functions.h:1.139.2.2 Sat Jan 28 06:14:34 2006
+++ php-src/ext/standard/basic_functions.h      Thu Feb 16 22:49:13 2006
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */

-/* $Id: basic_functions.h,v 1.139.2.2 2006/01/28 06:14:34 fmk Exp $ */
+/* $Id: basic_functions.h,v 1.139.2.3 2006/02/16 22:49:13 wez Exp $ */

 #ifndef BASIC_FUNCTIONS_H
 #define BASIC_FUNCTIONS_H
@@ -116,6 +116,9 @@

 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);

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to