From nobody Tue Nov 11 07:31:03 2025 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=1570461322; cv=none; d=zoho.com; s=zohoarc; b=IHICKf0ePGrvrIkXWpMr2Ht5JaWFX9f0jFRLPDHzdA+uCJbRfoqABgOLOPwPUDRWzNSRHI9G3AZtV1BkJqruMh7P6/OHxBOMaDg0TqaR7sq6meBxjScvpxAgy+40uLtKIjtdPVbfJkdL+nGITWhEXHUGD5WZZ4/CCrUm3ny2vQU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1570461322; 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:ARC-Authentication-Results; bh=FdI9L4eJfMKhrzE7EKRLAFGtMWNZdgleyo8PCuD5N1U=; b=EuWCEF+9jNR6x4e+BrqPK1GXKN3Vxa/eHHQHenb1K6vf40Lu9brOYUI0ktgyIbUdYZbusIbW47aXdmVl2Fvb6THBWXHvXRZ/Sv9Uifv7YUUCsU4R0aY3h7Y6Ij6yZ8FSrLN1x0U5YzSXBDJQVEyi9zBfgX307Hr/0AB2LLc28aI= 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 157046132225075.55934289184245; Mon, 7 Oct 2019 08:15:22 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iHUiN-0007C3-2c; Mon, 07 Oct 2019 15:14:23 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iHUiL-0007B2-O3 for xen-devel@lists.xenproject.org; Mon, 07 Oct 2019 15:14:21 +0000 Received: from mail-qk1-x741.google.com (unknown [2607:f8b0:4864:20::741]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 05e3b6e4-e915-11e9-8c93-bc764e2007e4; Mon, 07 Oct 2019 15:13:31 +0000 (UTC) Received: by mail-qk1-x741.google.com with SMTP id w2so12924996qkf.2 for ; Mon, 07 Oct 2019 08:13:31 -0700 (PDT) Received: from five.crux.rad.ainfosec.com (209-217-208-226.northland.net. [209.217.208.226]) by smtp.googlemail.com with ESMTPSA id c185sm8354313qkg.74.2019.10.07.08.13.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Oct 2019 08:13:30 -0700 (PDT) X-Inumbo-ID: 05e3b6e4-e915-11e9-8c93-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=2htTM68zxP0j1foVUJTAU8c3I7wf8QEtD5IUSCOUF2w=; b=XpawqHaOGMZrPEdiqmvvu6Ip2+9JMcXN8U45lfBeZCG15vItXP8B6eZgxYADpyStHQ jRyd0Gb+jHZhqY5p52UrXQhYm8wMeYml1ekyfEEeuw7d/MzqMz+tdpPoRDnNK70lob4g 1XxuFWyOP12Y485P0nZ6DIwBoWfBQseb9eG+EaGvepSJDzewglzZshhGE2Li0F33Jw0s v8MeHRR+OhgM6L80oDxhMseCmn/ebNIoOiSpnS8yj3IkjMIgR+3OO6K2EFWy0c22aNry P+Bq8cAqk00M9OnfpECusmApohOO4QU912rAQysIFW0d9YFSTPSN/pn4ClTLf/EBUewa x8Rg== 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=2htTM68zxP0j1foVUJTAU8c3I7wf8QEtD5IUSCOUF2w=; b=Tf0JwyDjRNyO5xjIgzaNb+jeaF3+qplJismUkS3sFwRfHxt1U27UZZEBm0pJZ8OQOk L/tKkyFNX3h+P57b9URmVK6f8dlnjTYHrZgHO5xlOIXcj20216KRxwGi+Ylia1DdFrKO DLcB0NMbu7Ku6fjMDjyjkvbx9NHCdNgc9OAe70A3dhONhIsEmWDuqiFIMZAqHvecaetQ yfCAeQHUkYZjW+PXm6uaA5v8nnqxPAYC96xrgnTjkpcRB1YbXRI7wiBb3J+83zGvQOke lw4L3LAfObAsLgVcK41MudyGVH+FNYT/41WKal/NdXQy73K488u3FdF4oypO/b5iNXqm BnEA== X-Gm-Message-State: APjAAAV4xVMEVjmMGHYhO13PqiKvzPL7K6NZH262vm1SRiNnISLaOzdK fb7hCXepR8PsUU+D3SnmKnsTPz/Q X-Google-Smtp-Source: APXvYqweIcEUUWwSORHvAEcZd/08vp6vrZlvlcZpod6RdYz23iHYY0feR6N4KM9CiiVRz4RCg1IcAQ== X-Received: by 2002:a37:66c8:: with SMTP id a191mr24153146qkc.108.1570461210702; Mon, 07 Oct 2019 08:13:30 -0700 (PDT) From: Nick Rosbrook To: xen-devel@lists.xenproject.org Date: Mon, 7 Oct 2019 11:13:00 -0400 Message-Id: <6dbe8bb54d634e7ebe4eb12245255c75ce22fbce.1570456846.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 13/24] 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 --- Cc: George Dunlap Cc: Ian Jackson Cc: Wei Liu tools/golang/xenlight/xenlight.go | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenl= ight.go index 3e3753f92e..8d520bbd98 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -307,20 +307,29 @@ type Context struct { logger *C.xentoollog_logger_stdiostream } =20 -type Hwcap []C.uint32_t - -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) +// Hwcap represents a libxl_hwcap. +type Hwcap [8]uint32 =20 +func (hwcap *Hwcap) fromC(chwcap *C.libxl_hwcap) error { // Make a slice pointing to the C array - mapslice :=3D (*[1 << 30]C.uint32_t)(unsafe.Pointer(&chwcap[0]))[:size:si= ze] + mapslice :=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 mapslice { + 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. @@ -465,7 +474,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