@@ -25,23 +25,6 @@ index fdd60a0..9f811f4 100644
25
25
.vscode
26
26
+ # clangd cache files:
27
27
+ .cache
28
- diff --git a/options/ansi/generic/stdlib-stubs.cpp b/options/ansi/generic/stdlib-stubs.cpp
29
- index c33dfba..ec8baa4 100644
30
- --- a/options/ansi/generic/stdlib-stubs.cpp
31
- +++ b/options/ansi/generic/stdlib-stubs.cpp
32
- @@ -396,8 +396,10 @@ int mbtowc(wchar_t *__restrict wc, const char *__restrict mb, size_t max_size) {
33
- mlibc::code_seq<wchar_t> wseq{wc, wc + 1};
34
- mlibc::code_seq<const char> nseq{mb, mb + max_size};
35
- auto e = cc->decode_wtranscode(nseq, wseq, mbtowc_state);
36
- - if (e != mlibc::charcode_error::null)
37
- - __ensure(!"decode_wtranscode() errors are not handled");
38
- + if (e != mlibc::charcode_error::null) {
39
- + errno = EILSEQ;
40
- + return -1;
41
- + }
42
-
43
- return nseq.it - mb;
44
- } else {
45
28
diff --git a/options/glibc/generic/execinfo.cpp b/options/glibc/generic/execinfo.cpp
46
29
index 3474615..10a2109 100644
47
30
--- a/options/glibc/generic/execinfo.cpp
@@ -71,196 +54,4 @@ index 003a162..ab01a7a 100644
71
54
+ constexpr bool logBaseAddresses = true;
72
55
constexpr bool logRpath = false;
73
56
constexpr bool eagerBinding = true;
74
-
75
- diff --git a/sysdeps/aero/generic/aero.cpp b/sysdeps/aero/generic/aero.cpp
76
- index 6eeb980..e6bd277 100644
77
- --- a/sysdeps/aero/generic/aero.cpp
78
- +++ b/sysdeps/aero/generic/aero.cpp
79
- @@ -176,13 +176,6 @@ int sys_kill(int pid, int sig) {
80
- return 0;
81
- }
82
-
83
- - int sys_getpgid(pid_t pid, pid_t *pgid) {
84
- - mlibc::infoLogger() << "sys_getpgid() is unimplemented" << frg::endlog;
85
- - *pgid = 0;
86
- -
87
- - return 0;
88
- - }
89
- -
90
- int sys_clock_get(int clock, time_t *secs, long *nanos) {
91
- struct timespec ts;
92
- auto result = syscall(SYS_GETTIME, clock, &ts);
93
- @@ -239,6 +232,21 @@ int sys_sleep(time_t *sec, long *nanosec) {
94
- return 0;
95
- }
96
-
97
- + pid_t sys_getpgid(pid_t pid, pid_t *pgid) {
98
- + auto ret = syscall(SYS_GETPGID, pid);
99
- + if(int e = sc_error(ret); e)
100
- + return e;
101
- + *pgid = ret;
102
- + return 0;
103
- + }
104
- +
105
- + int sys_setpgid(pid_t pid, pid_t pgid) {
106
- + auto ret = syscall(SYS_SETPGID, pid, pgid);
107
- + if(int e = sc_error(ret); e)
108
- + return e;
109
- + return 0;
110
- + }
111
- +
112
- uid_t sys_getuid() {
113
- mlibc::infoLogger() << "mlibc: sys_setuid is a stub" << frg::endlog;
114
- return 0;
115
- @@ -250,7 +258,10 @@ uid_t sys_geteuid() {
116
- }
117
-
118
- int sys_setsid(pid_t *sid) {
119
- - mlibc::infoLogger() << "mlibc: sys_setsid is a stub" << frg::endlog;
120
- + auto ret = syscall(SYS_SETSID);
121
- + if(int e = sc_error(ret); e)
122
- + return e;
123
- + *sid = ret;
124
- return 0;
125
- }
126
-
127
- diff --git a/sysdeps/aero/generic/filesystem.cpp b/sysdeps/aero/generic/filesystem.cpp
128
- index a2c483b..fa5a369 100644
129
- --- a/sysdeps/aero/generic/filesystem.cpp
130
- +++ b/sysdeps/aero/generic/filesystem.cpp
131
- @@ -155,14 +155,16 @@ int sys_tcgetattr(int fd, struct termios *attr) {
132
- }
133
-
134
- int sys_tcsetattr(int fd, int optional_action, const struct termios *attr) {
135
- - if (optional_action)
136
- - mlibc::infoLogger()
137
- - << "mlibc: warning: sys_tcsetattr ignores optional_action"
138
- - << frg::endlog;
139
- + int req;
140
-
141
- - int result;
142
- + switch (optional_action) {
143
- + case TCSANOW: req = TCSETS; break;
144
- + case TCSADRAIN: req = TCSETSW; break;
145
- + case TCSAFLUSH: req = TCSETSF; break;
146
- + default: return EINVAL;
147
- + }
148
-
149
- - if (int e = sys_ioctl(fd, TCSETSF, (void *)attr, &result); e)
150
- + if (int e = sys_ioctl(fd, req, (void *)attr, NULL); e)
151
- return e;
152
-
153
- return 0;
154
- @@ -178,9 +180,7 @@ int sys_mkdir(const char *path, mode_t) {
155
- return 0;
156
- }
157
-
158
- - int sys_rmdir(const char *path) UNIMPLEMENTED("sys_rmdir")
159
- -
160
- - int sys_link(const char *srcpath, const char *destpath) {
161
- + int sys_link(const char *srcpath, const char *destpath) {
162
- auto result =
163
- syscall(SYS_LINK, srcpath, strlen(srcpath), destpath, strlen(destpath));
164
-
165
- @@ -191,14 +191,15 @@ int sys_rmdir(const char *path) UNIMPLEMENTED("sys_rmdir")
166
- return 0;
167
- }
168
-
169
- - int sys_unlinkat(int fd, const char *path, int flags) {
170
- - auto result = syscall(SYS_UNLINK, fd, path, strlen(path), flags);
171
- -
172
- - if (result < 0) {
173
- - return -result;
174
- - }
175
- + int sys_rmdir(const char *path) {
176
- + return sys_unlinkat(AT_FDCWD, path, AT_REMOVEDIR);
177
- + }
178
-
179
- - return 0;
180
- + int sys_unlinkat(int fd, const char *path, int flags) {
181
- + auto ret = syscall(SYS_UNLINK, fd, path, strlen(path), flags);
182
- + if (int e = sc_error(ret); e)
183
- + return e;
184
- + return 0;
185
- }
186
-
187
- struct aero_dir_entry {
188
- diff --git a/sysdeps/aero/generic/sockets.cpp b/sysdeps/aero/generic/sockets.cpp
189
- index 4db9956..4cb3ee8 100644
190
- --- a/sysdeps/aero/generic/sockets.cpp
191
- +++ b/sysdeps/aero/generic/sockets.cpp
192
- @@ -5,7 +5,11 @@
193
- #include <abi-bits/errno.h>
194
-
195
- #include <aero/syscall.h>
196
- +
197
- + #include <unistd.h>
198
- #include <stdint.h>
199
- + #include <net/if.h>
200
- + #include <sys/ioctl.h>
201
-
202
- namespace {
203
-
204
- @@ -210,10 +214,31 @@ int sys_setsockopt(int fd, int layer, int number, const void *buffer,
205
- << frg::endlog;
206
- return 0;
207
- } else {
208
- - mlibc::panicLogger()
209
- + mlibc::infoLogger()
210
- << "\e[31mmlibc: Unexpected setsockopt() call, layer: " << layer
211
- << " number: " << number << "\e[39m" << frg::endlog;
212
- - __builtin_unreachable();
213
- + return 0;
214
- }
215
- }
216
- +
217
- + int sys_if_nametoindex(const char *name, unsigned int *ret) {
218
- + int fd = 0;
219
- +
220
- + // TODO(andypython): is the SOCK_CLOEXEC flag required in this case?
221
- + int r = sys_socket(AF_INET, SOCK_DGRAM, AF_UNSPEC, &fd);
222
- + if (r)
223
- + return r;
224
- +
225
- + struct ifreq ifr;
226
- + strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name);
227
- +
228
- + r = sys_ioctl(fd, SIOCGIFINDEX, &ifr, NULL);
229
- + close(fd);
230
- +
231
- + if (r)
232
- + return r;
233
- +
234
- + *ret = ifr.ifr_ifindex;
235
- + return 0;
236
- + }
237
- } // namespace mlibc
238
- diff --git a/sysdeps/aero/include/aero/syscall.h b/sysdeps/aero/include/aero/syscall.h
239
- index aa642e5..d8bf99e 100644
240
- --- a/sysdeps/aero/include/aero/syscall.h
241
- +++ b/sysdeps/aero/include/aero/syscall.h
242
- @@ -75,6 +75,10 @@
243
- #define SYS_RENAME 68
244
- #define SYS_MPROTECT 69
245
- #define SYS_SOCK_SEND 70
246
- + #define SYS_TRACE 71
247
- + #define SYS_SETPGID 72
248
- + #define SYS_SETSID 73
249
- + #define SYS_GETPGID 74
250
-
251
- // Invalid syscall used to trigger a log error in the kernel (as a hint)
252
- // so, that we can implement the syscall in the kernel.
253
- @@ -217,4 +221,10 @@ __attribute__((__always_inline__)) static inline long syscall(sc_word_t call,
254
- T... args) {
255
- return _syscall(call, sc_cast(args)...);
256
- }
257
- +
258
- + inline int sc_error(long ret) {
259
- + if (ret < 0)
260
- + return -ret;
261
- + return 0;
262
- + }
263
- #endif // SYSCALL_H
264
- - -
265
- 2.40.1
266
57
0 commit comments