aboutsummaryrefslogtreecommitdiff
path: root/lib/src/common.c
blob: 2d122f533f66cb77e8886b39280734ad86d0329d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Copyright (c) 2021 Johannes Stoelp

#include <common.h>

#if !defined(__linux__) || !defined(__x86_64__)
#    error "Only supported on linux(x86_64)!"
#endif

void* memset(void* s, int c, size_t n) {
    asm volatile(
        "cld"
        "\n"
        "rep stosb"
        : "+D"(s), "+c"(n)
        : "a"(c)
        : "memory");
    return s;
}