Magellan Linux

Annotation of /trunk/mkinitrd-magellan/klibc/usr/klibc/memset.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 532 - (hide annotations) (download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 9 months ago) by niro
File MIME type: text/plain
File size: 602 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd

1 niro 532 /*
2     * memset.c
3     */
4    
5     #include <string.h>
6     #include <stdint.h>
7    
8     void *memset(void *dst, int c, size_t n)
9     {
10     char *q = dst;
11    
12     #if defined(__i386__)
13     size_t nl = n >> 2;
14     asm volatile ("cld ; rep ; stosl ; movl %3,%0 ; rep ; stosb"
15     : "+c" (nl), "+D" (q)
16     : "a" ((unsigned char)c * 0x01010101U), "r" (n & 3));
17     #elif defined(__x86_64__)
18     size_t nq = n >> 3;
19     asm volatile ("cld ; rep ; stosq ; movl %3,%%ecx ; rep ; stosb"
20     :"+c" (nq), "+D" (q)
21     : "a" ((unsigned char)c * 0x0101010101010101U),
22     "r" ((uint32_t) n & 7));
23     #else
24     while (n--) {
25     *q++ = c;
26     }
27     #endif
28    
29     return dst;
30     }