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 void *memset(void *s
, int c
, size_t count
)
15 int destptr
, charcnt
, dwordcnt
, fill8reg
, wrkrega
;
23 char *xs
= (char *) s
;
30 __asm__
__volatile__ (
31 /* fill8 %3, %5 (c & 0xff) */
36 /* Word-align %0 (s) if necessary */
37 " andi %4, %0, 0x01\n"
43 /* Dword-align %0 (s) if necessary */
44 " andi %4, %0, 0x02\n"
50 /* %1 and %2 are how many more bytes to set */
52 /* %2 is how many dwords to set */
57 /* store residual word and/or byte if necessary */
58 " andi %4, %1, 0x02\n"
62 /* store residual byte if necessary */
63 "4: andi %4, %1, 0x01\n"
67 : "=r" (destptr
), /* %0 Output */
68 "=r" (charcnt
), /* %1 Output */
69 "=r" (dwordcnt
), /* %2 Output */
70 "=r" (fill8reg
), /* %3 Output */
71 "=&r" (wrkrega
) /* %4 Output only */
72 : "r" (c
), /* %5 Input */
73 "0" (s
), /* %0 Input/Output */
74 "1" (count
) /* %1 Input/Output */
75 : "memory" /* clobbered */