summaryrefslogtreecommitdiff
path: root/lib/memset.c
blob: cb378ff07a0d5c14f386ea090bf55db2fb25f190 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
** @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