The Pedigree Project 0.1
translate.h
1/*
2 * Copyright (c) 2008-2014, Pedigree Developers
3 *
4 * Please see the CONTRIB file in the root of the source tree for a full
5 * list of contributors.
6 *
7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */
19
20#ifndef _POSIX_SYSCALLS_TRANSLATE_H
21#define _POSIX_SYSCALLS_TRANSLATE_H
22
23#include <posixSyscallNumbers.h>
24
25enum PedigreeLinuxAmd64SyscallNumber {
26#define PEDIGREE_LINUX_AMD64_SYSCALL(name, number, target) \
27 PedigreeLinuxAmd64Syscall_##name = number,
28#include "linuxSyscallMappings-amd64.h"
29#undef PEDIGREE_LINUX_AMD64_SYSCALL
30};
31
32#if ARM64
33enum PedigreeLinuxArm64SyscallNumber {
34#define PEDIGREE_LINUX_ARM64_SYSCALL(name, number, target) \
35 PedigreeLinuxArm64Syscall_##name = number,
36#include "linuxSyscallMappings-arm64.h"
37#undef PEDIGREE_LINUX_ARM64_SYSCALL
38};
39#elif ARMV7
40enum PedigreeLinuxArmv7SyscallNumber {
41#define PEDIGREE_LINUX_ARMV7_SYSCALL(name, number, target) \
42 PedigreeLinuxArmv7Syscall_##name = number,
43#include "linuxSyscallMappings-armv7.h"
44#undef PEDIGREE_LINUX_ARMV7_SYSCALL
45};
46#endif
47
48static inline long posix_translate_syscall(long which) {
49 switch (which) {
50#if ARM64
51#define PEDIGREE_LINUX_ARM64_SYSCALL(name, number, target) \
52 case PedigreeLinuxArm64Syscall_##name: \
53 return target;
54#include "linuxSyscallMappings-arm64.h"
55#undef PEDIGREE_LINUX_ARM64_SYSCALL
56#elif ARMV7
57#define PEDIGREE_LINUX_ARMV7_SYSCALL(name, number, target) \
58 case PedigreeLinuxArmv7Syscall_##name: \
59 return target;
60#include "linuxSyscallMappings-armv7.h"
61#undef PEDIGREE_LINUX_ARMV7_SYSCALL
62#else
63#define PEDIGREE_LINUX_AMD64_SYSCALL(name, number, target) \
64 case PedigreeLinuxAmd64Syscall_##name: \
65 return target;
66#include "linuxSyscallMappings-amd64.h"
67#undef PEDIGREE_LINUX_AMD64_SYSCALL
68#endif
69 }
70 return -1;
71}
72
73#endif // _POSIX_SYSCALLS_TRANSLATE_H