com php-src: Revert "Add possibility to lower timer resolution": UPGRADING ext/standard/hrtime.c ext/standard/tests/hrtime/hrtime_ini. phpt
ext/standard/tests/hrtime/hrtime_resolution.phpt
| From: | Anatol Belski | Date: | Thu, 11 Jan 2018 11:40:01 +0000 |
| Subject: | com php-src: Revert "Add possibility to lower timer resolution": UPGRADING ext/standard/hrtime.c ext/standard/tests/hrtime/hrtime_ini. phpt ext/standard/tests/hrtime/hrtime_resolution.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100834@lists.php.net to get a copy of this message | ||
Commit: 45db77ed0d601e4be6252a1f742bc08f49408aad
Author: Anatol Belski <ab@php.net> Thu, 11 Jan 2018 12:40:01 +0100
Parents: 57e4be9cefa6edad4763dc26a01c74de922c8eba
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=45db77ed0d601e4be6252a1f742bc08f49408aad
Log:
Revert "Add possibility to lower timer resolution"
This reverts commit c3717d9aecbe65cb2e5778a24a91e9eaf638639e.
The final mitigation of the consequences with spectre should be
discussed more also with the regard to the happenings on the
developments. Right now a preliminary mitigation might be wrong or
suboptimal, thus reverting this.
Changed paths:
M UPGRADING
M ext/standard/hrtime..c
D ext/standard/tests/hrtime/hrtime_ini.phpt
D ext/standard/tests/hrtime/hrtime_resolution.phpt
Diff:
diff --git a/UPGRADING b/UPGRADING
index 5863680..56b979b 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -104,8 +104,7 @@ Core:
adjustable and is not related to wall clock or time of day. The timers
are available under Linux, FreeBSD, Windows, Mac, SunOS, AIX and their
derivatives. If no required timers are provided by a corresponding
- platform, the function returns false. See also the description for the
- hrtime.resolution INI directive for further configuration details.
+ platform, the function returns false.
Date:
. Added the DateTime::createFromImmutable() method, which mirrors
@@ -190,16 +189,6 @@ PGSQL:
. This INI directive has been removed. The value has already been ignored
since PHP 5.3.0.
-- hrtime.resolution
- . This INI directive is PHP_INI_SYSTEM and controls the precision of the
- timestamps delivered by hrtime(). It expects a positive number of
- nanoseconds, to which the timestamp is rounded. For example, if the max
- desired precision of the timestamp is 20us, the INI value would be 20000
- and the timestamp is rounded to the next 20us. If the INI value is zero
- (default), the measurement is returned without change. Note, that the
- timestamp itself stays monotonic. The provided precision still affects,
- in how far two adjacent timestamps can be distinquished.
-
========================================
12. Windows Support
========================================
diff --git a/ext/standard/hrtime.c b/ext/standard/hrtime.c
index af1a91c..c32aef4 100644
--- a/ext/standard/hrtime.c
+++ b/ext/standard/hrtime.c
@@ -56,8 +56,6 @@ static mach_timebase_info_data_t _timerlib_info;
#endif
#define NANO_IN_SEC 1000000000
-
-static php_hrtime_t _timer_resolution = 0;
/* }}} */
static int _timer_init()
@@ -102,32 +100,9 @@ static int _timer_init()
return 0;
}/*}}}*/
-
-/* {{{ ini */
-static PHP_INI_MH(OnUpdateResolution)
-{
- zend_long _val;
-
- ZEND_ATOL(_val, ZSTR_VAL(new_value));
-
- if (_val < 0) {
- return FAILURE;
- }
- _timer_resolution = _val;
-
- return SUCCESS;
-}
-
-PHP_INI_BEGIN()
- PHP_INI_ENTRY("hrtime.resolution", "0", PHP_INI_SYSTEM, OnUpdateResolution)
-PHP_INI_END()
-/* }}} */
-
-/* {{{ MINIT */
+/* {{{ */
PHP_MINIT_FUNCTION(hrtime)
{
- REGISTER_INI_ENTRIES();
-
if (0 > _timer_init()) {
php_error_docref(NULL, E_WARNING, "Failed to initialize high-resolution timer");
return FAILURE;
@@ -201,10 +176,6 @@ PHP_FUNCTION(hrtime)
Z_PARAM_BOOL(get_as_num)
ZEND_PARSE_PARAMETERS_END();
- if (_timer_resolution) {
- t = (php_hrtime_t)(t / _timer_resolution) * _timer_resolution;
- }
-
if (UNEXPECTED(get_as_num)) {
PHP_RETURN_HRTIME(t);
} else {
diff --git a/ext/standard/tests/hrtime/hrtime_ini.phpt b/ext/standard/tests/hrtime/hrtime_ini.phpt
deleted file mode 100644
index 68149ab..0000000
--- a/ext/standard/tests/hrtime/hrtime_ini.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-Ensure hrtime.resolution is not changeable from script
---INI--
-hrtime.resolution=1000000
---FILE--
-<?php
- var_dump(
- ini_set("hrtime.resolution", 0),
- ini_get("hrtime.resolution")
- );
-?>
---EXPECT--
-bool(false)
-string(7) "1000000"
-
diff --git a/ext/standard/tests/hrtime/hrtime_resolution.phpt
b/ext/standard/tests/hrtime/hrtime_resolution.phpt
deleted file mode 100644
index c546b03..0000000
--- a/ext/standard/tests/hrtime/hrtime_resolution.phpt
+++ /dev/null
@@ -1,34 +0,0 @@
---TEST--
-Test hrtime() reduced resolution
---INI--
-hrtime.resolution=20000
---FILE--
-<?php
-
-/* This may fail on a very slow machine. Two subsequent timestamp
- probes shoul lay in the configured interval. */
-
-$d0 = hrtime(true) - hrtime(true);
-$d0 = abs($d0);
-
-$t0 = hrtime();
-$t1 = hrtime();
-$d1 = ($t1[0] - $t0[0]) * 1000000000 + $t1[1] - $t0[1];
-
-if (0 == $d0 || 20000 == $d0) {
- echo "PASS hrtime(true)\n";
-} else {
- echo "Two subsequent hrtime(true) calls gave $d0\n";
-}
-
-if (0 == $d1 || 20000 == $d1) {
- echo "PASS hrtime()\n";
-} else {
- echo "Two subsequent hrtime() calls gave $d1\n";
-}
-
-?>
---EXPECT--
-PASS hrtime(true)
-PASS hrtime()
-