Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 324049
b: refs/heads/master
c: 535c611
h: refs/heads/master
i:
  324047: 27f0058
v: v3
  • Loading branch information
Heiko Carstens authored and Martin Schwidefsky committed Sep 26, 2012
1 parent 5707376 commit c77c7fc
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 82 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 68d9884dbc4215b6693c108eb35a02bd78f7956e
refs/heads/master: 535c611ddd3eb076f96579131e30bc5dd02a3b1c
45 changes: 24 additions & 21 deletions trunk/arch/s390/boot/compressed/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,34 +71,37 @@ void *memset(void *s, int c, size_t n)
{
char *xs;

if (c == 0)
return __builtin_memset(s, 0, n);

xs = (char *) s;
if (n > 0)
do {
*xs++ = c;
} while (--n > 0);
xs = s;
while (n--)
*xs++ = c;
return s;
}

void *memcpy(void *__dest, __const void *__src, size_t __n)
void *memcpy(void *dest, const void *src, size_t n)
{
return __builtin_memcpy(__dest, __src, __n);
const char *s = src;
char *d = dest;

while (n--)
*d++ = *s++;
return dest;
}

void *memmove(void *__dest, __const void *__src, size_t __n)
void *memmove(void *dest, const void *src, size_t n)
{
char *d;
const char *s;

if (__dest <= __src)
return __builtin_memcpy(__dest, __src, __n);
d = __dest + __n;
s = __src + __n;
while (__n--)
*--d = *--s;
return __dest;
const char *s = src;
char *d = dest;

if (d <= s) {
while (n--)
*d++ = *s++;
} else {
d += n;
s += n;
while (n--)
*--d = *--s;
}
return dest;
}

static void error(char *x)
Expand Down
8 changes: 0 additions & 8 deletions trunk/arch/s390/include/asm/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ static inline char *strcat(char *dst, const char *src)

static inline char *strcpy(char *dst, const char *src)
{
#if __GNUC__ < 4
register int r0 asm("0") = 0;
char *ret = dst;

Expand All @@ -106,14 +105,10 @@ static inline char *strcpy(char *dst, const char *src)
: "+&a" (dst), "+&a" (src) : "d" (r0)
: "cc", "memory");
return ret;
#else
return __builtin_strcpy(dst, src);
#endif
}

static inline size_t strlen(const char *s)
{
#if __GNUC__ < 4
register unsigned long r0 asm("0") = 0;
const char *tmp = s;

Expand All @@ -122,9 +117,6 @@ static inline size_t strlen(const char *s)
" jo 0b"
: "+d" (r0), "+a" (tmp) : : "cc");
return r0 - (unsigned long) s;
#else
return __builtin_strlen(s);
#endif
}

static inline size_t strnlen(const char * s, size_t n)
Expand Down
2 changes: 2 additions & 0 deletions trunk/arch/s390/kernel/s390_ksyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ EXPORT_SYMBOL(_mcount);
#if defined(CONFIG_KVM) || defined(CONFIG_KVM_MODULE)
EXPORT_SYMBOL(sie64a);
#endif
EXPORT_SYMBOL(memcpy);
EXPORT_SYMBOL(memset);
3 changes: 2 additions & 1 deletion trunk/arch/s390/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

lib-y += delay.o string.o uaccess_std.o uaccess_pt.o
obj-y += usercopy.o
obj-$(CONFIG_32BIT) += div64.o qrnnd.o ucmpdi2.o
obj-$(CONFIG_32BIT) += div64.o qrnnd.o ucmpdi2.o mem32.o
obj-$(CONFIG_64BIT) += mem64.o
lib-$(CONFIG_64BIT) += uaccess_mvcos.o
lib-$(CONFIG_SMP) += spinlock.o
92 changes: 92 additions & 0 deletions trunk/arch/s390/lib/mem32.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* String handling functions.
*
* Copyright IBM Corp. 2012
*/

#include <linux/linkage.h>

/*
* memset implementation
*
* This code corresponds to the C construct below. We do distinguish
* between clearing (c == 0) and setting a memory array (c != 0) simply
* because nearly all memset invocations in the kernel clear memory and
* the xc instruction is preferred in such cases.
*
* void *memset(void *s, int c, size_t n)
* {
* if (likely(c == 0))
* return __builtin_memset(s, 0, n);
* return __builtin_memset(s, c, n);
* }
*/
ENTRY(memset)
basr %r5,%r0
.Lmemset_base:
ltr %r4,%r4
bzr %r14
ltr %r3,%r3
jnz .Lmemset_fill
ahi %r4,-1
lr %r3,%r4
srl %r3,8
ltr %r3,%r3
lr %r1,%r2
je .Lmemset_clear_rest
.Lmemset_clear_loop:
xc 0(256,%r1),0(%r1)
la %r1,256(%r1)
brct %r3,.Lmemset_clear_loop
.Lmemset_clear_rest:
ex %r4,.Lmemset_xc-.Lmemset_base(%r5)
br %r14
.Lmemset_fill:
stc %r3,0(%r2)
chi %r4,1
lr %r1,%r2
ber %r14
ahi %r4,-2
lr %r3,%r4
srl %r3,8
ltr %r3,%r3
je .Lmemset_fill_rest
.Lmemset_fill_loop:
mvc 1(256,%r1),0(%r1)
la %r1,256(%r1)
brct %r3,.Lmemset_fill_loop
.Lmemset_fill_rest:
ex %r4,.Lmemset_mvc-.Lmemset_base(%r5)
br %r14
.Lmemset_xc:
xc 0(1,%r1),0(%r1)
.Lmemset_mvc:
mvc 1(1,%r1),0(%r1)

/*
* memcpy implementation
*
* void *memcpy(void *dest, const void *src, size_t n)
*/
ENTRY(memcpy)
basr %r5,%r0
.Lmemcpy_base:
ltr %r4,%r4
bzr %r14
ahi %r4,-1
lr %r0,%r4
srl %r0,8
ltr %r0,%r0
lr %r1,%r2
jnz .Lmemcpy_loop
.Lmemcpy_rest:
ex %r4,.Lmemcpy_mvc-.Lmemcpy_base(%r5)
br %r14
.Lmemcpy_loop:
mvc 0(256,%r1),0(%r3)
la %r1,256(%r1)
la %r3,256(%r3)
brct %r0,.Lmemcpy_loop
j .Lmemcpy_rest
.Lmemcpy_mvc:
mvc 0(1,%r1),0(%r3)
88 changes: 88 additions & 0 deletions trunk/arch/s390/lib/mem64.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* String handling functions.
*
* Copyright IBM Corp. 2012
*/

#include <linux/linkage.h>

/*
* memset implementation
*
* This code corresponds to the C construct below. We do distinguish
* between clearing (c == 0) and setting a memory array (c != 0) simply
* because nearly all memset invocations in the kernel clear memory and
* the xc instruction is preferred in such cases.
*
* void *memset(void *s, int c, size_t n)
* {
* if (likely(c == 0))
* return __builtin_memset(s, 0, n);
* return __builtin_memset(s, c, n);
* }
*/
ENTRY(memset)
ltgr %r4,%r4
bzr %r14
ltgr %r3,%r3
jnz .Lmemset_fill
aghi %r4,-1
srlg %r3,%r4,8
ltgr %r3,%r3
lgr %r1,%r2
jz .Lmemset_clear_rest
.Lmemset_clear_loop:
xc 0(256,%r1),0(%r1)
la %r1,256(%r1)
brctg %r3,.Lmemset_clear_loop
.Lmemset_clear_rest:
larl %r3,.Lmemset_xc
ex %r4,0(%r3)
br %r14
.Lmemset_fill:
stc %r3,0(%r2)
cghi %r4,1
lgr %r1,%r2
ber %r14
aghi %r4,-2
srlg %r3,%r4,8
ltgr %r3,%r3
jz .Lmemset_fill_rest
.Lmemset_fill_loop:
mvc 1(256,%r1),0(%r1)
la %r1,256(%r1)
brctg %r3,.Lmemset_fill_loop
.Lmemset_fill_rest:
larl %r3,.Lmemset_mvc
ex %r4,0(%r3)
br %r14
.Lmemset_xc:
xc 0(1,%r1),0(%r1)
.Lmemset_mvc:
mvc 1(1,%r1),0(%r1)

/*
* memcpy implementation
*
* void *memcpy(void *dest, const void *src, size_t n)
*/
ENTRY(memcpy)
ltgr %r4,%r4
bzr %r14
aghi %r4,-1
srlg %r5,%r4,8
ltgr %r5,%r5
lgr %r1,%r2
jnz .Lmemcpy_loop
.Lmemcpy_rest:
larl %r5,.Lmemcpy_mvc
ex %r4,0(%r5)
br %r14
.Lmemcpy_loop:
mvc 0(256,%r1),0(%r3)
la %r1,256(%r1)
la %r3,256(%r3)
brctg %r5,.Lmemcpy_loop
j .Lmemcpy_rest
.Lmemcpy_mvc:
mvc 0(1,%r1),0(%r3)
Loading

0 comments on commit c77c7fc

Please sign in to comment.