All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] m68k patches
@ 2006-10-04 23:24 zippel
  2006-10-04 23:24 ` [PATCH 1/5] provide tickadj define zippel
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: zippel @ 2006-10-04 23:24 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

Hi,

Here a few miscellaneous fixes for m68k, including the lost timeadj due
the ntp patches, which affected also other archs.

bye, Roman



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

* [PATCH 1/5] provide tickadj define
  2006-10-04 23:24 [PATCH 0/5] m68k patches zippel
@ 2006-10-04 23:24 ` zippel
  2006-10-04 23:24 ` [PATCH 2/5] m68k: cleanup string functions zippel
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: zippel @ 2006-10-04 23:24 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

[-- Attachment #1: tickadj_define --]
[-- Type: text/plain, Size: 662 bytes --]

Provide a tickadj compatibility define for archs still using it.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>

---
 include/linux/timex.h |    3 +++
 1 file changed, 3 insertions(+)

Index: linux-2.6/include/linux/timex.h
===================================================================
--- linux-2.6.orig/include/linux/timex.h
+++ linux-2.6/include/linux/timex.h
@@ -293,6 +293,9 @@ extern void second_overflow(void);
 extern void update_ntp_one_tick(void);
 extern int do_adjtimex(struct timex *);
 
+/* Don't use! Compatibility define for existing users. */
+#define tickadj	(500/HZ ? : 1)
+
 #endif /* KERNEL */
 
 #endif /* LINUX_TIMEX_H */

--


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

* [PATCH 2/5] m68k: cleanup string functions
  2006-10-04 23:24 [PATCH 0/5] m68k patches zippel
  2006-10-04 23:24 ` [PATCH 1/5] provide tickadj define zippel
@ 2006-10-04 23:24 ` zippel
  2006-10-04 23:24 ` [PATCH 3/5] m68k: fix type in __generic_copy_to_user zippel
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: zippel @ 2006-10-04 23:24 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

[-- Attachment #1: string --]
[-- Type: text/plain, Size: 7549 bytes --]

- cleanup asm of string functions
- deinline strncat()/strncmp()
- provide non-inlined strcpy()

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>

---
 arch/m68k/kernel/m68k_ksyms.c |    4 
 arch/m68k/lib/string.c        |   15 +++
 include/asm-m68k/string.h     |  194 ++++++++++++++++++------------------------
 3 files changed, 100 insertions(+), 113 deletions(-)

Index: linux-2.6/arch/m68k/kernel/m68k_ksyms.c
===================================================================
--- linux-2.6.orig/arch/m68k/kernel/m68k_ksyms.c
+++ linux-2.6/arch/m68k/kernel/m68k_ksyms.c
@@ -1,7 +1,6 @@
 #include <linux/module.h>
 #include <linux/linkage.h>
 #include <linux/sched.h>
-#include <linux/string.h>
 #include <linux/mm.h>
 #include <linux/user.h>
 #include <linux/elfcore.h>
@@ -53,9 +52,6 @@ EXPORT_SYMBOL(mach_beep);
 #endif
 EXPORT_SYMBOL(dump_fpu);
 EXPORT_SYMBOL(dump_thread);
-EXPORT_SYMBOL(strnlen);
-EXPORT_SYMBOL(strrchr);
-EXPORT_SYMBOL(strstr);
 EXPORT_SYMBOL(kernel_thread);
 #ifdef CONFIG_VME
 EXPORT_SYMBOL(vme_brdtype);
Index: linux-2.6/arch/m68k/lib/string.c
===================================================================
--- linux-2.6.orig/arch/m68k/lib/string.c
+++ linux-2.6/arch/m68k/lib/string.c
@@ -1,6 +1,19 @@
+/*
+ * 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/types.h>
 #include <linux/module.h>
+#include <linux/string.h>
+
+char *strcpy(char *dest, const char *src)
+{
+	return __kernel_strcpy(dest, src);
+}
+EXPORT_SYMBOL(strcpy);
 
 void *memset(void *s, int c, size_t count)
 {
Index: linux-2.6/include/asm-m68k/string.h
===================================================================
--- linux-2.6.orig/include/asm-m68k/string.h
+++ linux-2.6/include/asm-m68k/string.h
@@ -1,138 +1,114 @@
 #ifndef _M68K_STRING_H_
 #define _M68K_STRING_H_
 
-#include <asm/setup.h>
-#include <asm/page.h>
+#include <linux/types.h>
+#include <linux/compiler.h>
 
-#define __HAVE_ARCH_STRCPY
-static inline char * strcpy(char * dest,const char *src)
+static inline size_t __kernel_strlen(const char *s)
 {
-  char *xdest = dest;
+	const char *sc;
 
-  __asm__ __volatile__
-       ("1:\tmoveb %1@+,%0@+\n\t"
-        "jne 1b"
-	: "=a" (dest), "=a" (src)
-        : "0" (dest), "1" (src) : "memory");
-  return xdest;
+	for (sc = s; *sc++; )
+		;
+	return sc - s - 1;
 }
 
-#define __HAVE_ARCH_STRNCPY
-static inline char * strncpy(char *dest, const char *src, size_t n)
+static inline char *__kernel_strcpy(char *dest, const char *src)
 {
-  char *xdest = dest;
+	char *xdest = dest;
 
-  if (n == 0)
-    return xdest;
-
-  __asm__ __volatile__
-       ("1:\tmoveb %1@+,%0@+\n\t"
-	"jeq 2f\n\t"
-        "subql #1,%2\n\t"
-        "jne 1b\n\t"
-        "2:"
-        : "=a" (dest), "=a" (src), "=d" (n)
-        : "0" (dest), "1" (src), "2" (n)
-        : "memory");
-  return xdest;
+	asm volatile ("\n"
+		"1:	move.b	(%1)+,(%0)+\n"
+		"	jne	1b"
+		: "+a" (dest), "+a" (src)
+		: : "memory");
+	return xdest;
 }
 
-#define __HAVE_ARCH_STRCAT
-static inline char * strcat(char * dest, const char * src)
-{
-	char *tmp = dest;
-
-	while (*dest)
-		dest++;
-	while ((*dest++ = *src++))
-		;
+#ifndef __IN_STRING_C
 
-	return tmp;
+#define __HAVE_ARCH_STRLEN
+#define strlen(s)	(__builtin_constant_p(s) ?	\
+			 __builtin_strlen(s) :		\
+			 __kernel_strlen(s))
+
+#define __HAVE_ARCH_STRNLEN
+static inline size_t strnlen(const char *s, size_t count)
+{
+	const char *sc = s;
+
+	asm volatile ("\n"
+		"1:     subq.l  #1,%1\n"
+		"       jcs     2f\n"
+		"       tst.b   (%0)+\n"
+		"       jne     1b\n"
+		"       subq.l  #1,%0\n"
+		"2:"
+		: "+a" (sc), "+d" (count));
+	return sc - s;
 }
 
-#define __HAVE_ARCH_STRNCAT
-static inline char * strncat(char *dest, const char *src, size_t count)
-{
-	char *tmp = dest;
-
-	if (count) {
-		while (*dest)
-			dest++;
-		while ((*dest++ = *src++)) {
-			if (--count == 0) {
-				*dest++='\0';
-				break;
-			}
-		}
-	}
-
-	return tmp;
-}
+#define __HAVE_ARCH_STRCPY
+#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
 
-#define __HAVE_ARCH_STRCHR
-static inline char * strchr(const char * s, int c)
+#define __HAVE_ARCH_STRNCPY
+static inline char *strncpy(char *dest, const char *src, size_t n)
 {
-  const char ch = c;
+	char *xdest = dest;
 
-  for(; *s != ch; ++s)
-    if (*s == '\0')
-      return( NULL );
-  return( (char *) s);
+	asm volatile ("\n"
+		"	jra	2f\n"
+		"1:	move.b	(%1),(%0)+\n"
+		"	jeq	2f\n"
+		"	addq.l	#1,%1\n"
+		"2:	subq.l	#1,%2\n"
+		"	jcc	1b\n"
+		: "+a" (dest), "+a" (src), "+d" (n)
+		: : "memory");
+	return xdest;
 }
 
-/* strstr !! */
+#define __HAVE_ARCH_STRCAT
+#define strcat(d, s)	({			\
+	char *__d = (d);			\
+	strcpy(__d + strlen(__d), (s));		\
+})
 
-#define __HAVE_ARCH_STRLEN
-static inline size_t strlen(const char * s)
+#define __HAVE_ARCH_STRCHR
+static inline char *strchr(const char *s, int c)
 {
-  const char *sc;
-  for (sc = s; *sc != '\0'; ++sc) ;
-  return(sc - s);
-}
+	char sc, ch = c;
 
-/* strnlen !! */
+	for (; (sc = *s++) != ch; ) {
+		if (!sc)
+			return NULL;
+	}
+	return (char *)s - 1;
+}
 
 #define __HAVE_ARCH_STRCMP
-static inline int strcmp(const char * cs,const char * ct)
+static inline int strcmp(const char *cs, const char *ct)
 {
-  char __res;
+	char res;
 
-  __asm__
-       ("1:\tmoveb %0@+,%2\n\t" /* get *cs */
-        "cmpb %1@+,%2\n\t"      /* compare a byte */
-        "jne  2f\n\t"           /* not equal, break out */
-        "tstb %2\n\t"           /* at end of cs? */
-        "jne  1b\n\t"           /* no, keep going */
-        "jra  3f\n\t"		/* strings are equal */
-        "2:\tsubb %1@-,%2\n\t"  /* *cs - *ct */
-        "3:"
-        : "=a" (cs), "=a" (ct), "=d" (__res)
-        : "0" (cs), "1" (ct));
-  return __res;
-}
-
-#define __HAVE_ARCH_STRNCMP
-static inline int strncmp(const char * cs,const char * ct,size_t count)
-{
-  char __res;
-
-  if (!count)
-    return 0;
-  __asm__
-       ("1:\tmovb %0@+,%3\n\t"          /* get *cs */
-        "cmpb   %1@+,%3\n\t"            /* compare a byte */
-        "jne    3f\n\t"                 /* not equal, break out */
-        "tstb   %3\n\t"                 /* at end of cs? */
-        "jeq    4f\n\t"                 /* yes, all done */
-        "subql  #1,%2\n\t"              /* no, adjust count */
-        "jne    1b\n\t"                 /* more to do, keep going */
-        "2:\tmoveq #0,%3\n\t"           /* strings are equal */
-        "jra    4f\n\t"
-        "3:\tsubb %1@-,%3\n\t"          /* *cs - *ct */
-        "4:"
-        : "=a" (cs), "=a" (ct), "=d" (count), "=d" (__res)
-        : "0" (cs), "1" (ct), "2" (count));
-  return __res;
+	asm ("\n"
+		"1:	move.b	(%0)+,%2\n"	/* get *cs */
+		"	cmp.b	(%1)+,%2\n"	/* compare a byte */
+		"	jne	2f\n"		/* not equal, break out */
+		"	tst.b	%2\n"		/* at end of cs? */
+		"	jne	1b\n"		/* no, keep going */
+		"	jra	3f\n"		/* strings are equal */
+		"2:	sub.b	-(%1),%2\n"	/* *cs - *ct */
+		"3:"
+		: "+a" (cs), "+a" (ct), "=d" (res));
+	return res;
 }
 
 #define __HAVE_ARCH_MEMSET
@@ -150,4 +126,6 @@ extern void *memmove(void *, const void 
 extern int memcmp(const void *, const void *, __kernel_size_t);
 #define memcmp(d, s, n) __builtin_memcmp(d, s, n)
 
+#endif
+
 #endif /* _M68K_STRING_H_ */

--


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

* [PATCH 3/5] m68k: fix type in __generic_copy_to_user
  2006-10-04 23:24 [PATCH 0/5] m68k patches zippel
  2006-10-04 23:24 ` [PATCH 1/5] provide tickadj define zippel
  2006-10-04 23:24 ` [PATCH 2/5] m68k: cleanup string functions zippel
@ 2006-10-04 23:24 ` zippel
  2006-10-04 23:24 ` [PATCH 4/5] m68k: small system.h cleanup zippel
  2006-10-04 23:24 ` [PATCH 5/5] m68k: fix NBPG define zippel
  4 siblings, 0 replies; 6+ messages in thread
From: zippel @ 2006-10-04 23:24 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

[-- Attachment #1: uaccess_fix --]
[-- Type: text/plain, Size: 592 bytes --]

Jump to the correct exit label after exception

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>

---
 arch/m68k/lib/uaccess.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/arch/m68k/lib/uaccess.c
===================================================================
--- linux-2.6.orig/arch/m68k/lib/uaccess.c
+++ linux-2.6/arch/m68k/lib/uaccess.c
@@ -84,7 +84,7 @@ unsigned long __generic_copy_to_user(voi
 		"	.even\n"
 		"20:	lsl.l	#2,%0\n"
 		"50:	add.l	%5,%0\n"
-		"	jra	7b\n"
+		"	jra	8b\n"
 		"	.previous\n"
 		"\n"
 		"	.section __ex_table,\"a\"\n"

--


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

* [PATCH 4/5] m68k: small system.h cleanup
  2006-10-04 23:24 [PATCH 0/5] m68k patches zippel
                   ` (2 preceding siblings ...)
  2006-10-04 23:24 ` [PATCH 3/5] m68k: fix type in __generic_copy_to_user zippel
@ 2006-10-04 23:24 ` zippel
  2006-10-04 23:24 ` [PATCH 5/5] m68k: fix NBPG define zippel
  4 siblings, 0 replies; 6+ messages in thread
From: zippel @ 2006-10-04 23:24 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

[-- Attachment #1: set_current --]
[-- Type: text/plain, Size: 1022 bytes --]

avoid unnecessary xchg() use in set_mb()

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>

---
 include/asm-m68k/system.h |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: linux-2.6/include/asm-m68k/system.h
===================================================================
--- linux-2.6.orig/include/asm-m68k/system.h
+++ linux-2.6/include/asm-m68k/system.h
@@ -78,13 +78,13 @@ static inline int irqs_disabled(void)
 #define mb()		barrier()
 #define rmb()		barrier()
 #define wmb()		barrier()
-#define read_barrier_depends()	do { } while(0)
-#define set_mb(var, value)    do { xchg(&var, value); } while (0)
+#define read_barrier_depends()	((void)0)
+#define set_mb(var, value)	({ (var) = (value); wmb(); })
 
 #define smp_mb()	barrier()
 #define smp_rmb()	barrier()
 #define smp_wmb()	barrier()
-#define smp_read_barrier_depends()	do { } while(0)
+#define smp_read_barrier_depends()	((void)0)
 
 
 #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))

--


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

* [PATCH 5/5] m68k: fix NBPG define
  2006-10-04 23:24 [PATCH 0/5] m68k patches zippel
                   ` (3 preceding siblings ...)
  2006-10-04 23:24 ` [PATCH 4/5] m68k: small system.h cleanup zippel
@ 2006-10-04 23:24 ` zippel
  4 siblings, 0 replies; 6+ messages in thread
From: zippel @ 2006-10-04 23:24 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel

[-- Attachment #1: nbpg --]
[-- Type: text/plain, Size: 901 bytes --]

The recent header cleanup removed PAGE_SIZE from the exported
information as it depends on the configuration.
BTW This has possibly other consequences, as the core dump code is using
PAGE_SIZE directly, which may need fixing as well.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>

---

 include/asm-m68k/user.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/include/asm-m68k/user.h
===================================================================
--- linux-2.6.orig/include/asm-m68k/user.h
+++ linux-2.6/include/asm-m68k/user.h
@@ -81,7 +81,7 @@ struct user{
   unsigned long magic;		/* To uniquely identify a core file */
   char u_comm[32];		/* User command that was responsible */
 };
-#define NBPG PAGE_SIZE
+#define NBPG 4096
 #define UPAGES 1
 #define HOST_TEXT_START_ADDR (u.start_code)
 #define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)

--


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

end of thread, other threads:[~2006-10-04 23:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-04 23:24 [PATCH 0/5] m68k patches zippel
2006-10-04 23:24 ` [PATCH 1/5] provide tickadj define zippel
2006-10-04 23:24 ` [PATCH 2/5] m68k: cleanup string functions zippel
2006-10-04 23:24 ` [PATCH 3/5] m68k: fix type in __generic_copy_to_user zippel
2006-10-04 23:24 ` [PATCH 4/5] m68k: small system.h cleanup zippel
2006-10-04 23:24 ` [PATCH 5/5] m68k: fix NBPG define zippel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.