* [PATCH] m68k: use kernel's generic libgcc functions
@ 2023-09-13 7:13 Greg Ungerer
2023-10-04 14:52 ` Geert Uytterhoeven
0 siblings, 1 reply; 4+ messages in thread
From: Greg Ungerer @ 2023-09-13 7:13 UTC (permalink / raw)
To: linux-m68k; +Cc: geert, Greg Ungerer
From: Greg Ungerer <gerg@linux-m68k.org>
The arch/m68k/lib versions of the libgcc functions: ashldi3, ashrdi3
and lshrdi3 were taken directly from an older version of gcc.
We can use the kernel's own generic lib versions of these - they are
virtually identical. Switch to those and remove the m68k local ones.
Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
---
Tested on ColdFire and on an Atari build under aranym.
arch/m68k/Kconfig | 3 ++
arch/m68k/lib/Makefile | 3 +-
arch/m68k/lib/ashldi3.c | 61 ----------------------------------------
arch/m68k/lib/ashrdi3.c | 62 -----------------------------------------
arch/m68k/lib/lshrdi3.c | 61 ----------------------------------------
5 files changed, 4 insertions(+), 186 deletions(-)
delete mode 100644 arch/m68k/lib/ashldi3.c
delete mode 100644 arch/m68k/lib/ashrdi3.c
delete mode 100644 arch/m68k/lib/lshrdi3.c
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 3e318bf9504c..3e96486d9528 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -19,6 +19,9 @@ config M68K
select GENERIC_CPU_DEVICES
select GENERIC_IOMAP
select GENERIC_IRQ_SHOW
+ select GENERIC_LIB_ASHLDI3
+ select GENERIC_LIB_ASHRDI3
+ select GENERIC_LIB_LSHRDI3
select HAS_IOPORT if PCI || ISA || ATARI_ROM_ISA
select HAVE_ARCH_SECCOMP
select HAVE_ARCH_SECCOMP_FILTER
diff --git a/arch/m68k/lib/Makefile b/arch/m68k/lib/Makefile
index eca17f14b4d5..9158688e6cc6 100644
--- a/arch/m68k/lib/Makefile
+++ b/arch/m68k/lib/Makefile
@@ -4,8 +4,7 @@
# Makefile for m68k-specific library files..
#
-lib-y := ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \
- memcpy.o memset.o memmove.o
+lib-y := muldi3.o memcpy.o memset.o memmove.o
lib-$(CONFIG_MMU) += uaccess.o
lib-$(CONFIG_CPU_HAS_NO_MULDIV64) += mulsi3.o divsi3.o udivsi3.o
diff --git a/arch/m68k/lib/ashldi3.c b/arch/m68k/lib/ashldi3.c
deleted file mode 100644
index ac08f8141390..000000000000
--- a/arch/m68k/lib/ashldi3.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* ashrdi3.c extracted from gcc-2.95.2/libgcc2.c which is: */
-/* Copyright (C) 1989, 92-98, 1999 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details. */
-
-#include <linux/compiler.h>
-#include <linux/export.h>
-
-#define BITS_PER_UNIT 8
-
-typedef int SItype __mode(SI);
-typedef unsigned int USItype __mode(SI);
-typedef int DItype __mode(DI);
-typedef int word_type __mode(__word__);
-
-struct DIstruct {SItype high, low;};
-
-typedef union
-{
- struct DIstruct s;
- DItype ll;
-} DIunion;
-
-DItype
-__ashldi3 (DItype u, word_type b)
-{
- DIunion w;
- word_type bm;
- DIunion uu;
-
- if (b == 0)
- return u;
-
- uu.ll = u;
-
- bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
- if (bm <= 0)
- {
- w.s.low = 0;
- w.s.high = (USItype)uu.s.low << -bm;
- }
- else
- {
- USItype carries = (USItype)uu.s.low >> bm;
- w.s.low = (USItype)uu.s.low << b;
- w.s.high = ((USItype)uu.s.high << b) | carries;
- }
-
- return w.ll;
-}
-EXPORT_SYMBOL(__ashldi3);
diff --git a/arch/m68k/lib/ashrdi3.c b/arch/m68k/lib/ashrdi3.c
deleted file mode 100644
index 5837b1dd3334..000000000000
--- a/arch/m68k/lib/ashrdi3.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/* ashrdi3.c extracted from gcc-2.7.2/libgcc2.c which is: */
-/* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details. */
-
-#include <linux/compiler.h>
-#include <linux/export.h>
-
-#define BITS_PER_UNIT 8
-
-typedef int SItype __mode(SI);
-typedef unsigned int USItype __mode(SI);
-typedef int DItype __mode(DI);
-typedef int word_type __mode(__word__);
-
-struct DIstruct {SItype high, low;};
-
-typedef union
-{
- struct DIstruct s;
- DItype ll;
-} DIunion;
-
-DItype
-__ashrdi3 (DItype u, word_type b)
-{
- DIunion w;
- word_type bm;
- DIunion uu;
-
- if (b == 0)
- return u;
-
- uu.ll = u;
-
- bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
- if (bm <= 0)
- {
- /* w.s.high = 1..1 or 0..0 */
- w.s.high = uu.s.high >> (sizeof (SItype) * BITS_PER_UNIT - 1);
- w.s.low = uu.s.high >> -bm;
- }
- else
- {
- USItype carries = (USItype)uu.s.high << bm;
- w.s.high = uu.s.high >> b;
- w.s.low = ((USItype)uu.s.low >> b) | carries;
- }
-
- return w.ll;
-}
-EXPORT_SYMBOL(__ashrdi3);
diff --git a/arch/m68k/lib/lshrdi3.c b/arch/m68k/lib/lshrdi3.c
deleted file mode 100644
index 7f40566be6c8..000000000000
--- a/arch/m68k/lib/lshrdi3.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* lshrdi3.c extracted from gcc-2.7.2/libgcc2.c which is: */
-/* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
-
-This file is part of GNU CC.
-
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details. */
-
-#include <linux/compiler.h>
-#include <linux/export.h>
-
-#define BITS_PER_UNIT 8
-
-typedef int SItype __mode(SI);
-typedef unsigned int USItype __mode(SI);
-typedef int DItype __mode(DI);
-typedef int word_type __mode(__word__);
-
-struct DIstruct {SItype high, low;};
-
-typedef union
-{
- struct DIstruct s;
- DItype ll;
-} DIunion;
-
-DItype
-__lshrdi3 (DItype u, word_type b)
-{
- DIunion w;
- word_type bm;
- DIunion uu;
-
- if (b == 0)
- return u;
-
- uu.ll = u;
-
- bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
- if (bm <= 0)
- {
- w.s.high = 0;
- w.s.low = (USItype)uu.s.high >> -bm;
- }
- else
- {
- USItype carries = (USItype)uu.s.high << bm;
- w.s.high = (USItype)uu.s.high >> b;
- w.s.low = ((USItype)uu.s.low >> b) | carries;
- }
-
- return w.ll;
-}
-EXPORT_SYMBOL(__lshrdi3);
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] m68k: use kernel's generic libgcc functions
2023-09-13 7:13 [PATCH] m68k: use kernel's generic libgcc functions Greg Ungerer
@ 2023-10-04 14:52 ` Geert Uytterhoeven
2023-10-05 0:49 ` Greg Ungerer
0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2023-10-04 14:52 UTC (permalink / raw)
To: Greg Ungerer; +Cc: linux-m68k
Hi Greg,
On Wed, Sep 13, 2023 at 9:14 AM Greg Ungerer <gerg@kernel.org> wrote:
> From: Greg Ungerer <gerg@linux-m68k.org>
>
> The arch/m68k/lib versions of the libgcc functions: ashldi3, ashrdi3
> and lshrdi3 were taken directly from an older version of gcc.
> We can use the kernel's own generic lib versions of these - they are
> virtually identical. Switch to those and remove the m68k local ones.
>
> Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
Thanks for your patch!
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
i.e. will queue in the m68k for-v6.7 branch.
> --- a/arch/m68k/Kconfig
> +++ b/arch/m68k/Kconfig
> @@ -19,6 +19,9 @@ config M68K
> select GENERIC_CPU_DEVICES
> select GENERIC_IOMAP
> select GENERIC_IRQ_SHOW
> + select GENERIC_LIB_ASHLDI3
> + select GENERIC_LIB_ASHRDI3
> + select GENERIC_LIB_LSHRDI3
> select HAS_IOPORT if PCI || ISA || ATARI_ROM_ISA
> select HAVE_ARCH_SECCOMP
> select HAVE_ARCH_SECCOMP_FILTER
I guess we can select GENERIC_LIB_MULDI3 if CPU_HAS_NO_MULDIV64
and clean up arch/m68k/lib/muldi3.c, too?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] m68k: use kernel's generic libgcc functions
2023-10-04 14:52 ` Geert Uytterhoeven
@ 2023-10-05 0:49 ` Greg Ungerer
2023-10-05 7:04 ` Geert Uytterhoeven
0 siblings, 1 reply; 4+ messages in thread
From: Greg Ungerer @ 2023-10-05 0:49 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: linux-m68k
Hi Geert,
On 5/10/23 00:52, Geert Uytterhoeven wrote:
> Hi Greg,
>
> On Wed, Sep 13, 2023 at 9:14 AM Greg Ungerer <gerg@kernel.org> wrote:
>> From: Greg Ungerer <gerg@linux-m68k.org>
>>
>> The arch/m68k/lib versions of the libgcc functions: ashldi3, ashrdi3
>> and lshrdi3 were taken directly from an older version of gcc.
>> We can use the kernel's own generic lib versions of these - they are
>> virtually identical. Switch to those and remove the m68k local ones.
>>
>> Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
>
> Thanks for your patch!
>
> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
> i.e. will queue in the m68k for-v6.7 branch.
>
>> --- a/arch/m68k/Kconfig
>> +++ b/arch/m68k/Kconfig
>> @@ -19,6 +19,9 @@ config M68K
>> select GENERIC_CPU_DEVICES
>> select GENERIC_IOMAP
>> select GENERIC_IRQ_SHOW
>> + select GENERIC_LIB_ASHLDI3
>> + select GENERIC_LIB_ASHRDI3
>> + select GENERIC_LIB_LSHRDI3
>> select HAS_IOPORT if PCI || ISA || ATARI_ROM_ISA
>> select HAVE_ARCH_SECCOMP
>> select HAVE_ARCH_SECCOMP_FILTER
>
> I guess we can select GENERIC_LIB_MULDI3 if CPU_HAS_NO_MULDIV64
> and clean up arch/m68k/lib/muldi3.c, too?
Yes, that is true.
I was hoping we might be able to do something a little more clever.
The common muldi3.c is almost identical except our local macro for
umul_ppmm(). But looking at the common lib/muldi3.c code it has been
setup to handle an arch local definition of that. I didn't spend too much
time looking at it yet, not sure where we could put that for the whole
mechanism to work though.
Regards
Greg
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] m68k: use kernel's generic libgcc functions
2023-10-05 0:49 ` Greg Ungerer
@ 2023-10-05 7:04 ` Geert Uytterhoeven
0 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2023-10-05 7:04 UTC (permalink / raw)
To: Greg Ungerer; +Cc: linux-m68k
Hi Greg,
On Thu, Oct 5, 2023 at 2:49 AM Greg Ungerer <gerg@linux-m68k.org> wrote:
> On 5/10/23 00:52, Geert Uytterhoeven wrote:
> > I guess we can select GENERIC_LIB_MULDI3 if CPU_HAS_NO_MULDIV64
> > and clean up arch/m68k/lib/muldi3.c, too?
>
> Yes, that is true.
>
> I was hoping we might be able to do something a little more clever.
> The common muldi3.c is almost identical except our local macro for
> umul_ppmm(). But looking at the common lib/muldi3.c code it has been
> setup to handle an arch local definition of that. I didn't spend too much
> time looking at it yet, not sure where we could put that for the whole
> mechanism to work though.
For floating point, there are <math-emu/soft-fp.h> and <asm/sfp-machine.h>,
but abusing that for integer feels wrong.
'git grep "#\s*define\s*umul_ppmm"' shows there are already plenty of
definitions for umul_ppmm(), so moving these to arch-specific header
files can clean that up in the process.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-05 14:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-13 7:13 [PATCH] m68k: use kernel's generic libgcc functions Greg Ungerer
2023-10-04 14:52 ` Geert Uytterhoeven
2023-10-05 0:49 ` Greg Ungerer
2023-10-05 7:04 ` Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox