Tuesday, 5 July 2016

Program of the week

Hi folks,

Several small updates since the last time. Indeed, nothing too major but a bunch of contributions here and there.

First of all, I contributed a little bit for the first time to php (7). No new features, just some fixes
this PR which is merged already and another one still pending but there is actually a lot of branching for the next 7.1 branch so a little patience is required ;) some people might think I might be insane to try to fix php but :) ... it s quite popular, used by most of my colleagues and myself too sometimes so that might be useful ;)

Also I try to make sure Haproxy compiles always on BSD hence this very recent patch for the very next future 1.7 release (for this autumn).

At last, was always curious how a video game is made in a technical point of view, I chose a simple (code wise) and old one ... Tremulous, which I forked and cleaned up quite a lot as first step. It is more for "self-education" than anything else but I have better understanding at least :) I have other plans for next after cleaning up, we ll see ;)

Labels: , , ,

View David Carlier's profile on LinkedIn

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