summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibSystem/syscall.h
blob: ac9f38cb55d8572dfa148afee14c08fbb6b58857 (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
40
41
42
/*
 * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <Kernel/API/Syscall.h>
#include <sys/types.h>

extern "C" {

uintptr_t syscall0(uintptr_t function);
uintptr_t syscall1(uintptr_t function, uintptr_t arg0);
uintptr_t syscall2(uintptr_t function, uintptr_t arg0, uintptr_t arg1);
uintptr_t syscall3(uintptr_t function, uintptr_t arg0, uintptr_t arg1, uintptr_t arg2);
}

#ifdef __cplusplus

inline uintptr_t syscall(auto function)
{
    return syscall0(function);
}

inline uintptr_t syscall(auto function, auto arg0)
{
    return syscall1((uintptr_t)function, (uintptr_t)arg0);
}

inline uintptr_t syscall(auto function, auto arg0, auto arg1)
{
    return syscall2((uintptr_t)function, (uintptr_t)arg0, (uintptr_t)arg1);
}

inline uintptr_t syscall(auto function, auto arg0, auto arg1, auto arg2)
{
    return syscall3((uintptr_t)function, (uintptr_t)arg0, (uintptr_t)arg1, (uintptr_t)arg2);
}

#endif