CVS update: php3/functions

From: Date: Sun, 27 Dec 1998 07:09:55 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-3060@lists.php.net to get a copy of this message
Date: Sunday December 27, 1998 @ 2:09 Author: sas Update of /repository/php3/functions In directory asf:/u/temp/cvs-serv10974/functions Modified Files: basic_functions.c microtime.c microtime.h Log Message: add gettimeofday() add getrusage() Index: php3/functions/basic_functions.c diff -c php3/functions/basic_functions.c:1.242 php3/functions/basic_functions.c:1.243 *** php3/functions/basic_functions.c:1.242 Mon Dec 21 15:45:22 1998 --- php3/functions/basic_functions.c Sun Dec 27 02:09:51 1998 *************** *** 264,270 **** --- 264,276 ---- #if HAVE_PUTENV {"putenv", php3_putenv, NULL}, #endif + #if HAVE_GETRUSAGE + {"getrusage", php3_getrusage, NULL}, + #endif + #if HAVE_GETTIMEOFDAY + {"gettimeofday", php3_gettimeofday, NULL}, {"microtime", php3_microtime, NULL}, + #endif {"uniqid", php3_uniqid, NULL}, {"linkinfo", php3_linkinfo, NULL}, {"readlink", php3_readlink, NULL}, Index: php3/functions/microtime.c diff -c php3/functions/microtime.c:1.22 php3/functions/microtime.c:1.23 *** php3/functions/microtime.c:1.22 Wed Nov 18 16:23:10 1998 --- php3/functions/microtime.c Sun Dec 27 02:09:55 1998 *************** *** 27,45 **** +----------------------------------------------------------------------+ */ ! /* $Id: microtime.c,v 1.22 1998/11/18 21:23:10 ssb Exp $ */ #include <stdlib.h> #ifdef HAVE_UNISTD_H #include <unistd.h> #endif #include <string.h> #include <errno.h> #ifdef THREAD_SAFE #include "tls.h" #endif - #include "php.h" #include "internal_functions.h" #include "microtime.h" #include "snprintf.h" --- 27,51 ---- +----------------------------------------------------------------------+ */ ! /* $Id: microtime.c,v 1.23 1998/12/27 07:09:55 sas Exp $ */ + #include "php.h" #include <stdlib.h> #ifdef HAVE_UNISTD_H #include <unistd.h> #endif + #ifdef HAVE_SYS_TIME_H + #include <sys/time.h> + #endif + #ifdef HAVE_SYS_RESOURCE_H + #include <sys/resource.h> + #endif #include <string.h> #include <errno.h> #ifdef THREAD_SAFE #include "tls.h" #endif #include "internal_functions.h" #include "microtime.h" #include "snprintf.h" *************** *** 78,83 **** --- 84,152 ---- snprintf(ret, 100, "%.8f %ld", msec, sec); RETVAL_STRING(ret,1); #endif + } + /* }}} */ + + /* {{{ proto array gettimeofday(void) + Returns the current time as array */ + void php3_gettimeofday(INTERNAL_FUNCTION_PARAMETERS) + { + #if HAVE_GETTIMEOFDAY + struct timeval tp; + + if(gettimeofday(&tp, (struct timezone *) 0) == 0) { + array_init(return_value); + add_next_index_long(return_value, tp.tv_sec); + add_next_index_long(return_value, tp.tv_usec); + } else { + RETURN_FALSE; + } + #endif + } + /* }}} */ + + /* {{{ proto array getrusage([ int who ]) + returns an array of usage statistics */ + void php3_getrusage(INTERNAL_FUNCTION_PARAMETERS) + { + #ifdef HAVE_GETRUSAGE + struct rusage usg; + int ac = ARG_COUNT(ht); + pval *pwho; + int who = RUSAGE_SELF; + + if(ac == 1 && + getParameters(ht, ac, &pwho) != FAILURE) { + convert_to_long(pwho); + if(pwho->value.lval == 1) + who = RUSAGE_CHILDREN; + } + + if(getrusage(who, &usg) == -1) { + RETURN_FALSE; + } + + array_init(return_value); + #define PHP3_RUSAGE_PARA(a) \ + add_assoc_long(return_value, #a, usg.a) + PHP3_RUSAGE_PARA(ru_oublock); + PHP3_RUSAGE_PARA(ru_inblock); + PHP3_RUSAGE_PARA(ru_msgsnd); + PHP3_RUSAGE_PARA(ru_msgrcv); + PHP3_RUSAGE_PARA(ru_maxrss); + PHP3_RUSAGE_PARA(ru_ixrss); + PHP3_RUSAGE_PARA(ru_idrss); + PHP3_RUSAGE_PARA(ru_minflt); + PHP3_RUSAGE_PARA(ru_majflt); + PHP3_RUSAGE_PARA(ru_nsignals); + PHP3_RUSAGE_PARA(ru_nvcsw); + PHP3_RUSAGE_PARA(ru_nivcsw); + PHP3_RUSAGE_PARA(ru_utime.tv_usec); + PHP3_RUSAGE_PARA(ru_utime.tv_sec); + PHP3_RUSAGE_PARA(ru_stime.tv_usec); + PHP3_RUSAGE_PARA(ru_stime.tv_sec); + #undef PHP3_RUSAGE_PARA(a) + #endif /* HAVE_GETRUSAGE */ } /* }}} */ Index: php3/functions/microtime.h diff -c php3/functions/microtime.h:1.5 php3/functions/microtime.h:1.6 *** php3/functions/microtime.h:1.5 Wed Apr 29 09:24:17 1998 --- php3/functions/microtime.h Sun Dec 27 02:09:55 1998 *************** *** 27,37 **** +----------------------------------------------------------------------+ */ ! /* $Id: microtime.h,v 1.5 1998/04/29 13:24:17 ssb Exp $ */ #ifndef _MICROTIME_H #define _MICROTIME_H extern void php3_microtime(INTERNAL_FUNCTION_PARAMETERS); #endif /* _MICROTIME_H */ --- 27,39 ---- +----------------------------------------------------------------------+ */ ! /* $Id: microtime.h,v 1.6 1998/12/27 07:09:55 sas Exp $ */ #ifndef _MICROTIME_H #define _MICROTIME_H extern void php3_microtime(INTERNAL_FUNCTION_PARAMETERS); + extern void php3_getrusage(INTERNAL_FUNCTION_PARAMETERS); + extern void php3_gettimeofday(INTERNAL_FUNCTION_PARAMETERS); #endif /* _MICROTIME_H */ -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#3060) next »