Skip to content

Commit 1f13576

Browse files
ports(mlibc): bump
WARNING: ABI-BREAK The whole sysroot is required to be recompiled. Run `make deep-clean` and `make distro-image`. Signed-off-by: Anhad Singh <[email protected]>
1 parent d2dc8c0 commit 1f13576

File tree

8 files changed

+147
-254
lines changed

8 files changed

+147
-254
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ USERLAND_TARGET := builds/userland/target/init
2828
clean:
2929
rm -rf $(SOURCE_DIR)/target
3030

31+
.PHONY: deep-clean
32+
deep-clean: clean
33+
rm -rf target sysroot sources pkgs host-pkgs host-builds builds
34+
3135
.PHONY: check
3236
check:
3337
cd $(SOURCE_DIR) && cargo check
Lines changed: 53 additions & 195 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,25 @@
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>
199

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;
5915
}
6016

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) {
10418
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
10620
--- mlibc-clean/sysdeps/aero/generic/filesystem.cpp
10721
+++ 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) {
10923
return 0;
11024
}
11125

@@ -130,105 +44,49 @@ index 33a11f4..987dc8e 100644
13044
+
13145
int sys_stat(fsfd_target fsfdt, int fd, const char *path, int flags,
13246
struct stat *statbuf) {
133-
- auto result = 0;
134-
-
13547
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;
14950
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) {
17556
}
17657

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);
18364
+ if (int e = sc_error(ret); e)
18465
+ return e;
18566
+ 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+
}
20368

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+
}
23373

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

recipes/mlibc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name=mlibc
2-
version=0dd4dbdd377dc776e6f7d698281ac6781d652922
2+
version=882fdd99b503ee1b567ccacb75cf4d7b7c9395e1
33
revision=1
4-
tarball_url="https://github.com/aero-os/mlibc/archive/${version}.tar.gz"
5-
tarball_blake2b="a4886c2d6a85c781293db9139c0773469c3877e5db2a76f1a735e2cc04ee78fef5b8fc1693b724f9fc8879322464ddf48eac8c018ebfd4f8aa983141013d64e3"
4+
tarball_url="https://github.com/Andy-Python-Programmer/mlibc/archive/${version}.tar.gz"
5+
tarball_blake2b="3dcb34f3e2e2d8b1cbdd5d87e722fe03b23d9f460affd82ea888bcd6dabe96a475a2153f477360b78efcad421f83c534e308e6057c319c78c3bc666a03dbd6a7"
66
imagedeps="meson ninja"
77
hostdeps="gcc pkg-config libgcc-binaries"
88
builddeps="cxxshim frigg linux-headers"

src/aero_kernel/src/syscall/process.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ pub fn sigaction(
330330
};
331331

332332
let entry = if let Some(new) = new {
333-
Some(SignalEntry::from_sigaction(*new, sigreturn)?)
333+
Some(SignalEntry::from_sigaction(&*new, sigreturn)?)
334334
} else {
335335
None
336336
};

src/aero_kernel/src/userland/signals.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ pub struct SignalEntry {
147147
impl SignalEntry {
148148
/// Create a new `SignalEntry` with the provided `sigaction` and `sigreturn`.
149149
pub fn from_sigaction(
150-
sigaction: SigAction,
150+
sigaction: &SigAction,
151151
sigreturn: usize,
152152
) -> Result<SignalEntry, SyscallError> {
153153
Ok(SignalEntry {

src/aero_syscall/src/consts.rs

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,41 @@ pub const SYS_GETSOCKOPT: usize = 80;
104104
pub const SYS_SYMLINK_AT: usize = 81;
105105

106106
// constants for fcntl()'s command argument:
107-
pub const F_DUPFD: usize = 1;
108-
pub const F_DUPFD_CLOEXEC: usize = 2;
109-
pub const F_GETFD: usize = 3;
110-
pub const F_SETFD: usize = 4;
111-
pub const F_GETFL: usize = 5;
112-
pub const F_SETFL: usize = 6;
113-
pub const F_GETLK: usize = 7;
114-
pub const F_SETLK: usize = 8;
115-
pub const F_SETLKW: usize = 9;
116-
pub const F_GETOWN: usize = 10;
117-
pub const F_SETOWN: usize = 11;
107+
// mlibc/abis/linux/fcntl.h
108+
pub const F_DUPFD: usize = 0;
109+
pub const F_GETFD: usize = 1;
110+
pub const F_SETFD: usize = 2;
111+
pub const F_GETFL: usize = 3;
112+
pub const F_SETFL: usize = 4;
113+
114+
pub const F_SETOWN: usize = 8;
115+
pub const F_GETOWN: usize = 9;
116+
pub const F_SETSIG: usize = 10;
117+
pub const F_GETSIG: usize = 11;
118+
119+
pub const F_GETLK: usize = 5;
120+
pub const F_SETLK: usize = 6;
121+
pub const F_SETLKW: usize = 7;
122+
123+
pub const F_SETOWN_EX: usize = 15;
124+
pub const F_GETOWN_EX: usize = 16;
125+
126+
pub const F_GETOWNER_UIDS: usize = 17;
127+
128+
pub const F_DUPFD_CLOEXEC: usize = 1030;
129+
pub const F_ADD_SEALS: usize = 1033;
130+
pub const F_GET_SEALS: usize = 1034;
131+
132+
pub const F_SEAL_SEAL: usize = 0x0001;
133+
pub const F_SEAL_SHRINK: usize = 0x0002;
134+
pub const F_SEAL_GROW: usize = 0x0004;
135+
pub const F_SEAL_WRITE: usize = 0x0008;
136+
137+
pub const F_RDLCK: usize = 0;
138+
pub const F_WRLCK: usize = 1;
139+
pub const F_UNLCK: usize = 2;
140+
141+
pub const FD_CLOEXEC: usize = 1;
118142

119143
// constants for fcntl()'s additional argument of F_GETFD and F_SETFD:
120144
bitflags::bitflags! {

0 commit comments

Comments
 (0)