Main Page | Alphabetical List | Class List | File List | Class Members | File Members

memset.h

Go to the documentation of this file.
00001 #ifndef _MEMSET_H_
00002 #define _MEMSET_H_
00003 
00004 #include <nlibc.h>
00005 #include <inttypes.h>
00006 
00007 #define memset(DEST, C, BYTES)  wmemset((DEST),(C),(((BYTES)+15)>>4))
00008 
00009 #ifndef __HAS_MAIN
00010 extern void *wmemset(void *dest, int c, size_t words);
00011 #else
00012 #if !defined(__cflow_processed) || defined(_uses_wmemset_memset_h)
00013 #define _BLEN 8
00014 void *wmemset(void *dest, int c, size_t words) {
00015   typedef struct { int c[_BLEN]; } bursttype;
00016   register int i, n, ileft;
00017   register bursttype burst, *bdest;
00018 
00019   burst.c[0] = c;
00020   burst.c[1] = c;
00021   burst.c[2] = c;
00022   burst.c[3] = c;
00023   burst.c[4] = c;
00024   burst.c[5] = c;
00025   burst.c[6] = c;
00026   burst.c[7] = c;
00027 
00028   n = words / _BLEN;
00029   bdest = (bursttype *) dest;
00030   for (i = 0; i < n; i++) {
00031     bdest[i] = burst;
00032   }
00033 
00034   for (i = i*_BLEN; i < words; i++) {
00035     *(((int *) dest) + i) = c;
00036   }
00037 
00038   return dest;
00039 
00040 }
00041 #undef _BLEN
00042 #endif // _uses_wmemset_memset_h
00043 #endif // Has Main
00044 
00045 #endif // _MEMSET_H_

Generated on Fri Jul 14 10:51:31 2006 for nlibc by doxygen 1.3.5