Various fix

814309d fix an undefined behavior which cause build failure with gcc 4.9 and -O2.

Please check 1a99bf1

For da1c36b I'd like to use #ifdef HAVE_ARPA_INET_H but php_config.h is not included in this part.