Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79125 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59996 invoked from network); 24 Nov 2014 14:27:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Nov 2014 14:27:35 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.169 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.212.169 mail-wi0-f169.google.com Received: from [209.85.212.169] ([209.85.212.169:50831] helo=mail-wi0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FF/04-33396-65043745 for ; Mon, 24 Nov 2014 09:27:34 -0500 Received: by mail-wi0-f169.google.com with SMTP id r20so9024622wiv.2 for ; Mon, 24 Nov 2014 06:27:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Sa8G9AbXKRepEtrAhttDIyE/LbpFV/CgJBMo7QGkEJQ=; b=M1E0DUYLH9CYplYz6uLe5lEpiOuI95gsCQM6ZEal+TGBfcO9ZP6re+cVH+gOLulHP9 rFd4RxLx5YYN5J2VAzDYxj2L51Tl0T0FNLeEFdYayr0XWPi8b2riKjf0ND4S8qHebFom 412Cpyc5te49wC1HNF4J+n54lEhD7lxE9L6zGKZ75oC81Fp5v8mnpUzSRrh5o+LVO8h/ gI8cqcBYSnXtHDuNpdjCMp9td+kWO6xtiNlxnAbU6L5Rrr7BxPtz9OMJO2Ipz8SH7QN3 KeAOscsqUCj0yv7jMJXVfJipS0TW9AlVLHudY3H8GjOWnXGlHjSnjpObfKURfvk1an3o qbtg== MIME-Version: 1.0 X-Received: by 10.180.78.73 with SMTP id z9mr21899600wiw.52.1416839251030; Mon, 24 Nov 2014 06:27:31 -0800 (PST) Received: by 10.27.10.4 with HTTP; Mon, 24 Nov 2014 06:27:30 -0800 (PST) In-Reply-To: References: Date: Mon, 24 Nov 2014 15:27:30 +0100 Message-ID: To: Dmitry Stogov Cc: Xinchen Hui , Anatol Belski , PHP Internals Content-Type: multipart/alternative; boundary=f46d0438903b42f78405089b98f8 Subject: Re: Use zend_string* for op_array->arg_info[].name and class_name From: nikita.ppv@gmail.com (Nikita Popov) --f46d0438903b42f78405089b98f8 Content-Type: text/plain; charset=UTF-8 On Mon, Nov 17, 2014 at 10:25 AM, Dmitry Stogov wrote: > Hi, > > Please review the patch > https://gist.github.com/dstogov/47a39aff37f0a6441ea0 > > Thanks. Dmitry. > Hi Dmitry, sorry for late reply. The problem we're trying to solve here is lack of ability to create a zend_string at compile time. I just tried two ideas how we might be able to do that, to avoid introducing different arginfos for internal/userland functions. My first approach was to create a zend_string as a string literal using (zend_string *) ("\1\0\0\0" "\6\1\0\0" "\0\0\0\0" "\0\0\0\0" str) (for 32bit LE) and then update the length in zend_register_functions. However this didn't work because the string literal ends up in readonly memprotected memory, so this causes a segfault. My second approach was to use a C99 compound literal to create a temporary zend_string-like structure with the correct length: #define ZEND_STRING_CT(str) \ (zend_string *) (struct { \ uint32_t refcount; uint32_t type_info; \ zend_ulong h; size_t len; \ char val[sizeof(str)]; \ }[1]) {{ 1, IS_STRING | (IS_STR_PERSISTENT << 8), 0, sizeof(str)-1, str }} This seems to work fine (patch https://github.com/nikic/php-src/commit/5d49321cd9728e0cc1c2939432e46159f9a78472). However it requires C99, which we're currently not allowed to use. Maybe someone has an idea how this can be done in C89? Nikita --f46d0438903b42f78405089b98f8--