com php-src: more precise info on printf formats and fix some wording: compat/PECL_PORTING
| From: | Anatol Belski | Date: | Tue, 28 Jan 2014 23:16:47 +0000 |
| Subject: | com php-src: more precise info on printf formats and fix some wording: compat/PECL_PORTING | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-75833@lists.php.net to get a copy of this message | ||
Commit: 4347713fd2de5d7a3354e46bda295c959e70e0cc
Author: Anatol Belski <ab@php.net> Wed, 29 Jan 2014 00:16:47 +0100
Parents: febe4236433f148861a508920483e96a725a1337
Branches: str_size_and_int64
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4347713fd2de5d7a3354e46bda295c959e70e0cc
Log:
more precise info on printf formats and fix some wording
Changed paths:
M compat/PECL_PORTING
Diff:
diff --git a/compat/PECL_PORTING b/compat/PECL_PORTING
index f2885cb..08743d0 100644
--- a/compat/PECL_PORTING
+++ b/compat/PECL_PORTING
@@ -159,9 +159,11 @@ II. Porting steps
vi. spprintf() formats
- New printf modifier 'p' was implemented to platform independently output
- php_int_t datatype. That modifier can be used with 'd', 'u', 'x' and
'o' printf
- format specs with spprintf, snprintf and the wrapping printf implementations.
+ New printf modifier 'p' was implemented to platform independently output php_int_t,
+ php_uint_t and php_size_t datatypes. That modifier can be used with'd', 'u',
'x' and 'o'
+ printf format specs with spprintf, snprintf and the wrapping printf implementations.
+ %pu is sufficient for both php_uint_t and php_size_t.
+
To ensure compatibility, the macros ZEND_INT_FMT and ZEND_UINT_FMT should be
used
@@ -185,6 +187,9 @@ II. Porting steps
:%s,%ld," ZEND_INT_FMT ",g
+ With this in mind, the code using %p spec to output pointer address might
+ need to be enclosed into #ifdef when it unlickily followed by 'd', 'u',
'x' or 'o'.
+
vii. Array API
Datatype for array indexes was changed to php_uint_t, for key lengths to php_size_t
@@ -267,14 +272,13 @@ III. Pitfalls
v. Bitwise operations
Especialy some bitshift operations might bring unexpected results when mixing 32 and
- 64 bit variables or constants. For example this snippet works different on 32 and
- 64 bit platforms
+ 64 bit variables or constants. Here's the example snippet
php_int_t var = 1 << 31;
While a 32 bit variable can hold bits from 0 to 31, a 64 bit variable can hold bits
from 0 to 63. So with the snippet above the result the max negative value of 32 bit
- integer. To have it working correct way, an explicit cast
+ integer. To have it working correct way on 64 bit, an explicit cast
php_int_t var = (php_int_t)1 << 31;