3 <<memset>>---set an area of memory
10 void *memset(void *<[dst]>, int <[c]>, size_t <[length]>);
13 This function converts the argument <[c]> into an unsigned
14 char and fills the first <[length]> characters of the array
15 pointed to by <[dst]> to the value.
18 <<memset>> returns the value of <[dst]>.
23 <<memset>> requires no supporting OS subroutines.
32 #define LBLOCKSIZE (sizeof(long))
33 #define UNALIGNED(X) ((long)X & (LBLOCKSIZE - 1))
34 #define TOO_SMALL(LEN) ((LEN) < LBLOCKSIZE)
37 __inhibit_loop_to_libcall
44 #if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__)
47 unsigned long *aligned_addr
;
48 unsigned int d
= c
& 0xff; /* To avoid sign extension, copy C to an
61 /* If we get this far, we know that n is large and s is word-aligned. */
62 aligned_addr
= (unsigned long *) s
;
64 /* Store D into each char sized location in BUFFER so that
65 we can set large blocks quickly. */
66 buffer
= (d
<< 8) | d
;
67 buffer
|= (buffer
<< 16);
68 for (i
= 32; i
< LBLOCKSIZE
* 8; i
<<= 1)
69 buffer
= (buffer
<< i
) | buffer
;
71 /* Unroll the loop. */
72 while (n
>= LBLOCKSIZE
*4)
74 *aligned_addr
++ = buffer
;
75 *aligned_addr
++ = buffer
;
76 *aligned_addr
++ = buffer
;
77 *aligned_addr
++ = buffer
;
81 while (n
>= LBLOCKSIZE
)
83 *aligned_addr
++ = buffer
;
86 /* Pick up the remainder with a bytewise loop. */
87 s
= (char*)aligned_addr
;
90 #endif /* not PREFER_SIZE_OVER_SPEED */