2 * arch/v850/lib/memset.c -- Memory initialization
4 * Copyright (C) 2001,02,04 NEC Corporation
5 * Copyright (C) 2001,02,04 Miles Bader <miles@gnu.org>
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.
11 * Written by Miles Bader <miles@gnu.org>
14 #include <linux/types.h>
16 void *memset (void *dst
, int val
, __kernel_size_t count
)
19 register unsigned loop
;
20 register void *ptr
asm ("ep") = dst
;
22 /* replicate VAL into a long. */
27 /* copy initial unaligned bytes. */
30 ptr
= (void *)((char *)ptr
+ 1);
33 if (count
> 2 && ((long)ptr
& 2)) {
35 ptr
= (void *)((short *)ptr
+ 1);
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");
50 /* long copying loop. */
51 for (loop
= count
/ 4; loop
; loop
--) {
53 ptr
= (void *)((long *)ptr
+ 1);
57 /* finish up with any trailing bytes. */
60 ptr
= (void *)((short *)ptr
+ 1);