Skip to content

Commit 1d57d88

Browse files
mlibc: clang format :^)
Signed-off-by: Andy-Python-Programmer <[email protected]>
1 parent 4b716ef commit 1d57d88

File tree

1 file changed

+83
-81
lines changed

1 file changed

+83
-81
lines changed

patches/mlibc/mlibc.patch

Lines changed: 83 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
From 791ffe535a74e6df0809459c5283ac80c46d0d6c Mon Sep 17 00:00:00 2001
1+
From ef88dca94b8e13b78bdd0dc71df8b6062009c6f0 Mon Sep 17 00:00:00 2001
22
From: unknown <[email protected]>
33
Date: Sun, 6 Jun 2021 16:37:54 +1000
44
Subject: [PATCH] targets: add aero target port
55

66
Signed-off-by: Andy-Python-Programmer <[email protected]>
77
---
8-
.gitignore | 6 +
8+
.gitignore | 7 +
99
abis/aero/auxv.h | 13 +
1010
meson.build | 4 +
1111
options/ansi/generic/stdlib-stubs.cpp | 3 +
@@ -46,12 +46,12 @@ Signed-off-by: Andy-Python-Programmer <[email protected]>
4646
sysdeps/aero/include/abi-bits/uid_t.h | 1 +
4747
sysdeps/aero/include/abi-bits/vm-flags.h | 1 +
4848
sysdeps/aero/include/abi-bits/wait.h | 1 +
49-
sysdeps/aero/include/aero/syscall.h | 192 ++++++++++++++
49+
sysdeps/aero/include/aero/syscall.h | 194 ++++++++++++++
5050
sysdeps/aero/include/mlibc/thread-entry.hpp | 10 +
5151
sysdeps/aero/meson.build | 67 +++++
5252
sysdeps/dripos/generic/generic.cpp | 3 +
5353
sysdeps/lemon/generic/signals.S | 7 +
54-
46 files changed, 1022 insertions(+), 11 deletions(-)
54+
46 files changed, 1025 insertions(+), 11 deletions(-)
5555
create mode 100644 abis/aero/auxv.h
5656
create mode 100644 sysdeps/aero/crt-x86_64/crt0.S
5757
create mode 100644 sysdeps/aero/generic/aero.cc
@@ -93,10 +93,10 @@ Signed-off-by: Andy-Python-Programmer <[email protected]>
9393
create mode 100644 sysdeps/lemon/generic/signals.S
9494

9595
diff --git a/.gitignore b/.gitignore
96-
index 1701c90..6e0116b 100644
96+
index 1701c90..dbb35e8 100644
9797
--- a/.gitignore
9898
+++ b/.gitignore
99-
@@ -1,3 +1,9 @@
99+
@@ -1,3 +1,10 @@
100100
build
101101
+
102102
+# the menson vsocde extension auto generates another build directory
@@ -106,7 +106,7 @@ index 1701c90..6e0116b 100644
106106
subprojects/cxxshim
107107
subprojects/frigg
108108
+.vscode
109-
\ No newline at end of file
109+
+.clang-format
110110
diff --git a/abis/aero/auxv.h b/abis/aero/auxv.h
111111
new file mode 100644
112112
index 0000000..59d4d4d
@@ -1170,10 +1170,10 @@ index 0000000..6d911c7
11701170
\ No newline at end of file
11711171
diff --git a/sysdeps/aero/include/aero/syscall.h b/sysdeps/aero/include/aero/syscall.h
11721172
new file mode 100644
1173-
index 0000000..d3fe862
1173+
index 0000000..ef9f036
11741174
--- /dev/null
11751175
+++ b/sysdeps/aero/include/aero/syscall.h
1176-
@@ -0,0 +1,192 @@
1176+
@@ -0,0 +1,194 @@
11771177
+#ifndef SYSCALL_H
11781178
+#define SYSCALL_H
11791179
+
@@ -1229,141 +1229,143 @@ index 0000000..d3fe862
12291229
+// Invalid syscall used to trigger a log error in the kernel (as a hint)
12301230
+// so, that we can implement the syscall in the kernel.
12311231
+#define UNIMPLEMENTED(FUNCTION_NAME) \
1232-
+ { \
1233-
+ syscall(314, FUNCTION_NAME, strlen(FUNCTION_NAME)); \
1234-
+ __ensure(!"UNIMPLEMENTED function was called"); \
1235-
+ __builtin_unreachable(); \
1236-
+ }
1232+
+ { \
1233+
+ sys_libc_log("Unimplemented syscall: " FUNCTION_NAME); \
1234+
+ sys_exit(1); \
1235+
+ __builtin_unreachable(); \
1236+
+ }
12371237
+
12381238
+extern "C" {
12391239
+using sc_word_t = long;
12401240
+
12411241
+static sc_word_t syscall0(int sc) {
1242-
+ sc_word_t ret;
1243-
+ asm volatile("syscall" : "=a"(ret) : "a"(sc) : "rcx", "r11", "memory");
1244-
+ return ret;
1242+
+ sc_word_t ret;
1243+
+ asm volatile("syscall" : "=a"(ret) : "a"(sc) : "rcx", "r11", "memory");
1244+
+ return ret;
12451245
+}
12461246
+
12471247
+static sc_word_t syscall1(int sc, sc_word_t arg1) {
1248-
+ sc_word_t ret;
1249-
+ asm volatile("syscall"
1250-
+ : "=a"(ret)
1251-
+ : "a"(sc), "D"(arg1)
1252-
+ : "rcx", "r11", "memory");
1253-
+ return ret;
1248+
+ sc_word_t ret;
1249+
+ asm volatile("syscall"
1250+
+ : "=a"(ret)
1251+
+ : "a"(sc), "D"(arg1)
1252+
+ : "rcx", "r11", "memory");
1253+
+ return ret;
12541254
+}
12551255
+
12561256
+static sc_word_t syscall2(int sc, sc_word_t arg1, sc_word_t arg2) {
1257-
+ sc_word_t ret;
1258-
+ asm volatile("syscall"
1259-
+ : "=a"(ret)
1260-
+ : "a"(sc), "D"(arg1), "S"(arg2)
1261-
+ : "rcx", "r11", "memory");
1262-
+ return ret;
1257+
+ sc_word_t ret;
1258+
+ asm volatile("syscall"
1259+
+ : "=a"(ret)
1260+
+ : "a"(sc), "D"(arg1), "S"(arg2)
1261+
+ : "rcx", "r11", "memory");
1262+
+ return ret;
12631263
+}
12641264
+
12651265
+static sc_word_t syscall3(int sc, sc_word_t arg1, sc_word_t arg2,
1266-
+ sc_word_t arg3) {
1267-
+ sc_word_t ret;
1268-
+ asm volatile("syscall"
1269-
+ : "=a"(ret)
1270-
+ : "a"(sc), "D"(arg1), "S"(arg2), "d"(arg3)
1271-
+ : "rcx", "r11", "memory");
1272-
+ return ret;
1266+
+ sc_word_t arg3) {
1267+
+ sc_word_t ret;
1268+
+ asm volatile("syscall"
1269+
+ : "=a"(ret)
1270+
+ : "a"(sc), "D"(arg1), "S"(arg2), "d"(arg3)
1271+
+ : "rcx", "r11", "memory");
1272+
+ return ret;
12731273
+}
12741274
+
12751275
+static sc_word_t syscall4(int sc, sc_word_t arg1, sc_word_t arg2,
1276-
+ sc_word_t arg3, sc_word_t arg4) {
1277-
+ sc_word_t ret;
1276+
+ sc_word_t arg3, sc_word_t arg4) {
1277+
+ sc_word_t ret;
12781278
+
1279-
+ register sc_word_t arg4_reg asm("r10") = arg4;
1279+
+ register sc_word_t arg4_reg asm("r10") = arg4;
12801280
+
1281-
+ asm volatile("syscall"
1282-
+ : "=a"(ret)
1283-
+ : "a"(sc), "D"(arg1), "S"(arg2), "d"(arg3), "r"(arg4_reg)
1284-
+ : "rcx", "r11", "memory");
1285-
+ return ret;
1281+
+ asm volatile("syscall"
1282+
+ : "=a"(ret)
1283+
+ : "a"(sc), "D"(arg1), "S"(arg2), "d"(arg3), "r"(arg4_reg)
1284+
+ : "rcx", "r11", "memory");
1285+
+ return ret;
12861286
+}
12871287
+
12881288
+static sc_word_t syscall5(int sc, sc_word_t arg1, sc_word_t arg2,
1289-
+ sc_word_t arg3, sc_word_t arg4, sc_word_t arg5) {
1290-
+ sc_word_t ret;
1289+
+ sc_word_t arg3, sc_word_t arg4, sc_word_t arg5) {
1290+
+ sc_word_t ret;
12911291
+
1292-
+ register sc_word_t arg4_reg asm("r10") = arg4;
1293-
+ register sc_word_t arg5_reg asm("r8") = arg5;
1292+
+ register sc_word_t arg4_reg asm("r10") = arg4;
1293+
+ register sc_word_t arg5_reg asm("r8") = arg5;
12941294
+
1295-
+ asm volatile("syscall"
1296-
+ : "=a"(ret)
1297-
+ : "a"(sc), "D"(arg1), "S"(arg2), "d"(arg3), "r"(arg4_reg),
1298-
+ "r"(arg5_reg)
1299-
+ : "rcx", "r11", "memory");
1300-
+ return ret;
1295+
+ asm volatile("syscall"
1296+
+ : "=a"(ret)
1297+
+ : "a"(sc), "D"(arg1), "S"(arg2), "d"(arg3), "r"(arg4_reg),
1298+
+ "r"(arg5_reg)
1299+
+ : "rcx", "r11", "memory");
1300+
+ return ret;
13011301
+}
13021302
+
13031303
+static sc_word_t syscall6(int sc, sc_word_t arg1, sc_word_t arg2,
1304-
+ sc_word_t arg3, sc_word_t arg4, sc_word_t arg5,
1305-
+ sc_word_t arg6) {
1306-
+ sc_word_t ret;
1304+
+ sc_word_t arg3, sc_word_t arg4, sc_word_t arg5,
1305+
+ sc_word_t arg6) {
1306+
+ sc_word_t ret;
13071307
+
1308-
+ register sc_word_t arg4_reg asm("r10") = arg4;
1309-
+ register sc_word_t arg5_reg asm("r8") = arg5;
1310-
+ register sc_word_t arg6_reg asm("r9") = arg6;
1308+
+ register sc_word_t arg4_reg asm("r10") = arg4;
1309+
+ register sc_word_t arg5_reg asm("r8") = arg5;
1310+
+ register sc_word_t arg6_reg asm("r9") = arg6;
13111311
+
1312-
+ asm volatile("syscall"
1313-
+ : "=a"(ret)
1314-
+ : "a"(sc), "D"(arg1), "S"(arg2), "d"(arg3), "r"(arg4_reg),
1315-
+ "r"(arg5_reg), "r"(arg6_reg)
1316-
+ : "rcx", "r11", "memory");
1317-
+ return ret;
1312+
+ asm volatile("syscall"
1313+
+ : "=a"(ret)
1314+
+ : "a"(sc), "D"(arg1), "S"(arg2), "d"(arg3), "r"(arg4_reg),
1315+
+ "r"(arg5_reg), "r"(arg6_reg)
1316+
+ : "rcx", "r11", "memory");
1317+
+ return ret;
13181318
+}
13191319
+} // extern "C"
13201320
+
13211321
+// Cast to the argument type of the extern "C" functions.
13221322
+__attribute__((always_inline)) inline sc_word_t sc_cast(long x) { return x; }
1323-
+__attribute__((always_inline)) inline sc_word_t sc_cast(const void *x) { return reinterpret_cast<sc_word_t>(x); }
1323+
+__attribute__((always_inline)) inline sc_word_t sc_cast(const void *x) {
1324+
+ return reinterpret_cast<sc_word_t>(x);
1325+
+}
13241326
+
13251327
+// C++ wrappers for the extern "C" functions.
13261328
+__attribute__((always_inline)) static inline long _syscall(int call) {
1327-
+ return syscall0(call);
1329+
+ return syscall0(call);
13281330
+}
13291331
+
1330-
+__attribute__((always_inline))
1331-
+static inline long _syscall(int call, sc_word_t arg0) {
1332-
+ return syscall1(call, arg0);
1332+
+__attribute__((always_inline)) static inline long _syscall(int call,
1333+
+ sc_word_t arg0) {
1334+
+ return syscall1(call, arg0);
13331335
+}
13341336
+
13351337
+__attribute__((always_inline)) static inline long
13361338
+_syscall(int call, sc_word_t arg0, sc_word_t arg1) {
1337-
+ return syscall2(call, arg0, arg1);
1339+
+ return syscall2(call, arg0, arg1);
13381340
+}
13391341
+
13401342
+__attribute__((always_inline)) static inline long
13411343
+_syscall(int call, sc_word_t arg0, sc_word_t arg1, sc_word_t arg2) {
1342-
+ return syscall3(call, arg0, arg1, arg2);
1344+
+ return syscall3(call, arg0, arg1, arg2);
13431345
+}
13441346
+
13451347
+__attribute__((always_inline)) static inline long
13461348
+_syscall(int call, sc_word_t arg0, sc_word_t arg1, sc_word_t arg2,
1347-
+ sc_word_t arg3) {
1348-
+ return syscall4(call, arg0, arg1, arg2, arg3);
1349+
+ sc_word_t arg3) {
1350+
+ return syscall4(call, arg0, arg1, arg2, arg3);
13491351
+}
13501352
+
13511353
+__attribute__((always_inline)) static inline long
13521354
+_syscall(int call, sc_word_t arg0, sc_word_t arg1, sc_word_t arg2,
1353-
+ sc_word_t arg3, sc_word_t arg4) {
1354-
+ return syscall5(call, arg0, arg1, arg2, arg3, arg4);
1355+
+ sc_word_t arg3, sc_word_t arg4) {
1356+
+ return syscall5(call, arg0, arg1, arg2, arg3, arg4);
13551357
+}
13561358
+
13571359
+__attribute__((always_inline)) static inline long
13581360
+_syscall(int call, sc_word_t arg0, sc_word_t arg1, sc_word_t arg2,
1359-
+ sc_word_t arg3, sc_word_t arg4, sc_word_t arg5) {
1360-
+ return syscall6(call, arg0, arg1, arg2, arg3, arg4, arg5);
1361+
+ sc_word_t arg3, sc_word_t arg4, sc_word_t arg5) {
1362+
+ return syscall6(call, arg0, arg1, arg2, arg3, arg4, arg5);
13611363
+}
13621364
+
13631365
+template <typename... T>
13641366
+__attribute__((always_inline)) static inline long syscall(sc_word_t call,
1365-
+ T... args) {
1366-
+ return _syscall(call, sc_cast(args)...);
1367+
+ T... args) {
1368+
+ return _syscall(call, sc_cast(args)...);
13671369
+}
13681370
+#endif // SYSCALL_H
13691371
diff --git a/sysdeps/aero/include/mlibc/thread-entry.hpp b/sysdeps/aero/include/mlibc/thread-entry.hpp

0 commit comments

Comments
 (0)