2 * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
3 * Copyright (C) 2004 Microtronix Datacom Ltd
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
10 #include <linux/types.h>
11 #include <linux/string.h>
13 #ifdef __HAVE_ARCH_MEMSET
14 void *memset(void *s
, int c
, size_t count
)
16 int destptr
, charcnt
, dwordcnt
, fill8reg
, wrkrega
;
24 char *xs
= (char *) s
;
31 __asm__
__volatile__ (
32 /* fill8 %3, %5 (c & 0xff) */
37 /* Word-align %0 (s) if necessary */
38 " andi %4, %0, 0x01\n"
44 /* Dword-align %0 (s) if necessary */
45 " andi %4, %0, 0x02\n"
51 /* %1 and %2 are how many more bytes to set */
53 /* %2 is how many dwords to set */
58 /* store residual word and/or byte if necessary */
59 " andi %4, %1, 0x02\n"
63 /* store residual byte if necessary */
64 "4: andi %4, %1, 0x01\n"
68 : "=r" (destptr
), /* %0 Output */
69 "=r" (charcnt
), /* %1 Output */
70 "=r" (dwordcnt
), /* %2 Output */
71 "=r" (fill8reg
), /* %3 Output */
72 "=r" (wrkrega
) /* %4 Output */
73 : "r" (c
), /* %5 Input */
74 "0" (s
), /* %0 Input/Output */
75 "1" (count
) /* %1 Input/Output */
76 : "memory" /* clobbered */
81 #endif /* __HAVE_ARCH_MEMSET */