2 * arch/v850/lib/memset.c -- Memory initialization
4 * Copyright (C) 2001,02 NEC Corporation
5 * Copyright (C) 2001,02 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. */
29 *((char *)ptr)++ = val;
32 if (count > 2 && ((long)ptr & 2)) {
33 *((short *)ptr)++ = val;
37 /* 32-byte copying loop. */
38 for (loop = count / 32; loop; loop--) {
39 asm ("sst.w %0, 0[ep]; sst.w %0, 4[ep];"
40 "sst.w %0, 8[ep]; sst.w %0, 12[ep];"
41 "sst.w %0, 16[ep]; sst.w %0, 20[ep];"
42 "sst.w %0, 24[ep]; sst.w %0, 28[ep]"
43 :: "r" (val) : "memory");
48 /* long copying loop. */
49 for (loop = count / 4; loop; loop--)
50 *((long *)ptr)++ = val;
53 /* finish up with any trailing bytes. */
55 *((short *)ptr)++ = val;