summaryrefslogtreecommitdiff
path: root/lib/memset.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/memset.c')
-rw-r--r--lib/memset.c38
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