From nobody Mon Feb 9 02:52:01 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1603448293; cv=none; d=zohomail.com; s=zohoarc; b=F3OkCBK7KwNkfscXklR50AnL21phL2OJzxS1qTSN0de++cINzkdwHuPE6w97zZzRz+DldjS1zIDwx4exYx5L6ywn+58YA0cu5Fgo+5Vid74ZZJ336qRwziq/CFO/U/3LAiYyuvLhTTPQGFB2Edi3gvW8BQ2l2ImxTafWk97K+YA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603448293; 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=lboJsbVVVivJxZqzJYi7juIk44SP83bI03BaDd0lLh0=; b=W0w+D25rp65ZnWi8PXt942sho2Gt1z/v8PQBLIAlCL9HBzPcWg70vdx2+rK5f2W13pvQZohjz/5ktnpF7oKJ1UN8m/mNoD2tnnCZRxm2tvewWr4UxfV5i+KhhfEfRZMlKOzD60USlCCOMCumUwrRqjpEIlciDIqXJxvI+a+m5lk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass 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 1603448293599588.9883339108812; Fri, 23 Oct 2020 03:18:13 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.10838.28943 (Exim 4.92) (envelope-from ) id 1kVu8z-0000zA-Mz; Fri, 23 Oct 2020 10:17:57 +0000 Received: by outflank-mailman (output) from mailman id 10838.28943; Fri, 23 Oct 2020 10:17:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kVu8z-0000z3-Je; Fri, 23 Oct 2020 10:17:57 +0000 Received: by outflank-mailman (input) for mailman id 10838; Fri, 23 Oct 2020 10:17:56 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kVu8y-0000y9-LC for xen-devel@lists.xenproject.org; Fri, 23 Oct 2020 10:17:56 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d1efb48a-f6e2-4908-9f61-dd4124a1059b; Fri, 23 Oct 2020 10:17:55 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id CADF1ACE5; Fri, 23 Oct 2020 10:17:54 +0000 (UTC) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kVu8y-0000y9-LC for xen-devel@lists.xenproject.org; Fri, 23 Oct 2020 10:17:56 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d1efb48a-f6e2-4908-9f61-dd4124a1059b; Fri, 23 Oct 2020 10:17:55 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id CADF1ACE5; Fri, 23 Oct 2020 10:17:54 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: d1efb48a-f6e2-4908-9f61-dd4124a1059b X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1603448274; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lboJsbVVVivJxZqzJYi7juIk44SP83bI03BaDd0lLh0=; b=d7JRslfZpV10EQNMgStARo6DYp3Erxmt5QyZ7NOhx+0RYrveX2Dv0rybI26yPk6kSDz1EZ C5WOfuh/oH0vgxyaSslaMGJmWWOzqmqO4P0PelTqMt2m0litpYy3wei1DjCc7bzRRDFzX9 6786r+dMtVfrKAVAd8ucuW17fQ857vA= Subject: [PATCH v2 4/8] lib: move parse_size_and_unit() From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , George Dunlap , Ian Jackson , Julien Grall , Wei Liu , Stefano Stabellini References: Message-ID: Date: Fri, 23 Oct 2020 12:17:57 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" ... into its own CU, to build it into an archive. Signed-off-by: Jan Beulich ... into its own CU, to build it into an archive. Signed-off-by: Jan Beulich Acked-by: Julien Grall --- xen/common/lib.c | 39 ---------------------------------- xen/lib/Makefile | 1 + xen/lib/parse-size.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 39 deletions(-) create mode 100644 xen/lib/parse-size.c diff --git a/xen/common/lib.c b/xen/common/lib.c index a224efa8f6e8..6cfa332142a5 100644 --- a/xen/common/lib.c +++ b/xen/common/lib.c @@ -423,45 +423,6 @@ uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c) #endif } =20 -unsigned long long parse_size_and_unit(const char *s, const char **ps) -{ - unsigned long long ret; - const char *s1; - - ret =3D simple_strtoull(s, &s1, 0); - - switch ( *s1 ) - { - case 'T': case 't': - ret <<=3D 10; - /* fallthrough */ - case 'G': case 'g': - ret <<=3D 10; - /* fallthrough */ - case 'M': case 'm': - ret <<=3D 10; - /* fallthrough */ - case 'K': case 'k': - ret <<=3D 10; - /* fallthrough */ - case 'B': case 'b': - s1++; - break; - case '%': - if ( ps ) - break; - /* fallthrough */ - default: - ret <<=3D 10; /* default to kB */ - break; - } - - if ( ps !=3D NULL ) - *ps =3D s1; - - return ret; -} - typedef void (*ctor_func_t)(void); extern const ctor_func_t __ctors_start[], __ctors_end[]; =20 diff --git a/xen/lib/Makefile b/xen/lib/Makefile index 764f3624b5f9..99f857540c99 100644 --- a/xen/lib/Makefile +++ b/xen/lib/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_X86) +=3D x86/ =20 lib-y +=3D ctype.o lib-y +=3D list-sort.o +lib-y +=3D parse-size.o diff --git a/xen/lib/parse-size.c b/xen/lib/parse-size.c new file mode 100644 index 000000000000..ec980cadfff3 --- /dev/null +++ b/xen/lib/parse-size.c @@ -0,0 +1,50 @@ +#include + +unsigned long long parse_size_and_unit(const char *s, const char **ps) +{ + unsigned long long ret; + const char *s1; + + ret =3D simple_strtoull(s, &s1, 0); + + switch ( *s1 ) + { + case 'T': case 't': + ret <<=3D 10; + /* fallthrough */ + case 'G': case 'g': + ret <<=3D 10; + /* fallthrough */ + case 'M': case 'm': + ret <<=3D 10; + /* fallthrough */ + case 'K': case 'k': + ret <<=3D 10; + /* fallthrough */ + case 'B': case 'b': + s1++; + break; + case '%': + if ( ps ) + break; + /* fallthrough */ + default: + ret <<=3D 10; /* default to kB */ + break; + } + + if ( ps !=3D NULL ) + *ps =3D s1; + + return ret; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.22.0