Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:54109 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65600 invoked from network); 20 Jul 2011 11:25:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jul 2011 11:25:30 -0000 Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.170 as permitted sender) X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 209.85.216.170 mail-qy0-f170.google.com Received: from [209.85.216.170] ([209.85.216.170:47897] helo=mail-qy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0D/21-58957-92BB62E4 for ; Wed, 20 Jul 2011 07:25:30 -0400 Received: by qyg14 with SMTP id 14so2742992qyg.8 for ; Wed, 20 Jul 2011 04:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:reply-to:from:date:message-id:subject:to:content-type; bh=MpL10wnBsiTplz2RxLNyCQaZejXTS9cDXYYgMlhg6Zo=; b=qlpji/IY7Dotw9ioKwMKcJGD/DzkP7YYLZ2qUAxGzr3rCa0c7SauodZDHf6LAur2t/ vbwk/rpWtXqF2nZBBr9ckEg4WmuiCBKPZVB6CsYlNgPxR8qGMJNcneyuA2wX55NJFDYk I6cexH3jX4VhM3/TarE6Y16VzIjlNJTx/5D/o= Received: by 10.229.227.136 with SMTP id ja8mr6923954qcb.75.1311161127576; Wed, 20 Jul 2011 04:25:27 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.87.70 with HTTP; Wed, 20 Jul 2011 04:25:07 -0700 (PDT) Reply-To: RQuadling@GMail.com Date: Wed, 20 Jul 2011 12:25:07 +0100 Message-ID: To: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Coding for the differences in 5.3 and 5.4 _zend_class_entry structure. From: rquadling@gmail.com (Richard Quadling) Hi. Just seeing if I can get a small extension upgraded from 5.3 to 5.4 (the pecl/inclued extension). This is my attempt to learn more about internals and hopefully increase my contribution to the project. Prior to doing any work, I'm getting these errors ... ..\pecl\inclued\inclued.c(116) : error C2039: 'filename' : is not a member of '_zend_class_entry' D:\BuildPHP\PHP_5_4\PHP_5_4\Zend\zend.h(462) : see declaration of '_zend_class_entry' ..\pecl\inclued\inclued.c(116) : error C2198: 'add_assoc_string_ex' : too few arguments for call ..\pecl\inclued\inclued.c(117) : error C2039: 'line_start' : is not a member of '_zend_class_entry' D:\BuildPHP\PHP_5_4\PHP_5_4\Zend\zend.h(462) : see declaration of '_zend_class_entry' ..\pecl\inclued\inclued.c(117) : error C2198: 'add_assoc_long_ex' : too few arguments for call ..\pecl\inclued\inclued.c(130) : error C2039: 'filename' : is not a member of '_zend_class_entry' D:\BuildPHP\PHP_5_4\PHP_5_4\Zend\zend.h(462) : see declaration of '_zend_class_entry' ..\pecl\inclued\inclued.c(130) : error C2198: 'add_assoc_string_ex' : too few arguments for call ..\pecl\inclued\inclued.c(131) : error C2039: 'line_start' : is not a member of '_zend_class_entry' D:\BuildPHP\PHP_5_4\PHP_5_4\Zend\zend.h(462) : see declaration of '_zend_class_entry' ..\pecl\inclued\inclued.c(131) : error C2198: 'add_assoc_long_ex' : too few arguments for call So, filename and line_start are missing and should be user.info.filename and info.user.line_start. At this stage, I'm guessing that the add_assoc_string_ex errors are a knock-on effect as I can't see any difference in the macro definitions. So, I assume there has to be a #define to separate ... add_assoc_string_ex(class_entry, "filename", sizeof("filename"), ce->filename, 1); and add_assoc_string_ex(class_entry, "filename", sizeof("filename"), ce->info.user.filename, 1); http://svn.php.net/viewvc/pecl/apc/trunk/apc_zend.h?r1=303382&r2=303383& introduced a set of macros to cover some of the elements of zend_class_entry, but not for all of the elements of info.user, but contains an adequate pattern to implement the rest of the elements. Adding ... #if ZEND_MODULE_API_NO >= 20100409 #define ZEND_ENGINE_2_4 #endif ... #if defined(ZEND_ENGINE_2_4) #define ZEND_CE_FILENAME(ce) (ce)->info.user.filename #define ZEND_CE_LINESTART(ce) (ce)->info.user.line_start #else #define ZEND_CE_FILENAME(ce) (ce)->filename #define ZEND_CE_LINESTART(ce) (ce)->line_start #endif to inclued_zend.h (I don't know if I should put these in inclued_zend.h or php_include.h) and using these macros in inclued.c would be a start, but there are 2 ways I've found of determining the ZEND_ENGINE value. http://lxr.php.net/opengrok/xref/PECL/bcompiler/php_bcompiler.h#54, http://lxr.php.net/opengrok/xref/PECL/apc/apc_php.h#51 (others extensions also use #if ZEND_MODULE_API_NO >= 20100409 ...). As several extensions have had to implement these #defines to distinguish between the different zend engine versions, should these "level playing field" macros be moved (and completed) form the extension to core? OOI. Applying those changes allows inclued.c to compile, but now leaves me with errors in inclued_zend.c. These seem to be similar in issue but relate to the znode structures. -- Richard Quadling Twitter : EE : Zend : PHPDoc @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea