Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » PHP
  • » [PHP-CVS] cvs: php-src / NEWS /ext/standard basic_functions.c basic_functions.h [RSS Feed]

#1 April 10, 2005 17:45:44

Andrey H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-CVS] cvs: php-src / NEWS /ext/standard basic_functions.c basic_functions.h


Hi Ilia,
when I saw this commit I gazed half a minute to understand why
there is a time_ in front. Later I realized that you have introduced
a namespace for time functions. This is a good idea still the name is
a bit confusing IMO :) Also I saw that you have added quite a long ago
time_nanosleep(). I know we don't like polluting the global namespace,
but for functions that rely on system functions, like the case with
nanosleep they use the same name. Example: strpbrk().Because both functions are in HEAD and still the API is not released
I would appreciate if time_nanosleep() is renamed to nanosleep().
time_sleep_until() "emulate" a system function but uses it and in this
case maybe the name may stay the same.To rephrase, if there are no objections I will go and rename time_nanosleep()
to nanosleep() :)Best wishes,
AndreyIlia Alshanetsky wrote:iliaa Sun Apr 10 12:25:11 2005 EDTModified files:
/php-src NEWS
/php-src/ext/standard basic_functions.c basic_functions.h
Log:Added time_sleep_until() function, which is a high precision mechanism ofmaking a script sleep until specified timestamp.http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1867&r2=1.1868&ty=uIndex: php-src/NEWSdiff -u php-src/NEWS:1.1867php-src/NEWS:1.1868--- php-src/NEWS:1.1867Wed Apr 6 12:07:24 2005+++ php-src/NEWS Sun Apr 10 12:25:11 2005@@ -83,6 +83,7 @@. fputcsv() (David Sklar). posix_access() (Magnus). htmlspecialchars_decode() (Ilia)+ . time_sleep_until() (Ilia)- Added DomDocument::$recover property for parsing not well-formedXML Documents. (Christian)
- Added Cursor support for MySQL 5.0.x in mysqli (Georg)http://cvs.php.net/diff.php/php-src/ext/standard/basic_functions.c?r1=1.708&r2=1.709&ty=uIndex: php-src/ext/standard/basic_functions.cdiff -u php-src/ext/standard/basic_functions.c:1.708 php-src/ext/standard/basic_functions.c:1.709--- php-src/ext/standard/basic_functions.c:1.708 Wed Apr 6 10:19:14 2005+++ php-src/ext/standard/basic_functions.c Sun Apr 10 12:25:11 2005@@ -17,7 +17,7 @@+----------------------------------------------------------------------+*/-/* $Id: basic_functions.c,v 1.708 2005/04/06 14:19:14 iliaa Exp $ */+/* $Id: basic_functions.c,v 1.709 2005/04/10 16:25:11 iliaa Exp $ */#include "php.h"#include "php_streams.h"@@ -167,6 +167,7 @@PHP_FE(usleep, NULL)#if HAVE_NANOSLEEPPHP_FE(time_nanosleep, NULL)+ PHP_FE(time_sleep_until, NULL)#endifPHP_FE(time, NULL)PHP_FE(mktime, NULL)@@ -1790,6 +1791,48 @@RETURN_FALSE;}/* }}} */++/* {{{ proto mixed time_sleep_until(float timestamp)+ Make the script sleep until the specified time */+PHP_FUNCTION(time_sleep_until)+{+ double d_ts, c_ts;+ struct timeval tm;+ struct timespec php_req, php_rem;++ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &d_ts)) {+ WRONG_PARAM_COUNT;+ }++ if (gettimeofday((struct timeval *) &tm, NULL) != 0) {+ RETURN_FALSE;+ }++ c_ts = (double)(d_ts - tm.tv_sec - tm.tv_usec / 1000000.00);+ if (c_ts < 0) {+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Sleep until to time is less then current time.");+ RETURN_FALSE;+ }++ php_req.tv_sec = (time_t) c_ts;+ if (php_req.tv_sec > c_ts) { /* rounding up occurred */+ php_req.tv_sec--;+ }+ /* 1sec = 1000000000 nanoseconds */+ php_req.tv_nsec = (long) ((c_ts - php_req.tv_sec) * 1000000000.00);++ while (nanosleep(&php_req, &php_rem)) {+ if (errno == EINTR) {+ php_req.tv_sec = php_rem.tv_sec;+ php_req.tv_nsec = php_rem.tv_nsec;+ } else {+ RETURN_FALSE;+ }+ }++ RETURN_TRUE;+}+/* }}} */#endif/* {{{ proto string get_current_user(void)http://cvs.php.net/diff.php/php-src/ext/standard/basic_functions.h?r1=1.136&r2=1.137&ty=uIndex: php-src/ext/standard/basic_functions.hdiff -u php-src/ext/standard/basic_functions.h:1.136 php-src/ext/standard/basic_functions.h:1.137--- php-src/ext/standard/basic_functions.h:1.136 Wed Apr 6 10:19:14 2005+++ php-src/ext/standard/basic_functions.h Sun Apr 10 12:25:11 2005@@ -17,7 +17,7 @@+----------------------------------------------------------------------+*/-/* $Id: basic_functions.h,v 1.136 2005/04/06 14:19:14 iliaa Exp $ */+/* $Id: basic_functions.h,v 1.137 2005/04/10 16:25:11 iliaa Exp $ */#ifndef BASIC_FUNCTIONS_H#define BASIC_FUNCTIONS_H@@ -50,6 +50,7 @@PHP_FUNCTION(usleep);#if HAVE_NANOSLEEPPHP_FUNCTION(time_nanosleep);+PHP_FUNCTION(time_sleep_until);#endifPHP_FUNCTION(flush);#ifdef HAVE_INET_NTOP--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#2 April 10, 2005 17:54:43

Ilia A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

[PHP-CVS] cvs: php-src / NEWS /ext/standard basic_functions.c basic_functions.h


Andrey Hristov wrote:Because both functions are in HEAD and still the API is not released
I would appreciate if time_nanosleep() is renamed to nanosleep().
time_sleep_until() "emulate" a system function but uses it and in this
case maybe the name may stay the same.To rephrase, if there are no objections I will go and rename
time_nanosleep()to nanosleep() :)I'd prefer the function remain called time_nanosleep(), while there is
certainly a value to having C -> PHP mappings have the same name. The
direction we seem to be taking lately is towards "namespacing" similar
functions together.Ilia--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit:http://www.php.net/unsub.php

Offline

#3 May 7, 2017 02:05:21

Michaelnow
Registered: 2017-04-25
Posts: 1
Reputation: +  0  -
Profile   Send e-mail  

[PHP-CVS] cvs: php-src / NEWS /ext/standard basic_functions.c basic_functions.h

This post is being moderated

Offline

  • Root
  • » PHP
  • » [PHP-CVS] cvs: php-src / NEWS /ext/standard basic_functions.c basic_functions.h [RSS Feed]

Board footer

Moderator control

Enjoy the 23rd of June
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support