Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6837865ybf; Fri, 6 Mar 2020 05:33:55 -0800 (PST) X-Google-Smtp-Source: ADFU+vvB2MqBc+ht1kDzHKUOEyAjY22dMxCHSLbywbfAcAey+goUcJoKvRwVBkj0FUhJ+mdN9Hic X-Received: by 2002:aca:d954:: with SMTP id q81mr2581036oig.157.1583501635758; Fri, 06 Mar 2020 05:33:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583501635; cv=none; d=google.com; s=arc-20160816; b=DeSGukYGoWPsZzQd54eZSmG7EIt9xMkS9jXel0v1b9YQJ2jjwP9slaCwJ7aAk6QuyV pqQ992MYso6SGxs0ajYis1s2PMiSC6i7BN1U8FGJ3EhqELXvygukYng2IrZsL9E3+g2l OEFONTXm9+9SBSf2D9MKLBCPcoXnBuXowk8KkG8loRc8Q0P+eJExUXT/TzWy7538NIb+ sBBQ+1GgBr4Ew22/Rf01CC2NSUhaOgqR7xSuUaluSIukijSRpZV0Clz33wODUVwtqUpk 7fWFreCyExkTGdzmAOcnSXKrblIEFidFIQxwcwvu3zp7DZ1gWzRXMb6U0t3loqPlRY/W L7eQ== 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=cItu4gvtM5j7ZLMdp3xv86JN+pkSn3ZDYWEWFaBdSo0=; b=N6oQsLj0z/FAYNlKeKuj3MytBUNFr0NtdLjfaQK+hsFgBgvNtqhW1gxOejAElEKcOy qejL51RR0WjE/+l2dBjER0LXBW29W9NSfKhB/Q3//Ayed/eStLUADA5R0plGGVLek58F j/fswk9vz726KFnSu2Pi/nAHiYMiYTkrvem8lO9e6oA3DtEzCgu8GZLm1Q3+IV73pf2c gjTvCvm3cMtq5s7HR50DZl6PRoQ72pjePV4t331YwUpH+2dbKlh8NLQNEp3532TZBkyZ zj85jKsQSTgPntl3FXUQlXtHJnLfnK6bzpfz55EIwUJjnbK5N4w6yevEcCiLiDBLA2Z8 yRuQ== 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 x22si1326548oic.119.2020.03.06.05.33.39; Fri, 06 Mar 2020 05:33:55 -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 S1727317AbgCFNdH (ORCPT + 99 others); Fri, 6 Mar 2020 08:33:07 -0500 Received: from foss.arm.com ([217.140.110.172]:33392 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727152AbgCFNdG (ORCPT ); Fri, 6 Mar 2020 08:33:06 -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 D26A131B; Fri, 6 Mar 2020 05:33:05 -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 1E0EE3F6CF; Fri, 6 Mar 2020 05:33:03 -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: Vincenzo Frascino , Catalin Marinas , Will Deacon , Arnd Bergmann , Russell King , Paul Burton , Thomas Gleixner , Andy Lutomirski , Ingo Molnar , Borislav Petkov , Stephen Boyd , Mark Salyzyn , Kees Cook , Peter Collingbourne , Dmitry Safonov <0x7f454c46@gmail.com>, Andrei Vagin , Nick Desaulniers Subject: [PATCH v2 04/20] linux/math64.h: Extract common header for vDSO Date: Fri, 6 Mar 2020 13:32:26 +0000 Message-Id: <20200306133242.26279-5-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200306133242.26279-1-vincenzo.frascino@arm.com> References: <20200306133242.26279-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.1