Tuesday 15 December 2015

PHP 7.0.0 discovery

Hi folks,

Every PHP's developer on earth heard and was excited about the PHP 7 release and all its beneficial promises. Quite a revolution in term of performance, memory usage and type safety handling. Very well !

There is another revolution in the internal C api as well, more interesting then for native modules developers. Indeed, I developed couple of PHP modules myself C or C++ and wanted to update the very last to make it compatible for both 5.x and 7.0 branches. Nothing better than to read the zend engine code and what caught my eyes in the first place is the new zend_string type, using reference counter. Most of previous zend functions which dealt with raw C strings are updated (like the various hashtable ones). So yes in my case that was mainly adding a couple of PHP version checking here and there, was a dozen on lines changes, no more ; finally was less than I expected :-) Then testing with both php 5 and 7 from OpenBSD ports (thanks they made it cleverly as you can have distinct php versions w/o issues ...) so everything went smooth ...

#if PHP_MAJOR_VERSION < 7
 ...
 char *key;
 ulong idx;
 uint key_len;
 ...
#else
 ...
 zend_string *key;
 zend_ulong idx;
        ...
#endif
...
#if PHP_MAJOR_VERSION < 7
  if (zend_hash_get_current_key_ex(Z_ARRVAL_P(hdarray), &key, &key_len, &idx, 0, &ppos) !=
   HASH_KEY_IS_STRING) {
#else
  if (zend_hash_get_current_key_ex(Z_ARRVAL_P(hdarray), &key, &idx, &ppos) !=
   HASH_KEY_IS_STRING) {
  ...
  zend_string_addref(key);
  char *p = ZSTR_VAL(key);
  ...
#endif
...

Labels: , ,

View David Carlier's profile on LinkedIn

Monday 7 December 2015

50th post already ...

Hi folks,

The new BSDMag issue finally landed.

There is a nice introduction to NetBSD, another article about Xen on FreeBSD, TrueNAS, an original article about the GUI evolution through the software engineering history then my article about various development tools on FreeBSD for various programming languages / frameworks.

So that's already one year of writing and it is a worthy experience apart of the personal exposure ; indeed that greatly improved my english in general and the technical one in particular so that serves me professionally speaking as well !

Hope you'll enjoy the reading before entering in the Xmas/End of Year's "craziness" ;-)

Labels: , , , , , ,

View David Carlier's profile on LinkedIn