From patchwork Sat Aug 21 20:47:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 12451049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6C5FC4338F for ; Sat, 21 Aug 2021 21:12:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 22CCC61262 for ; Sat, 21 Aug 2021 21:12:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 22CCC61262 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=crudebyte.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:58328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mHYIR-00021T-PL for qemu-devel@archiver.kernel.org; Sat, 21 Aug 2021 17:12:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHYHC-00005f-Hp for qemu-devel@nongnu.org; Sat, 21 Aug 2021 17:11:38 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:34655) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mHYH8-0001Sk-1o for qemu-devel@nongnu.org; Sat, 21 Aug 2021 17:11:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Content-ID: Content-Description; bh=5W191dQubpiqUqsRb7aAR38bq6V5ebeVM0XrCOmo/Ec=; b=fnmbZ 5osX8eDJDVQ5og640XSqRdkpN7bFHMUTdn9TaexC8Th2Rwl3B6ojr8s0ruFLQr3aDeStLFuVoDYix 1D61Nj1uBC28DDTotREU1uMbYRVuAn2/qhgT1bmKZYHByMuEqPojm9BqIBhjxRL0ZPOOauOlMi6Jb VQXHDci6EiNfu1vpc1RdBTrP5EivNVTAPhXEiRb1lcnRkVLZDcyxkUsCXa12zxw0A3PJUEI5yOgbZ cdGmulAv1QIrkrx+zaov9RtojfBptYSJ3GlYpaTAKUpudZ/VJKQTzyJHQRB/sJ3OrrfTx3cNRjYte vigfjraOnjtRFjGipTFB96Tbuzkqw==; Message-Id: From: Christian Schoenebeck Date: Sat, 21 Aug 2021 22:47:55 +0200 Subject: [PATCH 0/5] introduce QArray To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: none client-ip=91.194.90.13; envelope-from=c34a1d230748f5a0996a60d7f2b7b3e95342ef4f@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Patches 1 and 2 introduce include/qemu/qarray.h which implements a deep auto free mechanism for arrays. Unlike GArray it does not require special macros, function calls or member dereferencing to access the individual array elements. So existing C-style array code can be retained with only very little changes. In this initial version QArray only supports the concept of unique pointers, i.e. it does not support reference counting. The array (and all dynamically allocated memory of individual array elements) is auto freed once execution leaves the scope of the reference variable (unique pointer) associated with the array. Patches 3..5 are provided (e.g. as example) for 9p being the first user of this new QArray API. These particular patches 3..5 are rebased on my current 9p queue: https://github.com/cschoenebeck/qemu/commits/9p.next which are basically just the following two queued patches: https://github.com/cschoenebeck/qemu/commit/7772715d43908235940f5b7dec68d0458b1ccdf4 https://github.com/cschoenebeck/qemu/commit/838b55e392ea7d52e714fdba1db777f658aee2cc Christian Schoenebeck (5): qemu/qarray.h: introduce QArray qemu/qarray.h: weak scalar type check in QARRAY_CREATE() 9pfs: make V9fsString usable via QArray API 9pfs: make V9fsPath usable via QArray API 9pfs: use QArray in v9fs_walk() fsdev/9p-marshal.c | 2 + fsdev/9p-marshal.h | 3 + fsdev/file-op-9p.h | 2 + hw/9pfs/9p.c | 19 ++---- include/qemu/qarray.h | 154 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 168 insertions(+), 12 deletions(-) create mode 100644 include/qemu/qarray.h