r6831@lvps87-230-33-50: verhaegs | 2008-02-03 14:08:57 +0100
[tangerine.git] / compiler / clib / memset.c
blob907006ba6cc7b1b8891a0ed5434618e7a585acb4
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
5 ANSI C function memcpy().
6 */
8 #include <proto/exec.h>
10 /*****************************************************************************
12 NAME */
13 #include <string.h>
15 void * memset (
17 /* SYNOPSIS */
18 void * dest,
19 int c,
20 size_t count)
22 /* FUNCTION
23 Fill the memory at dest with count times c.
25 INPUTS
26 dest - The first byte of the destination area in memory
27 c - The byte to fill memory with
28 count - How many bytes to write
30 RESULT
31 dest.
33 NOTES
35 EXAMPLE
37 BUGS
39 SEE ALSO
40 memmove(), memcpy()
42 INTERNALS
44 ******************************************************************************/
46 UBYTE * ptr = dest;
48 while (((IPTR)ptr)&(AROS_LONGALIGN-1) && count)
50 *ptr ++ = c;
51 count --;
54 if (count > sizeof(ULONG))
56 ULONG * ulptr = (ULONG *)ptr;
57 ULONG fill;
59 fill = (ULONG)(c & 0xFF);
60 fill = (fill << 8) | fill;
61 fill = (fill << 16) | fill;
63 while (count > sizeof(ULONG))
65 *ulptr ++ = fill;
66 count -= sizeof(ULONG);
69 ptr = (UBYTE *)ulptr;
72 while (count --)
73 *ptr ++ = c;
75 return dest;
76 } /* memset */