1
- diff --git mlibc-clean/options/ansi/generic/time-stubs.cpp mlibc-workdir/options/ansi/generic/time-stubs.cpp
2
- index 887a7d3..7fd46bc 100644
3
- --- mlibc-clean/options/ansi/generic/time-stubs.cpp
4
- +++ mlibc-workdir/options/ansi/generic/time-stubs.cpp
5
- @@ -242,6 +242,7 @@ size_t strftime(char *__restrict dest, size_t max_size,
6
- c++;
7
- break;
8
- }
9
- + case 'l':
10
- case 'I': {
11
- int hour = tm->tm_hour;
12
- if(!hour)
13
- diff --git mlibc-clean/options/posix/generic/posix_stdlib.cpp mlibc-workdir/options/posix/generic/posix_stdlib.cpp
14
- index 7128e16..14e1dd7 100644
15
- --- mlibc-clean/options/posix/generic/posix_stdlib.cpp
16
- +++ mlibc-workdir/options/posix/generic/posix_stdlib.cpp
17
- @@ -139,23 +139,34 @@ char *setstate(char *state) {
18
- // ----------------------------------------------------------------------------
1
+ diff --git mlibc-clean/options/glibc/generic/execinfo.cpp mlibc-workdir/options/glibc/generic/execinfo.cpp
2
+ index 3474615..d06f130 100644
3
+ --- mlibc-clean/options/glibc/generic/execinfo.cpp
4
+ +++ mlibc-workdir/options/glibc/generic/execinfo.cpp
5
+ @@ -1,9 +1,10 @@
6
+ #include <execinfo.h>
7
+ #include <bits/ensure.h>
8
+ + #include <mlibc/charset.hpp>
19
9
20
- int mkostemp(char *pattern, int flags) {
21
- + return mkostemps(pattern, 0, flags);
22
- + }
23
- +
24
- + int mkstemp(char *path) {
25
- + return mkostemp(path, 0);
26
- + }
27
- +
28
- + int mkostemps(char *pattern, int suffixlen, int flags) {
29
- flags &= ~O_WRONLY;
30
- auto n = strlen(pattern);
31
- __ensure(n >= 6);
32
- - if(n < 6) {
33
- +
34
- + if(n < 6 || suffixlen > (n - 6)) {
35
- errno = EINVAL;
36
- return -1;
37
- }
38
- - for(size_t i = 0; i < 6; i++) {
39
- - if(pattern[n - 6 + i] == 'X')
40
- - continue;
41
- +
42
- + if (memcmp(pattern + (n - suffixlen - 6), "XXXXXX", 6)) {
43
- errno = EINVAL;
44
- return -1;
45
- }
46
-
47
- // TODO: Do an exponential search.
48
- for(size_t i = 0; i < 999999; i++) {
49
- - __ensure(sprintf(pattern + (n - 6), "%06zu", i) == 6);
50
- + int x = i;
51
- + for (int j = 0; j < 6; j++, x >>= 5) {
52
- + pattern[(n - suffixlen - 6) + j] = 'A' + (x & 15) + (x & 16) * 2;
53
- + }
54
- // mlibc::infoLogger() << "mlibc: mkstemp candidate is "
55
- // << (const char *)pattern << frg::endlog;
56
-
57
- @@ -172,16 +183,6 @@ int mkostemp(char *pattern, int flags) {
58
- return -1;
10
+ int backtrace(void **, int) {
11
+ - __ensure(!"Not implemented");
12
+ - __builtin_unreachable();
13
+ + mlibc::infoLogger() << "backtrace: Not implemented" << frg::endlog;
14
+ + return 0;
59
15
}
60
16
61
- - int mkstemp(char *path) {
62
- - return mkostemp(path, 0);
63
- - }
64
- -
65
- - int mkostemps(char *pattern, int suffixlen, int flags) {
66
- - (void)suffixlen;
67
- - mlibc::infoLogger() << "mlibc: mkostemps ignores suffixlen!" << frg::endlog;
68
- - return mkostemp(pattern, flags);
69
- - }
70
- -
71
- int mkstemps(char *pattern, int suffixlen) {
72
- return mkostemps(pattern, suffixlen, 0);
73
- }
74
- diff --git mlibc-workdir/sysdeps/aero/crt-x86_64/crti.S mlibc-workdir/sysdeps/aero/crt-x86_64/crti.S
75
- new file mode 100644
76
- index 0000000..f04679c
77
- --- /dev/null
78
- +++ mlibc-workdir/sysdeps/aero/crt-x86_64/crti.S
79
- @@ -0,0 +1,10 @@
80
- + .section .init
81
- + .global _init
82
- + _init:
83
- + push %rax
84
- +
85
- + .section .fini
86
- + .global _fini
87
- + _fini:
88
- + push %rax
89
- + .section .note.GNU-stack,"",%progbits
90
- diff --git mlibc-workdir/sysdeps/aero/crt-x86_64/crtn.S mlibc-workdir/sysdeps/aero/crt-x86_64/crtn.S
91
- new file mode 100644
92
- index 0000000..1b61d5a
93
- --- /dev/null
94
- +++ mlibc-workdir/sysdeps/aero/crt-x86_64/crtn.S
95
- @@ -0,0 +1,8 @@
96
- + .section .init
97
- + pop %rax
98
- + ret
99
- +
100
- + .section .fini
101
- + pop %rax
102
- + ret
103
- + .section .note.GNU-stack,"",%progbits
17
+ char **backtrace_symbols(void *const *, int) {
104
18
diff --git mlibc-clean/sysdeps/aero/generic/filesystem.cpp mlibc-workdir/sysdeps/aero/generic/filesystem.cpp
105
- index 33a11f4..987dc8e 100644
19
+ index b9a812b..95c49b9 100644
106
20
--- mlibc-clean/sysdeps/aero/generic/filesystem.cpp
107
21
+++ mlibc-workdir/sysdeps/aero/generic/filesystem.cpp
108
- @@ -89,44 +89,38 @@ int sys_close(int fd) {
22
+ @@ -89,23 +89,24 @@ int sys_close(int fd) {
109
23
return 0;
110
24
}
111
25
@@ -130,105 +44,49 @@ index 33a11f4..987dc8e 100644
130
44
+
131
45
int sys_stat(fsfd_target fsfdt, int fd, const char *path, int flags,
132
46
struct stat *statbuf) {
133
- - auto result = 0;
134
- -
135
47
switch (fsfdt) {
136
- - case fsfd_target::path: {
137
- - result = syscall(SYS_STAT, path, strlen(path), statbuf);
138
- + case fsfd_target::path:
139
- + fd = AT_FDCWD;
140
- break;
141
- - }
142
-
143
- - case fsfd_target::fd: {
144
- - result = syscall(SYS_FSTAT, fd, statbuf);
145
- + case fsfd_target::fd:
146
- + flags |= AT_EMPTY_PATH;
147
- +
148
- + case fsfd_target::fd_path:
48
+ case fsfd_target::path:
49
+ fd = AT_FDCWD;
149
50
break;
150
- - }
151
-
152
- - default: {
153
- - mlibc::infoLogger()
154
- - << "mlibc warning: sys_stat: unsupported fsfd target"
155
- - << frg::endlog;
156
- - return EINVAL;
157
- - }
158
- - }
159
- -
160
- - if (result < 0) {
161
- - return -result;
162
- + default:
163
- + __ensure(!"Invalid fsfd_target");
164
- + __builtin_unreachable();
165
- }
166
-
167
- + auto ret = syscall(SYS_FSTAT, fd, path, strlen(path), flags, statbuf);
168
- + if(int e = sc_error(ret); e)
169
- + return e;
170
- return 0;
171
- }
172
-
173
- @@ -212,6 +206,17 @@ int sys_unlinkat(int fd, const char *path, int flags) {
174
- return 0;
51
+ +
52
+ case fsfd_target::fd:
53
+ flags |= AT_EMPTY_PATH;
54
+
55
+ @@ -199,14 +200,14 @@ int sys_rmdir(const char *path) {
175
56
}
176
57
177
- + int sys_symlink(const char *target_path , const char *link_path ) {
178
- + return sys_symlinkat(target_path, AT_FDCWD, link_path );
179
- + }
180
- +
181
- + int sys_symlinkat(const char *target_path, int dirfd, const char *link_path) {
182
- + auto ret = syscall(SYS_SYMLINK_AT, dirfd, target_path , strlen(target_path ), link_path, strlen(link_path) );
58
+ int sys_unlinkat(int fd , const char *path, int flags ) {
59
+ - auto ret = syscall(SYS_UNLINK, fd, path, strlen(path), flags );
60
+ - if (int e = sc_error(ret); e)
61
+ - return e;
62
+ - return 0;
63
+ + auto ret = syscall(SYS_UNLINK, fd, path , strlen(path ), flags );
183
64
+ if (int e = sc_error(ret); e)
184
65
+ return e;
185
66
+ return 0;
186
- + }
187
- +
188
- struct aero_dir_entry {
189
- size_t inode;
190
- size_t offset;
191
- diff --git mlibc-clean/sysdeps/aero/include/aero/syscall.h mlibc-workdir/sysdeps/aero/include/aero/syscall.h
192
- index 39c5b65..49533cc 100644
193
- --- mlibc-clean/sysdeps/aero/include/aero/syscall.h
194
- +++ mlibc-workdir/sysdeps/aero/include/aero/syscall.h
195
- @@ -82,6 +82,10 @@
196
- #define SYS_SOCK_SHUTDOWN 75
197
- #define SYS_GETPEERNAME 76
198
- #define SYS_GETSOCKNAME 77
199
- + #define SYS_DEBUG 78
200
- + #define SYS_SETSOCKOPT 79
201
- + #define SYS_GETSOCKOPT 80
202
- + #define SYS_SYMLINK_AT 81
67
+ }
203
68
204
- // Invalid syscall used to trigger a log error in the kernel (as a hint)
205
- // so, that we can implement the syscall in the kernel.
206
- diff --git mlibc-clean/sysdeps/aero/meson.build mlibc-workdir/sysdeps/aero/meson.build
207
- index 9d10701..3d2a883 100644
208
- --- mlibc-clean/sysdeps/aero/meson.build
209
- +++ mlibc-workdir/sysdeps/aero/meson.build
210
- @@ -75,6 +75,24 @@ if not headers_only
211
- install: true,
212
- install_dir: get_option('libdir')
213
- )
214
- +
215
- + custom_target('crti',
216
- + build_by_default: true,
217
- + command: c_compiler.cmd_array() + ['-c', '-o', '@OUTPUT@', '@INPUT@'],
218
- + input: 'crt-x86_64/crti.S',
219
- + output: 'crti.o',
220
- + install: true,
221
- + install_dir: get_option('libdir')
222
- + )
223
- +
224
- + custom_target('crtn',
225
- + build_by_default: true,
226
- + command: c_compiler.cmd_array() + ['-c', '-o', '@OUTPUT@', '@INPUT@'],
227
- + input: 'crt-x86_64/crtn.S',
228
- + output: 'crtn.o',
229
- + install: true,
230
- + install_dir: get_option('libdir')
231
- + )
232
- endif
69
+ int sys_symlink(const char *target_path, const char *link_path) {
70
+ - return sys_symlinkat(target_path, AT_FDCWD, link_path);
71
+ + return sys_symlinkat(target_path, AT_FDCWD, link_path);
72
+ }
233
73
234
- if host_machine.cpu_family() == 'x86_64'
74
+ int sys_symlinkat(const char *target_path, int dirfd, const char *link_path) {
75
+ diff --git mlibc-clean/sysdeps/aero/include/abi-bits/fcntl.h mlibc-workdir/sysdeps/aero/include/abi-bits/fcntl.h
76
+ index ea5323a..463e2c9 120000
77
+ --- mlibc-clean/sysdeps/aero/include/abi-bits/fcntl.h
78
+ +++ mlibc-workdir/sysdeps/aero/include/abi-bits/fcntl.h
79
+ @@ -1 +1 @@
80
+ - ../../../../abis/mlibc/fcntl.h
81
+ \ No newline at end of file
82
+ + ../../../../abis/linux/fcntl.h
83
+ \ No newline at end of file
84
+ diff --git mlibc-clean/sysdeps/aero/include/abi-bits/stat.h mlibc-workdir/sysdeps/aero/include/abi-bits/stat.h
85
+ index 82642c3..1f63b41 120000
86
+ --- mlibc-clean/sysdeps/aero/include/abi-bits/stat.h
87
+ +++ mlibc-workdir/sysdeps/aero/include/abi-bits/stat.h
88
+ @@ -1 +1 @@
89
+ - ../../../../abis/mlibc/stat.h
90
+ \ No newline at end of file
91
+ + ../../../../abis/linux/stat.h
92
+ \ No newline at end of file
0 commit comments