nckernel  0.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
memset.c
Go to the documentation of this file.
1 #include <sys/types.h>
2 #include <stdio.h>
3 #include <string.h>
4 
5 #include <debug.h>
6 
7 void memset(void *buffer, int data, size_t size)
8 {
9  unsigned long *word;
10  unsigned char *byte;
11  unsigned long fill_word;
12  size_t i;
13 
14  word = buffer;
15 
16  i = size >> 2;
17  fill_word = ((unsigned char)data);
18  fill_word = (fill_word << 8) | ((unsigned char)data);
19  fill_word = (fill_word << 8) | ((unsigned char)data);
20  fill_word = (fill_word << 8) | ((unsigned char)data);
21  while (i-- > 0) {
22  *word++ = fill_word;
23  }
24 
25  byte = (unsigned char*)word;
26  i = size & 0x00000003;
27  while (i-- > 0) {
28  byte[i] = ((unsigned char*)&data)[i];
29  }
30 }
31 
32 /* End of a file */