From nobody Mon Feb 9 12:11:15 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1573847216; cv=none; d=zoho.com; s=zohoarc; b=RTS96ItF7IivZw4/8+4R1XPcLahtIMMPkpIVDw5jzToRPOuyPLx8Q0RQwzXVgpEysIgs/J8G0eytPu0Z89pq2afvs6Nj0EXHe67iuEki8HVdoZsUk0s/ct7U8BZK0stz5zJ5EqKk4JSr1dCRH+/RKbiNdpK1Adtyxm8WGhmEyog= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573847216; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7KZ2/arN/70oxMfur3M2hE19Ju7Civyp94jayE/ALuE=; b=OIGsG83MpJhNmuu7yAQHm8Cq+uL+Pn1R/t2ur/EZAYO5baODUL7zXXEJRLKH9/1hQP0sSpqoy1ZiADqMeqa25otib9AZnQDH7xIg2YcCy6Q0Ayt8/UcH0sjt92LImbfPRWKmvG1uiG2W2uIrneJNqQ1dpN6MAejtGh9SwdELVb4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1573847216991825.321457541331; Fri, 15 Nov 2019 11:46:56 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iVhXc-0001oy-Ok; Fri, 15 Nov 2019 19:46:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iVhXb-0001nZ-Hc for xen-devel@lists.xenproject.org; Fri, 15 Nov 2019 19:45:59 +0000 Received: from mail-qk1-x743.google.com (unknown [2607:f8b0:4864:20::743]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 70d7d4a0-07e0-11ea-b678-bc764e2007e4; Fri, 15 Nov 2019 19:45:13 +0000 (UTC) Received: by mail-qk1-x743.google.com with SMTP id d13so9051132qko.3 for ; Fri, 15 Nov 2019 11:45:13 -0800 (PST) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id y10sm4649679qkb.55.2019.11.15.11.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2019 11:45:12 -0800 (PST) X-Inumbo-ID: 70d7d4a0-07e0-11ea-b678-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H+WE+lipIRlB+Fufpf96h4a0peDgVnMvRPfh/PoDswM=; b=rzSzXp3UJ/tuXb0n9DlnOT73g4cWmaDw4lpVYUaDTm6SGpvOU/kJPudRyvWf/0RhNE owu4UgBvxXPVy2HHQP1Yr2kKM/mcT2oY1YDtWLxxBKRvcvWFI4XGDGvB7RRg1rJ3cDVQ rIJop2eCiHMhHubSy9Wzj9xuUUpxMR39dmoUMC56U06hOdFn4LUbyBNXtS8yc1P8Kh1f uGb9NWNkGFjY0bAwbopeBtWOhDBPXoYlj/2Csu/76NnspcepX9BaUCJ7u4TkVnkddLJu 380TaFeMxISwE9lmVqutCR068d6tabKaUnYZCJFrU4fxHifFPJ43zSfDhZQVTYwN7F95 UIcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H+WE+lipIRlB+Fufpf96h4a0peDgVnMvRPfh/PoDswM=; b=Uk5Vp/bqnzraumBAvtMWhhbybrwIp3rF8Sfs6ixXngKbR2pafkBqiIoYQ2FkNSLlSU qqqPlyXcDkRUSXOT4WtVlRFDUQq9xCybHkIwzAZoFcCHpMdPqADE+7JyPxYW31UDIU7P obuXPUpYtbJzk5IWDxE6szlCh55jBH0zmLtMuS6EU/lcP7NBSw0BjwsHAuxZi2E7t3T1 BzRSx9R648Nhdtv9jNgIXoC0r11bFhdd/T8E0WkgtEW9jcM+YajvThMr+DC1RqdQuhds vmzzX6ZY3k63xUrAW6AJo2a67/O9+7rG4NdqQ8rqgVdqwq3N6QA9kAxCrzIs2LOEj/KY dX6w== X-Gm-Message-State: APjAAAV3/KWWx2zbN4fF1F3XMXNR2tWkyjO/sLY7wMa6iMS4963sjf5W JrMqD3koubdPtQfTIjr1HoLIG1VV X-Google-Smtp-Source: APXvYqzLS0MWglIeOpaqAjwbcybOsjEdU/E43FGKVhft+NhdZu5cEg8rblonadNsl5l3bFEDyLx9kQ== X-Received: by 2002:a37:9c85:: with SMTP id f127mr14392162qke.186.1573847112857; Fri, 15 Nov 2019 11:45:12 -0800 (PST) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Fri, 15 Nov 2019 14:44:19 -0500 Message-Id: <3bf4e3167d703d680a6bd6f3226ba394b0ed443f.1573840474.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 12/22] golang/xenlight: re-factor Hwcap type implementation X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nick Rosbrook , Ian Jackson , kerriganb@ainfosec.com, George Dunlap , Wei Liu Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Nick Rosbrook Re-define Hwcap as [8]uint32, and implement toC function. Also, re-name and modify signature of toGo function to fromC. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- Changes in v2: - Fix comment in fromC since an array is being used now, not a slice. - Use a concise variable name instead of mapslice for the C array.=20 tools/golang/xenlight/xenlight.go | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index 67c1bb1225..d6d912a037 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -312,20 +312,29 @@ type Context struct { logger *C.xentoollog_logger_stdiostream } =20 -type Hwcap []C.uint32_t +// Hwcap represents a libxl_hwcap. +type Hwcap [8]uint32 =20 -func (chwcap C.libxl_hwcap) toGo() (ghwcap Hwcap) { - // Alloc a Go slice for the bytes - size :=3D 8 - ghwcap =3D make([]C.uint32_t, size) - - // Make a slice pointing to the C array - mapslice :=3D (*[1 << 30]C.uint32_t)(unsafe.Pointer(&chwcap[0]))[:size:si= ze] +func (hwcap *Hwcap) fromC(chwcap *C.libxl_hwcap) error { + // Make an array pointing to the C array + a :=3D (*[8]C.uint32_t)(unsafe.Pointer(chwcap)) =20 // And copy the C array into the Go array - copy(ghwcap, mapslice) + for i, v :=3D range a { + hwcap[i] =3D uint32(v) + } =20 - return + return nil +} + +func (hwcap *Hwcap) toC() (C.libxl_hwcap, error) { + var chwcap C.libxl_hwcap + + for i, v :=3D range hwcap { + chwcap[i] =3D C.uint32_t(v) + } + + return chwcap, nil } =20 // KeyValueList represents a libxl_key_value_list. @@ -448,7 +457,7 @@ func (cphys *C.libxl_physinfo) toGo() (physinfo *Physin= fo) { physinfo.SharingFreedPages =3D uint64(cphys.sharing_freed_pages) physinfo.SharingUsedFrames =3D uint64(cphys.sharing_used_frames) physinfo.NrNodes =3D uint32(cphys.nr_nodes) - physinfo.HwCap =3D cphys.hw_cap.toGo() + physinfo.HwCap.fromC(&cphys.hw_cap) physinfo.CapHvm =3D bool(cphys.cap_hvm) physinfo.CapHvmDirectio =3D bool(cphys.cap_hvm_directio) =20 --=20 2.19.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel