summaryrefslogtreecommitdiff
path: root/src/stem/lib/stdlib.c
blob: 904126efe42365591b46fe8a73309e6bddaf6a37 (plain) (blame)
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
#include "stdlib.h"

void *memcpy(void *dest, const void *src, int count) {
	int i;
	uint8_t *d = (uint8_t*)dest, *s = (uint8_t*)src;
	for (i = 0; i < count; i++) {
		d[i] = s[i];
	}
	return dest;
}

uint8_t *memset(uint8_t *dest, uint8_t val, int count) {
	int i;
	for (i = 0; i < count; i++) {
		dest[i] = val;
	}
}

uint16_t *memsetw(uint16_t *dest, uint16_t val, int count) {
	int i;
	for (i = 0; i < count; i++) {
		dest[i] = val;
	}
	return dest;
}

int strlen(const char *str) {
	int i = 0;
	while (str[i++]);
	return i;
}