diff options
author | Freya Murphy <freya@freyacat.org> | 2025-03-25 17:36:52 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-03-25 17:38:22 -0400 |
commit | 6af21e6a4f2251e71353562d5df7f376fdffc270 (patch) | |
tree | de20c7afc9878422c81e34f30c6b010075e9e69a /lib/memset.c | |
download | comus-6af21e6a4f2251e71353562d5df7f376fdffc270.tar.gz comus-6af21e6a4f2251e71353562d5df7f376fdffc270.tar.bz2 comus-6af21e6a4f2251e71353562d5df7f376fdffc270.zip |
initial checkout from wrc
Diffstat (limited to 'lib/memset.c')
-rw-r--r-- | lib/memset.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/memset.c b/lib/memset.c new file mode 100644 index 0000000..a93815c --- /dev/null +++ b/lib/memset.c @@ -0,0 +1,38 @@ +/** +** @file memset.c +** +** @author Numerous CSCI-452 classes +** +** @brief C implementations of common library functions +*/ + +#ifndef MEMSET_SRC_INC +#define MEMSET_SRC_INC + +#include <common.h> + +#include <lib.h> + +/** +** memset(buf,len,value) +** +** initialize all bytes of a block of memory to a specific value +** +** @param buf The buffer to initialize +** @param len Buffer size (in bytes) +** @param value Initialization value +*/ +void memset( void *buf, register uint32_t len, register uint32_t value ) { + register uint8_t *bp = buf; + + /* + ** We could speed this up by unrolling it and copying + ** words at a time (instead of bytes). + */ + + while( len-- ) { + *bp++ = value; + } +} + +#endif |