From nobody Mon Feb 9 19:53:18 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; dkim=fail spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498159318621263.8890001922483; Thu, 22 Jun 2017 12:21:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D5ADC63E1B; Thu, 22 Jun 2017 19:21:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A885C5C542; Thu, 22 Jun 2017 19:21:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4D27C41F63; Thu, 22 Jun 2017 19:21:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5MJED5q013738 for ; Thu, 22 Jun 2017 15:14:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id BDD6968D46; Thu, 22 Jun 2017 19:14:13 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B7B2B65E9B for ; Thu, 22 Jun 2017 19:14:11 +0000 (UTC) Received: from mail-qk0-f179.google.com (mail-qk0-f179.google.com [209.85.220.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C0AE7C0587C3 for ; Thu, 22 Jun 2017 19:14:10 +0000 (UTC) Received: by mail-qk0-f179.google.com with SMTP id d14so19992489qkb.1 for ; Thu, 22 Jun 2017 12:14:10 -0700 (PDT) Received: from dawid-fedora.datto.lan ([47.19.105.250]) by smtp.gmail.com with ESMTPSA id g39sm1837145qtc.12.2017.06.22.12.14.09 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Jun 2017 12:14:09 -0700 (PDT) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D5ADC63E1B Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D5ADC63E1B Authentication-Results: mx1.redhat.com; dkim=fail reason="signature verification failed" (2048-bit key) header.d=datto-com.20150623.gappssmtp.com header.i=@datto-com.20150623.gappssmtp.com header.b="qlNLOLL+" DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C0AE7C0587C3 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=datto.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=dzamirski@datto.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C0AE7C0587C3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=datto-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=b7KSNtFFFGH3dEO3l0cMATfzFx3d1NcKPlrtZq7/YQs=; b=qlNLOLL+/7PGqlQg7XYoPrZy0ms9sVpTtwJ+7gEV4757l1w6UpVNmh7RpiDS2LhKiW K+ESL/I3aqPR4TM3yxUUPMbKg4CXDa8v3CzasbMy5VneeBowZgAmDIxcFVBiJ2wsovie p6JyxUjAN/BWBYQK/xv3gm30aY3mJXubNp9XBsIQ4u+eiiH2hxMpp12M+IQY4N8JRddL pIlb1mgFf5wL/JeERQe3zbqohn9Go5Gi8fsuyhSVdiSBCLt9b787sd44GdZVwm7ifyML OPaf/k3A0yzvW8D0mjHvyg8zziuKgI57S2/UUHE5Kr01R5osYt0M8ZZtJM/mD4tDg2HZ TgBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=b7KSNtFFFGH3dEO3l0cMATfzFx3d1NcKPlrtZq7/YQs=; b=U8+OTh/TNz0vX+UlxUZ2D3gXiSmXFoLWjdhWj9FDscQQ278Q7jTmTwWAcReafaGMfk 0FgOAiOo+F8IpHHGAmFxaevyxFCjgKZZEnyIBAsW3ZGCy9Lnaqim/X90e3IJagweQOMB DKDedrCqSadkKcg1xiYyOJMTkpYhnaNDqM4hHFg09LXqJAQmmXqW00xuQ0D0BzftmsWe TVMvrqY17APahQNGeXd1c40sliI6Uthqjx7QVfpigsmdfU10ZdE6ZFmgZlS33JWdGjv9 j5yxzAxmdpIPE3U9/E+tRdZ7Cnyszuap6//5w9QsrTSRJgy5jaWO46oZlvI9Ew71RhZG 8bBA== X-Gm-Message-State: AKS2vOx93p8Z5qr9FZG5+q62gQFkRIIh4rykQbVoSRHWUmmOsc64BB2E /+JOoRc6f+sLvs8UCAjhDQ== X-Received: by 10.55.71.20 with SMTP id u20mr4596733qka.66.1498158849962; Thu, 22 Jun 2017 12:14:09 -0700 (PDT) From: Dawid Zamirski To: libvir-list@redhat.com Date: Thu, 22 Jun 2017 15:14:02 -0400 Message-Id: <20170622191407.15570-3-dzamirski@datto.com> In-Reply-To: <20170622191407.15570-1-dzamirski@datto.com> References: <20170622191407.15570-1-dzamirski@datto.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 22 Jun 2017 19:14:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 22 Jun 2017 19:14:11 +0000 (UTC) for IP:'209.85.220.179' DOMAIN:'mail-qk0-f179.google.com' HELO:'mail-qk0-f179.google.com' FROM:'dzamirski@datto.com' RCPT:'' X-RedHat-Spam-Score: 0.369 (BAYES_50, DCC_REPUT_00_12, DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.220.179 mail-qk0-f179.google.com 209.85.220.179 mail-qk0-f179.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [libvirt-php PATCH 2/7] add wrappers for PHP resource handling. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 22 Jun 2017 19:21:56 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" There were quite a few places in code that were using preprocessor directives to handle differences in dealing with resources between PHP versions which can be dealt with by using typdefs and macros. --- src/libvirt-php.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/libvirt-php.h b/src/libvirt-php.h index d25fa94..0422661 100644 --- a/src/libvirt-php.h +++ b/src/libvirt-php.h @@ -121,6 +121,19 @@ typedef uint64_t arch_uint; =20 #if PHP_MAJOR_VERSION >=3D 7 typedef size_t strsize_t; +typedef zend_resource virt_resource; + +#define VIRT_RETURN_RESOURCE(_resource) \ + RETVAL_RES(_resource) + +#define VIRT_REGISTER_RESOURCE(_resource, _le_resource) \ + VIRT_RETURN_RESOURCE(zend_register_resource(_resource, _le_resource)) + +#define VIRT_REGISTER_LIST_RESOURCE(_name) do { \ + zval zret; \ + ZVAL_RES(&zret, zend_register_resource(res_##_name, le_libvirt_##_name= )); \ + add_next_index_zval(return_value, &zret); \ + } while(0) =20 #define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ if ((_state =3D (_type)zend_fetch_resource(Z_RES_P(*_zval), _name, _le= )) =3D=3D NULL) { \ @@ -165,6 +178,20 @@ typedef size_t strsize_t; typedef int strsize_t; typedef long zend_long; typedef unsigned long zend_ulong; +typedef zend_rsrc_list_entry virt_resource; + +#define VIRT_RETURN_RESOURCE(_resource) \ + RETVAL_RESOURCE((long) _resource) + +#define VIRT_REGISTER_RESOURCE(_resource, _le_resource) \ + ZEND_REGISTER_RESOURCE(return_value, _resource, _le_resource) + +#define VIRT_REGISTER_LIST_RESOURCE(_name) do { \ + zval *zret; \ + ALLOC_INIT_ZVAL(zret); \ + ZEND_REGISTER_RESOURCE(zret, res_##_name, le_libvirt_##_name); \ + add_next_index_zval(return_value, zret); \ + } while(0) =20 #define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ ZEND_FETCH_RESOURCE(_state, _type, _zval, -1, _name, _le); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list