public inbox for linux-m68k@lists.linux-m68k.org
 help / color / mirror / Atom feed
* [PATCH 0/6] m68k: merge and clean up files in m68k/lib
@ 2011-03-30  7:58 Greg Ungerer
  2011-03-30  7:58 ` [PATCH 1/6] m68k: merge mmu and non-mmu versions of muldi3 Greg Ungerer
  2011-03-30 18:41 ` [PATCH 0/6] m68k: merge and clean up files in m68k/lib Geert Uytterhoeven
  0 siblings, 2 replies; 17+ messages in thread
From: Greg Ungerer @ 2011-03-30  7:58 UTC (permalink / raw)
  To: linux-m68k


The following set of patches cleans up and merges individual files in
the arch/m68k/lib directory. Mostly strait forward stuff,

I have build and run tested on ARAnyM/Atari and ColdFire (non-mmu)
targets.

Not sure why git/diff mangled some of these a little. The changes to
patche 5, string.h, are simpler than it looks... These where generated
with "git format-patch -M -B" to make it easier to review the file
movements.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/6] m68k: merge mmu and non-mmu versions of muldi3
  2011-03-30  7:58 [PATCH 0/6] m68k: merge and clean up files in m68k/lib Greg Ungerer
@ 2011-03-30  7:58 ` Greg Ungerer
  2011-03-30  7:58   ` [PATCH 2/6] m68k: merge mmu and non-mmu versions of lib/Makefile Greg Ungerer
                     ` (5 more replies)
  2011-03-30 18:41 ` [PATCH 0/6] m68k: merge and clean up files in m68k/lib Geert Uytterhoeven
  1 sibling, 6 replies; 17+ messages in thread
From: Greg Ungerer @ 2011-03-30  7:58 UTC (permalink / raw)
  To: linux-m68k; +Cc: Greg Ungerer

The implementation of gcc's muldi3 support function differs only in
the use of the machine's 64 bit sized mul or not. (It isn't based
on using an MMU or not). Merge the current mmu and non-mmu versions
of arc/m68k/lib/muldi3 and use the appropriate pre-processor
conditionals to get the right version for all m68k processor types.

Signed-off-by: Greg Ungerer <gerg@uclinux.org>
---
 arch/m68k/lib/{muldi3_no.c => muldi3.c} |   14 +++++++
 arch/m68k/lib/muldi3_mm.c               |   63 -------------------------------
 2 files changed, 14 insertions(+), 63 deletions(-)
 rename arch/m68k/lib/{muldi3_no.c => muldi3.c} (88%)
 delete mode 100644 arch/m68k/lib/muldi3_mm.c

diff --git a/arch/m68k/lib/muldi3_no.c b/arch/m68k/lib/muldi3.c
similarity index 88%
rename from arch/m68k/lib/muldi3_no.c
rename to arch/m68k/lib/muldi3.c
index 34af72c..6bc1c16 100644
--- a/arch/m68k/lib/muldi3_no.c
+++ b/arch/m68k/lib/muldi3.c
@@ -22,6 +22,18 @@ Boston, MA 02111-1307, USA.  */
 #define BITS_PER_UNIT 8
 #define SI_TYPE_SIZE 32
 
+#if defined(__mc68020__) || defined(__mc68030__) || \
+    defined(__mc68040__) || defined(__mc68060__)
+
+#define umul_ppmm(w1, w0, u, v) \
+  __asm__ ("mulu%.l %3,%1:%0"						\
+           : "=d" ((USItype)(w0)),					\
+             "=d" ((USItype)(w1))					\
+           : "%0" ((USItype)(u)),					\
+             "dmi" ((USItype)(v)))
+
+#else
+
 #define __BITS4 (SI_TYPE_SIZE / 4)
 #define __ll_B (1L << (SI_TYPE_SIZE / 2))
 #define __ll_lowpart(t) ((USItype) (t) % __ll_B)
@@ -51,6 +63,8 @@ Boston, MA 02111-1307, USA.  */
     (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0);		\
   } while (0)
 
+#endif
+
 #define __umulsidi3(u, v) \
   ({DIunion __w;							\
     umul_ppmm (__w.s.high, __w.s.low, u, v);				\
diff --git a/arch/m68k/lib/muldi3_mm.c b/arch/m68k/lib/muldi3_mm.c
deleted file mode 100644
index be4f275..0000000
--- a/arch/m68k/lib/muldi3_mm.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/* muldi3.c extracted from gcc-2.7.2.3/libgcc2.c and
-			   gcc-2.7.2.3/longlong.h 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.
-
-You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-
-#define BITS_PER_UNIT 8
-
-#define umul_ppmm(w1, w0, u, v) \
-  __asm__ ("mulu%.l %3,%1:%0"						\
-           : "=d" ((USItype)(w0)),					\
-             "=d" ((USItype)(w1))					\
-           : "%0" ((USItype)(u)),					\
-             "dmi" ((USItype)(v)))
-
-#define __umulsidi3(u, v) \
-  ({DIunion __w;							\
-    umul_ppmm (__w.s.high, __w.s.low, u, v);				\
-    __w.ll; })
-
-typedef		 int SItype	__attribute__ ((mode (SI)));
-typedef unsigned int USItype	__attribute__ ((mode (SI)));
-typedef		 int DItype	__attribute__ ((mode (DI)));
-typedef int word_type __attribute__ ((mode (__word__)));
-
-struct DIstruct {SItype high, low;};
-
-typedef union
-{
-  struct DIstruct s;
-  DItype ll;
-} DIunion;
-
-DItype
-__muldi3 (DItype u, DItype v)
-{
-  DIunion w;
-  DIunion uu, vv;
-
-  uu.ll = u,
-  vv.ll = v;
-
-  w.ll = __umulsidi3 (uu.s.low, vv.s.low);
-  w.s.high += ((USItype) uu.s.low * (USItype) vv.s.high
-	       + (USItype) uu.s.high * (USItype) vv.s.low);
-
-  return w.ll;
-}
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 2/6] m68k: merge mmu and non-mmu versions of lib/Makefile
  2011-03-30  7:58 ` [PATCH 1/6] m68k: merge mmu and non-mmu versions of muldi3 Greg Ungerer
@ 2011-03-30  7:58   ` Greg Ungerer
  2011-03-30  7:58   ` [PATCH 3/6] m68k: remove duplicate memmove() implementation Greg Ungerer
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Greg Ungerer @ 2011-03-30  7:58 UTC (permalink / raw)
  To: linux-m68k; +Cc: Greg Ungerer

We can easily support the slight differences in libs needed by the
mmu and non-mmu builds in a single Makefile, so merge them back into
a single file again.

Signed-off-by: Greg Ungerer <gerg@uclinux.org>
---
 arch/m68k/lib/Makefile    |   13 +++++++++++--
 arch/m68k/lib/Makefile_mm |    6 ------
 arch/m68k/lib/Makefile_no |    7 -------
 3 files changed, 11 insertions(+), 15 deletions(-)
 delete mode 100644 arch/m68k/lib/Makefile_mm
 delete mode 100644 arch/m68k/lib/Makefile_no

diff --git a/arch/m68k/lib/Makefile b/arch/m68k/lib/Makefile
index 1f95881..3d85fb6 100644
--- a/arch/m68k/lib/Makefile
+++ b/arch/m68k/lib/Makefile
@@ -1,5 +1,14 @@
+
+#
+# Makefile for m68k-specific library files..
+#
+
+lib-y	:= ashldi3.o ashrdi3.o lshrdi3.o muldi3.o checksum.o
+
 ifdef CONFIG_MMU
-include arch/m68k/lib/Makefile_mm
+lib-y	+= string.o uaccess.o
 else
-include arch/m68k/lib/Makefile_no
+lib-y	+= mulsi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o \
+	   memcpy.o memmove.o memset.o delay.o
 endif
+
diff --git a/arch/m68k/lib/Makefile_mm b/arch/m68k/lib/Makefile_mm
deleted file mode 100644
index af9abf8..0000000
--- a/arch/m68k/lib/Makefile_mm
+++ /dev/null
@@ -1,6 +0,0 @@
-#
-# Makefile for m68k-specific library files..
-#
-
-lib-y	:= ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \
-	   checksum.o string.o uaccess.o
diff --git a/arch/m68k/lib/Makefile_no b/arch/m68k/lib/Makefile_no
deleted file mode 100644
index 32d852e..0000000
--- a/arch/m68k/lib/Makefile_no
+++ /dev/null
@@ -1,7 +0,0 @@
-#
-# Makefile for m68knommu specific library files..
-#
-
-lib-y	:= ashldi3.o ashrdi3.o lshrdi3.o \
-	   muldi3.o mulsi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o \
-	   checksum.o memcpy.o memmove.o memset.o delay.o
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 3/6] m68k: remove duplicate memmove() implementation
  2011-03-30  7:58 ` [PATCH 1/6] m68k: merge mmu and non-mmu versions of muldi3 Greg Ungerer
  2011-03-30  7:58   ` [PATCH 2/6] m68k: merge mmu and non-mmu versions of lib/Makefile Greg Ungerer
@ 2011-03-30  7:58   ` Greg Ungerer
  2011-03-30  7:58   ` [PATCH 4/6] m68k: remove duplicate memset() implementation Greg Ungerer
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Greg Ungerer @ 2011-03-30  7:58 UTC (permalink / raw)
  To: linux-m68k; +Cc: Greg Ungerer

Merging the mmu and non-mmu directories we ended up with duplicate
(and identical) implementations of memmove(). Remove one of them.

Signed-off-by: Greg Ungerer <gerg@uclinux.org>
---
 arch/m68k/lib/Makefile  |    4 +-
 arch/m68k/lib/memmove.c |    2 -
 arch/m68k/lib/string.c  |   95 -----------------------------------------------
 3 files changed, 2 insertions(+), 99 deletions(-)

diff --git a/arch/m68k/lib/Makefile b/arch/m68k/lib/Makefile
index 3d85fb6..ec479a9 100644
--- a/arch/m68k/lib/Makefile
+++ b/arch/m68k/lib/Makefile
@@ -3,12 +3,12 @@
 # Makefile for m68k-specific library files..
 #
 
-lib-y	:= ashldi3.o ashrdi3.o lshrdi3.o muldi3.o checksum.o
+lib-y	:= ashldi3.o ashrdi3.o lshrdi3.o muldi3.o memmove.o checksum.o
 
 ifdef CONFIG_MMU
 lib-y	+= string.o uaccess.o
 else
 lib-y	+= mulsi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o \
-	   memcpy.o memmove.o memset.o delay.o
+	   memcpy.o memset.o delay.o
 endif
 
diff --git a/arch/m68k/lib/memmove.c b/arch/m68k/lib/memmove.c
index b3dcfe9..6519f7f 100644
--- a/arch/m68k/lib/memmove.c
+++ b/arch/m68k/lib/memmove.c
@@ -4,8 +4,6 @@
  * for more details.
  */
 
-#define __IN_STRING_C
-
 #include <linux/module.h>
 #include <linux/string.h>
 
diff --git a/arch/m68k/lib/string.c b/arch/m68k/lib/string.c
index d399c5f..711fa74 100644
--- a/arch/m68k/lib/string.c
+++ b/arch/m68k/lib/string.c
@@ -148,98 +148,3 @@ void *memcpy(void *to, const void *from, size_t n)
 	return xto;
 }
 EXPORT_SYMBOL(memcpy);
-
-void *memmove(void *dest, const void *src, size_t n)
-{
-	void *xdest = dest;
-	size_t temp;
-
-	if (!n)
-		return xdest;
-
-	if (dest < src) {
-		if ((long)dest & 1) {
-			char *cdest = dest;
-			const char *csrc = src;
-			*cdest++ = *csrc++;
-			dest = cdest;
-			src = csrc;
-			n--;
-		}
-		if (n > 2 && (long)dest & 2) {
-			short *sdest = dest;
-			const short *ssrc = src;
-			*sdest++ = *ssrc++;
-			dest = sdest;
-			src = ssrc;
-			n -= 2;
-		}
-		temp = n >> 2;
-		if (temp) {
-			long *ldest = dest;
-			const long *lsrc = src;
-			temp--;
-			do
-				*ldest++ = *lsrc++;
-			while (temp--);
-			dest = ldest;
-			src = lsrc;
-		}
-		if (n & 2) {
-			short *sdest = dest;
-			const short *ssrc = src;
-			*sdest++ = *ssrc++;
-			dest = sdest;
-			src = ssrc;
-		}
-		if (n & 1) {
-			char *cdest = dest;
-			const char *csrc = src;
-			*cdest = *csrc;
-		}
-	} else {
-		dest = (char *)dest + n;
-		src = (const char *)src + n;
-		if ((long)dest & 1) {
-			char *cdest = dest;
-			const char *csrc = src;
-			*--cdest = *--csrc;
-			dest = cdest;
-			src = csrc;
-			n--;
-		}
-		if (n > 2 && (long)dest & 2) {
-			short *sdest = dest;
-			const short *ssrc = src;
-			*--sdest = *--ssrc;
-			dest = sdest;
-			src = ssrc;
-			n -= 2;
-		}
-		temp = n >> 2;
-		if (temp) {
-			long *ldest = dest;
-			const long *lsrc = src;
-			temp--;
-			do
-				*--ldest = *--lsrc;
-			while (temp--);
-			dest = ldest;
-			src = lsrc;
-		}
-		if (n & 2) {
-			short *sdest = dest;
-			const short *ssrc = src;
-			*--sdest = *--ssrc;
-			dest = sdest;
-			src = ssrc;
-		}
-		if (n & 1) {
-			char *cdest = dest;
-			const char *csrc = src;
-			*--cdest = *--csrc;
-		}
-	}
-	return xdest;
-}
-EXPORT_SYMBOL(memmove);
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 4/6] m68k: remove duplicate memset() implementation
  2011-03-30  7:58 ` [PATCH 1/6] m68k: merge mmu and non-mmu versions of muldi3 Greg Ungerer
  2011-03-30  7:58   ` [PATCH 2/6] m68k: merge mmu and non-mmu versions of lib/Makefile Greg Ungerer
  2011-03-30  7:58   ` [PATCH 3/6] m68k: remove duplicate memmove() implementation Greg Ungerer
@ 2011-03-30  7:58   ` Greg Ungerer
  2011-03-30  7:58   ` [PATCH 5/6] m68k: remove duplicate memcpy() implementation Greg Ungerer
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Greg Ungerer @ 2011-03-30  7:58 UTC (permalink / raw)
  To: linux-m68k; +Cc: Greg Ungerer

Merging the mmu and non-mmu directories we ended up with duplicate
implementations of memset(). One is a little more optimized for the
>68020 case, but that can easily be inserted into a single
implementation of memset(). Clean up the exporting of this symbol
too, otherwise we end up exporting it twice on a no-mmu build.

Signed-off-by: Greg Ungerer <gerg@uclinux.org>
---
 arch/m68k/kernel/m68k_ksyms_no.c |    1 -
 arch/m68k/lib/Makefile           |    5 +-
 arch/m68k/lib/memset.c           |  122 +++++++++++++++++++++++---------------
 arch/m68k/lib/string.c           |   61 -------------------
 4 files changed, 78 insertions(+), 111 deletions(-)
 rewrite arch/m68k/lib/memset.c (99%)

diff --git a/arch/m68k/kernel/m68k_ksyms_no.c b/arch/m68k/kernel/m68k_ksyms_no.c
index 39fe0a7..346bce6 100644
--- a/arch/m68k/kernel/m68k_ksyms_no.c
+++ b/arch/m68k/kernel/m68k_ksyms_no.c
@@ -36,7 +36,6 @@ EXPORT_SYMBOL(csum_partial_copy_nocheck);
    their interface isn't gonna change any time soon now, so
    it's OK to leave it out of version control.  */
 EXPORT_SYMBOL(memcpy);
-EXPORT_SYMBOL(memset);
 
 /*
  * libgcc functions - functions that are used internally by the
diff --git a/arch/m68k/lib/Makefile b/arch/m68k/lib/Makefile
index ec479a9..ac275d5 100644
--- a/arch/m68k/lib/Makefile
+++ b/arch/m68k/lib/Makefile
@@ -3,12 +3,13 @@
 # Makefile for m68k-specific library files..
 #
 
-lib-y	:= ashldi3.o ashrdi3.o lshrdi3.o muldi3.o memmove.o checksum.o
+lib-y	:= ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \
+	   memset.o memmove.o checksum.o
 
 ifdef CONFIG_MMU
 lib-y	+= string.o uaccess.o
 else
 lib-y	+= mulsi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o \
-	   memcpy.o memset.o delay.o
+	   memcpy.o delay.o
 endif
 
diff --git a/arch/m68k/lib/memset.c b/arch/m68k/lib/memset.c
dissimilarity index 99%
index 1389bf4..eea2834 100644
--- a/arch/m68k/lib/memset.c
+++ b/arch/m68k/lib/memset.c
@@ -1,47 +1,75 @@
-#include <linux/types.h>
-
-void * memset(void * s, int c, size_t count)
-{
-  void *xs = s;
-  size_t temp;
-
-  if (!count)
-    return xs;
-  c &= 0xff;
-  c |= c << 8;
-  c |= c << 16;
-  if ((long) s & 1)
-    {
-      char *cs = s;
-      *cs++ = c;
-      s = cs;
-      count--;
-    }
-  if (count > 2 && (long) s & 2)
-    {
-      short *ss = s;
-      *ss++ = c;
-      s = ss;
-      count -= 2;
-    }
-  temp = count >> 2;
-  if (temp)
-    {
-      long *ls = s;
-      for (; temp; temp--)
-	*ls++ = c;
-      s = ls;
-    }
-  if (count & 2)
-    {
-      short *ss = s;
-      *ss++ = c;
-      s = ss;
-    }
-  if (count & 1)
-    {
-      char *cs = s;
-      *cs = c;
-    }
-  return xs;
-}
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file COPYING in the main directory of this archive
+ * for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/string.h>
+
+void *memset(void *s, int c, size_t count)
+{
+	void *xs = s;
+	size_t temp;
+
+	if (!count)
+		return xs;
+	c &= 0xff;
+	c |= c << 8;
+	c |= c << 16;
+	if ((long)s & 1) {
+		char *cs = s;
+		*cs++ = c;
+		s = cs;
+		count--;
+	}
+	if (count > 2 && (long)s & 2) {
+		short *ss = s;
+		*ss++ = c;
+		s = ss;
+		count -= 2;
+	}
+	temp = count >> 2;
+	if (temp) {
+		long *ls = s;
+#if defined(__mc68020__) || defined(__mc68030__) || \
+    defined(__mc68040__) || defined(__mc68060__)
+		size_t temp1;
+		asm volatile (
+			"	movel %1,%2\n"
+			"	andw  #7,%2\n"
+			"	lsrl  #3,%1\n"
+			"	negw  %2\n"
+			"	jmp   %%pc@(2f,%2:w:2)\n"
+			"1:	movel %3,%0@+\n"
+			"	movel %3,%0@+\n"
+			"	movel %3,%0@+\n"
+			"	movel %3,%0@+\n"
+			"	movel %3,%0@+\n"
+			"	movel %3,%0@+\n"
+			"	movel %3,%0@+\n"
+			"	movel %3,%0@+\n"
+			"2:	dbra  %1,1b\n"
+			"	clrw  %1\n"
+			"	subql #1,%1\n"
+			"	jpl   1b"
+			: "=a" (ls), "=d" (temp), "=&d" (temp1)
+			: "d" (c), "0" (ls), "1" (temp));
+#else
+		for (; temp; temp--)
+			*ls++ = c;
+#endif
+		s = ls;
+	}
+	if (count & 2) {
+		short *ss = s;
+		*ss++ = c;
+		s = ss;
+	}
+	if (count & 1) {
+		char *cs = s;
+		*cs = c;
+	}
+	return xs;
+}
+EXPORT_SYMBOL(memset);
diff --git a/arch/m68k/lib/string.c b/arch/m68k/lib/string.c
index 711fa74..6d24612 100644
--- a/arch/m68k/lib/string.c
+++ b/arch/m68k/lib/string.c
@@ -21,67 +21,6 @@ char *strcat(char *dest, const char *src)
 }
 EXPORT_SYMBOL(strcat);
 
-void *memset(void *s, int c, size_t count)
-{
-	void *xs = s;
-	size_t temp, temp1;
-
-	if (!count)
-		return xs;
-	c &= 0xff;
-	c |= c << 8;
-	c |= c << 16;
-	if ((long)s & 1) {
-		char *cs = s;
-		*cs++ = c;
-		s = cs;
-		count--;
-	}
-	if (count > 2 && (long)s & 2) {
-		short *ss = s;
-		*ss++ = c;
-		s = ss;
-		count -= 2;
-	}
-	temp = count >> 2;
-	if (temp) {
-		long *ls = s;
-
-		asm volatile (
-			"	movel %1,%2\n"
-			"	andw  #7,%2\n"
-			"	lsrl  #3,%1\n"
-			"	negw  %2\n"
-			"	jmp   %%pc@(2f,%2:w:2)\n"
-			"1:	movel %3,%0@+\n"
-			"	movel %3,%0@+\n"
-			"	movel %3,%0@+\n"
-			"	movel %3,%0@+\n"
-			"	movel %3,%0@+\n"
-			"	movel %3,%0@+\n"
-			"	movel %3,%0@+\n"
-			"	movel %3,%0@+\n"
-			"2:	dbra  %1,1b\n"
-			"	clrw  %1\n"
-			"	subql #1,%1\n"
-			"	jpl   1b"
-			: "=a" (ls), "=d" (temp), "=&d" (temp1)
-			: "d" (c), "0" (ls), "1" (temp));
-		s = ls;
-	}
-	if (count & 2) {
-		short *ss = s;
-		*ss++ = c;
-		s = ss;
-	}
-	if (count & 1) {
-		char *cs = s;
-		*cs = c;
-	}
-	return xs;
-}
-EXPORT_SYMBOL(memset);
-
 void *memcpy(void *to, const void *from, size_t n)
 {
 	void *xto = to;
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 5/6] m68k: remove duplicate memcpy() implementation
  2011-03-30  7:58 ` [PATCH 1/6] m68k: merge mmu and non-mmu versions of muldi3 Greg Ungerer
                     ` (2 preceding siblings ...)
  2011-03-30  7:58   ` [PATCH 4/6] m68k: remove duplicate memset() implementation Greg Ungerer
@ 2011-03-30  7:58   ` Greg Ungerer
  2011-03-30  7:58   ` [PATCH 6/6] m68k: remove no longer used arch/m68k/lib/string.c Greg Ungerer
  2011-03-30 18:11   ` [PATCH 1/6] m68k: merge mmu and non-mmu versions of muldi3 Geert Uytterhoeven
  5 siblings, 0 replies; 17+ messages in thread
From: Greg Ungerer @ 2011-03-30  7:58 UTC (permalink / raw)
  To: linux-m68k; +Cc: Greg Ungerer

Merging the mmu and non-mmu directories we ended up with duplicate
implementations of memcpy(). One is a little more optimized for the
>68020 case, but that can easily be inserted into a single
implementation of memcpy(). Clean up the exporting of this symbol
too, otherwise we end up exporting it twice on a no-mmu build.

Signed-off-by: Greg Ungerer <gerg@uclinux.org>
---
 arch/m68k/kernel/m68k_ksyms_no.c     |    6 --
 arch/m68k/lib/Makefile               |    5 +-
 arch/m68k/lib/{string.c => memcpy.c} |   21 ++-----
 arch/m68k/lib/string.c               |  111 +++++++---------------------------
 4 files changed, 30 insertions(+), 113 deletions(-)
 rename arch/m68k/lib/{string.c => memcpy.c} (84%)
 rewrite arch/m68k/lib/string.c (71%)

diff --git a/arch/m68k/kernel/m68k_ksyms_no.c b/arch/m68k/kernel/m68k_ksyms_no.c
index 346bce6..10af0af 100644
--- a/arch/m68k/kernel/m68k_ksyms_no.c
+++ b/arch/m68k/kernel/m68k_ksyms_no.c
@@ -31,12 +31,6 @@ EXPORT_SYMBOL(kernel_thread);
 /* Networking helper routines. */
 EXPORT_SYMBOL(csum_partial_copy_nocheck);
 
-/* The following are special because they're not called
-   explicitly (the C compiler generates them).  Fortunately,
-   their interface isn't gonna change any time soon now, so
-   it's OK to leave it out of version control.  */
-EXPORT_SYMBOL(memcpy);
-
 /*
  * libgcc functions - functions that are used internally by the
  * compiler...  (prototypes are not correct though, but that
diff --git a/arch/m68k/lib/Makefile b/arch/m68k/lib/Makefile
index ac275d5..2438d02 100644
--- a/arch/m68k/lib/Makefile
+++ b/arch/m68k/lib/Makefile
@@ -4,12 +4,11 @@
 #
 
 lib-y	:= ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \
-	   memset.o memmove.o checksum.o
+	   memcpy.o memset.o memmove.o checksum.o
 
 ifdef CONFIG_MMU
 lib-y	+= string.o uaccess.o
 else
-lib-y	+= mulsi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o \
-	   memcpy.o delay.o
+lib-y	+= mulsi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o delay.o
 endif
 
diff --git a/arch/m68k/lib/string.c b/arch/m68k/lib/memcpy.c
similarity index 84%
rename from arch/m68k/lib/string.c
rename to arch/m68k/lib/memcpy.c
index 6d24612..2592171 100644
--- a/arch/m68k/lib/string.c
+++ b/arch/m68k/lib/memcpy.c
@@ -4,23 +4,9 @@
  * for more details.
  */
 
-#define __IN_STRING_C
-
 #include <linux/module.h>
 #include <linux/string.h>
 
-char *strcpy(char *dest, const char *src)
-{
-	return __kernel_strcpy(dest, src);
-}
-EXPORT_SYMBOL(strcpy);
-
-char *strcat(char *dest, const char *src)
-{
-	return __kernel_strcpy(dest + __kernel_strlen(dest), src);
-}
-EXPORT_SYMBOL(strcat);
-
 void *memcpy(void *to, const void *from, size_t n)
 {
 	void *xto = to;
@@ -48,7 +34,8 @@ void *memcpy(void *to, const void *from, size_t n)
 	if (temp) {
 		long *lto = to;
 		const long *lfrom = from;
-
+#if defined(__mc68020__) || defined(__mc68030__) || \
+    defined(__mc68040__) || defined(__mc68060__)
 		asm volatile (
 			"	movel %2,%3\n"
 			"	andw  #7,%3\n"
@@ -69,6 +56,10 @@ void *memcpy(void *to, const void *from, size_t n)
 			"	jpl   4b"
 			: "=a" (lfrom), "=a" (lto), "=d" (temp), "=&d" (temp1)
 			: "0" (lfrom), "1" (lto), "2" (temp));
+#else
+		for (; temp; temp--)
+			*lto++ = *lfrom++;
+#endif
 		to = lto;
 		from = lfrom;
 	}
diff --git a/arch/m68k/lib/string.c b/arch/m68k/lib/string.c
dissimilarity index 71%
index 6d24612..b9a57ab 100644
--- a/arch/m68k/lib/string.c
+++ b/arch/m68k/lib/string.c
@@ -1,89 +1,22 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of this archive
- * for more details.
- */
-
-#define __IN_STRING_C
-
-#include <linux/module.h>
-#include <linux/string.h>
-
-char *strcpy(char *dest, const char *src)
-{
-	return __kernel_strcpy(dest, src);
-}
-EXPORT_SYMBOL(strcpy);
-
-char *strcat(char *dest, const char *src)
-{
-	return __kernel_strcpy(dest + __kernel_strlen(dest), src);
-}
-EXPORT_SYMBOL(strcat);
-
-void *memcpy(void *to, const void *from, size_t n)
-{
-	void *xto = to;
-	size_t temp, temp1;
-
-	if (!n)
-		return xto;
-	if ((long)to & 1) {
-		char *cto = to;
-		const char *cfrom = from;
-		*cto++ = *cfrom++;
-		to = cto;
-		from = cfrom;
-		n--;
-	}
-	if (n > 2 && (long)to & 2) {
-		short *sto = to;
-		const short *sfrom = from;
-		*sto++ = *sfrom++;
-		to = sto;
-		from = sfrom;
-		n -= 2;
-	}
-	temp = n >> 2;
-	if (temp) {
-		long *lto = to;
-		const long *lfrom = from;
-
-		asm volatile (
-			"	movel %2,%3\n"
-			"	andw  #7,%3\n"
-			"	lsrl  #3,%2\n"
-			"	negw  %3\n"
-			"	jmp   %%pc@(1f,%3:w:2)\n"
-			"4:	movel %0@+,%1@+\n"
-			"	movel %0@+,%1@+\n"
-			"	movel %0@+,%1@+\n"
-			"	movel %0@+,%1@+\n"
-			"	movel %0@+,%1@+\n"
-			"	movel %0@+,%1@+\n"
-			"	movel %0@+,%1@+\n"
-			"	movel %0@+,%1@+\n"
-			"1:	dbra  %2,4b\n"
-			"	clrw  %2\n"
-			"	subql #1,%2\n"
-			"	jpl   4b"
-			: "=a" (lfrom), "=a" (lto), "=d" (temp), "=&d" (temp1)
-			: "0" (lfrom), "1" (lto), "2" (temp));
-		to = lto;
-		from = lfrom;
-	}
-	if (n & 2) {
-		short *sto = to;
-		const short *sfrom = from;
-		*sto++ = *sfrom++;
-		to = sto;
-		from = sfrom;
-	}
-	if (n & 1) {
-		char *cto = to;
-		const char *cfrom = from;
-		*cto = *cfrom;
-	}
-	return xto;
-}
-EXPORT_SYMBOL(memcpy);
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file COPYING in the main directory of this archive
+ * for more details.
+ */
+
+#define __IN_STRING_C
+
+#include <linux/module.h>
+#include <linux/string.h>
+
+char *strcpy(char *dest, const char *src)
+{
+	return __kernel_strcpy(dest, src);
+}
+EXPORT_SYMBOL(strcpy);
+
+char *strcat(char *dest, const char *src)
+{
+	return __kernel_strcpy(dest + __kernel_strlen(dest), src);
+}
+EXPORT_SYMBOL(strcat);
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH 6/6] m68k: remove no longer used arch/m68k/lib/string.c
  2011-03-30  7:58 ` [PATCH 1/6] m68k: merge mmu and non-mmu versions of muldi3 Greg Ungerer
                     ` (3 preceding siblings ...)
  2011-03-30  7:58   ` [PATCH 5/6] m68k: remove duplicate memcpy() implementation Greg Ungerer
@ 2011-03-30  7:58   ` Greg Ungerer
  2011-03-30 18:26     ` Geert Uytterhoeven
  2011-03-30 18:11   ` [PATCH 1/6] m68k: merge mmu and non-mmu versions of muldi3 Geert Uytterhoeven
  5 siblings, 1 reply; 17+ messages in thread
From: Greg Ungerer @ 2011-03-30  7:58 UTC (permalink / raw)
  To: linux-m68k; +Cc: Greg Ungerer

The last remaining functions in string.c, strcpy() and strcat(), are
not actually used. They are defined inline in asm/string.h. So remove
string.h.

Signed-off-by: Greg Ungerer <gerg@uclinux.org>
---
 arch/m68k/lib/Makefile |    2 +-
 arch/m68k/lib/string.c |   22 ----------------------
 2 files changed, 1 insertions(+), 23 deletions(-)
 delete mode 100644 arch/m68k/lib/string.c

diff --git a/arch/m68k/lib/Makefile b/arch/m68k/lib/Makefile
index 2438d02..60fae1c 100644
--- a/arch/m68k/lib/Makefile
+++ b/arch/m68k/lib/Makefile
@@ -7,7 +7,7 @@ lib-y	:= ashldi3.o ashrdi3.o lshrdi3.o muldi3.o \
 	   memcpy.o memset.o memmove.o checksum.o
 
 ifdef CONFIG_MMU
-lib-y	+= string.o uaccess.o
+lib-y	+= uaccess.o
 else
 lib-y	+= mulsi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o delay.o
 endif
diff --git a/arch/m68k/lib/string.c b/arch/m68k/lib/string.c
deleted file mode 100644
index b9a57ab..0000000
--- a/arch/m68k/lib/string.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file COPYING in the main directory of this archive
- * for more details.
- */
-
-#define __IN_STRING_C
-
-#include <linux/module.h>
-#include <linux/string.h>
-
-char *strcpy(char *dest, const char *src)
-{
-	return __kernel_strcpy(dest, src);
-}
-EXPORT_SYMBOL(strcpy);
-
-char *strcat(char *dest, const char *src)
-{
-	return __kernel_strcpy(dest + __kernel_strlen(dest), src);
-}
-EXPORT_SYMBOL(strcat);
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/6] m68k: merge mmu and non-mmu versions of muldi3
  2011-03-30  7:58 ` [PATCH 1/6] m68k: merge mmu and non-mmu versions of muldi3 Greg Ungerer
                     ` (4 preceding siblings ...)
  2011-03-30  7:58   ` [PATCH 6/6] m68k: remove no longer used arch/m68k/lib/string.c Greg Ungerer
@ 2011-03-30 18:11   ` Geert Uytterhoeven
  2011-03-31  3:57     ` Greg Ungerer
  5 siblings, 1 reply; 17+ messages in thread
From: Geert Uytterhoeven @ 2011-03-30 18:11 UTC (permalink / raw)
  To: Greg Ungerer; +Cc: linux-m68k

On Wed, Mar 30, 2011 at 09:58, Greg Ungerer <gerg@uclinux.org> wrote:
> The implementation of gcc's muldi3 support function differs only in
> the use of the machine's 64 bit sized mul or not. (It isn't based
> on using an MMU or not). Merge the current mmu and non-mmu versions
> of arc/m68k/lib/muldi3 and use the appropriate pre-processor
> conditionals to get the right version for all m68k processor types.
>
> Signed-off-by: Greg Ungerer <gerg@uclinux.org>
> ---
>  arch/m68k/lib/{muldi3_no.c => muldi3.c} |   14 +++++++
>  arch/m68k/lib/muldi3_mm.c               |   63 -------------------------------
>  2 files changed, 14 insertions(+), 63 deletions(-)
>  rename arch/m68k/lib/{muldi3_no.c => muldi3.c} (88%)
>  delete mode 100644 arch/m68k/lib/muldi3_mm.c
>
> diff --git a/arch/m68k/lib/muldi3_no.c b/arch/m68k/lib/muldi3.c
> similarity index 88%
> rename from arch/m68k/lib/muldi3_no.c
> rename to arch/m68k/lib/muldi3.c
> index 34af72c..6bc1c16 100644
> --- a/arch/m68k/lib/muldi3_no.c
> +++ b/arch/m68k/lib/muldi3.c
> @@ -22,6 +22,18 @@ Boston, MA 02111-1307, USA.  */
>  #define BITS_PER_UNIT 8
>  #define SI_TYPE_SIZE 32

SI_TYPE_SIZE is used by the "nommu" (sic) case only.

And BITS_PER_UNIT seems to be unused for both.

> +#if defined(__mc68020__) || defined(__mc68030__) || \
> +    defined(__mc68040__) || defined(__mc68060__)
> +
> +#define umul_ppmm(w1, w0, u, v) \
> +  __asm__ ("mulu%.l %3,%1:%0"                                          \
> +           : "=d" ((USItype)(w0)),                                     \
> +             "=d" ((USItype)(w1))                                      \
> +           : "%0" ((USItype)(u)),                                      \
> +             "dmi" ((USItype)(v)))
> +
> +#else
> +
>  #define __BITS4 (SI_TYPE_SIZE / 4)
>  #define __ll_B (1L << (SI_TYPE_SIZE / 2))
>  #define __ll_lowpart(t) ((USItype) (t) % __ll_B)
> @@ -51,6 +63,8 @@ Boston, MA 02111-1307, USA.  */
>     (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0);         \
>   } while (0)
>
> +#endif
> +
>  #define __umulsidi3(u, v) \
>   ({DIunion __w;                                                       \
>     umul_ppmm (__w.s.high, __w.s.low, u, v);                           \
> diff --git a/arch/m68k/lib/muldi3_mm.c b/arch/m68k/lib/muldi3_mm.c
> deleted file mode 100644
> index be4f275..0000000
> --- a/arch/m68k/lib/muldi3_mm.c
> +++ /dev/null
> @@ -1,63 +0,0 @@
> -/* muldi3.c extracted from gcc-2.7.2.3/libgcc2.c and
> -                          gcc-2.7.2.3/longlong.h 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.
> -
> -You should have received a copy of the GNU General Public License
> -along with GNU CC; see the file COPYING.  If not, write to
> -the Free Software Foundation, 59 Temple Place - Suite 330,
> -Boston, MA 02111-1307, USA.  */
> -
> -#define BITS_PER_UNIT 8
> -
> -#define umul_ppmm(w1, w0, u, v) \
> -  __asm__ ("mulu%.l %3,%1:%0"                                          \
> -           : "=d" ((USItype)(w0)),                                     \
> -             "=d" ((USItype)(w1))                                      \
> -           : "%0" ((USItype)(u)),                                      \
> -             "dmi" ((USItype)(v)))
> -
> -#define __umulsidi3(u, v) \
> -  ({DIunion __w;                                                       \
> -    umul_ppmm (__w.s.high, __w.s.low, u, v);                           \
> -    __w.ll; })
> -
> -typedef                 int SItype     __attribute__ ((mode (SI)));
> -typedef unsigned int USItype   __attribute__ ((mode (SI)));
> -typedef                 int DItype     __attribute__ ((mode (DI)));
> -typedef int word_type __attribute__ ((mode (__word__)));
> -
> -struct DIstruct {SItype high, low;};
> -
> -typedef union
> -{
> -  struct DIstruct s;
> -  DItype ll;
> -} DIunion;
> -
> -DItype
> -__muldi3 (DItype u, DItype v)
> -{
> -  DIunion w;
> -  DIunion uu, vv;
> -
> -  uu.ll = u,
> -  vv.ll = v;
> -
> -  w.ll = __umulsidi3 (uu.s.low, vv.s.low);
> -  w.s.high += ((USItype) uu.s.low * (USItype) vv.s.high
> -              + (USItype) uu.s.high * (USItype) vv.s.low);
> -
> -  return w.ll;
> -}
> --
> 1.7.0.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>



-- 
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] 17+ messages in thread

* Re: [PATCH 6/6] m68k: remove no longer used arch/m68k/lib/string.c
  2011-03-30  7:58   ` [PATCH 6/6] m68k: remove no longer used arch/m68k/lib/string.c Greg Ungerer
@ 2011-03-30 18:26     ` Geert Uytterhoeven
  2011-03-31  3:58       ` Greg Ungerer
  0 siblings, 1 reply; 17+ messages in thread
From: Geert Uytterhoeven @ 2011-03-30 18:26 UTC (permalink / raw)
  To: Greg Ungerer; +Cc: linux-m68k

On Wed, Mar 30, 2011 at 09:58, Greg Ungerer <gerg@uclinux.org> wrote:
> The last remaining functions in string.c, strcpy() and strcat(), are
> not actually used. They are defined inline in asm/string.h. So remove
> string.h.
  ^^^^^^^^
string.c

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] 17+ messages in thread

* Re: [PATCH 0/6] m68k: merge and clean up files in m68k/lib
  2011-03-30  7:58 [PATCH 0/6] m68k: merge and clean up files in m68k/lib Greg Ungerer
  2011-03-30  7:58 ` [PATCH 1/6] m68k: merge mmu and non-mmu versions of muldi3 Greg Ungerer
@ 2011-03-30 18:41 ` Geert Uytterhoeven
  2011-03-31  4:01   ` Greg Ungerer
  2011-04-06 19:36   ` Geert Uytterhoeven
  1 sibling, 2 replies; 17+ messages in thread
From: Geert Uytterhoeven @ 2011-03-30 18:41 UTC (permalink / raw)
  To: Greg Ungerer; +Cc: linux-m68k

Hi Greg,

On Wed, Mar 30, 2011 at 09:58, Greg Ungerer <gerg@uclinux.org> wrote:
> The following set of patches cleans up and merges individual files in
> the arch/m68k/lib directory. Mostly strait forward stuff,
>
> I have build and run tested on ARAnyM/Atari and ColdFire (non-mmu)
> targets.

Thanks! Looks good! Haven't tested it yet, though (see below).

> Not sure why git/diff mangled some of these a little. The changes to
> patche 5, string.h, are simpler than it looks... These where generated
> with "git format-patch -M -B" to make it easier to review the file
> movements.

Patch 1:

| Applying: m68k: merge mmu and non-mmu versions of muldi3
| error: arch/m68k/lib/muldi3.c: already exists in index
| Patch failed at 0001 m68k: merge mmu and non-mmu versions of muldi3
| When you have resolved this problem run "git am --resolved".
| If you would prefer to skip this patch, instead run "git am --skip".
| To restore the original branch and stop patching run "git am --abort".

Doing "git rm arch/m68k/lib/muldi3.c && git commit -a" first fixes it.

Patch5:

| Applying: m68k: remove duplicate memcpy() implementation
| error: arch/m68k/lib/string.c: has been deleted/renamed
| Patch failed at 0001 m68k: remove duplicate memcpy() implementation
| When you have resolved this problem run "git am --resolved".
| If you would prefer to skip this patch, instead run "git am --skip".
| To restore the original branch and stop patching run "git am --abort".

Doing "git rm arch/m68k/lib/string.c && git commit -a" did not fix it :-(

Any chance you can send a "normal" patch, or a place to pull from?

Anyway, I did a thorough review, so consider it
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

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] 17+ messages in thread

* Re: [PATCH 1/6] m68k: merge mmu and non-mmu versions of muldi3
  2011-03-30 18:11   ` [PATCH 1/6] m68k: merge mmu and non-mmu versions of muldi3 Geert Uytterhoeven
@ 2011-03-31  3:57     ` Greg Ungerer
  0 siblings, 0 replies; 17+ messages in thread
From: Greg Ungerer @ 2011-03-31  3:57 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Greg Ungerer, linux-m68k


Hi Geert,

On 31/03/11 04:11, Geert Uytterhoeven wrote:
> On Wed, Mar 30, 2011 at 09:58, Greg Ungerer<gerg@uclinux.org>  wrote:
>> The implementation of gcc's muldi3 support function differs only in
>> the use of the machine's 64 bit sized mul or not. (It isn't based
>> on using an MMU or not). Merge the current mmu and non-mmu versions
>> of arc/m68k/lib/muldi3 and use the appropriate pre-processor
>> conditionals to get the right version for all m68k processor types.
>>
>> Signed-off-by: Greg Ungerer<gerg@uclinux.org>
>> ---
>> áarch/m68k/lib/{muldi3_no.c =>  muldi3.c} | á 14 +++++++
>> áarch/m68k/lib/muldi3_mm.c á á á á á á á | á 63 -------------------------------
>> á2 files changed, 14 insertions(+), 63 deletions(-)
>> árename arch/m68k/lib/{muldi3_no.c =>  muldi3.c} (88%)
>> ádelete mode 100644 arch/m68k/lib/muldi3_mm.c
>>
>> diff --git a/arch/m68k/lib/muldi3_no.c b/arch/m68k/lib/muldi3.c
>> similarity index 88%
>> rename from arch/m68k/lib/muldi3_no.c
>> rename to arch/m68k/lib/muldi3.c
>> index 34af72c..6bc1c16 100644
>> --- a/arch/m68k/lib/muldi3_no.c
>> +++ b/arch/m68k/lib/muldi3.c
>> @@ -22,6 +22,18 @@ Boston, MA 02111-1307, USA. á*/
>> á#define BITS_PER_UNIT 8
>> á#define SI_TYPE_SIZE 32
>
> SI_TYPE_SIZE is used by the "nommu" (sic) case only.
>
> And BITS_PER_UNIT seems to be unused for both.

Indeed, well spotted. I'll remove BITS_PER_UNIT and move
SI_TYPE_SIZE into the "nommu" section.

Thanks
Greg



>> +#if defined(__mc68020__) || defined(__mc68030__) || \
>> + á ádefined(__mc68040__) || defined(__mc68060__)
>> +
>> +#define umul_ppmm(w1, w0, u, v) \
>> + á__asm__ ("mulu%.l %3,%1:%0" á á á á á á á á á á á á á á á á á á á á á\
>> + á á á á á : "=d" ((USItype)(w0)), á á á á á á á á á á á á á á á á á á \
>> + á á á á á á "=d" ((USItype)(w1)) á á á á á á á á á á á á á á á á á á á\
>> + á á á á á : "%0" ((USItype)(u)), á á á á á á á á á á á á á á á á á á á\
>> + á á á á á á "dmi" ((USItype)(v)))
>> +
>> +#else
>> +
>> á#define __BITS4 (SI_TYPE_SIZE / 4)
>> á#define __ll_B (1L<<  (SI_TYPE_SIZE / 2))
>> á#define __ll_lowpart(t) ((USItype) (t) % __ll_B)
>> @@ -51,6 +63,8 @@ Boston, MA 02111-1307, USA. á*/
>> á á (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); á á á á \
>> á } while (0)
>>
>> +#endif
>> +
>> á#define __umulsidi3(u, v) \
>> á ({DIunion __w; á á á á á á á á á á á á á á á á á á á á á á á á á á á \
>> á á umul_ppmm (__w.s.high, __w.s.low, u, v); á á á á á á á á á á á á á \
>> diff --git a/arch/m68k/lib/muldi3_mm.c b/arch/m68k/lib/muldi3_mm.c
>> deleted file mode 100644
>> index be4f275..0000000
>> --- a/arch/m68k/lib/muldi3_mm.c
>> +++ /dev/null
>> @@ -1,63 +0,0 @@
>> -/* muldi3.c extracted from gcc-2.7.2.3/libgcc2.c and
>> - á á á á á á á á á á á á ágcc-2.7.2.3/longlong.h 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.
>> -
>> -You should have received a copy of the GNU General Public License
>> -along with GNU CC; see the file COPYING. áIf not, write to
>> -the Free Software Foundation, 59 Temple Place - Suite 330,
>> -Boston, MA 02111-1307, USA. á*/
>> -
>> -#define BITS_PER_UNIT 8
>> -
>> -#define umul_ppmm(w1, w0, u, v) \
>> - á__asm__ ("mulu%.l %3,%1:%0" á á á á á á á á á á á á á á á á á á á á á\
>> - á á á á á : "=d" ((USItype)(w0)), á á á á á á á á á á á á á á á á á á \
>> - á á á á á á "=d" ((USItype)(w1)) á á á á á á á á á á á á á á á á á á á\
>> - á á á á á : "%0" ((USItype)(u)), á á á á á á á á á á á á á á á á á á á\
>> - á á á á á á "dmi" ((USItype)(v)))
>> -
>> -#define __umulsidi3(u, v) \
>> - á({DIunion __w; á á á á á á á á á á á á á á á á á á á á á á á á á á á \
>> - á áumul_ppmm (__w.s.high, __w.s.low, u, v); á á á á á á á á á á á á á \
>> - á á__w.ll; })
>> -
>> -typedef á á á á á á á á int SItype á á __attribute__ ((mode (SI)));
>> -typedef unsigned int USItype á __attribute__ ((mode (SI)));
>> -typedef á á á á á á á á int DItype á á __attribute__ ((mode (DI)));
>> -typedef int word_type __attribute__ ((mode (__word__)));
>> -
>> -struct DIstruct {SItype high, low;};
>> -
>> -typedef union
>> -{
>> - ástruct DIstruct s;
>> - áDItype ll;
>> -} DIunion;
>> -
>> -DItype
>> -__muldi3 (DItype u, DItype v)
>> -{
>> - áDIunion w;
>> - áDIunion uu, vv;
>> -
>> - áuu.ll = u,
>> - ávv.ll = v;
>> -
>> - áw.ll = __umulsidi3 (uu.s.low, vv.s.low);
>> - áw.s.high += ((USItype) uu.s.low * (USItype) vv.s.high
>> - á á á á á á á+ (USItype) uu.s.high * (USItype) vv.s.low);
>> -
>> - áreturn w.ll;
>> -}
>> --
>> 1.7.0.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at áhttp://vger.kernel.org/majordomo-info.html
>>
>
>
>


-- 
------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     gerg@snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close                             FAX:         +61 7 3217 5323
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 6/6] m68k: remove no longer used arch/m68k/lib/string.c
  2011-03-30 18:26     ` Geert Uytterhoeven
@ 2011-03-31  3:58       ` Greg Ungerer
  0 siblings, 0 replies; 17+ messages in thread
From: Greg Ungerer @ 2011-03-31  3:58 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Greg Ungerer, linux-m68k

Hi Geert,

On 31/03/11 04:26, Geert Uytterhoeven wrote:
> On Wed, Mar 30, 2011 at 09:58, Greg Ungerer<gerg@uclinux.org>  wrote:
>> The last remaining functions in string.c, strcpy() and strcat(), are
>> not actually used. They are defined inline in asm/string.h. So remove
>> string.h.
>    ^^^^^^^^
> string.c

Thanks, I'll fix that too :-)

Regards
Greg


> 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
> --
> To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
>


-- 
------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     gerg@snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close                             FAX:         +61 7 3217 5323
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 0/6] m68k: merge and clean up files in m68k/lib
  2011-03-30 18:41 ` [PATCH 0/6] m68k: merge and clean up files in m68k/lib Geert Uytterhoeven
@ 2011-03-31  4:01   ` Greg Ungerer
  2011-04-06 19:36   ` Geert Uytterhoeven
  1 sibling, 0 replies; 17+ messages in thread
From: Greg Ungerer @ 2011-03-31  4:01 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Greg Ungerer, linux-m68k


Hi Geert,

On 31/03/11 04:41, Geert Uytterhoeven wrote:
> On Wed, Mar 30, 2011 at 09:58, Greg Ungerer<gerg@uclinux.org>  wrote:
>> The following set of patches cleans up and merges individual files in
>> the arch/m68k/lib directory. Mostly strait forward stuff,
>>
>> I have build and run tested on ARAnyM/Atari and ColdFire (non-mmu)
>> targets.
>
> Thanks! Looks good! Haven't tested it yet, though (see below).
>
>> Not sure why git/diff mangled some of these a little. The changes to
>> patche 5, string.h, are simpler than it looks... These where generated
>> with "git format-patch -M -B" to make it easier to review the file
>> movements.
>
> Patch 1:
>
> | Applying: m68k: merge mmu and non-mmu versions of muldi3
> | error: arch/m68k/lib/muldi3.c: already exists in index
> | Patch failed at 0001 m68k: merge mmu and non-mmu versions of muldi3
> | When you have resolved this problem run "git am --resolved".
> | If you would prefer to skip this patch, instead run "git am --skip".
> | To restore the original branch and stop patching run "git am --abort".
>
> Doing "git rm arch/m68k/lib/muldi3.c&&  git commit -a" first fixes it.
>
> Patch5:
>
> | Applying: m68k: remove duplicate memcpy() implementation
> | error: arch/m68k/lib/string.c: has been deleted/renamed
> | Patch failed at 0001 m68k: remove duplicate memcpy() implementation
> | When you have resolved this problem run "git am --resolved".
> | If you would prefer to skip this patch, instead run "git am --skip".
> | To restore the original branch and stop patching run "git am --abort".
>
> Doing "git rm arch/m68k/lib/string.c&&  git commit -a" did not fix it :-(
>
> Any chance you can send a "normal" patch, or a place to pull from?

Certainly. You can pull just these patches on the m68k-lib branch at:

git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu.git m68k-lib

I can re-send here if anyone wants to see them as normal patches?


> Anyway, I did a thorough review, so consider it
> Acked-by: Geert Uytterhoeven<geert@linux-m68k.org>

Thanks. I have added that, and fixed the other issues.

Thanks!
Greg


> 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
> --
> To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
>


-- 
------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     gerg@snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close                             FAX:         +61 7 3217 5323
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 0/6] m68k: merge and clean up files in m68k/lib
  2011-03-30 18:41 ` [PATCH 0/6] m68k: merge and clean up files in m68k/lib Geert Uytterhoeven
  2011-03-31  4:01   ` Greg Ungerer
@ 2011-04-06 19:36   ` Geert Uytterhoeven
  2011-04-07  3:55     ` Greg Ungerer
  1 sibling, 1 reply; 17+ messages in thread
From: Geert Uytterhoeven @ 2011-04-06 19:36 UTC (permalink / raw)
  To: Greg Ungerer; +Cc: linux-m68k

On Wed, Mar 30, 2011 at 20:41, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> Hi Greg,
>
> On Wed, Mar 30, 2011 at 09:58, Greg Ungerer <gerg@uclinux.org> wrote:
>> The following set of patches cleans up and merges individual files in
>> the arch/m68k/lib directory. Mostly strait forward stuff,
>>
>> I have build and run tested on ARAnyM/Atari and ColdFire (non-mmu)
>> targets.

> Anyway, I did a thorough review, so consider it
> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Upon actually trying it, I get:

arch/m68k/kernel/setup_mm.c:488: undefined reference to `strcpy'
arch/m68k/q40/config.c:149: undefined reference to `strcpy'
arch/m68k/atari/config.c:582: undefined reference to `strcpy'
arch/m68k/atari/config.c:588: undefined reference to `strcpy'
arch/m68k/atari/config.c:604: undefined reference to `strcpy'
arch/m68k/mac/built-in.o:arch/m68k/mac/config.c:916: more undefined
references to `strcpy' follow

Some of these are sprintf() or strcat() calls, "optimized" into strcpy() by gcc
(4.1.2 20061115 (prerelease) (Ubuntu 4.1.1-21)). Should have thought about
that, cfr. commit f9b07897c6288d7e5fc1fd004fccb0c5f1a0e570
("m68k: Uninline strchr()").
But not all of them: some are real strcpy() calls. Why are they the
inline version?

Reverting 7a2dc626ba38595bf04c663d834c394e7c0aa1f7 ("m68k: remove no
longer used arch/m68k/lib/string.c") fixes this.

So we need to keep at least the out-of-line strcpy().

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] 17+ messages in thread

* Re: [PATCH 0/6] m68k: merge and clean up files in m68k/lib
  2011-04-06 19:36   ` Geert Uytterhoeven
@ 2011-04-07  3:55     ` Greg Ungerer
  2011-04-07  8:22       ` Andreas Schwab
  0 siblings, 1 reply; 17+ messages in thread
From: Greg Ungerer @ 2011-04-07  3:55 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Greg Ungerer, linux-m68k


Hi Geert,

On 07/04/11 05:36, Geert Uytterhoeven wrote:
> On Wed, Mar 30, 2011 at 20:41, Geert Uytterhoeven<geert@linux-m68k.org>  wrote:
>> Hi Greg,
>>
>> On Wed, Mar 30, 2011 at 09:58, Greg Ungerer<gerg@uclinux.org>  wrote:
>>> The following set of patches cleans up and merges individual files in
>>> the arch/m68k/lib directory. Mostly strait forward stuff,
>>>
>>> I have build and run tested on ARAnyM/Atari and ColdFire (non-mmu)
>>> targets.
>
>> Anyway, I did a thorough review, so consider it
>> Acked-by: Geert Uytterhoeven<geert@linux-m68k.org>
>
> Upon actually trying it, I get:
>
> arch/m68k/kernel/setup_mm.c:488: undefined reference to `strcpy'
> arch/m68k/q40/config.c:149: undefined reference to `strcpy'
> arch/m68k/atari/config.c:582: undefined reference to `strcpy'
> arch/m68k/atari/config.c:588: undefined reference to `strcpy'
> arch/m68k/atari/config.c:604: undefined reference to `strcpy'
> arch/m68k/mac/built-in.o:arch/m68k/mac/config.c:916: more undefined
> references to `strcpy' follow
>
> Some of these are sprintf() or strcat() calls, "optimized" into strcpy() by gcc
> (4.1.2 20061115 (prerelease) (Ubuntu 4.1.1-21)). Should have thought about
> that, cfr. commit f9b07897c6288d7e5fc1fd004fccb0c5f1a0e570
> ("m68k: Uninline strchr()").
> But not all of them: some are real strcpy() calls. Why are they the
> inline version?

That does seem odd. One way or another strcpy is defined in
arch/m68k/include/asm/string.h. I would expect no real calls to
strcpy() after that. (And for me on my hand built gcc-4.5.1 I
don't end up with any).

At a guess the section for __GNUC__ > 4 must end up still trying
to use a real strcpy (presumably the __builtom_strcpy call) on
some versions of gcc.

#if __GNUC__ >= 4
#define strcpy(d, s)    (__builtin_constant_p(s) &&     \
                          __builtin_strlen(s) <= 32 ?    \
                          __builtin_strcpy(d, s) :       \
                          __kernel_strcpy(d, s))
#else
#define strcpy(d, s)    __kernel_strcpy(d, s)
#endif

Is there any reason we don't just drop the __GNUC__ >= 4 bit
and always just use __kernel_strcpy()?  After all kernel_strcpy
is a pretty tight optimized loop for m68k anyway.


> Reverting 7a2dc626ba38595bf04c663d834c394e7c0aa1f7 ("m68k: remove no
> longer used arch/m68k/lib/string.c") fixes this.
>
> So we need to keep at least the out-of-line strcpy().

Interestingly we haven't had a real strcpy defined on m68knommu
for quite a long time.

Regards
Greg


------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     gerg@snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close                             FAX:         +61 7 3217 5323
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 0/6] m68k: merge and clean up files in m68k/lib
  2011-04-07  3:55     ` Greg Ungerer
@ 2011-04-07  8:22       ` Andreas Schwab
  2011-04-07 11:26         ` Greg Ungerer
  0 siblings, 1 reply; 17+ messages in thread
From: Andreas Schwab @ 2011-04-07  8:22 UTC (permalink / raw)
  To: Greg Ungerer; +Cc: Geert Uytterhoeven, Greg Ungerer, linux-m68k

Greg Ungerer <gerg@snapgear.com> writes:

> That does seem odd. One way or another strcpy is defined in
> arch/m68k/include/asm/string.h. I would expect no real calls to
> strcpy() after that. (And for me on my hand built gcc-4.5.1 I
> don't end up with any).

Did you compile with -Os?

> At a guess the section for __GNUC__ > 4 must end up still trying
> to use a real strcpy (presumably the __builtom_strcpy call) on
> some versions of gcc.
>
> #if __GNUC__ >= 4
> #define strcpy(d, s)    (__builtin_constant_p(s) &&     \
>                          __builtin_strlen(s) <= 32 ?    \
>                          __builtin_strcpy(d, s) :       \
>                          __kernel_strcpy(d, s))
> #else
> #define strcpy(d, s)    __kernel_strcpy(d, s)
> #endif
>
> Is there any reason we don't just drop the __GNUC__ >= 4 bit
> and always just use __kernel_strcpy()?  After all kernel_strcpy
> is a pretty tight optimized loop for m68k anyway.

The compiler can generate libcalls to strcpy any time while optimizing
any other standard C function, and those libcalls won't see the macros,
of course.  The only way to stop the compiler from doing that is to
disable all builtin functions (just -fno-builtin-strcpy is not enough),
but that would disable a lot of useful opimisations.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 0/6] m68k: merge and clean up files in m68k/lib
  2011-04-07  8:22       ` Andreas Schwab
@ 2011-04-07 11:26         ` Greg Ungerer
  0 siblings, 0 replies; 17+ messages in thread
From: Greg Ungerer @ 2011-04-07 11:26 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Geert Uytterhoeven, Greg Ungerer, linux-m68k

Hi Andreas,

On 07/04/11 18:22, Andreas Schwab wrote:
> Greg Ungerer<gerg@snapgear.com>  writes:
>
>> That does seem odd. One way or another strcpy is defined in
>> arch/m68k/include/asm/string.h. I would expect no real calls to
>> strcpy() after that. (And for me on my hand built gcc-4.5.1 I
>> don't end up with any).
>
> Did you compile with -Os?

No, -O2. Here is a typical gcc line:

m68k-linux-gcc -Wp,-MD,kernel/.printk.o.d  -nostdinc -isystem 
/usr/local/lib/gcc/m68k-linux/4.5.1/include 
-I/home/gerg/new-wave.merge/linux-2.6.x/arch/m68k/include -Iinclude 
-include include/generated/autoconf.h -D__KERNEL__ -Wall -Wundef 
-Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common 
-Werror-implicit-function-declaration -Wno-format-security 
-fno-delete-null-pointer-checks -O2 -pipe -fno-strength-reduce 
-ffixed-a2 -Wframe-larger-than=1024 -fno-stack-protector 
-fomit-frame-pointer -Wdeclaration-after-statement -Wno-pointer-sign 
-fno-strict-overflow -fconserve-stack -DCC_HAVE_ASM_GOTO 
-D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(printk)" 
-D"KBUILD_MODNAME=KBUILD_STR(printk)" -c -o kernel/printk.o kernel/printk.c

This is vanilla 2.6.39-rc2...


>> At a guess the section for __GNUC__>  4 must end up still trying
>> to use a real strcpy (presumably the __builtom_strcpy call) on
>> some versions of gcc.
>>
>> #if __GNUC__>= 4
>> #define strcpy(d, s)    (__builtin_constant_p(s)&&      \
>>                           __builtin_strlen(s)<= 32 ?    \
>>                           __builtin_strcpy(d, s) :       \
>>                           __kernel_strcpy(d, s))
>> #else
>> #define strcpy(d, s)    __kernel_strcpy(d, s)
>> #endif
>>
>> Is there any reason we don't just drop the __GNUC__>= 4 bit
>> and always just use __kernel_strcpy()?  After all kernel_strcpy
>> is a pretty tight optimized loop for m68k anyway.
>
> The compiler can generate libcalls to strcpy any time while optimizing
> any other standard C function, and those libcalls won't see the macros,
> of course.  The only way to stop the compiler from doing that is to
> disable all builtin functions (just -fno-builtin-strcpy is not enough),
> but that would disable a lot of useful opimisations.

Yes, ok. It is just that I hadn't seen gcc emit calls to strcpy
on my m68knommu builds (at least not in recent years since we
removed the local strcpy).

Regards
Greg

------------------------------------------------------------------------
Greg Ungerer  --  Principal Engineer        EMAIL:     gerg@snapgear.com
SnapGear Group, McAfee                      PHONE:       +61 7 3435 2888
8 Gardner Close                             FAX:         +61 7 3217 5323
Milton, QLD, 4064, Australia                WEB: http://www.SnapGear.com

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2011-04-07 11:34 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-30  7:58 [PATCH 0/6] m68k: merge and clean up files in m68k/lib Greg Ungerer
2011-03-30  7:58 ` [PATCH 1/6] m68k: merge mmu and non-mmu versions of muldi3 Greg Ungerer
2011-03-30  7:58   ` [PATCH 2/6] m68k: merge mmu and non-mmu versions of lib/Makefile Greg Ungerer
2011-03-30  7:58   ` [PATCH 3/6] m68k: remove duplicate memmove() implementation Greg Ungerer
2011-03-30  7:58   ` [PATCH 4/6] m68k: remove duplicate memset() implementation Greg Ungerer
2011-03-30  7:58   ` [PATCH 5/6] m68k: remove duplicate memcpy() implementation Greg Ungerer
2011-03-30  7:58   ` [PATCH 6/6] m68k: remove no longer used arch/m68k/lib/string.c Greg Ungerer
2011-03-30 18:26     ` Geert Uytterhoeven
2011-03-31  3:58       ` Greg Ungerer
2011-03-30 18:11   ` [PATCH 1/6] m68k: merge mmu and non-mmu versions of muldi3 Geert Uytterhoeven
2011-03-31  3:57     ` Greg Ungerer
2011-03-30 18:41 ` [PATCH 0/6] m68k: merge and clean up files in m68k/lib Geert Uytterhoeven
2011-03-31  4:01   ` Greg Ungerer
2011-04-06 19:36   ` Geert Uytterhoeven
2011-04-07  3:55     ` Greg Ungerer
2011-04-07  8:22       ` Andreas Schwab
2011-04-07 11:26         ` Greg Ungerer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox