Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp719442ybv; Thu, 13 Feb 2020 08:17:25 -0800 (PST) X-Google-Smtp-Source: APXvYqypknImCm+WDC5tom6cs0t7ILOd3d8eHZmhYYu6sLHUa29Q0k5C71+dSbFq5u6gHPPzz4qR X-Received: by 2002:aca:1011:: with SMTP id 17mr3550711oiq.72.1581610645691; Thu, 13 Feb 2020 08:17:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581610645; cv=none; d=google.com; s=arc-20160816; b=d9TYBHM2RwUpvTN7k+WJP6yT86dgJjwfZPzM10HRXMe2UevcbTISD2jxzGuWF1Y6bC 71zW++qCypkI9ADgOk/qMU5xF3EL4rgqYAzuXQL4nF2384+EJl/v/GSa458RpLbaAHCy 6gdqlk9tzLOUVGpS9N5YQFZv8/ScFafjJFLkcGzML4djRYibP794zLCVXh/B3FOiUX3F xHCNLDD5DzRmpkXHyoZw9+LKINT43oFo7Tn42RtMyP9J+xYA5JavbC0UjX05NdjfouNx jiHzDWJLc7t95ypnVBVEXZUqdQYmdEP5oVnSyLtQU/sqlXbbjXe1Cz0majktqAjnF1Yv GXYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=xYErZ2u4v0dgbU611s53VEUKOqRinwxv5THB9AkA8MA=; b=roSSq8unn19Cyfx/goUMAMBk3FEwU0DN4AqJGgeJnT1QgW1Av90baJdhHjkdcVfPik rIxhU6OERxp+DWazgnnJqABvlLMpc+vt19kmgl2KKjURfHJPVtitRdJc6SAgRxGRIwIc VJgyigteTiygs4eUrKppDm8OzadZBIbd+29LvGQUECKR2b4IGoRycceYsOMq5pzFbe+L XX4tfOS3xlmNsq3cwo/gkwpWgSXreBzBCvFMVGeH/XqttuSz5KcQ/ecYIUZNIuFCWre4 ok//t82HRAcd15pM3LXeHTwVqCFtnPMFSPyJc6jPQuQCAQ6WYxCJ7R1rck8OyEcDEbvv CPyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q17si1328204otk.321.2020.02.13.08.17.11; Thu, 13 Feb 2020 08:17:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728405AbgBMQQz (ORCPT + 99 others); Thu, 13 Feb 2020 11:16:55 -0500 Received: from foss.arm.com ([217.140.110.172]:49788 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728267AbgBMQQy (ORCPT ); Thu, 13 Feb 2020 11:16:54 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DF45F328; Thu, 13 Feb 2020 08:16:53 -0800 (PST) Received: from e119884-lin.cambridge.arm.com (e119884-lin.cambridge.arm.com [10.1.196.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5F1B43F6CF; Thu, 13 Feb 2020 08:16:51 -0800 (PST) From: Vincenzo Frascino To: linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, clang-built-linux@googlegroups.com, x86@kernel.org Cc: catalin.marinas@arm.com, will.deacon@arm.com, arnd@arndb.de, linux@armlinux.org.uk, paul.burton@mips.com, tglx@linutronix.de, luto@kernel.org, mingo@redhat.com, bp@alien8.de, sboyd@kernel.org, salyzyn@android.com, pcc@google.com, 0x7f454c46@gmail.com, ndesaulniers@google.com, avagin@openvz.org Subject: [PATCH 04/19] linux/math64.h: Extract common header for vDSO Date: Thu, 13 Feb 2020 16:15:59 +0000 Message-Id: <20200213161614.23246-5-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213161614.23246-1-vincenzo.frascino@arm.com> References: <20200213161614.23246-1-vincenzo.frascino@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The vDSO library should only include the necessary headers required for a userspace library (UAPI and a minimal set of kernel headers). To make this possible it is necessary to isolate from the kernel headers the common parts that are strictly necessary to build the library. Split math64.h into linux and common headers to make the latter suitable for inclusion in the vDSO library. Signed-off-by: Vincenzo Frascino --- include/common/math64.h | 24 ++++++++++++++++++++++++ include/linux/math64.h | 20 +------------------- 2 files changed, 25 insertions(+), 19 deletions(-) create mode 100644 include/common/math64.h diff --git a/include/common/math64.h b/include/common/math64.h new file mode 100644 index 000000000000..4e1870e40182 --- /dev/null +++ b/include/common/math64.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __COMMON_MATH64_H +#define __COMMON_MATH64_H + +static __always_inline u32 +__iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder) +{ + u32 ret = 0; + + while (dividend >= divisor) { + /* The following asm() prevents the compiler from + optimising this loop into a modulo operation. */ + asm("" : "+rm"(dividend)); + + dividend -= divisor; + ret++; + } + + *remainder = dividend; + + return ret; +} + +#endif /* __COMMON_MATH64_H */ diff --git a/include/linux/math64.h b/include/linux/math64.h index 65bef21cdddb..54eb486b5d1a 100644 --- a/include/linux/math64.h +++ b/include/linux/math64.h @@ -3,6 +3,7 @@ #define _LINUX_MATH64_H #include +#include #include #if BITS_PER_LONG == 64 @@ -142,25 +143,6 @@ static inline s64 div_s64(s64 dividend, s32 divisor) u32 iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder); -static __always_inline u32 -__iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder) -{ - u32 ret = 0; - - while (dividend >= divisor) { - /* The following asm() prevents the compiler from - optimising this loop into a modulo operation. */ - asm("" : "+rm"(dividend)); - - dividend -= divisor; - ret++; - } - - *remainder = dividend; - - return ret; -} - #ifndef mul_u32_u32 /* * Many a GCC version messes this up and generates a 64x64 mult :-( -- 2.25.0