diff options
| author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
| commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
| tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/v850/lib/memset.c | |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/v850/lib/memset.c')
| -rw-r--r-- | arch/v850/lib/memset.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/arch/v850/lib/memset.c b/arch/v850/lib/memset.c new file mode 100644 index 000000000000..d1b2ad821b15 --- /dev/null +++ b/arch/v850/lib/memset.c | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | /* | ||
| 2 | * arch/v850/lib/memset.c -- Memory initialization | ||
| 3 | * | ||
| 4 | * Copyright (C) 2001,02,04 NEC Corporation | ||
| 5 | * Copyright (C) 2001,02,04 Miles Bader <miles@gnu.org> | ||
| 6 | * | ||
| 7 | * This file is subject to the terms and conditions of the GNU General | ||
| 8 | * Public License. See the file COPYING in the main directory of this | ||
| 9 | * archive for more details. | ||
| 10 | * | ||
| 11 | * Written by Miles Bader <miles@gnu.org> | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include <linux/types.h> | ||
| 15 | |||
| 16 | void *memset (void *dst, int val, __kernel_size_t count) | ||
| 17 | { | ||
| 18 | if (count) { | ||
| 19 | register unsigned loop; | ||
| 20 | register void *ptr asm ("ep") = dst; | ||
| 21 | |||
| 22 | /* replicate VAL into a long. */ | ||
| 23 | val &= 0xff; | ||
| 24 | val |= val << 8; | ||
| 25 | val |= val << 16; | ||
| 26 | |||
| 27 | /* copy initial unaligned bytes. */ | ||
| 28 | if ((long)ptr & 1) { | ||
| 29 | *(char *)ptr = val; | ||
| 30 | ptr = (void *)((char *)ptr + 1); | ||
| 31 | count--; | ||
| 32 | } | ||
| 33 | if (count > 2 && ((long)ptr & 2)) { | ||
| 34 | *(short *)ptr = val; | ||
| 35 | ptr = (void *)((short *)ptr + 1); | ||
| 36 | count -= 2; | ||
| 37 | } | ||
| 38 | |||
| 39 | /* 32-byte copying loop. */ | ||
| 40 | for (loop = count / 32; loop; loop--) { | ||
| 41 | asm ("sst.w %0, 0[ep]; sst.w %0, 4[ep];" | ||
| 42 | "sst.w %0, 8[ep]; sst.w %0, 12[ep];" | ||
| 43 | "sst.w %0, 16[ep]; sst.w %0, 20[ep];" | ||
| 44 | "sst.w %0, 24[ep]; sst.w %0, 28[ep]" | ||
| 45 | :: "r" (val) : "memory"); | ||
| 46 | ptr += 32; | ||
| 47 | } | ||
| 48 | count %= 32; | ||
| 49 | |||
| 50 | /* long copying loop. */ | ||
| 51 | for (loop = count / 4; loop; loop--) { | ||
| 52 | *(long *)ptr = val; | ||
| 53 | ptr = (void *)((long *)ptr + 1); | ||
| 54 | } | ||
| 55 | count %= 4; | ||
| 56 | |||
| 57 | /* finish up with any trailing bytes. */ | ||
| 58 | if (count & 2) { | ||
| 59 | *(short *)ptr = val; | ||
| 60 | ptr = (void *)((short *)ptr + 1); | ||
| 61 | } | ||
| 62 | if (count & 1) { | ||
| 63 | *(char *)ptr = val; | ||
| 64 | } | ||
| 65 | } | ||
| 66 | |||
| 67 | return dst; | ||
| 68 | } | ||
