Commit 74cad25c authored by Andreas Larsson's avatar Andreas Larsson Committed by David S. Miller

sparc: Let memset return the address argument

This makes memset follow the standard (instead of returning 0 on success). This
is needed when certain versions of gcc optimizes around memset calls and assume
that the address argument is preserved in %o0.
Signed-off-by: default avatarAndreas Larsson <andreas@gaisler.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 40831625
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
* Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
* Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
* *
* Returns 0, if ok, and number of bytes not yet set if exception * Calls to memset returns initial %o0. Calls to bzero returns 0, if ok, and
* occurs and we were called as clear_user. * number of bytes not yet set if exception occurs and we were called as
* clear_user.
*/ */
#include <asm/ptrace.h> #include <asm/ptrace.h>
...@@ -65,6 +66,8 @@ __bzero_begin: ...@@ -65,6 +66,8 @@ __bzero_begin:
.globl __memset_start, __memset_end .globl __memset_start, __memset_end
__memset_start: __memset_start:
memset: memset:
mov %o0, %g1
mov 1, %g4
and %o1, 0xff, %g3 and %o1, 0xff, %g3
sll %g3, 8, %g2 sll %g3, 8, %g2
or %g3, %g2, %g3 or %g3, %g2, %g3
...@@ -89,6 +92,7 @@ memset: ...@@ -89,6 +92,7 @@ memset:
sub %o0, %o2, %o0 sub %o0, %o2, %o0
__bzero: __bzero:
clr %g4
mov %g0, %g3 mov %g0, %g3
1: 1:
cmp %o1, 7 cmp %o1, 7
...@@ -151,8 +155,8 @@ __bzero: ...@@ -151,8 +155,8 @@ __bzero:
bne,a 8f bne,a 8f
EX(stb %g3, [%o0], and %o1, 1) EX(stb %g3, [%o0], and %o1, 1)
8: 8:
retl b 0f
clr %o0 nop
7: 7:
be 13b be 13b
orcc %o1, 0, %g0 orcc %o1, 0, %g0
...@@ -164,6 +168,12 @@ __bzero: ...@@ -164,6 +168,12 @@ __bzero:
bne 8b bne 8b
EX(stb %g3, [%o0 - 1], add %o1, 1) EX(stb %g3, [%o0 - 1], add %o1, 1)
0: 0:
andcc %g4, 1, %g0
be 5f
nop
retl
mov %g1, %o0
5:
retl retl
clr %o0 clr %o0
__memset_end: __memset_end:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment