From: Nicolas Pitre <nicolas.pitre@linaro.org>
To: "Alexey Brodkin" <Alexey.Brodkin@synopsys.com>,
"Måns Rullgård" <mans@mansr.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
rmk+kernel@arm.linux.org.uk, linux-arch@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 4/5] __div64_32(): make it overridable at compile time
Date: Mon, 02 Nov 2015 17:33:29 -0500 [thread overview]
Message-ID: <1446503610-6942-5-git-send-email-nicolas.pitre@linaro.org> (raw)
In-Reply-To: <1446503610-6942-1-git-send-email-nicolas.pitre@linaro.org>
Some architectures may want to override the default implementation
at compile time to do things inline. For example, ARM uses a
non-standard calling convention for better efficiency in this case.
Signed-off-by: Nicolas Pitre <nico@linaro.org>
---
include/asm-generic/div64.h | 2 ++
lib/div64.c | 6 ++++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/asm-generic/div64.h b/include/asm-generic/div64.h
index 34722c5a80..6daad94055 100644
--- a/include/asm-generic/div64.h
+++ b/include/asm-generic/div64.h
@@ -204,7 +204,9 @@ static inline uint64_t __arch_xprod_64(const uint64_t m, uint64_t n, bool bias)
}
#endif
+#ifndef __div64_32
extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
+#endif
/* The unnecessary pointer compare is there
* to check for type safety (n must be 64bit)
diff --git a/lib/div64.c b/lib/div64.c
index 19ea7ed4b9..69df4f6d52 100644
--- a/lib/div64.c
+++ b/lib/div64.c
@@ -13,7 +13,8 @@
*
* Code generated for this function might be very inefficient
* for some CPUs. __div64_32() can be overridden by linking arch-specific
- * assembly versions such as arch/ppc/lib/div64.S and arch/sh/lib/div64.S.
+ * assembly versions such as arch/ppc/lib/div64.S and arch/sh/lib/div64.S
+ * or by defining a preprocessor macro in arch/include/asm/div64.h.
*/
#include <linux/export.h>
@@ -23,6 +24,7 @@
/* Not needed on 64bit architectures */
#if BITS_PER_LONG == 32
+#ifndef __div64_32
uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
{
uint64_t rem = *n;
@@ -55,8 +57,8 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
*n = res;
return rem;
}
-
EXPORT_SYMBOL(__div64_32);
+#endif
#ifndef div_s64_rem
s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
--
2.4.3
next prev parent reply other threads:[~2015-11-02 22:33 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-02 22:33 [PATCH 0/5] 64-by-32 ddivision optimization for constant divisors on 32-bit machines Nicolas Pitre
2015-11-02 22:33 ` Nicolas Pitre
2015-11-02 22:33 ` [PATCH 1/5] div64.h: optimize do_div() for power-of-two constant divisors Nicolas Pitre
2015-11-02 22:33 ` Nicolas Pitre
2015-11-02 22:33 ` [PATCH 2/5] do_div(): generic optimization for constant divisor on 32-bit machines Nicolas Pitre
2015-11-03 5:32 ` kbuild test robot
2015-11-03 9:15 ` Arnd Bergmann
2015-11-04 21:04 ` Nicolas Pitre
2015-11-04 21:42 ` Måns Rullgård
2015-11-04 21:42 ` Måns Rullgård
2015-11-02 22:33 ` [PATCH 3/5] __div64_const32(): abstract out the actual 128-bit cross product code Nicolas Pitre
2015-11-02 22:33 ` Nicolas Pitre
2015-11-02 22:33 ` Nicolas Pitre [this message]
2015-11-02 22:33 ` [PATCH 4/5] __div64_32(): make it overridable at compile time Nicolas Pitre
2015-11-02 22:33 ` [PATCH 5/5] ARM: asm/div64.h: adjust to generic codde Nicolas Pitre
2015-11-02 22:33 ` Nicolas Pitre
2015-11-03 1:25 ` kbuild test robot
2015-11-03 4:03 ` Nicolas Pitre
2015-11-03 21:39 ` kbuild test robot
2015-11-19 16:36 ` Måns Rullgård
2015-11-19 16:42 ` Nicolas Pitre
2015-11-19 16:44 ` Måns Rullgård
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1446503610-6942-5-git-send-email-nicolas.pitre@linaro.org \
--to=nicolas.pitre@linaro.org \
--cc=Alexey.Brodkin@synopsys.com \
--cc=arnd@arndb.de \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mans@mansr.com \
--cc=rmk+kernel@arm.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox