From: zippel@linux-m68k.org
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 01/21] fix uaccess.h for gcc-3.x
Date: Fri, 23 Jun 2006 20:30:57 +0200 [thread overview]
Message-ID: <20060623183909.041973000@linux-m68k.org> (raw)
In-Reply-To: 20060623183056.479024000@linux-m68k.org
[-- Attachment #1: 0001-M68K-fix-uaccess.h-for-gcc-3.x.txt --]
[-- Type: text/plain, Size: 7524 bytes --]
gcc-3.x has a few problems detecting a constant parameter.
Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
---
include/asm-m68k/uaccess.h | 234 ++++++++++++++++++++++++--------------------
1 files changed, 127 insertions(+), 107 deletions(-)
fc73eb3c1c20f01114bd452fc8140ead1575e447
diff --git a/include/asm-m68k/uaccess.h b/include/asm-m68k/uaccess.h
index b761ef2..ef7963f 100644
--- a/include/asm-m68k/uaccess.h
+++ b/include/asm-m68k/uaccess.h
@@ -181,144 +181,164 @@ #define get_user(x, ptr) __get_user(x, p
unsigned long __generic_copy_from_user(void *to, const void __user *from, unsigned long n);
unsigned long __generic_copy_to_user(void __user *to, const void *from, unsigned long n);
+#define __constant_copy_from_user_asm(res, to, from, tmp, n, s1, s2, s3)\
+ asm volatile ("\n" \
+ "1: moves."#s1" (%2)+,%3\n" \
+ " move."#s1" %3,(%1)+\n" \
+ "2: moves."#s2" (%2)+,%3\n" \
+ " move."#s2" %3,(%1)+\n" \
+ " .ifnc \""#s3"\",\"\"\n" \
+ "3: moves."#s3" (%2)+,%3\n" \
+ " move."#s3" %3,(%1)+\n" \
+ " .endif\n" \
+ "4:\n" \
+ " .section __ex_table,\"a\"\n" \
+ " .align 4\n" \
+ " .long 1b,10f\n" \
+ " .long 2b,20f\n" \
+ " .ifnc \""#s3"\",\"\"\n" \
+ " .long 3b,30f\n" \
+ " .endif\n" \
+ " .previous\n" \
+ "\n" \
+ " .section .fixup,\"ax\"\n" \
+ " .even\n" \
+ "10: clr."#s1" (%1)+\n" \
+ "20: clr."#s2" (%1)+\n" \
+ " .ifnc \""#s3"\",\"\"\n" \
+ "30: clr."#s3" (%1)+\n" \
+ " .endif\n" \
+ " moveq.l #"#n",%0\n" \
+ " jra 4b\n" \
+ " .previous\n" \
+ : "+d" (res), "+&a" (to), "+a" (from), "=&d" (tmp) \
+ : : "memory")
+
static __always_inline unsigned long
__constant_copy_from_user(void *to, const void __user *from, unsigned long n)
{
unsigned long res = 0, tmp;
- /* limit the inlined version to 3 moves */
- if (n == 11 || n > 12)
- return __generic_copy_from_user(to, from, n);
-
switch (n) {
case 1:
__get_user_asm(res, *(u8 *)to, (u8 *)from, u8, b, d, 1);
- return res;
+ break;
case 2:
__get_user_asm(res, *(u16 *)to, (u16 *)from, u16, w, d, 2);
- return res;
+ break;
+ case 3:
+ __constant_copy_from_user_asm(res, to, from, tmp, 3, w, b,);
+ break;
case 4:
__get_user_asm(res, *(u32 *)to, (u32 *)from, u32, l, r, 4);
- return res;
+ break;
+ case 5:
+ __constant_copy_from_user_asm(res, to, from, tmp, 5, l, b,);
+ break;
+ case 6:
+ __constant_copy_from_user_asm(res, to, from, tmp, 6, l, w,);
+ break;
+ case 7:
+ __constant_copy_from_user_asm(res, to, from, tmp, 7, l, w, b);
+ break;
+ case 8:
+ __constant_copy_from_user_asm(res, to, from, tmp, 8, l, l,);
+ break;
+ case 9:
+ __constant_copy_from_user_asm(res, to, from, tmp, 9, l, l, b);
+ break;
+ case 10:
+ __constant_copy_from_user_asm(res, to, from, tmp, 10, l, l, w);
+ break;
+ case 12:
+ __constant_copy_from_user_asm(res, to, from, tmp, 12, l, l, l);
+ break;
+ default:
+ /* we limit the inlined version to 3 moves */
+ return __generic_copy_from_user(to, from, n);
}
- asm volatile ("\n"
- " .ifndef .Lfrom_user\n"
- " .set .Lfrom_user,1\n"
- " .macro copy_from_user to,from,tmp\n"
- " .if .Lcnt >= 4\n"
- "1: moves.l (\\from)+,\\tmp\n"
- " move.l \\tmp,(\\to)+\n"
- " .set .Lcnt,.Lcnt-4\n"
- " .elseif .Lcnt & 2\n"
- "1: moves.w (\\from)+,\\tmp\n"
- " move.w \\tmp,(\\to)+\n"
- " .set .Lcnt,.Lcnt-2\n"
- " .elseif .Lcnt & 1\n"
- "1: moves.b (\\from)+,\\tmp\n"
- " move.b \\tmp,(\\to)+\n"
- " .set .Lcnt,.Lcnt-1\n"
- " .else\n"
- " .exitm\n"
- " .endif\n"
- "\n"
- " .section __ex_table,\"a\"\n"
- " .align 4\n"
- " .long 1b,3f\n"
- " .previous\n"
- " .endm\n"
- " .endif\n"
- "\n"
- " .set .Lcnt,%c4\n"
- " copy_from_user %1,%2,%3\n"
- " copy_from_user %1,%2,%3\n"
- " copy_from_user %1,%2,%3\n"
- "2:\n"
- " .section .fixup,\"ax\"\n"
- " .even\n"
- "3: moveq.l %4,%0\n"
- " move.l %5,%1\n"
- " .rept %c4 / 4\n"
- " clr.l (%1)+\n"
- " .endr\n"
- " .if %c4 & 2\n"
- " clr.w (%1)+\n"
- " .endif\n"
- " .if %c4 & 1\n"
- " clr.b (%1)+\n"
- " .endif\n"
- " jra 2b\n"
- " .previous\n"
- : "+r" (res), "+a" (to), "+a" (from), "=&d" (tmp)
- : "i" (n), "g" (to)
- : "memory");
-
return res;
}
+#define __constant_copy_to_user_asm(res, to, from, tmp, n, s1, s2, s3) \
+ asm volatile ("\n" \
+ " move."#s1" (%2)+,%3\n" \
+ "11: moves."#s1" %3,(%1)+\n" \
+ "12: move."#s2" (%2)+,%3\n" \
+ "21: moves."#s2" %3,(%1)+\n" \
+ "22:\n" \
+ " .ifnc \""#s3"\",\"\"\n" \
+ " move."#s3" (%2)+,%3\n" \
+ "31: moves."#s3" %3,(%1)+\n" \
+ "32:\n" \
+ " .endif\n" \
+ "4:\n" \
+ "\n" \
+ " .section __ex_table,\"a\"\n" \
+ " .align 4\n" \
+ " .long 11b,5f\n" \
+ " .long 12b,5f\n" \
+ " .long 21b,5f\n" \
+ " .long 22b,5f\n" \
+ " .ifnc \""#s3"\",\"\"\n" \
+ " .long 31b,5f\n" \
+ " .long 32b,5f\n" \
+ " .endif\n" \
+ " .previous\n" \
+ "\n" \
+ " .section .fixup,\"ax\"\n" \
+ " .even\n" \
+ "5: moveq.l #"#n",%0\n" \
+ " jra 4b\n" \
+ " .previous\n" \
+ : "+d" (res), "+a" (to), "+a" (from), "=&d" (tmp) \
+ : : "memory")
+
static __always_inline unsigned long
__constant_copy_to_user(void __user *to, const void *from, unsigned long n)
{
unsigned long res = 0, tmp;
- /* limit the inlined version to 3 moves */
- if (n == 11 || n > 12)
- return __generic_copy_to_user(to, from, n);
-
switch (n) {
case 1:
__put_user_asm(res, *(u8 *)from, (u8 *)to, b, d, 1);
- return res;
+ break;
case 2:
__put_user_asm(res, *(u16 *)from, (u16 *)to, w, d, 2);
- return res;
+ break;
+ case 3:
+ __constant_copy_to_user_asm(res, to, from, tmp, 3, w, b,);
+ break;
case 4:
__put_user_asm(res, *(u32 *)from, (u32 *)to, l, r, 4);
- return res;
+ break;
+ case 5:
+ __constant_copy_to_user_asm(res, to, from, tmp, 5, l, b,);
+ break;
+ case 6:
+ __constant_copy_to_user_asm(res, to, from, tmp, 6, l, w,);
+ break;
+ case 7:
+ __constant_copy_to_user_asm(res, to, from, tmp, 7, l, w, b);
+ break;
+ case 8:
+ __constant_copy_to_user_asm(res, to, from, tmp, 8, l, l,);
+ break;
+ case 9:
+ __constant_copy_to_user_asm(res, to, from, tmp, 9, l, l, b);
+ break;
+ case 10:
+ __constant_copy_to_user_asm(res, to, from, tmp, 10, l, l, w);
+ break;
+ case 12:
+ __constant_copy_to_user_asm(res, to, from, tmp, 12, l, l, l);
+ break;
+ default:
+ /* limit the inlined version to 3 moves */
+ return __generic_copy_to_user(to, from, n);
}
- asm volatile ("\n"
- " .ifndef .Lto_user\n"
- " .set .Lto_user,1\n"
- " .macro copy_to_user to,from,tmp\n"
- " .if .Lcnt >= 4\n"
- " move.l (\\from)+,\\tmp\n"
- "11: moves.l \\tmp,(\\to)+\n"
- "12: .set .Lcnt,.Lcnt-4\n"
- " .elseif .Lcnt & 2\n"
- " move.w (\\from)+,\\tmp\n"
- "11: moves.w \\tmp,(\\to)+\n"
- "12: .set .Lcnt,.Lcnt-2\n"
- " .elseif .Lcnt & 1\n"
- " move.b (\\from)+,\\tmp\n"
- "11: moves.b \\tmp,(\\to)+\n"
- "12: .set .Lcnt,.Lcnt-1\n"
- " .else\n"
- " .exitm\n"
- " .endif\n"
- "\n"
- " .section __ex_table,\"a\"\n"
- " .align 4\n"
- " .long 11b,3f\n"
- " .long 12b,3f\n"
- " .previous\n"
- " .endm\n"
- " .endif\n"
- "\n"
- " .set .Lcnt,%c4\n"
- " copy_to_user %1,%2,%3\n"
- " copy_to_user %1,%2,%3\n"
- " copy_to_user %1,%2,%3\n"
- "2:\n"
- " .section .fixup,\"ax\"\n"
- " .even\n"
- "3: moveq.l %4,%0\n"
- " jra 2b\n"
- " .previous\n"
- : "+r" (res), "+a" (to), "+a" (from), "=&d" (tmp)
- : "i" (n)
- : "memory");
-
return res;
}
--
1.3.3
--
next prev parent reply other threads:[~2006-06-23 18:42 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-23 18:30 [PATCH 00/21] m68k patches zippel
2006-06-23 18:30 ` zippel [this message]
2006-06-23 18:30 ` [PATCH 02/21] fix constraints of the signal functions and some cleanup zippel
2006-06-23 18:30 ` [PATCH 03/21] fix __iounmap for 030 zippel
2006-06-23 18:31 ` [PATCH 04/21] small flush_icache() cleanup zippel
2006-06-23 18:31 ` [PATCH 05/21] Add the generic dma API functions zippel
2006-06-23 18:31 ` [PATCH 06/21] dma API addition zippel
2006-06-23 18:31 ` [PATCH 07/21] fix show_registers() zippel
2006-06-23 18:31 ` [PATCH 08/21] gcc 4 fix zippel
2006-06-23 19:35 ` Al Viro
2006-06-23 20:05 ` Roman Zippel
2006-06-24 4:45 ` Finn Thain
2006-06-26 17:43 ` Brad Boyer
2006-06-23 18:31 ` [PATCH 09/21] separate handler for auto and user vector interrupt zippel
2006-06-23 18:31 ` [PATCH 10/21] cleanup generic irq names zippel
2006-06-23 18:31 ` [PATCH 11/21] cleanup amiga irq numbering zippel
2006-06-23 18:31 ` [PATCH 12/21] introduce irq controller zippel
2006-06-23 18:31 ` [PATCH 13/21] convert generic irq code to " zippel
2006-06-23 18:31 ` [PATCH 14/21] convert amiga irq code zippel
2006-06-23 18:31 ` [PATCH 15/21] convert apollo " zippel
2006-06-23 18:31 ` [PATCH 16/21] convert atari " zippel
2006-06-23 18:31 ` [PATCH 17/21] convert hp300 " zippel
2006-06-23 18:31 ` [PATCH 18/21] convert mac " zippel
2006-06-23 18:31 ` [PATCH 19/21] convert q40 " zippel
2006-06-23 18:31 ` [PATCH 20/21] convert sun3 " zippel
2006-06-23 18:31 ` [PATCH 21/21] convert VME " zippel
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=20060623183909.041973000@linux-m68k.org \
--to=zippel@linux-m68k.org \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).