summaryrefslogtreecommitdiff
path: root/base.c
blob: 8d095be4d9954654f8a71d666338753ae4510551 (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
#include <unistd.h>
#include <stdbool.h>

int __errno = 0;
void *_impure_ptr = NULL;

void __sinit(void) {
}

void *memset(void *s, int c, size_t n) {
    char *end = (char *)s + n;
    for (char *p = (char *)s; p < end; p++)
        *p = (char)c;
    return s;
}

void *memcpy(void *dest, const void *src, size_t n) {
    uint8_t *out = (uint8_t *)dest;
    const uint8_t *in = (const uint8_t *)src;

    while (n--)
        *out++ = *in++;

    return dest;
}

size_t strlen(const char *s) {
    const char *start = s;
    while (*s++);
    return s - start - 1;
}

void __assert_func(bool value) {
}