From c63e0369ae36578de94c3fb416d880c8aa8c74dd Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 29 Sep 2023 19:23:04 +1000 Subject: [PATCH 001/112] fix(kernel): fix panic handler function signature The panic handler needs to be an extern "Rust" function not a extern "C" function. This commit fixes that by making the panic handler a normal function. Signed-off-by: Anhad Singh --- src/aero_kernel/src/unwind.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aero_kernel/src/unwind.rs b/src/aero_kernel/src/unwind.rs index a6d59abc1a7..855caa37268 100644 --- a/src/aero_kernel/src/unwind.rs +++ b/src/aero_kernel/src/unwind.rs @@ -160,7 +160,7 @@ use crate::emu; use crate::utils::sync::IrqGuard; #[panic_handler] -extern "C" fn rust_begin_unwind(info: &PanicInfo) -> ! { +fn rust_begin_unwind(info: &PanicInfo) -> ! { prepare_panic(); let default_panic = &format_args!(""); From f7cd1a06957418bce8f35364e42d01d27658f5f7 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 29 Sep 2023 20:02:35 +1000 Subject: [PATCH 002/112] feat(kernel): bump `crabnet` and `crabnet_tcp` * Bump `crabnet` and `crabnet_tcp` * No longer ignore the TCP options and pass them to `on_packet` on the respective TCP socket. Signed-off-by: Anhad Singh --- src/Cargo.lock | 4 ++-- src/aero_kernel/Cargo.toml | 2 ++ src/aero_kernel/src/net/mod.rs | 30 ++++++++++++++++++++++++----- src/aero_kernel/src/net/tcp.rs | 6 +++--- src/aero_kernel/src/socket/tcp.rs | 32 ++++++++++++++++--------------- 5 files changed, 49 insertions(+), 25 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index d873aefc2c5..cae1db1890e 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -139,7 +139,7 @@ dependencies = [ [[package]] name = "crabnet" version = "0.1.0" -source = "git+https://github.com/aero-os/crabnet#4e9e10290136ab34b2b73bd7ce81803c2303674c" +source = "git+https://github.com/aero-os/crabnet#95894c3885b6b3b50942488075631f087cfa9d75" dependencies = [ "bit_field", "bitflags 2.4.0", @@ -150,7 +150,7 @@ dependencies = [ [[package]] name = "crabnet_tcp" version = "0.1.0" -source = "git+https://github.com/aero-os/crabnet#4e9e10290136ab34b2b73bd7ce81803c2303674c" +source = "git+https://github.com/aero-os/crabnet#95894c3885b6b3b50942488075631f087cfa9d75" dependencies = [ "crabnet", "log", diff --git a/src/aero_kernel/Cargo.toml b/src/aero_kernel/Cargo.toml index f1f9cac37a2..ae6589737e2 100644 --- a/src/aero_kernel/Cargo.toml +++ b/src/aero_kernel/Cargo.toml @@ -50,6 +50,8 @@ vte = { git = "https://github.com/alacritty/vte", features = ["ansi"] } byte_endian = { git = "https://github.com/aero-os/byte_endian" } crabnet = { git = "https://github.com/aero-os/crabnet" } crabnet_tcp = { git = "https://github.com/aero-os/crabnet", default-features = false } +# crabnet = { path = "../../../orgs/aero/crabnet" } +# crabnet_tcp = { path = "../../../orgs/aero/crabnet/crabnet_tcp", default-features = false } # X86_64 specific dependencies: [target.'cfg(target_arch = "x86_64")'.dependencies] diff --git a/src/aero_kernel/src/net/mod.rs b/src/aero_kernel/src/net/mod.rs index 43829ff30aa..3a2f4767948 100644 --- a/src/aero_kernel/src/net/mod.rs +++ b/src/aero_kernel/src/net/mod.rs @@ -18,6 +18,7 @@ use alloc::boxed::Box; use alloc::sync::Arc; use alloc::vec::Vec; +use crabnet::transport::TcpOptions; use spin::RwLock; pub mod arp; @@ -132,12 +133,11 @@ fn packet_processor_thread() { Ipv4Type::Tcp => { let tcp = parser.next::(); - let options_size = tcp.options_size() as usize; - let size = ip.payload_len() as usize - core::mem::size_of::(); + let size = ip.payload_len() as usize - tcp.header_size() as usize; + let options = parser.next::(); + let payload = &parser.payload()[..size]; - // TODO(andypython): do not ignore TCP options. - let payload = &parser.payload()[options_size..size]; - tcp::on_packet(tcp, payload) + tcp::on_packet(tcp, options, payload) } } } @@ -217,6 +217,26 @@ pub mod shim { } } + impl PacketSend + for Stacked, T>, U>, S> + { + fn send(mut self) { + let device = net::default_device(); + + let eth = &mut self.upper.upper.upper.upper; + let ip = &self.upper.upper.upper.lower; + + eth.src_mac = device.mac(); + + if let Some(addr) = arp::get(ip.dest_ip()) { + eth.dest_mac = addr; + device.send(self.into_boxed_bytes_in(DmaAllocator)); + } else { + arp::request_ip(ip.dest_ip(), self.into_boxed_bytes_in(DmaAllocator)); + } + } + } + impl PacketSend for Arp { fn send(self) { let device = net::default_device(); diff --git a/src/aero_kernel/src/net/tcp.rs b/src/aero_kernel/src/net/tcp.rs index ea57b60c778..cdef80717d9 100644 --- a/src/aero_kernel/src/net/tcp.rs +++ b/src/aero_kernel/src/net/tcp.rs @@ -18,18 +18,18 @@ use alloc::collections::BTreeMap; use alloc::sync::Arc; -use crabnet::transport::Tcp; +use crabnet::transport::{Tcp, TcpOptions}; use spin::RwLock; use crate::socket::tcp::TcpSocket; static HANDLERS: RwLock>> = RwLock::new(BTreeMap::new()); -pub fn on_packet(tcp: &Tcp, payload: &[u8]) { +pub fn on_packet(tcp: &Tcp, options: TcpOptions, payload: &[u8]) { let handlers = HANDLERS.read(); if let Some(handler) = handlers.get(&tcp.dest_port()) { - handler.on_packet(tcp, payload); + handler.on_packet(tcp, options, payload); } else { log::warn!("tcp: no handler registered for port {}", tcp.dest_port()); } diff --git a/src/aero_kernel/src/socket/tcp.rs b/src/aero_kernel/src/socket/tcp.rs index 0af5ce56e24..849d8680032 100644 --- a/src/aero_kernel/src/socket/tcp.rs +++ b/src/aero_kernel/src/socket/tcp.rs @@ -3,11 +3,12 @@ use aero_syscall::{InAddr, OpenFlags, SocketAddrInet, AF_INET}; use alloc::sync::{Arc, Weak}; use alloc::vec::Vec; +use crabnet::network::Ipv4Addr; use spin::Once; use crabnet::data_link::{Eth, EthType, MacAddr}; -use crabnet::transport::Tcp; -use crabnet_tcp::{Address, Error as TcpError, State}; +use crabnet::transport::{Tcp, TcpOptions}; +use crabnet_tcp::{Address, Error as TcpError, Packet as TcpPacket, State}; use crate::fs::file_table::FileHandle; use crate::fs::inode::{FileType, INodeInterface, Metadata, PollFlags, PollTable}; @@ -23,19 +24,14 @@ use crate::utils::sync::{Mutex, WaitQueue}; struct DeviceShim(Arc); impl crabnet_tcp::NetworkDevice for DeviceShim { - fn send( - &self, - ipv4: crabnet::network::Ipv4, - tcp: Tcp, - payload: &[u8], - _handle: crabnet_tcp::RetransmitHandle, - ) { - // TODO(andypython): Handle TCP retransmission here. + fn ip(&self) -> Ipv4Addr { + self.0.ip() + } + fn send(&self, packet: TcpPacket, _handle: crabnet_tcp::RetransmitHandle) { + // TODO(andypython): Handle TCP retransmission here. let eth = Eth::new(MacAddr::NULL, self.0.mac(), EthType::Ip); - let ipv4 = ipv4.set_src_ip(self.0.ip()); - - (eth / ipv4 / tcp / payload).send(); + (eth / packet.ip / packet.tcp / packet.options / packet.payload).send(); } fn remove_retransmit(&self, _seq_number: u32) { @@ -62,9 +58,15 @@ impl TcpSocket { }) } - pub fn on_packet(&self, tcp: &Tcp, payload: &[u8]) { + pub fn on_packet(&self, tcp: &Tcp, options: TcpOptions, payload: &[u8]) { if let Some(socket) = self.tcp.lock_irq().as_mut() { - socket.on_packet(tcp, payload); + // Ignore any invalid TCP options. + let options = options + .iter() + .filter_map(|option| option.ok()) + .collect::>(); + + socket.on_packet(tcp, &options, payload); self.wq.notify_all(); } } From e9077a0621195c01de0812cac122d5f170006289 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 29 Sep 2023 20:59:04 +1000 Subject: [PATCH 003/112] misc(kernel): bump dependencies * Bump dependencies * Remove `cfg_if` since now we have the `cfg_match` macro in `core` :) Signed-off-by: Anhad Singh --- src/Cargo.lock | 49 +++++++++++++++--------------- src/aero_kernel/Cargo.toml | 11 +++---- src/aero_kernel/src/drivers/mod.rs | 8 +++-- src/aero_kernel/src/main.rs | 1 + 4 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index cae1db1890e..14e7f194731 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -12,11 +12,10 @@ dependencies = [ "bitflags 1.3.2", "byte_endian", "bytemuck", - "cfg-if", "cpio_reader", "crabnet", "crabnet_tcp", - "hashbrown 0.14.0", + "hashbrown", "intrusive-collections", "lai", "lazy_static", @@ -109,9 +108,9 @@ source = "git+https://github.com/aero-os/byte_endian#540be6149cd9408088a9e45be2d [[package]] name = "bytemuck" -version = "1.13.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17febce684fd15d89027105661fec94afb475cb995fbc59d2865198446ba2eea" +checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" [[package]] name = "cc" @@ -139,7 +138,7 @@ dependencies = [ [[package]] name = "crabnet" version = "0.1.0" -source = "git+https://github.com/aero-os/crabnet#95894c3885b6b3b50942488075631f087cfa9d75" +source = "git+https://github.com/aero-os/crabnet#a46a02f9f650cbe8d7436b322f924510e5bda9f7" dependencies = [ "bit_field", "bitflags 2.4.0", @@ -150,7 +149,7 @@ dependencies = [ [[package]] name = "crabnet_tcp" version = "0.1.0" -source = "git+https://github.com/aero-os/crabnet#95894c3885b6b3b50942488075631f087cfa9d75" +source = "git+https://github.com/aero-os/crabnet#a46a02f9f650cbe8d7436b322f924510e5bda9f7" dependencies = [ "crabnet", "log", @@ -200,25 +199,22 @@ dependencies = [ ] [[package]] -name = "either" -version = "1.9.0" +name = "cursor-icon" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "740bb192a8e2d1350119916954f4409ee7f62f149b536911eeb78ba5a20526bf" [[package]] -name = "hashbrown" -version = "0.13.2" +name = "either" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash", -] +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "hashbrown" -version = "0.14.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a" +checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" dependencies = [ "ahash", "allocator-api2", @@ -282,11 +278,11 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "lru" -version = "0.10.1" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670" +checksum = "a4a83fb7698b3643a0e34f9ae6f2e8f0178c0fd42f8b59d493aa271ff3a5bf21" dependencies = [ - "hashbrown 0.13.2", + "hashbrown", ] [[package]] @@ -493,7 +489,8 @@ checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "utf8parse" version = "0.2.1" -source = "git+https://github.com/alacritty/vte#94e74f3a64f42d5dad4e3d42dbe8c23291038214" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "version_check" @@ -503,10 +500,13 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "vte" -version = "0.11.1" -source = "git+https://github.com/alacritty/vte#94e74f3a64f42d5dad4e3d42dbe8c23291038214" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "401dc1020e10f74d38616c1f1ab92ccd85dc902705a29d0730e0fbea8534f91a" dependencies = [ "arrayvec", + "bitflags 2.4.0", + "cursor-icon", "log", "utf8parse", "vte_generate_state_changes", @@ -515,7 +515,8 @@ dependencies = [ [[package]] name = "vte_generate_state_changes" version = "0.1.1" -source = "git+https://github.com/alacritty/vte#94e74f3a64f42d5dad4e3d42dbe8c23291038214" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d257817081c7dffcdbab24b9e62d2def62e2ff7d00b1c20062551e6cccc145ff" dependencies = [ "proc-macro2", "quote", diff --git a/src/aero_kernel/Cargo.toml b/src/aero_kernel/Cargo.toml index ae6589737e2..330b80b8a64 100644 --- a/src/aero_kernel/Cargo.toml +++ b/src/aero_kernel/Cargo.toml @@ -30,22 +30,21 @@ bitflags = "1.2.1" bit_field = "0.10.2" log = "0.4.19" xmas-elf = "0.9.0" -hashbrown = "0.14.0" +hashbrown = "0.14.1" rustc-demangle = "0.1.23" # intrusive-collections: # `nightly`: Get access to const variants of the functions. -intrusive-collections = { version = "0.9.5", features = ["nightly"] } +intrusive-collections = { version = "0.9.6", features = ["nightly"] } serde_json = { version = "1.0", default-features = false, features = ["alloc"] } lai = { git = "https://github.com/aero-os/lai-rs" } uapi = { path = "../uapi" } cpio_reader = { git = "https://github.com/Andy-Python-Programmer/cpio_reader" } static_assertions = "1.1.0" -lru = "0.10.0" -bytemuck = "1.13.1" +lru = "0.11.1" +bytemuck = "1.14.0" limine = { git = "https://github.com/limine-bootloader/limine-rs" } -cfg-if = "1.0" num-traits = { version = "0.2", default-features = false } -vte = { git = "https://github.com/alacritty/vte", features = ["ansi"] } +vte = { version = "0.12.0", features = ["ansi"] } byte_endian = { git = "https://github.com/aero-os/byte_endian" } crabnet = { git = "https://github.com/aero-os/crabnet" } diff --git a/src/aero_kernel/src/drivers/mod.rs b/src/aero_kernel/src/drivers/mod.rs index de2dff01226..795bdb8985d 100644 --- a/src/aero_kernel/src/drivers/mod.rs +++ b/src/aero_kernel/src/drivers/mod.rs @@ -33,11 +33,13 @@ pub mod pci; pub mod pty; pub mod tty; -cfg_if::cfg_if! { - if #[cfg(target_arch = "x86_64")] { +cfg_match! { + cfg(target_arch = "x86_64") => { pub mod uart_16550; pub use self::uart_16550 as uart; - } else if #[cfg(target_arch = "aarch64")] { + } + + cfg(target_arch = "aarch64") => { pub mod uart_pl011; pub use self::uart_pl011 as uart; } diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index 2e276084404..e0c73d006cd 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -47,6 +47,7 @@ const_ptr_is_null, // https://github.com/rust-lang/rust/issues/74939 trait_upcasting, // https://github.com/rust-lang/rust/issues/65991 naked_functions, // https://github.com/rust-lang/rust/issues/32408 + cfg_match, // https://github.com/rust-lang/rust/issues/115585 strict_provenance )] // TODO(andypython): can we remove the dependency of "prelude_import" and "lang_items"? From d8c14285b54d4cff2f89f22cc94c6048fb4566eb Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 4 Oct 2023 19:07:24 +1100 Subject: [PATCH 004/112] feat(kernel): make DNS resolution work properly * Add the loopback device * Create the /etc/resolv.conf file, where the entry is the default SLIRP DNS server address. * Add sock_send() for Unix sockets. * On socket(), create the inode with name <{type}_socket> instead of just which makes debugging easier. * Add some assertions that I will deal with later :) Signed-off-by: Anhad Singh --- CONTRIBUTING.md | 4 +- base-files/etc/resolv.conf | 1 + src/Cargo.lock | 99 ++++++++++++++--------------- src/aero_kernel/src/net/arp.rs | 4 ++ src/aero_kernel/src/net/loopback.rs | 60 +++++++++++++++++ src/aero_kernel/src/net/mod.rs | 46 ++++++++++++-- src/aero_kernel/src/net/tcp.rs | 2 + src/aero_kernel/src/net/udp.rs | 1 + src/aero_kernel/src/socket/tcp.rs | 4 ++ src/aero_kernel/src/socket/udp.rs | 20 +++--- src/aero_kernel/src/socket/unix.rs | 12 ++++ src/aero_kernel/src/syscall/net.rs | 15 +++-- 12 files changed, 195 insertions(+), 73 deletions(-) create mode 100644 base-files/etc/resolv.conf create mode 100644 src/aero_kernel/src/net/loopback.rs diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 746c0e124a1..1ab51c94ade 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -36,4 +36,6 @@ $ lldb (lldb) ```` -Check out the docs for your debugger for information about how to use the debugger. \ No newline at end of file +Check out the docs for your debugger for information about how to use the debugger. + +`./aero.py -- -netdev user,id=spider -device e1000,netdev=spider,id=ck_nic0 -object filter-dump,id=spider,netdev=spider,file=qemulog.log` \ No newline at end of file diff --git a/base-files/etc/resolv.conf b/base-files/etc/resolv.conf new file mode 100644 index 00000000000..27a94c07e56 --- /dev/null +++ b/base-files/etc/resolv.conf @@ -0,0 +1 @@ +nameserver 10.0.2.3 diff --git a/src/Cargo.lock b/src/Cargo.lock index 14e7f194731..773f4b49eac 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -41,7 +41,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -114,9 +114,9 @@ checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" [[package]] name = "cc" -version = "1.0.81" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c6b2562119bf28c3439f7f02db99faf0aa1a8cdfe5772a2ee155d32227239f0" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "libc", ] @@ -138,7 +138,7 @@ dependencies = [ [[package]] name = "crabnet" version = "0.1.0" -source = "git+https://github.com/aero-os/crabnet#a46a02f9f650cbe8d7436b322f924510e5bda9f7" +source = "git+https://github.com/aero-os/crabnet#14fd222842e717c63b695f09790726b209165715" dependencies = [ "bit_field", "bitflags 2.4.0", @@ -149,22 +149,12 @@ dependencies = [ [[package]] name = "crabnet_tcp" version = "0.1.0" -source = "git+https://github.com/aero-os/crabnet#a46a02f9f650cbe8d7436b322f924510e5bda9f7" +source = "git+https://github.com/aero-os/crabnet#14fd222842e717c63b695f09790726b209165715" dependencies = [ "crabnet", "log", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - [[package]] name = "crossbeam-deque" version = "0.8.3" @@ -220,12 +210,6 @@ dependencies = [ "allocator-api2", ] -[[package]] -name = "hermit-abi" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" - [[package]] name = "intrusive-collections" version = "0.9.6" @@ -261,9 +245,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.147" +version = "0.2.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" [[package]] name = "limine" @@ -311,7 +295,7 @@ checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -323,16 +307,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "once_cell" version = "1.18.0" @@ -348,7 +322,7 @@ dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", - "syn", + "syn 1.0.109", "version_check", ] @@ -365,18 +339,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.32" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -392,9 +366,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" dependencies = [ "either", "rayon-core", @@ -402,14 +376,12 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" dependencies = [ - "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", - "num_cpus", ] [[package]] @@ -432,15 +404,29 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.180" +version = "1.0.188" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ea67f183f058fe88a4e3ec6e2788e003840893b91bac4559cabedd00863b3ed" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.37", +] [[package]] name = "serde_json" -version = "1.0.104" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "076066c5f1078eac5b722a31827a8832fe108bed65dfa75e233c89f8206e976c" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", @@ -476,15 +462,26 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "uapi" version = "0.1.0" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "utf8parse" diff --git a/src/aero_kernel/src/net/arp.rs b/src/aero_kernel/src/net/arp.rs index a7f77d73e6e..ce804f5a789 100644 --- a/src/aero_kernel/src/net/arp.rs +++ b/src/aero_kernel/src/net/arp.rs @@ -76,6 +76,10 @@ impl Cache { } fn request(&mut self, ip: Ipv4Addr, packet: RawPacket) { + if ip == Ipv4Addr::LOOPBACK { + panic!() + } + if self.0.get_mut(&ip).is_some() { todo!() } else { diff --git a/src/aero_kernel/src/net/loopback.rs b/src/aero_kernel/src/net/loopback.rs new file mode 100644 index 00000000000..6a43b41b0e7 --- /dev/null +++ b/src/aero_kernel/src/net/loopback.rs @@ -0,0 +1,60 @@ +// Copyright (C) 2021-2023 The Aero Project Developers. +// +// This file is part of The Aero Project. +// +// Aero is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Aero is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Aero. If not, see . + +//! Loopback device. + +use alloc::boxed::Box; +use alloc::sync::Arc; +use crabnet::data_link::MacAddr; +use crabnet::network::Ipv4Addr; + +use crate::utils::dma::DmaAllocator; + +use super::{NetworkDevice, NetworkDriver, RecvPacket}; + +pub struct Loopback; + +impl NetworkDriver for Loopback { + fn send(&self, _packet: Box<[u8], DmaAllocator>) { + todo!() + } + + fn recv(&self) -> RecvPacket { + todo!() + } + + fn recv_end(&self, _packet_id: usize) { + todo!() + } + + #[inline] + fn mac(&self) -> MacAddr { + // TODO: What should this really be? + MacAddr::NULL + } +} + +lazy_static::lazy_static! { + pub static ref LOOPBACK: Arc = (|| { + let device = Arc::new(NetworkDevice::new(Arc::new(Loopback))); + + device.set_ip(Ipv4Addr::LOOPBACK); + device.set_subnet_mask(Ipv4Addr::new(255, 0, 0, 0)); + + device + })(); +} diff --git a/src/aero_kernel/src/net/mod.rs b/src/aero_kernel/src/net/mod.rs index 3a2f4767948..1ef19dd290b 100644 --- a/src/aero_kernel/src/net/mod.rs +++ b/src/aero_kernel/src/net/mod.rs @@ -22,6 +22,7 @@ use crabnet::transport::TcpOptions; use spin::RwLock; pub mod arp; +pub mod loopback; pub mod tcp; pub mod udp; @@ -45,8 +46,12 @@ struct Metadata { ip: Ipv4Addr, #[allow(dead_code)] subnet_mask: Ipv4Addr, + default_gateway: Ipv4Addr, } +// FIXME(andypython): This is very inefficient. We store the driver as an Arc and +// the device with metadata as an Arc. Two heap allocations for nothing, bruh +// moments. pub struct NetworkDevice { driver: Arc, metadata: RwLock, @@ -55,8 +60,15 @@ pub struct NetworkDevice { impl NetworkDevice { pub fn new(driver: Arc) -> Self { // FIXME(andy): DHCPD should handle static IP assignment. - let mut metadata = Metadata::default(); - metadata.ip = Ipv4Addr::new([192, 168, 100, 0]); + // + // https://wiki.qemu.org/Documentation/Networking + let metadata = Metadata { + ip: Ipv4Addr::new(192, 168, 100, 0), + // What should the default be? Also this should really be handled inside dhcpd. + default_gateway: Ipv4Addr::new(10, 0, 2, 2), + subnet_mask: Ipv4Addr::new(255, 255, 255, 0), + ..Default::default() + }; Self { driver, @@ -79,6 +91,11 @@ impl NetworkDevice { pub fn subnet_mask(&self) -> Ipv4Addr { self.metadata.read().subnet_mask } + + #[inline] + pub fn default_gateway(&self) -> Ipv4Addr { + self.metadata.read().default_gateway + } } impl core::ops::Deref for NetworkDevice { @@ -180,6 +197,7 @@ pub fn init() { return; } + DEVICES.write().push(loopback::LOOPBACK.clone()); arp::init(); log::info!("net::arp: initialized cache"); } @@ -199,6 +217,8 @@ pub mod shim { } // Deref for Stacked where T: Stacked? + // + // TODO(andypython): Can all of the packet send impls be refactored? impl PacketSend for Stacked, T>, U> { fn send(mut self) { let device = net::default_device(); @@ -206,13 +226,20 @@ pub mod shim { let eth = &mut self.upper.upper.upper; let ip = &self.upper.upper.lower; + let mut dest_ip = ip.dest_ip(); + + if !dest_ip.is_broadcast() && !dest_ip.is_same_subnet(device.ip(), device.subnet_mask()) + { + dest_ip = device.default_gateway(); + } + eth.src_mac = device.mac(); - if let Some(addr) = arp::get(ip.dest_ip()) { + if let Some(addr) = arp::get(dest_ip) { eth.dest_mac = addr; device.send(self.into_boxed_bytes_in(DmaAllocator)); } else { - arp::request_ip(ip.dest_ip(), self.into_boxed_bytes_in(DmaAllocator)); + arp::request_ip(dest_ip, self.into_boxed_bytes_in(DmaAllocator)); } } } @@ -226,13 +253,20 @@ pub mod shim { let eth = &mut self.upper.upper.upper.upper; let ip = &self.upper.upper.upper.lower; + let mut dest_ip = ip.dest_ip(); + + if !dest_ip.is_broadcast() && !dest_ip.is_same_subnet(device.ip(), device.subnet_mask()) + { + dest_ip = device.default_gateway(); + } + eth.src_mac = device.mac(); - if let Some(addr) = arp::get(ip.dest_ip()) { + if let Some(addr) = arp::get(dest_ip) { eth.dest_mac = addr; device.send(self.into_boxed_bytes_in(DmaAllocator)); } else { - arp::request_ip(ip.dest_ip(), self.into_boxed_bytes_in(DmaAllocator)); + arp::request_ip(dest_ip, self.into_boxed_bytes_in(DmaAllocator)); } } } diff --git a/src/aero_kernel/src/net/tcp.rs b/src/aero_kernel/src/net/tcp.rs index cdef80717d9..9ffb6f520cf 100644 --- a/src/aero_kernel/src/net/tcp.rs +++ b/src/aero_kernel/src/net/tcp.rs @@ -53,6 +53,8 @@ pub fn alloc_ephemeral_port(socket: Arc) -> Option { continue; } + log::warn!("[ TCP ] Listening on port {port}"); + handlers.insert(port, socket); return Some(port); } diff --git a/src/aero_kernel/src/net/udp.rs b/src/aero_kernel/src/net/udp.rs index f93eef32ef2..f90ea9d284c 100644 --- a/src/aero_kernel/src/net/udp.rs +++ b/src/aero_kernel/src/net/udp.rs @@ -54,6 +54,7 @@ pub fn alloc_ephemeral_port(socket: Arc) -> Option { continue; } + log::warn!("[ UDP ] Listening on port {port}"); handlers.insert(port, socket); return Some(port); } diff --git a/src/aero_kernel/src/socket/tcp.rs b/src/aero_kernel/src/socket/tcp.rs index 849d8680032..34d29602714 100644 --- a/src/aero_kernel/src/socket/tcp.rs +++ b/src/aero_kernel/src/socket/tcp.rs @@ -131,6 +131,10 @@ impl INodeInterface for TcpSocket { let addr = address.as_inet().ok_or(FileSystemError::NotSupported)?; self.peer.call_once(|| addr.clone()); + if addr.addr() == Ipv4Addr::LOOPBACK.0 { + return Err(FileSystemError::NotSupported); + } + let addr = Address::new(port, addr.port(), addr.addr().into()); let device = Arc::new(DeviceShim(net::default_device())); diff --git a/src/aero_kernel/src/socket/udp.rs b/src/aero_kernel/src/socket/udp.rs index 27e98af35c4..0409073d0bf 100644 --- a/src/aero_kernel/src/socket/udp.rs +++ b/src/aero_kernel/src/socket/udp.rs @@ -140,7 +140,7 @@ impl INodeInterface for UdpSocket { fn connect(&self, address: super::SocketAddrRef, _length: usize) -> fs::Result<()> { let address = address.as_inet().ok_or(FileSystemError::NotSupported)?; - let host_addr = Ipv4Addr::new(address.sin_addr.addr.to_be_bytes()); + let host_addr = Ipv4Addr::from(address.sin_addr.addr.to_be_bytes()); udp::connect(host_addr, address.port.to_native()); self.set_state(SocketState::Connected(address.clone())); @@ -154,7 +154,7 @@ impl INodeInterface for UdpSocket { .unwrap_or_else(|| self.dest()); let dest_port = name.port.to_native(); - let dest_ip = Ipv4Addr::new(name.addr()); + let dest_ip = Ipv4Addr::from(name.addr()); let src_port; @@ -165,11 +165,6 @@ impl INodeInterface for UdpSocket { log::debug!("Inet::send(): allocated ephemeral port {}", src_port); } - // FIXME: loopback - if dest_ip == Ipv4Addr::new([127, 0, 0, 1]) { - return Err(FileSystemError::NotSupported); - } - let data = message_hdr .iovecs() .iter() @@ -177,6 +172,13 @@ impl INodeInterface for UdpSocket { .copied() .collect::>(); + // FIXME: loopback + if dest_ip == Ipv4Addr::LOOPBACK { + log::debug!("looback moments :)"); + return Err(FileSystemError::NotSupported); + // return Ok(data.len()); + } + use crate::net::shim::PacketSend; let eth = Eth::new(MacAddr::NULL, MacAddr::NULL, EthType::Ip); @@ -245,7 +247,7 @@ impl INodeInterface for UdpSocket { assert!(name == "eth0"); let device = net::default_device(); - device.set_ip(Ipv4Addr::new(socket.addr())); + device.set_ip(Ipv4Addr::from(socket.addr())); Ok(0) } @@ -262,7 +264,7 @@ impl INodeInterface for UdpSocket { assert!(name == "eth0"); let device = net::default_device(); - device.set_subnet_mask(Ipv4Addr::new(socket.addr())); + device.set_subnet_mask(Ipv4Addr::from(socket.addr())); Ok(0) } diff --git a/src/aero_kernel/src/socket/unix.rs b/src/aero_kernel/src/socket/unix.rs index 03ca06b7594..f8d635e4e4e 100644 --- a/src/aero_kernel/src/socket/unix.rs +++ b/src/aero_kernel/src/socket/unix.rs @@ -411,6 +411,18 @@ impl INodeInterface for UnixSocket { .sum::()) } + fn send(&self, message_hdr: &mut MessageHeader, _flags: MessageFlags) -> fs::Result { + // FIXME(andyython): figure out the message header stuff... + let data = message_hdr + .iovecs() + .iter() + .flat_map(|e| e.as_slice()) + .copied() + .collect::>(); + + self.write_at(0, &data) + } + fn poll(&self, table: Option<&mut PollTable>) -> fs::Result { let buffer = self.buffer.lock_irq(); let inner = self.inner.lock_irq(); diff --git a/src/aero_kernel/src/syscall/net.rs b/src/aero_kernel/src/syscall/net.rs index 0433281f569..4f864f20908 100644 --- a/src/aero_kernel/src/syscall/net.rs +++ b/src/aero_kernel/src/syscall/net.rs @@ -127,16 +127,19 @@ fn create_socket( let typ = SocketType::from_usize(socket_type & 0b1111).ok_or(SyscallError::EINVAL)?; let protocol = IpProtocol::from_usize(protocol).ok_or(SyscallError::EINVAL)?; - let socket = match domain as u32 { - AF_UNIX => UnixSocket::new() as Arc, + let (name, socket) = match domain as u32 { + AF_UNIX => ("unix", UnixSocket::new() as Arc), AF_INET => match (typ, protocol) { (SocketType::Dgram, IpProtocol::Default | IpProtocol::Udp) => { - UdpSocket::new() as Arc + ("udp", UdpSocket::new() as Arc) + } + + (SocketType::Dgram, IpProtocol::Raw) => { + ("ipv4", Ipv4Socket::new() as Arc) } - (SocketType::Dgram, IpProtocol::Raw) => Ipv4Socket::new() as Arc, (SocketType::Stream, IpProtocol::Default | IpProtocol::Tcp) => { - TcpSocket::new() as Arc + ("tcp", TcpSocket::new() as Arc) } _ => { @@ -157,7 +160,7 @@ fn create_socket( } }; - let entry = DirEntry::from_inode(socket, String::from("")); + let entry = DirEntry::from_inode(socket, alloc::format!("<{name}_socket>")); Ok(entry) } From c558b7958913e82105066cf36403a16f165200c2 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 6 Oct 2023 17:53:42 +1100 Subject: [PATCH 005/112] misc(kernel): make use of the stabilized div_ceil Signed-off-by: Anhad Singh --- src/aero_kernel/src/drivers/block/ahci.rs | 4 +-- src/aero_kernel/src/drivers/block/ide/mod.rs | 3 +-- src/aero_kernel/src/drivers/block/nvme/mod.rs | 4 +-- src/aero_kernel/src/fs/ext2/disk.rs | 3 +-- src/aero_kernel/src/fs/ext2/mod.rs | 3 +-- src/aero_kernel/src/syscall/time.rs | 3 +-- src/aero_kernel/src/utils/mod.rs | 27 ------------------- 7 files changed, 8 insertions(+), 39 deletions(-) diff --git a/src/aero_kernel/src/drivers/block/ahci.rs b/src/aero_kernel/src/drivers/block/ahci.rs index d8ac56d497f..bbe5b67c291 100644 --- a/src/aero_kernel/src/drivers/block/ahci.rs +++ b/src/aero_kernel/src/drivers/block/ahci.rs @@ -25,7 +25,7 @@ use crate::mem::paging::*; use crate::mem::AddressSpace; use crate::utils::sync::Mutex; -use crate::utils::{CeilDiv, VolatileCell}; +use crate::utils::VolatileCell; use crate::drivers::pci::*; @@ -201,7 +201,7 @@ pub struct DmaBuffer { impl DmaBuffer { pub fn sectors(&self) -> usize { - self.data_size.ceil_div(512) + self.data_size.div_ceil(512) } pub fn start(&self) -> PhysAddr { diff --git a/src/aero_kernel/src/drivers/block/ide/mod.rs b/src/aero_kernel/src/drivers/block/ide/mod.rs index 16ea8ef7bc8..688172d8909 100644 --- a/src/aero_kernel/src/drivers/block/ide/mod.rs +++ b/src/aero_kernel/src/drivers/block/ide/mod.rs @@ -32,7 +32,6 @@ use crate::fs::block::{BlockDevice, BlockDeviceInterface}; use crate::mem::paging::OffsetPageTable; use crate::utils::sync::Mutex; -use crate::utils::CeilDiv; use super::ahci::DmaRequest; @@ -51,7 +50,7 @@ impl IdeDrive { impl BlockDeviceInterface for IdeDrive { fn read_block(&self, sector: usize, dest: &mut [MaybeUninit]) -> Option { - let count = dest.len().ceil_div(512); + let count = dest.len().div_ceil(512); let request = Arc::new(DmaRequest::new(sector, count)); let res = self.channel.run_request(request, self.slave); diff --git a/src/aero_kernel/src/drivers/block/nvme/mod.rs b/src/aero_kernel/src/drivers/block/nvme/mod.rs index 48c69103f12..706776e5149 100644 --- a/src/aero_kernel/src/drivers/block/nvme/mod.rs +++ b/src/aero_kernel/src/drivers/block/nvme/mod.rs @@ -35,7 +35,7 @@ use crate::mem::paging::*; use crate::utils::dma::*; use crate::utils::sync::BMutex; -use crate::utils::{CeilDiv, VolatileCell}; +use crate::utils::VolatileCell; #[derive(Copy, Clone, Debug)] enum Error { @@ -231,7 +231,7 @@ impl<'a> Namespace<'a> { fn rw_command(&self, opcode: CommandOpcode, sector: usize, start: PhysAddr, size_bytes: usize) { assert!(size_bytes != 0); - let blocks = size_bytes.ceil_div(self.block_size); + let blocks = size_bytes.div_ceil(self.block_size); let mut read_cmd = ReadWriteCommand::default(); read_cmd.opcode = opcode as u8; diff --git a/src/aero_kernel/src/fs/ext2/disk.rs b/src/aero_kernel/src/fs/ext2/disk.rs index 2f55f8eca96..f99f046c45c 100644 --- a/src/aero_kernel/src/fs/ext2/disk.rs +++ b/src/aero_kernel/src/fs/ext2/disk.rs @@ -18,7 +18,6 @@ use bit_field::BitField; use crate::fs::inode; -use crate::utils::CeilDiv; trait Revsion {} @@ -112,7 +111,7 @@ impl SuperBlock { /// Returns the length of the BGDT. pub fn bgdt_len(&self) -> usize { - self.blocks_count.ceil_div(self.blocks_per_group) as usize + self.blocks_count.div_ceil(self.blocks_per_group) as usize } pub fn bgdt_block(&self) -> usize { diff --git a/src/aero_kernel/src/fs/ext2/mod.rs b/src/aero_kernel/src/fs/ext2/mod.rs index 987531513b3..817d09a570e 100644 --- a/src/aero_kernel/src/fs/ext2/mod.rs +++ b/src/aero_kernel/src/fs/ext2/mod.rs @@ -34,7 +34,6 @@ use crate::mem::paging::*; use crate::socket::unix::UnixSocket; use crate::socket::SocketAddrRef; -use crate::utils::CeilDiv; use self::group_desc::GroupDescriptors; @@ -186,7 +185,7 @@ impl INode { let new_block = fs.bgdt.alloc_block_ptr()?; - let mut next_block_num = self.inode.read().size().ceil_div(block_size); + let mut next_block_num = self.inode.read().size().div_ceil(block_size); if next_block_num < 12 { let mut inode = self.inode.write(); diff --git a/src/aero_kernel/src/syscall/time.rs b/src/aero_kernel/src/syscall/time.rs index f48328cf11e..cde62a4eeaa 100644 --- a/src/aero_kernel/src/syscall/time.rs +++ b/src/aero_kernel/src/syscall/time.rs @@ -23,14 +23,13 @@ use alloc::vec::Vec; use crate::userland::scheduler; use crate::userland::task::Task; use crate::utils::sync::{IrqGuard, Mutex}; -use crate::utils::CeilDiv; const CLOCK_TYPE_REALTIME: usize = 0; const CLOCK_TYPE_MONOTONIC: usize = 1; #[syscall] pub fn sleep(timespec: &TimeSpec) -> Result { - let duration = (timespec.tv_nsec as usize).ceil_div(1000000000) + timespec.tv_sec as usize; + let duration = (timespec.tv_nsec as usize).div_ceil(1000000000) + timespec.tv_sec as usize; scheduler::get_scheduler().inner.sleep(Some(duration))?; diff --git a/src/aero_kernel/src/utils/mod.rs b/src/aero_kernel/src/utils/mod.rs index 5678717fce6..081c8284836 100644 --- a/src/aero_kernel/src/utils/mod.rs +++ b/src/aero_kernel/src/utils/mod.rs @@ -223,32 +223,5 @@ impl<'a> StackHelper<'a> { } } -pub trait CeilDiv { - fn ceil_div(self, d: Self) -> Self; -} - -macro_rules! ceil_div_impl { - ($($t:ty)*) => ($( - impl CeilDiv for $t { - fn ceil_div(self, d: $t) -> $t { - (self + d - 1) / d - } - } - )*) -} - -ceil_div_impl!(u8 u16 u32 u64 usize u128); - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn unsigned_div_ceil() { - assert_eq!((8usize).ceil_div(3), 3); - assert_eq!((7usize).ceil_div(4), 2); - } -} - #[repr(transparent)] pub struct LinkerSymbol(core::cell::UnsafeCell); From f0c6d28053b4d30569417fd2b2f5ee408aafcd51 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 7 Oct 2023 16:31:07 +1100 Subject: [PATCH 006/112] misc(unwind): update to the new panic message format https://blog.rust-lang.org/2023/10/05/Rust-1.73.0.html#cleaner-panic-messages Signed-off-by: Anhad Singh --- src/aero_kernel/src/unwind.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/aero_kernel/src/unwind.rs b/src/aero_kernel/src/unwind.rs index 855caa37268..af3f49a7698 100644 --- a/src/aero_kernel/src/unwind.rs +++ b/src/aero_kernel/src/unwind.rs @@ -163,8 +163,8 @@ use crate::utils::sync::IrqGuard; fn rust_begin_unwind(info: &PanicInfo) -> ! { prepare_panic(); - let default_panic = &format_args!(""); - let panic_message = info.message().unwrap_or(default_panic); + let message = info.message().unwrap(); + let location = info.location().unwrap(); // Get the CPU ID where this panic happened and if PANIC_HOOK_READY is false // then we cannot get the CPU where this panic happened. @@ -174,14 +174,8 @@ fn rust_begin_unwind(info: &PanicInfo) -> ! { 0x00 }; - log::error!("cpu '{}' panicked at '{}'", cpu_id, panic_message); - - // Print the panic location if it is available. - if let Some(panic_location) = info.location() { - log::error!("{}", panic_location); - } - - // Add a new line to make the stack trace more readable. + log::error!("cpu '{cpu_id}' panicked at {location}:"); + log::error!("{message}"); log::error!(""); unwind_stack_trace(); From deb049b04ed3e3f55e292bd62f9ac37cc7b0dade Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 13 Oct 2023 20:04:03 +1100 Subject: [PATCH 007/112] ports: add webkitgtk Signed-off-by: Anhad Singh --- base-files/a | 21 +- bootstrap.yml | 54 +- bootstrap/net.yml | 476 +++++++-- bootstrap/x11-themes.yml | 49 + bootstrap/xorg.yml | 139 ++- extra-files/firefox/mozconfig | 26 + patches/alsa-lib/alsa-lib.patch | 124 +++ patches/mlibc/mlibc.patch | 2 +- patches/nss/0001-Add-a-missing-include.patch | 24 + patches/nss/0002-NSS-Standalone-patch.patch | 258 +++++ patches/rust-getrandom/rust-getrandom.patch | 53 + patches/rust-libc/rust-libc.patch | 996 ------------------ patches/rust-libloading/rust-libloading.patch | 23 +- patches/rust-nix/rust-nix.patch | 506 ++++++--- patches/webkitgtk/webkitgtk.patch | 45 +- patches/xorg-server/xorg-server.patch | 181 ++-- src/aero_kernel/src/arch/x86_64/task.rs | 4 +- src/aero_kernel/src/fs/block/mod.rs | 1 + src/aero_kernel/src/fs/eventfd.rs | 4 +- src/aero_kernel/src/fs/ext2/group_desc.rs | 18 +- src/aero_kernel/src/fs/ext2/mod.rs | 15 +- src/aero_kernel/src/fs/mod.rs | 16 +- src/aero_kernel/src/main.rs | 1 + src/aero_kernel/src/mem/paging/mapper.rs | 7 +- src/aero_kernel/src/rendy.rs | 5 +- src/aero_kernel/src/syscall/fs.rs | 5 +- src/aero_kernel/src/syscall/mod.rs | 4 + src/aero_kernel/src/userland/vm.rs | 20 +- src/aero_proc/src/syscall.rs | 32 +- tools/cargo-inject-patches.py | 10 +- userland/apps/init/src/main.rs | 24 +- 31 files changed, 1714 insertions(+), 1429 deletions(-) create mode 100644 bootstrap/x11-themes.yml create mode 100644 extra-files/firefox/mozconfig create mode 100644 patches/alsa-lib/alsa-lib.patch create mode 100644 patches/nss/0001-Add-a-missing-include.patch create mode 100644 patches/nss/0002-NSS-Standalone-patch.patch create mode 100644 patches/rust-getrandom/rust-getrandom.patch delete mode 100644 patches/rust-libc/rust-libc.patch diff --git a/base-files/a b/base-files/a index d9ae7e1d5e3..6a904dd38ac 100644 --- a/base-files/a +++ b/base-files/a @@ -1,2 +1,21 @@ #!/usr/bin/bash -systrace curl 192.168.1.25:8080 + +echo "Running update-mime-database to get the mime database" +update-mime-database /usr/share/mime/ + +echo "Running gio-querymodules to generate gio cache" +gio-querymodules /usr/lib/gio/modules/ + +echo "Running glib-compile-schemas to get gtk3 working" +glib-compile-schemas /usr/share/glib-2.0/schemas/ + +echo "Running gdk-pixbuf-query-loaders to get gtk3 working" +gdk-pixbuf-query-loaders --update-cache + +echo "Running gtk-query-immodules-3.0 to get gtk3 working" +gtk-query-immodules-3.0 --update-cache + +echo "Running gtk-query-immodules-2.0 to get gtk2 working" +gtk-query-immodules-2.0 --update-cache + +/usr/libexec/webkit2gtk-4.0/MiniBrowser diff --git a/bootstrap.yml b/bootstrap.yml index 4991de639da..dd8b37f0753 100644 --- a/bootstrap.yml +++ b/bootstrap.yml @@ -1,5 +1,6 @@ imports: - file: bootstrap/xorg.yml + - file: bootstrap/x11-themes.yml - file: bootstrap/net.yml - file: bootstrap/vcs.yml - file: bootstrap/db.yml @@ -94,13 +95,14 @@ sources: - name: rust-libc subdir: 'bundled' git: 'https://github.com/Andy-Python-Programmer/libc.git' + commit: 'fe4e9cda46b0be8421b0f56df0b63b8c4dcaf5e6' branch: 'master' - name: rust-num-cpus subdir: 'bundled' git: 'https://github.com/seanmonstar/num_cpus.git' - tag: 'v1.13.0' - version: '1.13.0' + tag: 'v1.15.0' + version: '1.15.0' - name: rust-users subdir: 'bundled' @@ -123,8 +125,8 @@ sources: - name: rust-nix subdir: 'bundled' git: 'https://github.com/nix-rust/nix.git' - tag: 'v0.22.3' - version: '0.22.3' + tag: 'v0.24.3' + version: '0.24.3' - name: rust-mio-0.6 subdir: 'bundled' @@ -148,8 +150,21 @@ sources: - name: rust-libloading subdir: 'bundled' git: 'https://github.com/nagisa/rust_libloading.git' - tag: '0.7.3' - version: '0.7.3' + tag: '0.8.1' + version: '0.8.1' + + - name: rust-getrandom + subdir: 'bundled' + git: 'https://github.com/rust-random/getrandom.git' + tag: 'v0.2.9' + version: '0.2.9' + + - name: rust-rustix + subdir: 'bundled' + git: 'https://github.com/bytecodealliance/rustix' + branch: 'main' + # For some reason they do not have a release tag for the latest release. Bruh momento. + commit: '2eedbb2fa1e18a11f44df10fa41ef82a6756caf3' - name: rust-patched-libs subdir: 'bundled' @@ -174,6 +189,10 @@ sources: recursive: true - name: rust-libloading recursive: true + - name: rust-getrandom + recursive: true + - name: rust-rustix + recursive: true # --------------------------------------------------------------------------- # Rust patched crates end # --------------------------------------------------------------------------- @@ -229,15 +248,15 @@ sources: - name: icu subdir: 'bundled' git: 'https://github.com/unicode-org/icu.git' - tag: 'release-70-1' - version: '70.1' + tag: 'release-73-2' + version: '73.2' tools_required: - host-autoconf-v2.69 - host-automake-v1.16 - host-libtool regenerate: - args: ['cp', - '@BUILD_ROOT@/tools/host-automake-v1.15/share/automake-1.15/config.sub', + '@BUILD_ROOT@/tools/host-automake-v1.16/share/automake-1.16/config.sub', '@THIS_SOURCE_DIR@/icu4c/source'] tools: @@ -303,6 +322,23 @@ tools: install: - args: ['make', 'install'] + + - name: host-autoconf-v2.13 + source: + name: autoconf-v2.13 + subdir: 'bundled' + url: 'https://ftp.gnu.org/gnu/autoconf/autoconf-2.13.tar.gz' + format: 'tar.gz' + extract_path: 'autoconf-2.13' + patch-path-strip: 3 + version: '2.13' + configure: + - args: ['@THIS_SOURCE_DIR@/configure', '--prefix=@PREFIX@'] + compile: + - args: ['make', '-j@PARALLELISM@'] + install: + - args: ['make', 'install'] + - name: host-automake-v1.16 source: name: automake-v1.16 diff --git a/bootstrap/net.yml b/bootstrap/net.yml index 5960dc8c71e..fb8a47a2d2c 100644 --- a/bootstrap/net.yml +++ b/bootstrap/net.yml @@ -1,3 +1,10 @@ +sources: + - name: nss + subdir: 'bundled' + git: 'https://github.com/nss-dev/nss.git' + tag: 'NSS_3_94_RTM' + version: '3.94.RTM' + packages: - name: dhcpd source: @@ -318,88 +325,409 @@ packages: environ: DESTDIR: '@THIS_COLLECT_DIR@' - # - name: webkitgtk - # metadata: - # summary: 'An open source web browser engine, with a small example browser' - # description: 'This package provides WebKitGTK, a port of the portable web rendering engine WebKit to the GTK+ 3 and GTK 4 platforms.' - # spdx: 'LGPL-2.0-or-later BSD-2-Clause' - # website: 'https://webkitgtk.org' - # maintainer: "Dennis Bonke " - # categories: ['net-libs'] + - name: alsa-lib + source: + subdir: 'bundled' + git: 'https://github.com/alsa-project/alsa-lib.git' + tag: 'v1.2.9' + version: '1.2.9' + tools_required: + - host-autoconf-v2.69 + - host-automake-v1.16 + - host-libtool + - host-pkg-config + - virtual: pkgconfig-for-target + triple: "x86_64-aero" + regenerate: + - args: ['autoreconf', '-fvi'] + tools_required: + - host-gcc + pkgs_required: + - mlibc + configure: + - args: + - '@THIS_SOURCE_DIR@/configure' + - '--host=x86_64-aero' + - '--prefix=/usr' + - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. + build: + - args: ['make', '-j@PARALLELISM@'] + - args: ['make', 'install'] + environ: + DESTDIR: '@THIS_COLLECT_DIR@' + + - name: nspr + source: + subdir: 'bundled' + hg: 'https://hg.mozilla.org/projects/nspr/' + tag: 'NSPR_4_35_RTM' + version: '4.35.1' + tools_required: + - host-autoconf-v2.69 + - host-automake-v1.16 + - host-libtool + regenerate: + - args: ['autoreconf', '-fvi'] + - args: ['cp', + '@BUILD_ROOT@/tools/host-automake-v1.16/share/automake-1.16/config.sub', + '@THIS_SOURCE_DIR@/build/autoconf/'] + tools_required: + - host-gcc + pkgs_required: + - mlibc + configure: + # Disable installing two unneeded scripts. + - args: ['sed', '-ri', '/^RELEASE/s/^/#/', '@THIS_SOURCE_DIR@/pr/src/misc/Makefile.in'] + # Disable installing static libraries. + - args: ['sed', '-i', 's#$(LIBRARY) ##', '@THIS_SOURCE_DIR@/config/rules.mk'] + - args: + - '@THIS_SOURCE_DIR@/configure' + - '--host=x86_64-linux' + - '--build=x86_64-linux' + - '--prefix=/usr' + - '--with-mozilla' + - '--with-pthreads' + - '--enable-64bit' + environ: + CROSS_COMPILE: '1' + ac_cv_func_syscall: 'no' + build: + # We first build a native nsinstall that the build can use later on. + - args: ['make', 'CC=gcc', 'CXX=g++', '-C', '@THIS_BUILD_DIR@/config/'] + - args: ['mv', '-v', '@THIS_BUILD_DIR@/config/nsinstall', '@THIS_BUILD_DIR@/config/native-nsinstall'] + - args: ['sed', '-s', 's#/nsinstall$#/native-nsinstall#', '-i', '@THIS_BUILD_DIR@/config/autoconf.mk'] + - args: ['rm', '-v', '@THIS_BUILD_DIR@/config/nsinstall.o'] + # Then build the real deal + - args: ['make', 'CC=x86_64-aero-gcc', 'CXX=x86_64-aero-g++', '-j@PARALLELISM@'] + - args: ['make', 'install'] + environ: + DESTDIR: '@THIS_COLLECT_DIR@' + quiet: true + + - name: nss + from_source: nss + tools_required: + - host-gcc + pkgs_required: + - mlibc + - nspr + - sqlite + - zlib + configure: + - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] + build: + # First, build a host version of nsinstall. + - args: ['make', '-C', '@THIS_BUILD_DIR@/coreconf/'] + environ: + CC: 'gcc' + BUILD_OPT: '1' + NSPR_INCLUDE_DIR: '/usr/include/nspr' + USE_SYSTEM_ZLIB: '1' + ZLIB_LIBS: '-lz' + NSS_ENABLE_WERROR: '0' + USE_64: '1' + NSS_USE_SYSTEM_SQLITE: '1' + NS_USE_GCC: '1' + CC_IS_GCC: '1' + NSDISTMODE: 'copy' + # Then, build some configuration items courtesy of BLFS (see the patches). + - args: | + make V=1 -C @THIS_BUILD_DIR@/config NSINSTALL=@THIS_BUILD_DIR@/$(find -type f -name nsinstall) -j1 + environ: + # Optimized builds. + BUILD_OPT: '1' + # NSPR is here. + NSPR_INCLUDE_DIR: '@SYSROOT_DIR@/usr/include/nspr' + # Use our zlib. + USE_SYSTEM_ZLIB: '1' + # Freestanding freebl yes please. + FREEBL_NO_DEPEND: '1' + FREEBL_LOWHASH: '1' + NSS_SEED_ONLY_DEV_URANDOM: '1' + # Link with zlib. + ZLIB_LIBS: '-lz' + # Do not enable Werror. + NSS_ENABLE_WERROR: '0' + # We are 64 bit. + USE_64: '1' + # Use system sqlite. + NSS_USE_SYSTEM_SQLITE: '1' + # We're using gcc. + NS_USE_GCC: '1' + CC_IS_GCC: '1' + # We're cross compiling. + CROSS_COMPILE: '1' + # Don't symlink files, copy them. + NSDISTMODE: 'copy' + # Do not build the tests. + NSS_DISABLE_GTESTS: '1' + # Put the libs and binaries here. + SOURCE_PREFIX: '@THIS_BUILD_DIR@/dist' + # Specify the compiler. + CC: 'x86_64-aero-gcc' + CXX: 'x86_64-aero-g++' + # Then build the main libraries and binaries. + - args: | + make V=1 -C @THIS_BUILD_DIR@/. NSINSTALL=@THIS_BUILD_DIR@/$(find -type f -name nsinstall) -j1 + environ: + BUILD_OPT: '1' + NSPR_INCLUDE_DIR: '@SYSROOT_DIR@/usr/include/nspr' + USE_SYSTEM_ZLIB: '1' + FREEBL_NO_DEPEND: '1' + FREEBL_LOWHASH: '1' + NSS_SEED_ONLY_DEV_URANDOM: '1' + ZLIB_LIBS: '-lz' + NSS_ENABLE_WERROR: '0' + USE_64: '1' + NSS_USE_SYSTEM_SQLITE: '1' + NS_USE_GCC: '1' + CC_IS_GCC: '1' + CROSS_COMPILE: '1' + NSDISTMODE: 'copy' + NSS_DISABLE_GTESTS: '1' + SOURCE_PREFIX: '@THIS_BUILD_DIR@/dist' + CC: 'x86_64-aero-gcc' + CXX: 'x86_64-aero-g++' + # Create some directories to install into. + - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/usr/lib/pkgconfig'] + - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/usr/bin'] + - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/usr/include'] + # And install everything, this _will_ break on a non Linux box, but unfortunately NSS hardcodes kernel names and versions. + # If someone wants to patch NSS to not do that, greatly appreciated. + # These install instructions are adapted from BLFS, and not Gentoo as I usually do. + - args: | + cd dist + install -v -m755 Linux*/lib/*.so @THIS_COLLECT_DIR@/usr/lib + install -v -m644 Linux*/lib/{*.chk,libcrmf.a} @THIS_COLLECT_DIR@/usr/lib + install -v -m755 -d @THIS_COLLECT_DIR@/usr/include/nss + cp -v -RL {public,private}/nss/* @THIS_COLLECT_DIR@/usr/include/nss + chmod -v 644 @THIS_COLLECT_DIR@/usr/include/nss/* + install -v -m755 Linux*/bin/{certutil,nss-config,pk12util} @THIS_COLLECT_DIR@/usr/bin + install -v -m644 Linux*/lib/pkgconfig/nss.pc @THIS_COLLECT_DIR@/usr/lib/pkgconfig + + - name: libevent + source: + subdir: bundled + git: 'https://github.com/libevent/libevent.git' + tag: 'release-2.1.12-stable' + version: '2.1.12' + tools_required: + - host-autoconf-v2.69 + - host-automake-v1.16 + - host-libtool + - host-pkg-config + regenerate: + - args: ['./autogen.sh'] + # Fix an issue that prevents event_rpcgen.py from working. + - args: ['sed', '-i', 's/python/&3/', '@THIS_SOURCE_DIR@/event_rpcgen.py'] + tools_required: + - host-gcc + pkgs_required: + - mlibc + - openssl + - zlib + configure: + - args: + - '@THIS_SOURCE_DIR@/configure' + - '--host=x86_64-aero' + - '--prefix=/usr' + - '--disable-static' + build: + - args: ['make', '-j@PARALLELISM@'] + - args: ['make', 'install'] + environ: + DESTDIR: '@THIS_COLLECT_DIR@' + + - name: libvpx + source: + subdir: 'bundled' + git: 'https://chromium.googlesource.com/webm/libvpx.git' + tag: 'v1.11.0' + version: '1.11.0' + tools_required: + - host-gcc + pkgs_required: + - mlibc + configure: + # Fix ownership and permission of installed files. + - args: ['sed', '-i', 's/cp -p/cp/', '@THIS_SOURCE_DIR@/build/make/Makefile'] + - args: + - '@THIS_SOURCE_DIR@/configure' + - '--prefix=/usr' + - '--disable-static' + - '--enable-shared' + # Generic GNU target to disable optimizations + - '--force-target=generic-gnu' + - '--enable-pic' + - '--enable-vp8' + - '--enable-vp9' + - '--enable-multithread' + - '--enable-vp9-highbitdepth' + - '--disable-examples' + - '--disable-install-docs' + - '--disable-docs' + build: + - args: ['make', 'HAVE_GNU_STRIP=no', 'CC=x86_64-aero-gcc', 'LD=x86_64-aero-gcc', 'CXX=x86_64-aero-g++', 'AR=x86_64-aero-ar', 'NM=x86_64-aero-nm', '-j@PARALLELISM@'] + - args: ['make', 'install'] + environ: + DESTDIR: '@THIS_COLLECT_DIR@' + + # - name: firefox # source: # subdir: 'bundled' - # git: 'https://github.com/WebKit/WebKit.git' - # # I think? Apple is weird with naming - # tag: 'Safari-612.1.27.0.24' - # version: '2.33.3' + # git: 'https://github.com/mozilla/gecko-dev' + # commit: 7baa783763c946ff667c3faea292e91d3de1e459 + # branch: master + # configure: + # - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] + # - args: ['cp', '@SOURCE_ROOT@/extra-files/firefox/mozconfig', '@THIS_BUILD_DIR@/mozconfig'] # tools_required: # - host-gcc - # - host-cmake + # - host-rust + # - host-pkg-config + # # - virtual: pkgconfig-for-target + # # triple: "x86_64-aero" # pkgs_required: # - mlibc - # - cairo - # - fontconfig - # - freetype - # - libgcrypt + # - alsa-lib # - glib - # - harfbuzz - # - icu - # - libjpeg-turbo - # - zlib - # - libpng - # - libxml - # - atk - # - sqlite - # - libwebp # - gtk+-3 - # - libsoup - # - libxslt - # - at-spi2-core - # - libtasn - # - libx11 - # - libxcomposite - # - libxdamage - # - libxrender - # - libxt - # - mesa - # # - gst-plugins-base + # - gtk+-2 + # - icu + # - gcc + # - nspr + # - nss + # - libvpx + # - libevent + # sources_required: + # - rust-patched-libs + # build: + # - args: ['./mach', 'build'] + # environ: + # HOST_CC: 'gcc' + # HOST_CXX: 'g++' + # CC: 'x86_64-aero-gcc' + # CXX: 'x86_64-aero-g++' + # CARGOFLAGS: '--verbose' + # MOZ_RUST_TIER: '1' + # BINDGEN_EXTRA_CLANG_ARGS: '-isystem@SYSROOT_DIR/usr/include' + # # CROSS_SYSROOT: '@SYSROOT_DIR@'./system-root/usr/include/c++/11.2.0/memory + + # cargo install cbindgen + # + # pacman -S autoconf2.13 + # - name: firefox-esr + # source: + # subdir: 'bundled' + # git: 'https://github.com/mozilla/gecko-dev' + # branch: 'FIREFOX_ESR_68_0_X_RELBRANCH' # configure: - # - args: - # - 'cmake' - # - '-GNinja' - # - '-DCMAKE_TOOLCHAIN_FILE=@SOURCE_ROOT@/userland/CMakeToolchain-x86_64.cmake' - # - '-DCMAKE_INSTALL_PREFIX=/usr' - # - '-DCMAKE_SYSTEM_PROCESSOR=x86_64' - # - '-DCMAKE_BUILD_TYPE=Release' - # - '-DCMAKE_SKIP_RPATH=ON' - # - '-DPORT=GTK' - # - '-DLIB_INSTALL_DIR=/usr/lib' - # - '-DUSE_LIBHYPHEN=OFF' - # - '-DENABLE_GAMEPAD=OFF' - # - '-DENABLE_MINIBROWSER=ON' - # - '-DUSE_WOFF2=OFF' - # - '-DUSE_SYSTEMD=OFF' - # - '-DENABLE_BUBBLEWRAP_SANDBOX=OFF' - # - '-Wno-dev -G Ninja' - # - '-DUSE_LIBNOTIFY=OFF' - # - '-DUSE_SYSTEM_MALLOC=ON' - # - '-DENABLE_GEOLOCATION=OFF' - # - '-DENABLE_VIDEO=OFF' - # - '-DENABLE_WEB_AUDIO=OFF' - # - '-DENABLE_INTROSPECTION=OFF' - # - '-DUSE_LIBSECRET=OFF' - # - '-DUSE_OPENJPEG=OFF' - # - '-DENABLE_SPELLCHECK=OFF' - # - '-DENABLE_WAYLAND_TARGET=OFF' - # - '-DENABLE_X11_TARGET=ON' - # - '-DENABLE_WEBGL=ON' - # - '-DUSE_WPE_RENDERER=OFF' - # - '-DENABLE_WEBGL2=OFF' - # - '-DUSE_SOUP2=ON' - # - '-DUSE_LCMS=OFF' - # - '@THIS_SOURCE_DIR@' + # - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] + # - args: ['cp', '@SOURCE_ROOT@/extra-files/firefox/mozconfig', '@THIS_BUILD_DIR@/mozconfig'] + # tools_required: + # - host-gcc + # - host-rust + # - host-pkg-config + # # - virtual: pkgconfig-for-target + # # triple: "x86_64-aero" + # pkgs_required: + # - mlibc + # - alsa-lib + # - glib + # - gtk+-3 + # - gtk+-2 + # - gcc # build: - # - args: ['ninja', '-j8'] - # - args: ['ninja', 'install'] + # # python ~/work/aero/tools/cargo-inject-patches.py ./Cargo.toml + # - args: ['./mach', 'build'] # environ: - # DESTDIR: '@THIS_COLLECT_DIR@' + # HOST_CC: 'clang' + # CC: 'x86_64-aero-gcc' + # CARGOFLAGS: '--verbose' + # # - args: ['./mach', 'install'] + # # environ: + # # DESTDIR: '@THIS_COLLECT_DIR@' + + # /home/andy/work/aero/bundled/webkitgtk/Source/ThirdParty/ANGLE/src/common/system_utils_posix.cpp:313:14: error: ‘mkstemps’ was not declared in this scope; did you mean ‘mkstemp’? + # 313 | int fd = mkstemps(&tempFileTemplate[0], static_cast(extension.size())); + # | ^~~~~~~~ + # | mkstemp + - name: webkitgtk + source: + subdir: bundled + git: 'https://github.com/WebKit/WebKit.git' + # I think? Apple is weird with naming + tag: 'Safari-612.1.27.0.24' + version: '2.33.3' + tools_required: + - host-gcc + - host-cmake + pkgs_required: + - mlibc + - cairo + - fontconfig + - freetype + - libgcrypt + - glib + - harfbuzz + - icu + - libjpeg-turbo + - zlib + - sqlite + - libpng + - libxml + - atk + - libwebp + - gtk+-3 + - libsoup + - libxslt + - at-spi2-core + - libtasn + - libx11 + - libxcomposite + - libxdamage + - libxrender + - libxt + - mesa + configure: + - args: + - 'cmake' + - '-GNinja' + - '-DCMAKE_TOOLCHAIN_FILE=@SOURCE_ROOT@/userland/CMakeToolchain-x86_64.cmake' + - '-DCMAKE_INSTALL_PREFIX=/usr' + - '-DCMAKE_SYSTEM_PROCESSOR=x86_64' + - '-DCMAKE_BUILD_TYPE=Release' + - '-DCMAKE_SKIP_RPATH=ON' + - '-DPORT=GTK' + - '-DLIB_INSTALL_DIR=/usr/lib' + - '-DUSE_LIBHYPHEN=OFF' + - '-DENABLE_GAMEPAD=OFF' + - '-DENABLE_MINIBROWSER=ON' + - '-DUSE_WOFF2=OFF' + - '-DUSE_SYSTEMD=OFF' + - '-DENABLE_BUBBLEWRAP_SANDBOX=OFF' + - '-Wno-dev -G Ninja' + - '-DUSE_LIBNOTIFY=OFF' + - '-DUSE_SYSTEM_MALLOC=ON' + - '-DENABLE_GEOLOCATION=OFF' + - '-DENABLE_VIDEO=OFF' + - '-DENABLE_WEB_AUDIO=OFF' + - '-DENABLE_INTROSPECTION=OFF' + - '-DUSE_LIBSECRET=OFF' + - '-DUSE_OPENJPEG=OFF' + - '-DENABLE_SPELLCHECK=OFF' + - '-DENABLE_WAYLAND_TARGET=OFF' + - '-DENABLE_X11_TARGET=ON' + - '-DENABLE_WEBGL=ON' + - '-DUSE_WPE_RENDERER=OFF' + - '-DENABLE_WEBGL2=OFF' + - '-DUSE_SOUP2=ON' + - '-DUSE_LCMS=OFF' + - '@THIS_SOURCE_DIR@' + build: + - args: ['ninja', '-j6'] + # environ: + # CXXFLAGS: '-std=c++11' + - args: ['ninja', 'install'] + environ: + DESTDIR: '@THIS_COLLECT_DIR@' diff --git a/bootstrap/x11-themes.yml b/bootstrap/x11-themes.yml new file mode 100644 index 00000000000..09506dfd667 --- /dev/null +++ b/bootstrap/x11-themes.yml @@ -0,0 +1,49 @@ +packages: + # This package contains a default fallback theme for implementations of the icon theme specification. + - name: hicolor-icon-theme + source: + subdir: 'bundled' + git: 'https://gitlab.freedesktop.org/xdg/default-icon-theme.git' + tag: '0.17' + version: '0.17' + tools_required: + - host-autoconf-v2.69 + - host-automake-v1.16 + regenerate: + - args: ['./autogen.sh', '--no-configure'] + tools_required: + - host-gcc + configure: + - args: + - '@THIS_SOURCE_DIR@/configure' + - '--host=x86_64-aero' + - '--prefix=/usr' + build: + - args: ['make', '-j@PARALLELISM@'] + - args: ['make', 'install'] + environ: + DESTDIR: '@THIS_COLLECT_DIR@' + + - name: adwaita-icon-theme + source: + subdir: 'bundled' + git: 'https://gitlab.gnome.org/GNOME/adwaita-icon-theme.git' + tag: '45.0' + version: '45.0' + tools_required: + - host-gcc + pkgs_required: + - hicolor-icon-theme + configure: + - args: + - 'meson' + - '--cross-file' + - '@SOURCE_ROOT@/userland/cross-file.ini' + - '--prefix=/usr' + - '--sysconfdir=/etc' + - '@THIS_SOURCE_DIR@' + build: + - args: ['ninja'] + - args: ['ninja', 'install'] + environ: + DESTDIR: '@THIS_COLLECT_DIR@' diff --git a/bootstrap/xorg.yml b/bootstrap/xorg.yml index cfde0b56cd7..2c9f9a4b604 100644 --- a/bootstrap/xorg.yml +++ b/bootstrap/xorg.yml @@ -1008,8 +1008,8 @@ packages: source: subdir: 'bundled' git: 'https://gitlab.freedesktop.org/xorg/xserver.git' - tag: 'xorg-server-21.1.8' - version: '21.1.8' + tag: 'xorg-server-1.20.14' + version: '1.20.14' tools_required: - host-autoconf-v2.69 - host-automake-v1.16 @@ -2357,6 +2357,104 @@ packages: # post_install: # - args: 'glib-compile-schemas /usr/share/glib-2.0/schemas' + # Deprecated, please don't depend on this anymore. Only here for gtklife and hexchat. + - name: gtk+-2 + source: + subdir: 'bundled' + url: 'https://download.gnome.org/sources/gtk+/2.24/gtk+-2.24.32.tar.xz' + format: 'tar.xz' + checksum: blake2b:03f4c0a8be98473f62bc8c86859937969c4169960a5f93d37ff6dcde00413215fa6c7125b15781bf50d67b40aa0056cb71b83fb50acb2c3467b5deb3c8d938f0 + extract_path: 'gtk+-2.24.32' + patch-path-strip: 1 + version: '2.24.32' + tools_required: + - host-autoconf-v2.69 + - host-automake-v1.16 + - host-libtool + - host-pkg-config + - host-xorg-macros + - host-glib + regenerate: + - args: ['autoreconf', '-fvi'] + tools_required: + - host-gcc + - virtual: pkgconfig-for-target + triple: "x86_64-aero" + pkgs_required: + - mlibc + - atk + - cairo + - glib + - gdk-pixbuf + - libx11 + - libxext + - libxcb + - pango + configure: + - args: + - '@THIS_SOURCE_DIR@/configure' + - '--host=x86_64-aero' + - '--prefix=/usr' + - '--sysconfdir=/etc' + - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. + - '--disable-gtk-doc-html' + - '--disable-cups' + - '--disable-papi' + - '--disable-introspection' + - '--disable-glibtest' + - '--disable-test-print-backend' + - '--enable-xkb' + environ: + ac_cv_func_getresuid: 'no' + build: + - args: ['make', '-j@PARALLELISM@'] + - args: ['make', 'install'] + environ: + DESTDIR: '@THIS_COLLECT_DIR@' + quiet: true + # Rename a file to avoid conflicts, we will use gtk3 as default, so rename this one. + - args: ['mv', '-v', '@THIS_COLLECT_DIR@/usr/bin/gtk-update-icon-cache', '@THIS_COLLECT_DIR@/usr/bin/gtk2-update-icon-cache'] + scripts: + post_install: + - args: ['gtk-query-immodules-2.0', '--update-cache'] + - args: ['glib-compile-schemas', '/usr/share/glib-2.0/schemas'] + + # Collection of GSettings schemas for GNOME desktop + - name: gsettings-desktop-schemas + source: + subdir: 'bundled' + git: 'https://gitlab.gnome.org/GNOME/gsettings-desktop-schemas.git' + tag: '42.0' + version: '42.0' + tools_required: + - host-gcc + - host-gobject-introspection + - host-libtool + - host-pkg-config + - virtual: pkgconfig-for-target + triple: "x86_64-aero" + pkgs_required: + - mlibc + - glib + configure: + - args: | + sed -i -r 's:"(/system):"/org/gnome\1:g' @THIS_SOURCE_DIR@/schemas/*.in + - args: + - 'meson' + - '--cross-file' + - '@SOURCE_ROOT@/userland/cross-file.ini' + - '--prefix=/usr' + - '-Dintrospection=false' + - '@THIS_SOURCE_DIR@' + build: + - args: ['ninja'] + - args: ['ninja', 'install'] + environ: + DESTDIR: '@THIS_COLLECT_DIR@' + scripts: + post_install: + - args: 'glib-compile-schemas /usr/share/glib-2.0/schemas' + - name: gtk+-3 source: subdir: 'bundled' @@ -2391,7 +2489,7 @@ packages: - libxi - harfbuzz - libxcursor - #- gsettings-desktop-schemas + - gsettings-desktop-schemas - dbus configure: - args: @@ -2502,3 +2600,38 @@ packages: - args: ['make', 'install'] environ: DESTDIR: '@THIS_COLLECT_DIR@' + + - name: gdk-pixbuf-xlib + source: + subdir: 'bundled' + url: 'https://download.gnome.org/sources/gdk-pixbuf-xlib/2.40/gdk-pixbuf-xlib-2.40.2.tar.xz' + format: 'tar.xz' + checksum: blake2b:a515e86bc69f59910f61fe9c275ab89c0732f0aa2cfb614ac94e597de420d25708a11b9b21313c7cfe3763434f45a8318412ae5889c24c8ed57dac68e09c0227 + extract_path: 'gdk-pixbuf-xlib-2.40.2' + patch-path-strip: 1 + version: '2.40.2' + tools_required: + - host-gcc + - host-libtool + - host-pkg-config + - virtual: pkgconfig-for-target + triple: "x86_64-aero" + pkgs_required: + - mlibc + - gdk-pixbuf + - libx11 + configure: + - args: + - 'meson' + - '--cross-file' + - '@SOURCE_ROOT@/userland/cross-file.ini' + - '--prefix=/usr' + - '@THIS_SOURCE_DIR@' + build: + - args: ['ninja'] + - args: ['ninja', 'install'] + environ: + DESTDIR: '@THIS_COLLECT_DIR@' + scripts: + post_install: + - args: ['gdk-pixbuf-query-loaders', '--update-cache'] diff --git a/extra-files/firefox/mozconfig b/extra-files/firefox/mozconfig new file mode 100644 index 00000000000..fe6dcdbdeb6 --- /dev/null +++ b/extra-files/firefox/mozconfig @@ -0,0 +1,26 @@ +ac_add_options --disable-necko-wifi +ac_add_options --target=x86_64-aero +ac_add_options --with-toolchain-prefix=x86_64-aero +ac_add_options --enable-project=browser +ac_add_options --enable-alsa +ac_add_options --prefix=/usr + +ac_add_options --enable-optimize + +# use system libs if possible +ac_add_options --with-system-nss +ac_add_options --with-system-jpeg +ac_add_options --with-system-zlib +ac_add_options --with-system-icu +ac_add_options --with-system-libevent +ac_add_options --with-system-nspr +ac_add_options --with-system-nss +ac_add_options --with-system-webp + +ac_add_options --enable-default-toolkit=cairo-gtk3 + +ac_add_options --disable-pulseaudio +ac_add_options --disable-crashreporter +ac_add_options --disable-dbus +ac_add_options --disable-updater +ac_add_options --disable-tests diff --git a/patches/alsa-lib/alsa-lib.patch b/patches/alsa-lib/alsa-lib.patch new file mode 100644 index 00000000000..1ebb5b22abc --- /dev/null +++ b/patches/alsa-lib/alsa-lib.patch @@ -0,0 +1,124 @@ +From 3b4d643d6648ead86648e0033868f903af6aeb70 Mon Sep 17 00:00:00 2001 +From: Dennis Bonke +Date: Wed, 2 Aug 2023 13:50:05 +0200 +Subject: [PATCH] Add Managarm support + +Signed-off-by: Dennis Bonke +--- + src/conf.c | 10 ++++++++++ + src/pcm/pcm_ladspa.c | 5 +++++ + src/ucm/main.c | 5 +++++ + src/ucm/parser.c | 8 ++++++++ + src/ucm/ucm_exec.c | 7 +++++++ + src/ucm/ucm_subs.c | 5 +++++ + 6 files changed, 40 insertions(+) + +diff --git a/src/conf.c b/src/conf.c +index da51182..743e4cd 100644 +--- a/src/conf.c ++++ b/src/conf.c +@@ -435,6 +435,16 @@ beginning:

+ #include + #endif + ++#ifdef __aero__ ++#define stat64 stat ++#define dirent64 dirent ++#define lstat64 lstat ++#define readdir64 readdir ++#define scandir64 scandir ++#define versionsort64 versionsort ++typedef ino_t ino64_t; ++#endif ++ + #ifndef DOC_HIDDEN + + #ifdef HAVE_LIBPTHREAD +diff --git a/src/pcm/pcm_ladspa.c b/src/pcm/pcm_ladspa.c +index 9b2b32d..dde5d2a 100644 +--- a/src/pcm/pcm_ladspa.c ++++ b/src/pcm/pcm_ladspa.c +@@ -41,6 +41,11 @@ + + #include "ladspa.h" + ++#ifdef __aero__ ++#define readdir64 readdir ++#define dirent64 dirent ++#endif ++ + #ifndef PIC + /* entry for static linking */ + const char *_snd_module_pcm_ladspa = ""; +diff --git a/src/ucm/main.c b/src/ucm/main.c +index 66ffd00..7448963 100644 +--- a/src/ucm/main.c ++++ b/src/ucm/main.c +@@ -40,6 +40,11 @@ + #include + #include + ++#ifdef __aero__ ++#define stat64 stat ++#define fstat64 fstat ++#endif ++ + /* + * misc + */ +diff --git a/src/ucm/parser.c b/src/ucm/parser.c +index c111661..2115ac7 100644 +--- a/src/ucm/parser.c ++++ b/src/ucm/parser.c +@@ -36,6 +36,14 @@ + #include + #include + ++#ifdef __aero__ ++#define stat64 stat ++#define lstat64 lstat ++#define scandir64 scandir ++#define versionsort64 versionsort ++#define dirent64 dirent ++#endif ++ + static int filename_filter(const struct dirent64 *dirent); + + static int parse_sequence(snd_use_case_mgr_t *uc_mgr, +diff --git a/src/ucm/ucm_exec.c b/src/ucm/ucm_exec.c +index 276cf59..a6890dd 100644 +--- a/src/ucm/ucm_exec.c ++++ b/src/ucm/ucm_exec.c +@@ -42,6 +42,13 @@ extern char **environ; + #endif + #endif + ++#ifdef __aero__ ++#define stat64 stat ++#define dirent64 dirent ++#define lstat64 lstat ++#define readdir64 readdir ++#endif ++ + static pthread_mutex_t fork_lock = PTHREAD_MUTEX_INITIALIZER; + + /* +diff --git a/src/ucm/ucm_subs.c b/src/ucm/ucm_subs.c +index e62290e..b4dbff2 100644 +--- a/src/ucm/ucm_subs.c ++++ b/src/ucm/ucm_subs.c +@@ -30,6 +30,11 @@ + #include + #include + ++#ifdef __aero__ ++#define stat64 stat ++#define lstat64 lstat ++#endif ++ + static char *rval_open_name(snd_use_case_mgr_t *uc_mgr) + { + const char *name; +-- +2.40.1 + diff --git a/patches/mlibc/mlibc.patch b/patches/mlibc/mlibc.patch index e16aed655cc..924b3edfad2 100644 --- a/patches/mlibc/mlibc.patch +++ b/patches/mlibc/mlibc.patch @@ -1,4 +1,4 @@ -From 1e4603c9de5ce2dcb596dfb95254b0ae119d1036 Mon Sep 17 00:00:00 2001 +From d33a19a85fd625a2acf53f95f32c369b7f91e230 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 3 Aug 2023 16:36:12 +1000 Subject: [PATCH] socket: implement shutdown(2) diff --git a/patches/nss/0001-Add-a-missing-include.patch b/patches/nss/0001-Add-a-missing-include.patch new file mode 100644 index 00000000000..eb71fcab2a5 --- /dev/null +++ b/patches/nss/0001-Add-a-missing-include.patch @@ -0,0 +1,24 @@ +From 8c7f96493b8706d43b30f49d56e0e84ee27fe65e Mon Sep 17 00:00:00 2001 +From: Dennis Bonke +Date: Wed, 27 Apr 2022 20:27:21 +0200 +Subject: [PATCH 1/2] Add a missing include + +Signed-off-by: Dennis Bonke +--- + lib/dbm/src/h_page.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/lib/dbm/src/h_page.c b/lib/dbm/src/h_page.c +index d4e4ff6..7b3271e 100644 +--- a/lib/dbm/src/h_page.c ++++ b/lib/dbm/src/h_page.c +@@ -81,6 +81,7 @@ static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94"; + #endif + + #include ++#include + + #include "mcom_db.h" + #include "hash.h" +-- +2.36.0 diff --git a/patches/nss/0002-NSS-Standalone-patch.patch b/patches/nss/0002-NSS-Standalone-patch.patch new file mode 100644 index 00000000000..cd78732af8a --- /dev/null +++ b/patches/nss/0002-NSS-Standalone-patch.patch @@ -0,0 +1,258 @@ +From ee4b3e43e0143f94289c418c0db5f803119e8be6 Mon Sep 17 00:00:00 2001 +From: Dennis Bonke +Date: Wed, 27 Apr 2022 20:35:40 +0200 +Subject: [PATCH 2/2] NSS Standalone patch + +Taken from Beyond Linux From Scratch (https://www.linuxfromscratch.org/patches/blfs/svn/nss-3.77-standalone-1.patch) + +Adds auto-generated nss.pc and nss-config script, and allows building without nspr in the source tree. +Minimum NSPR version is now read out from package, instead of hardcoded value in the patch. + +Signed-off-by: Dennis Bonke +--- + config/Makefile | 41 ++++++++++++ + config/nss-config.in | 152 +++++++++++++++++++++++++++++++++++++++++++ + config/nss.pc.in | 11 ++++ + manifest.mn | 2 +- + 4 files changed, 205 insertions(+), 1 deletion(-) + create mode 100644 config/Makefile + create mode 100644 config/nss-config.in + create mode 100644 config/nss.pc.in + +diff --git a/config/Makefile b/config/Makefile +new file mode 100644 +index 0000000..662020a +--- /dev/null ++++ b/config/Makefile +@@ -0,0 +1,41 @@ ++CORE_DEPTH = .. ++DEPTH = .. ++ ++include $(CORE_DEPTH)/coreconf/config.mk ++ ++NSS_MAJOR_VERSION = `grep "NSS_VMAJOR" ../lib/nss/nss.h | awk '{print $$3}'` ++NSS_MINOR_VERSION = `grep "NSS_VMINOR" ../lib/nss/nss.h | awk '{print $$3}'` ++NSS_PATCH_VERSION = `grep "NSS_VPATCH" ../lib/nss/nss.h | awk '{print $$3}'` ++NSS_NSPR_MINIMUM = `head -n1 ../automation/release/nspr-version.txt` ++PREFIX = /usr ++ ++all: export libs ++ ++export: ++ # Create the nss.pc file ++ mkdir -p $(DIST)/lib/pkgconfig ++ sed -e "s,@prefix@,$(PREFIX)," \ ++ -e "s,@exec_prefix@,\$${prefix}," \ ++ -e "s,@libdir@,\$${prefix}/lib," \ ++ -e "s,@includedir@,\$${prefix}/include/nss," \ ++ -e "s,@NSS_MAJOR_VERSION@,$(NSS_MAJOR_VERSION),g" \ ++ -e "s,@NSS_MINOR_VERSION@,$(NSS_MINOR_VERSION)," \ ++ -e "s,@NSS_PATCH_VERSION@,$(NSS_PATCH_VERSION)," \ ++ -e "s,@NSS_NSPR_MINIMUM@,$(NSS_NSPR_MINIMUM)," \ ++ nss.pc.in > nss.pc ++ chmod 0644 nss.pc ++ cp -v nss.pc $(DIST)/lib/pkgconfig ++ ++ # Create the nss-config script ++ mkdir -p $(DIST)/bin ++ sed -e "s,@prefix@,$(PREFIX)," \ ++ -e "s,@NSS_MAJOR_VERSION@,$(NSS_MAJOR_VERSION)," \ ++ -e "s,@NSS_MINOR_VERSION@,$(NSS_MINOR_VERSION)," \ ++ -e "s,@NSS_PATCH_VERSION@,$(NSS_PATCH_VERSION)," \ ++ nss-config.in > nss-config ++ chmod 0755 nss-config ++ cp -v nss-config $(DIST)/bin ++ ++libs: ++ ++dummy: all export libs +diff --git a/config/nss-config.in b/config/nss-config.in +new file mode 100644 +index 0000000..7e3750d +--- /dev/null ++++ b/config/nss-config.in +@@ -0,0 +1,152 @@ ++#!/bin/sh ++ ++prefix=@prefix@ ++ ++major_version=@NSS_MAJOR_VERSION@ ++minor_version=@NSS_MINOR_VERSION@ ++patch_version=@NSS_PATCH_VERSION@ ++ ++usage() ++{ ++ cat <&2 ++fi ++ ++lib_nss=yes ++lib_nssutil=yes ++lib_smime=yes ++lib_ssl=yes ++lib_softokn=yes ++ ++while test $# -gt 0; do ++ case "$1" in ++ -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; ++ *) optarg= ;; ++ esac ++ ++ case $1 in ++ --prefix=*) ++ prefix=$optarg ++ ;; ++ --prefix) ++ echo_prefix=yes ++ ;; ++ --exec-prefix=*) ++ exec_prefix=$optarg ++ ;; ++ --exec-prefix) ++ echo_exec_prefix=yes ++ ;; ++ --includedir=*) ++ includedir=$optarg ++ ;; ++ --includedir) ++ echo_includedir=yes ++ ;; ++ --libdir=*) ++ libdir=$optarg ++ ;; ++ --libdir) ++ echo_libdir=yes ++ ;; ++ --version) ++ echo ${major_version}.${minor_version}.${patch_version} ++ ;; ++ --cflags) ++ echo_cflags=yes ++ ;; ++ --libs) ++ echo_libs=yes ++ ;; ++ nss) ++ lib_nss=yes ++ ;; ++ nssutil) ++ lib_nssutil=yes ++ ;; ++ smime) ++ lib_smime=yes ++ ;; ++ ssl) ++ lib_ssl=yes ++ ;; ++ softokn) ++ lib_softokn=yes ++ ;; ++ *) ++ usage 1 1>&2 ++ ;; ++ esac ++ shift ++done ++ ++# Set variables that may be dependent upon other variables ++if test -z "$exec_prefix"; then ++ exec_prefix=`pkg-config --variable=exec_prefix nss` ++fi ++if test -z "$includedir"; then ++ includedir=`pkg-config --variable=includedir nss` ++fi ++if test -z "$libdir"; then ++ libdir=`pkg-config --variable=libdir nss` ++fi ++ ++if test "$echo_prefix" = "yes"; then ++ echo $prefix ++fi ++ ++if test "$echo_exec_prefix" = "yes"; then ++ echo $exec_prefix ++fi ++ ++if test "$echo_includedir" = "yes"; then ++ echo $includedir ++fi ++ ++if test "$echo_libdir" = "yes"; then ++ echo $libdir ++fi ++ ++if test "$echo_cflags" = "yes"; then ++ echo -I$includedir ++fi ++ ++if test "$echo_libs" = "yes"; then ++ libdirs="-L$libdir" ++ if test -n "$lib_nss"; then ++ libdirs="$libdirs -lnss${major_version}" ++ fi ++ if test -n "$lib_nssutil"; then ++ libdirs="$libdirs -lnssutil${major_version}" ++ fi ++ if test -n "$lib_smime"; then ++ libdirs="$libdirs -lsmime${major_version}" ++ fi ++ if test -n "$lib_ssl"; then ++ libdirs="$libdirs -lssl${major_version}" ++ fi ++ if test -n "$lib_softokn"; then ++ libdirs="$libdirs -lsoftokn${major_version}" ++ fi ++ echo $libdirs ++fi +diff --git a/config/nss.pc.in b/config/nss.pc.in +new file mode 100644 +index 0000000..c8c263d +--- /dev/null ++++ b/config/nss.pc.in +@@ -0,0 +1,11 @@ ++prefix=@prefix@ ++exec_prefix=@exec_prefix@ ++libdir=@libdir@ ++includedir=@includedir@ ++ ++Name: NSS ++Description: Network Security Services ++Version: @NSS_MAJOR_VERSION@.@NSS_MINOR_VERSION@.@NSS_PATCH_VERSION@ ++Requires: nspr >= @NSS_NSPR_MINIMUM@ ++Libs: -L@libdir@ -lnss@NSS_MAJOR_VERSION@ -lnssutil@NSS_MAJOR_VERSION@ -lsmime@NSS_MAJOR_VERSION@ -lssl@NSS_MAJOR_VERSION@ -lsoftokn@NSS_MAJOR_VERSION@ ++Cflags: -I${includedir} +diff --git a/manifest.mn b/manifest.mn +index fbc420a..b983d88 100644 +--- a/manifest.mn ++++ b/manifest.mn +@@ -10,7 +10,7 @@ IMPORTS = nspr20/v4.8 \ + + RELEASE = nss + +-DIRS = coreconf lib cmd cpputil gtests ++DIRS = coreconf lib cmd cpputil gtests config + + HAVE_ALL_TARGET := 1 + +-- +2.36.0 diff --git a/patches/rust-getrandom/rust-getrandom.patch b/patches/rust-getrandom/rust-getrandom.patch new file mode 100644 index 00000000000..9b244bc8249 --- /dev/null +++ b/patches/rust-getrandom/rust-getrandom.patch @@ -0,0 +1,53 @@ +From 7ffdb350f8bf10017165131c8433e8371df89754 Mon Sep 17 00:00:00 2001 +From: Dennis Bonke +Date: Mon, 7 Aug 2023 16:07:20 +0200 +Subject: [PATCH] Add aero support + +Signed-off-by: Dennis Bonke +--- + src/lib.rs | 2 +- + src/use_file.rs | 1 + + src/util_libc.rs | 2 +- + 3 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/lib.rs b/src/lib.rs +index 931856f..e700572 100644 +--- a/src/lib.rs ++++ b/src/lib.rs +@@ -215,7 +215,7 @@ pub use crate::error::Error; + // The function MUST NOT ever write uninitialized bytes into `dest`, + // regardless of what value it returns. + cfg_if! { +- if #[cfg(any(target_os = "haiku", target_os = "redox", target_os = "nto", target_os = "aix"))] { ++ if #[cfg(any(target_os = "haiku", target_os = "redox", target_os = "nto", target_os = "aix", target_os = "aero"))] { + mod util_libc; + #[path = "use_file.rs"] mod imp; + } else if #[cfg(any(target_os = "android", target_os = "linux"))] { +diff --git a/src/use_file.rs b/src/use_file.rs +index a6ef0d2..ef9bf54 100644 +--- a/src/use_file.rs ++++ b/src/use_file.rs +@@ -33,6 +33,7 @@ const FILE_PATH: &str = "/dev/random\0"; + target_os = "haiku", + target_os = "macos", + target_os = "nto", ++ target_os = "aero", + ))] + const FILE_PATH: &str = "/dev/urandom\0"; + +diff --git a/src/util_libc.rs b/src/util_libc.rs +index de1455c..65bc1a6 100644 +--- a/src/util_libc.rs ++++ b/src/util_libc.rs +@@ -19,7 +19,7 @@ use libc::c_void; + cfg_if! { + if #[cfg(any(target_os = "netbsd", target_os = "openbsd", target_os = "android"))] { + use libc::__errno as errno_location; +- } else if #[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "redox"))] { ++ } else if #[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "redox", target_os = "aero"))] { + use libc::__errno_location as errno_location; + } else if #[cfg(any(target_os = "solaris", target_os = "illumos"))] { + use libc::___errno as errno_location; +-- +2.42.0 + diff --git a/patches/rust-libc/rust-libc.patch b/patches/rust-libc/rust-libc.patch deleted file mode 100644 index 04bc44bb09e..00000000000 --- a/patches/rust-libc/rust-libc.patch +++ /dev/null @@ -1,996 +0,0 @@ -From a23324fdc96748fc48b5deb824db43b693b6c5dc Mon Sep 17 00:00:00 2001 -From: Anhad Singh -Date: Sun, 21 May 2023 12:58:08 +1000 -Subject: [PATCH] - ---- - .../linux_like/linux/gnu/b64/x86_64/mod.rs | 4 +- - src/unix/linux_like/linux/gnu/mod.rs | 4 +- - src/unix/linux_like/linux/mod.rs | 28 +- - src/unix/mlibc/mod.rs | 568 ++++++++++++++++-- - 4 files changed, 550 insertions(+), 54 deletions(-) - -diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs -index e6307e2..cae81c4 100644 ---- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs -+++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs -@@ -330,7 +330,7 @@ cfg_if! { - impl Eq for user_fpregs_struct {} - - impl ::fmt::Debug for user_fpregs_struct { -- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { - f.debug_struct("user_fpregs_struct") - .field("cwd", &self.cwd) - .field("ftw", &self.ftw) -@@ -375,7 +375,7 @@ cfg_if! { - impl Eq for ucontext_t {} - - impl ::fmt::Debug for ucontext_t { -- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { - f.debug_struct("ucontext_t") - .field("uc_flags", &self.uc_flags) - .field("uc_link", &self.uc_link) -diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs -index b8b6ded..98b49a0 100644 ---- a/src/unix/linux_like/linux/gnu/mod.rs -+++ b/src/unix/linux_like/linux/gnu/mod.rs -@@ -519,7 +519,7 @@ cfg_if! { - impl Eq for utmpx {} - - impl ::fmt::Debug for utmpx { -- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { - f.debug_struct("utmpx") - .field("ut_type", &self.ut_type) - .field("ut_pid", &self.ut_pid) -@@ -568,7 +568,7 @@ cfg_if! { - - #[cfg(libc_union)] - impl ::fmt::Debug for __c_anonymous_ptrace_syscall_info_data { -- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { - unsafe { - f.debug_struct("__c_anonymous_ptrace_syscall_info_data") - .field("entry", &self.entry) -diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs -index be12190..c8762d5 100644 ---- a/src/unix/linux_like/linux/mod.rs -+++ b/src/unix/linux_like/linux/mod.rs -@@ -840,7 +840,7 @@ cfg_if! { - } - impl Eq for sockaddr_nl {} - impl ::fmt::Debug for sockaddr_nl { -- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { - f.debug_struct("sockaddr_nl") - .field("nl_family", &self.nl_family) - .field("nl_pid", &self.nl_pid) -@@ -873,7 +873,7 @@ cfg_if! { - impl Eq for dirent {} - - impl ::fmt::Debug for dirent { -- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { - f.debug_struct("dirent") - .field("d_ino", &self.d_ino) - .field("d_off", &self.d_off) -@@ -911,7 +911,7 @@ cfg_if! { - impl Eq for dirent64 {} - - impl ::fmt::Debug for dirent64 { -- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { - f.debug_struct("dirent64") - .field("d_ino", &self.d_ino) - .field("d_off", &self.d_off) -@@ -941,7 +941,7 @@ cfg_if! { - impl Eq for pthread_cond_t {} - - impl ::fmt::Debug for pthread_cond_t { -- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { - f.debug_struct("pthread_cond_t") - // FIXME: .field("size", &self.size) - .finish() -@@ -963,7 +963,7 @@ cfg_if! { - impl Eq for pthread_mutex_t {} - - impl ::fmt::Debug for pthread_mutex_t { -- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { - f.debug_struct("pthread_mutex_t") - // FIXME: .field("size", &self.size) - .finish() -@@ -985,7 +985,7 @@ cfg_if! { - impl Eq for pthread_rwlock_t {} - - impl ::fmt::Debug for pthread_rwlock_t { -- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { - f.debug_struct("pthread_rwlock_t") - // FIXME: .field("size", &self.size) - .finish() -@@ -1007,7 +1007,7 @@ cfg_if! { - impl Eq for pthread_barrier_t {} - - impl ::fmt::Debug for pthread_barrier_t { -- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { - f.debug_struct("pthread_barrier_t") - .field("size", &self.size) - .finish() -@@ -1041,7 +1041,7 @@ cfg_if! { - impl Eq for sockaddr_alg {} - - impl ::fmt::Debug for sockaddr_alg { -- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { - f.debug_struct("sockaddr_alg") - .field("salg_family", &self.salg_family) - .field("salg_type", &self.salg_type) -@@ -1072,7 +1072,7 @@ cfg_if! { - impl Eq for uinput_setup {} - - impl ::fmt::Debug for uinput_setup { -- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { - f.debug_struct("uinput_setup") - .field("id", &self.id) - .field("name", &&self.name[..]) -@@ -1103,7 +1103,7 @@ cfg_if! { - impl Eq for uinput_user_dev {} - - impl ::fmt::Debug for uinput_user_dev { -- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { - f.debug_struct("uinput_setup") - .field("name", &&self.name[..]) - .field("id", &self.id) -@@ -1152,7 +1152,7 @@ cfg_if! { - - #[allow(deprecated)] - impl ::fmt::Debug for af_alg_iv { -- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { - f.debug_struct("af_alg_iv") - .field("ivlen", &self.ivlen) - .finish() -@@ -1176,7 +1176,7 @@ cfg_if! { - } - impl Eq for mq_attr {} - impl ::fmt::Debug for mq_attr { -- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { - f.debug_struct("mq_attr") - .field("mq_flags", &self.mq_flags) - .field("mq_maxmsg", &self.mq_maxmsg) -@@ -1195,7 +1195,7 @@ cfg_if! { - } - #[cfg(libc_union)] - impl ::fmt::Debug for __c_anonymous_ifr_ifru { -- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { - f.debug_struct("ifr_ifru") - .field("ifru_addr", unsafe { &self.ifru_addr }) - .field("ifru_dstaddr", unsafe { &self.ifru_dstaddr }) -@@ -1214,7 +1214,7 @@ cfg_if! { - } - } - impl ::fmt::Debug for ifreq { -- fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { - f.debug_struct("ifreq") - .field("ifr_name", &self.ifr_name) - .field("ifr_ifru", &self.ifr_ifru) -diff --git a/src/unix/mlibc/mod.rs b/src/unix/mlibc/mod.rs -index 2046530..8a4f974 100644 ---- a/src/unix/mlibc/mod.rs -+++ b/src/unix/mlibc/mod.rs -@@ -47,7 +47,6 @@ pub type fsfilcnt_t = ::c_uint; - pub type sigset_t = ::c_long; - - // abis/mlibc/termios.h --pub type cc_t = ::c_uint; - pub type speed_t = ::c_uint; - pub type tcflag_t = ::c_uint; - -@@ -70,7 +69,7 @@ pub type in_addr_t = u32; - pub type in_port_t = u16; - - // abis/mlibc/socket.h --pub type sa_family_t = ::c_uint; -+pub type sa_family_t = ::c_int; - - // options/linux/include/sys/poll.h - pub type nfds_t = ::size_t; -@@ -112,7 +111,7 @@ s! { - pub sa_handler: ::Option, - pub sa_mask: sigset_t, - pub sa_flags: ::c_int, -- pub sa_sigaction: ::Option, -+ pub sa_sigaction: ::sighandler_t, - } - - // abis/mlibc/termios.h -@@ -121,7 +120,8 @@ s! { - pub c_oflag: tcflag_t, - pub c_cflag: tcflag_t, - pub c_lflag: tcflag_t, -- pub c_cc: [cc_t; NCCS], -+ pub c_line: ::cc_t, -+ pub c_cc: [::cc_t; NCCS], - pub ibaud: speed_t, - pub obaud: speed_t, - } -@@ -174,7 +174,7 @@ s! { - pub sin_family: sa_family_t, - pub sin_port: in_port_t, - pub sin_addr: in_addr, -- pub __padding: [u8; 8], // std relies on this being public -+ pub sin_zero: [u8; 8], // std relies on this being public - } - pub struct sockaddr_in6 { - pub sin6_family: sa_family_t, -@@ -238,22 +238,51 @@ s! { - // options/posix/include/bits/posix/pthread_t.h - pub struct __mlibc_thread_data {} - -+ // options/posix/include/sched.h -+ pub struct sched_param { -+ pub sched_priority: ::c_int, -+ } -+ -+ pub struct __mlibc_cpu_set { -+ pub __bits: [::c_ulong; 128 / core::mem::size_of::<::c_long>()], -+ } -+ - // options/posix/include/bits/posix/pthread.h - pub struct pthread_attr_t { -- pub __mlibc_deatchstate: ::c_int, -+ pub __mlibc_guardsize: ::size_t, -+ pub __mlibc_stacksize: ::size_t, -+ pub __mlibc_stackaddr: *mut ::c_void, -+ pub __mlibc_detachstate: ::c_int, -+ pub __mlibc_scope: ::c_int, -+ pub __mlibc_inheritsched: ::c_int, -+ pub __mlibc_schedparam: sched_param, -+ pub __mlibc_schedpolicy: ::c_int, -+ pub __mlibc_cpuset: *mut __mlibc_cpu_set, -+ pub __mlibc_cpusetsize: ::size_t, -+ pub __mlibc_sigmask: sigset_t, -+ pub __mlibc_sigmaskset: ::c_int, - } - pub struct pthread_cond_t { - pub __mlibc_seq: ::c_uint, -+ pub __mlibc_flags: ::c_uint, -+ pub __mlibc_clock: clockid_t, -+ } -+ pub struct pthread_condattr_t { -+ pub __mlibc_pshared: ::c_int, -+ pub __mlibc_clock: clockid_t, - } -- pub struct pthread_condattr_t {} - pub struct pthread_mutex_t { - pub __mlibc_state: ::c_uint, - pub __mlibc_recursion: ::c_uint, - pub __mlibc_flags: ::c_uint, -+ pub __mlibc_prioceiling: ::c_int, - } - pub struct pthread_mutexattr_t { - pub __mlibc_type: ::c_int, - pub __mlibc_robust: ::c_int, -+ pub __mlibc_protocol: ::c_int, -+ pub __mlibc_pshared: ::c_int, -+ pub __mlibc_prioceiling: ::c_int, - } - pub struct pthread_rwlock_t { - pub __mlibc_m: ::c_uint, -@@ -319,10 +348,172 @@ s! { - pub struct fd_set { - pub fds_bits: [c_char; 128], - } -+ -+ pub struct cmsghdr { -+ // FIXME: mio needs this to be a size_t for some reason -+ // pub cmsg_len: ::socklen_t, -+ pub cmsg_len: ::size_t, -+ pub cmsg_level: ::c_int, -+ pub cmsg_type: ::c_int, -+ } -+ -+ pub struct msghdr { -+ pub msg_name: *mut ::c_void, -+ pub msg_namelen: ::socklen_t, -+ pub msg_iov: *mut ::iovec, -+ pub msg_iovlen: ::c_int, -+ pub msg_control: *mut ::c_void, -+ pub msg_controllen: ::size_t, // nix assumes this is a size_t -+ pub msg_flags: ::c_int, -+ } -+ -+ // options/linux-headers/include/linux/if_packet.h -+ pub struct sockaddr_ll { -+ pub sll_family: ::c_ushort, -+ pub sll_protocol: ::c_ushort, -+ pub sll_ifindex: ::c_int, -+ pub sll_hatype: ::c_ushort, -+ pub sll_pkttype: ::c_uchar, -+ pub sll_halen: ::c_uchar, -+ pub sll_addr: [::c_uchar; 8] -+ } -+ -+ pub struct flock { -+ pub l_type: ::c_short, -+ pub l_whence: ::c_short, -+ pub l_start: ::off_t, -+ pub l_len: ::off_t, -+ pub l_pid: ::pid_t, -+ } -+ -+ pub struct __c_anonymous_ifru_map { -+ pub mem_start: ::c_ulong, -+ pub mem_end: ::c_ulong, -+ pub base_addr: ::c_ushort, -+ pub irq: ::c_uchar, -+ pub dma: ::c_uchar, -+ pub port: ::c_uchar, -+ } -+} -+ -+cfg_if! { -+ if #[cfg(feature = "extra_traits")] { -+ impl ::fmt::Debug for epoll_event { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { -+ let events = self.events; -+ let u64 = self.u64; -+ f.debug_struct("epoll_event") -+ .field("events", &events) -+ .field("u64", &u64) -+ .finish() -+ } -+ } -+ impl PartialEq for epoll_event { -+ fn eq(&self, other: &epoll_event) -> bool { -+ self.events == other.events -+ && self.u64 == other.u64 -+ } -+ } -+ impl Eq for epoll_event {} -+ impl ::hash::Hash for epoll_event { -+ fn hash(&self, state: &mut H) { -+ let events = self.events; -+ let u64 = self.u64; -+ events.hash(state); -+ u64.hash(state); -+ } -+ } -+ -+ #[cfg(libc_union)] -+ impl ::fmt::Debug for __c_anonymous_ifr_ifru { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { -+ f.debug_struct("ifr_ifru") -+ .field("ifru_addr", unsafe { &self.ifru_addr }) -+ .field("ifru_dstaddr", unsafe { &self.ifru_dstaddr }) -+ .field("ifru_broadaddr", unsafe { &self.ifru_broadaddr }) -+ .field("ifru_netmask", unsafe { &self.ifru_netmask }) -+ .field("ifru_hwaddr", unsafe { &self.ifru_hwaddr }) -+ .field("ifru_flags", unsafe { &self.ifru_flags }) -+ .field("ifru_ifindex", unsafe { &self.ifru_ifindex }) -+ .field("ifru_metric", unsafe { &self.ifru_metric }) -+ .field("ifru_mtu", unsafe { &self.ifru_mtu }) -+ .field("ifru_map", unsafe { &self.ifru_map }) -+ .field("ifru_slave", unsafe { &self.ifru_slave }) -+ .field("ifru_newname", unsafe { &self.ifru_newname }) -+ .field("ifru_data", unsafe { &self.ifru_data }) -+ .finish() -+ } -+ } -+ -+ impl ::fmt::Debug for ifreq { -+ fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result { -+ f.debug_struct("ifreq") -+ .field("ifr_name", &self.ifr_name) -+ .field("ifr_ifru", &self.ifr_ifru) -+ .finish() -+ } -+ } -+ } -+} -+ -+s_no_extra_traits! { -+ // options/linux/include/sys/epoll.h -+ #[cfg_attr(target_arch = "x86_64", repr(packed))] -+ pub struct epoll_event { -+ pub events: u32, -+ pub u64: u64, -+ } -+ -+ // options/posix/include/net/if.h -+ #[cfg(libc_union)] -+ pub union __c_anonymous_ifr_ifru { -+ pub ifru_addr: ::sockaddr, -+ pub ifru_dstaddr: ::sockaddr, -+ pub ifru_broadaddr: ::sockaddr, -+ pub ifru_netmask: ::sockaddr, -+ pub ifru_hwaddr: ::sockaddr, -+ pub ifru_flags: ::c_short, -+ pub ifru_ifindex: ::c_int, -+ pub ifru_metric: ::c_int, -+ pub ifru_mtu: ::c_int, -+ pub ifru_map: __c_anonymous_ifru_map, -+ pub ifru_slave: [::c_char; ::IFNAMSIZ], -+ pub ifru_newname: [::c_char; ::IFNAMSIZ], -+ pub ifru_data: *mut ::c_char, -+ } -+ -+ pub struct ifreq { -+ /// if name, e.g. "en0" -+ pub ifr_name: [::c_char; ::IFNAMSIZ], -+ #[cfg(libc_union)] -+ pub ifr_ifru: __c_anonymous_ifr_ifru, -+ #[cfg(not(libc_union))] -+ pub ifr_ifru: ::sockaddr, -+ } - } - - // options/posix/include/sys/wait.h - safe_f! { -+ pub fn CMSG_FIRSTHDR(_mhdr: *const msghdr) -> *mut cmsghdr { -+ core::unimplemented!() -+ } -+ -+ pub fn CMSG_NXTHDR(_mhdr: *const ::msghdr, _cmsg: *const ::cmsghdr) -> *mut ::cmsghdr { -+ core::unimplemented!() -+ } -+ -+ pub fn CMSG_LEN(_length: ::c_uint) -> ::c_uint { -+ core::unimplemented!() -+ } -+ -+ pub fn CMSG_DATA(_cmsg: *const cmsghdr) -> *mut ::c_uchar { -+ core::unimplemented!() -+ } -+ -+ pub fn CMSG_SPACE(_len: ::c_uint) -> ::c_uint { -+ core::unimplemented!() -+ } -+ - pub {const} fn WCOREDUMP(x: ::c_int) -> bool { - x & WCOREFLAG != 0 - } -@@ -349,6 +540,104 @@ safe_f! { - } - } - -+// abis/linux/termios.h - indices for the `c_cc` array in struct termios -+pub const NCCS: ::size_t = 32; -+pub const VINTR: ::c_int = 0; -+pub const VQUIT: ::c_int = 1; -+pub const VERASE: ::c_int = 2; -+pub const VKILL: ::c_int = 3; -+pub const VEOF: ::size_t = 4; -+pub const VTIME: ::c_int = 5; -+pub const VMIN: ::c_int = 6; -+pub const VSWTC: ::c_int = 7; -+pub const VSTART: ::c_int = 8; -+pub const VSTOP: ::c_int = 9; -+pub const VSUSP: ::c_int = 10; -+pub const VEOL: ::c_int = 11; -+pub const VREPRINT: ::c_int = 12; -+pub const VDISCARD: ::c_int = 13; -+pub const VWERASE: ::c_int = 14; -+pub const VLNEXT: ::c_int = 15; -+pub const VEOL2: ::c_int = 16; -+ -+// abis/linux/termios.h - bitwise flags for c_iflag in struct termios -+pub const BRKINT: ::c_uint = 0o000002; -+pub const ICRNL: ::c_uint = 0o000400; -+pub const IGNBRK: ::c_uint = 0o000001; -+pub const IGNCR: ::c_uint = 0o000200; -+pub const IGNPAR: ::c_uint = 0o000004; -+pub const INLCR: ::c_uint = 0o000100; -+pub const INPCK: ::c_uint = 0o000020; -+pub const ISTRIP: ::c_uint = 0o000040; -+pub const IXANY: ::c_uint = 0o004000; -+pub const IXOFF: ::c_uint = 0o010000; -+pub const IXON: ::c_uint = 0o002000; -+pub const PARMRK: ::c_uint = 0o000010; -+ -+// abis/linux/termios.h - bitwise flags for c_oflag in struct termios -+pub const OPOST: ::c_uint = 0o000001; -+pub const ONLCR: ::c_int = 0o000004; -+pub const OCRNL: ::c_int = 0o000010; -+pub const ONOCR: ::c_int = 0o000020; -+pub const ONLRET: ::c_int = 0o000040; -+pub const OFDEL: ::c_int = 0o000200; -+pub const OFILL: ::c_int = 0o000100; -+ -+pub const NLDLY: ::c_int = 0o000400; -+pub const NL0: ::c_int = 0o000000; -+pub const NL1: ::c_int = 0o000400; -+ -+pub const CRDLY: ::c_int = 0o003000; -+pub const CR0: ::c_int = 0o000000; -+pub const CR1: ::c_int = 0o001000; -+pub const CR2: ::c_int = 0o002000; -+pub const CR3: ::c_int = 0o003000; -+ -+pub const TABDLY: ::c_int = 0o014000; -+pub const TAB0: ::c_int = 0o000000; -+pub const TAB1: ::c_int = 0o004000; -+pub const TAB2: ::c_int = 0o010000; -+pub const TAB3: ::c_int = 0o014000; -+ -+pub const XTABS: ::c_int = 0o014000; -+pub const BSDLY: ::c_int = 0o020000; -+pub const BS0: ::c_int = 0o000000; -+pub const BS1: ::c_int = 0o020000; -+ -+pub const VTDLY: ::c_int = 0o040000; -+pub const VT0: ::c_int = 0o000000; -+pub const VT1: ::c_int = 0o040000; -+ -+pub const FFDLY: ::c_int = 0o100000; -+pub const FF0: ::c_int = 0o000000; -+pub const FF1: ::c_int = 0o100000; -+ -+// abis/linux/termios.h - bitwise constants for c_cflag in struct termios -+pub const CSIZE: ::c_int = 0o000060; -+pub const CS5: ::c_uint = 0o000000; -+pub const CS6: ::c_int = 0o000020; -+pub const CS7: ::c_int = 0o000040; -+pub const CS8: ::c_int = 0o000060; -+ -+pub const CSTOPB: ::c_int = 0o000100; -+pub const CREAD: ::c_int = 0o000200; -+pub const PARENB: ::c_int = 0o000400; -+pub const PARODD: ::c_int = 0o001000; -+pub const HUPCL: ::c_int = 0o002000; -+pub const CLOCAL: ::c_int = 0o004000; -+ -+// abis/linux/termios.h - bitwise constants for c_lflag in struct termios -+pub const ECHO: ::c_uint = 0o000010; -+pub const ECHOE: ::c_int = 0o000020; -+pub const ECHOK: ::c_int = 0o000040; -+pub const ECHONL: ::c_int = 0o000100; -+pub const ICANON: ::c_int = 0o000002; -+pub const IEXTEN: ::c_int = 0o100000; -+pub const ISIG: ::c_int = 0o000001; -+pub const NOFLSH: ::c_int = 0o000200; -+pub const TOSTOP: ::c_int = 0o000400; -+pub const ECHOPRT: ::c_int = 0o002000; -+ - // abis/mlibc/vm-flags.h - pub const MAP_ANON: ::c_int = 8; - pub const MAP_PRIVATE: ::c_int = 1; -@@ -356,11 +645,24 @@ pub const MAP_SHARED: ::c_int = 2; - pub const PROT_EXEC: ::c_int = 4; - pub const PROT_READ: ::c_int = 1; - pub const PROT_WRITE: ::c_int = 2; -+pub const PROT_NONE: ::c_int = 0; -+pub const MAP_FIXED: ::c_int = 2; -+pub const MAP_NORESERVE: ::c_int = 0x10; - - // options/posix/include/sys/mman.h -+pub const MAP_FILE: ::c_int = 0; - pub const MAP_FAILED: *mut ::c_void = usize::MAX as *mut ::c_void; - pub const MS_ASYNC: ::c_int = 1; - pub const MS_SYNC: ::c_int = 2; -+pub const MADV_NORMAL: ::c_int = 0; -+pub const MADV_RANDOM: ::c_int = 1; -+pub const MADV_SEQUENTIAL: ::c_int = 2; -+pub const MADV_WILLNEED: ::c_int = 3; -+pub const MADV_DONTNEED: ::c_int = 4; -+pub const MADV_FREE: ::c_int = 8; -+pub const MS_INVALIDATE: ::c_int = 4; -+pub const MCL_CURRENT: ::c_int = 1; -+pub const MCL_FUTURE: ::c_int = 2; - - // options/ansi/include/time.h - pub const CLOCK_MONOTONIC: clockid_t = 1; -@@ -369,33 +671,49 @@ pub const CLOCK_REALTIME: clockid_t = 0; - // options/posix/include/netdb.h - pub const EAI_SYSTEM: ::c_int = 9; - --// options/posix/include/termios.h - constants for tcsetattr() --pub const TCSANOW: ::c_int = 1; --pub const TCSADRAIN: ::c_int = 2; --pub const TCSAFLUSH: ::c_int = 3; -- --// options/posix/include/termios.h - bitwise constants for c_lflag in struct termios --pub const ECHO: ::tcflag_t = 0x0001; --pub const ECHOE: ::tcflag_t = 0x0002; --pub const ECHOK: ::tcflag_t = 0x0004; --pub const ECHONL: ::tcflag_t = 0x0008; --pub const ICANON: ::tcflag_t = 0x0010; --pub const IEXTEN: ::tcflag_t = 0x0020; --pub const ISIG: ::tcflag_t = 0x0040; --pub const NOFLSH: ::tcflag_t = 0x0080; --pub const TOSTOP: ::tcflag_t = 0x0100; --pub const ECHOPR: ::tcflag_t = 0x0200; -- - // abis/mlibc/in.h --pub const IPV6_ADD_MEMBERSHIP: ::c_int = 1; --pub const IPV6_DROP_MEMBERSHIP: ::c_int = 2; -+pub const IPV6_JOIN_GROUP: ::c_int = 1; -+pub const IPV6_LEAVE_GROUP: ::c_int = 2; -+pub const IPV6_MULTICAST_HOPS: ::c_int = 3; -+pub const IPV6_MULTICAST_IF: ::c_int = 4; - pub const IPV6_MULTICAST_LOOP: ::c_int = 5; -+pub const IPV6_UNICAST_HOPS: ::c_int = 6; - pub const IPV6_V6ONLY: ::c_int = 7; -+pub const IPV6_PMTUDISC_DONT: ::c_int = 8; -+pub const IPV6_PMTUDISC_DO: ::c_int = 9; -+pub const IPV6_MTU_DISCOVER: ::c_int = 23; -+pub const IPV6_RECVERR: ::c_int = 25; -+pub const IPV6_RECVPKTINFO: ::c_int = 49; -+pub const IPV6_PKTINFO: ::c_int = 50; -+pub const IPV6_RECVHOPLIMIT: ::c_int = 51; -+pub const IPV6_HOPLIMIT: ::c_int = 52; -+pub const IPV6_TCLASS: ::c_int = 67; -+pub const IP_TOS: ::c_int = 1; -+pub const IP_TTL: ::c_int = 2; -+pub const IP_OPTIONS: ::c_int = 4; -+pub const IP_PKTINFO: ::c_int = 8; -+pub const IP_MTU_DISCOVER: ::c_int = 10; -+pub const IP_RECVERR: ::c_int = 11; -+pub const IP_RECVTTL: ::c_int = 12; -+ -+pub const IP_DEFAULT_MULTICAST_TTL: ::c_int = 1; -+pub const IP_MULTICAST_IF: ::c_int = 32; -+pub const IP_MULTICAST_TTL: ::c_int = 33; -+pub const IP_MULTICAST_LOOP: ::c_int = 34; - pub const IP_ADD_MEMBERSHIP: ::c_int = 35; - pub const IP_DROP_MEMBERSHIP: ::c_int = 36; --pub const IP_MULTICAST_LOOP: ::c_int = 34; --pub const IP_MULTICAST_TTL: ::c_int = 33; --pub const IP_TTL: ::c_int = 2; -+pub const IP_UNBLOCK_SOURCE: ::c_int = 37; -+pub const IP_BLOCK_SOURCE: ::c_int = 38; -+pub const IP_ADD_SOURCE_MEMBERSHIP: ::c_int = 39; -+pub const IP_DROP_SOURCE_MEMBERSHIP: ::c_int = 40; -+pub const MCAST_JOIN_SOURCE_GROUP: ::c_int = 46; -+pub const MCAST_LEAVE_SOURCE_GROUP: ::c_int = 47; -+ -+pub const IPV6_ADD_MEMBERSHIP: ::c_int = IPV6_JOIN_GROUP; -+pub const IPV6_DROP_MEMBERSHIP: ::c_int = IPV6_LEAVE_GROUP; -+ -+// FIXME: not defined in mlibc -+pub const TCP_KEEPIDLE: ::c_int = 4; - - // abis/linux/signal.h - pub const SIGABRT: ::c_int = 6; -@@ -436,45 +754,121 @@ pub const SIGSYS: ::c_int = 31; - pub const SIGUNUSED: ::c_int = SIGSYS; - pub const SIGCANCEL: ::c_int = 32; - -+pub const SA_SIGINFO: ::c_int = 4; -+pub const SA_RESTART: ::c_int = 0x10000000; -+ -+pub const SIG_DFL: ::sighandler_t = 0 as ::sighandler_t; -+pub const SIG_IGN: ::sighandler_t = 1 as ::sighandler_t; -+pub const SIG_ERR: ::sighandler_t = !0 as ::sighandler_t; -+ - // abis/mlibc/signal.h - constants for sigprocmask() - pub const SIG_BLOCK: ::c_int = 0; - pub const SIG_UNBLOCK: ::c_int = 1; - pub const SIG_SETMASK: ::c_int = 2; - - // abis/mlibc/termios.h --pub const NCCS: usize = 11; -+pub const B0: ::c_uint = 0; -+pub const B50: ::c_uint = 1; -+pub const B75: ::c_uint = 2; -+pub const B110: ::c_uint = 3; -+pub const B134: ::c_uint = 4; -+pub const B150: ::c_uint = 5; -+pub const B200: ::c_uint = 6; -+pub const B300: ::c_uint = 7; -+pub const B600: ::c_uint = 8; -+pub const B1200: ::c_uint = 9; -+pub const B1800: ::c_uint = 10; -+pub const B2400: ::c_uint = 11; -+pub const B4800: ::c_uint = 12; -+pub const B9600: ::c_uint = 13; -+pub const B19200: ::c_uint = 14; -+pub const B38400: ::c_uint = 15; -+pub const B57600: ::c_uint = 16; -+pub const B115200: ::c_uint = 17; -+pub const B230400: ::c_uint = 18; -+pub const TCIFLUSH: ::c_int = 1; -+pub const TCIOFF: ::c_int = 1; -+pub const TCIOFLUSH: ::c_int = 2; -+pub const TCION: ::c_int = 2; -+pub const TCOFLUSH: ::c_int = 3; -+pub const TCOOFF: ::c_int = 3; -+pub const TCOON: ::c_int = 4; -+pub const TCSADRAIN: ::c_int = 2; -+pub const TCSAFLUSH: ::c_int = 3; -+pub const TCSANOW: ::c_int = 1; -+pub const TIOCSCTTY: ::c_ulong = 0x540e; -+pub const TIOCSWINSZ: ::c_ulong = 0x5414; - - // options/posix/include/termios.h - pub const TIOCGWINSZ: ::c_ulong = 0x5413; - -+// options/ansi/include/locale.h -+pub const LC_CTYPE: ::c_int = 3; -+ - // options/ansi/include/stdlib.h - pub const EXIT_FAILURE: ::c_int = 1; - pub const EXIT_SUCCESS: ::c_int = 0; - - // options/posix/include/dlfcn.h - pub const RTLD_DEFAULT: *mut ::c_void = 0 as *mut ::c_void; -+pub const RTLD_LAZY: ::c_int = 32; - - // options/posix/include/unistd.h -+pub const F_OK: ::c_int = 1; -+pub const R_OK: ::c_int = 2; - pub const STDERR_FILENO: ::c_int = 2; - pub const STDIN_FILENO: ::c_int = 0; - pub const STDOUT_FILENO: ::c_int = 1; -+pub const W_OK: ::c_int = 4; -+pub const X_OK: ::c_int = 8; -+pub const _PC_NAME_MAX: ::c_int = 3; -+pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 7; - pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 1; - pub const _SC_NPROCESSORS_ONLN: ::c_int = 6; -+pub const _SC_NGROUPS_MAX: ::c_int = 10; - pub const _SC_PAGESIZE: ::c_int = _SC_PAGE_SIZE; - pub const _SC_PAGE_SIZE: ::c_int = 3; - - // abis/mlibc/socket.h -+pub const AF_APPLETALK: ::c_int = PF_APPLETALK; -+pub const AF_BLUETOOTH: ::c_int = PF_BLUETOOTH; -+pub const AF_DECnet: ::c_int = PF_DECnet; - pub const AF_INET6: ::c_int = PF_INET6; - pub const AF_INET: ::c_int = PF_INET; -+pub const AF_IPX: ::c_int = PF_IPX; -+pub const AF_ISDN: ::c_int = PF_ISDN; -+pub const AF_PACKET: ::c_int = PF_PACKET; -+pub const AF_SNA: ::c_int = PF_SNA; - pub const AF_UNIX: ::c_int = 3; - pub const MSG_PEEK: ::c_int = 0x20; -+pub const MSG_TRUNC: ::c_int = 0x40; -+pub const AF_UNSPEC: ::c_int = PF_UNSPEC; -+pub const MSG_CTRUNC: ::c_int = 1; -+pub const MSG_CMSG_CLOEXEC: ::c_int = 0x2000; -+pub const MSG_EOR: ::c_int = 4; -+pub const MSG_OOB: ::c_int = 8; -+pub const MSG_WAITALL: ::c_int = 0x80; -+pub const PF_APPLETALK: ::c_int = 7; -+pub const PF_BLUETOOTH: ::c_int = 8; -+pub const PF_DECnet: ::c_int = 9; -+pub const MSG_DONTWAIT: ::c_int = 0x1000; - pub const PF_INET6: ::c_int = 2; - pub const PF_INET: ::c_int = 1; - pub const PF_UNIX: ::c_int = 3; -+pub const PF_UNSPEC: ::c_int = 4; -+pub const SCM_RIGHTS: ::c_int = 1; -+pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP; - pub const SHUT_RD: ::c_int = 1; - pub const SHUT_RDWR: ::c_int = 2; - pub const SHUT_WR: ::c_int = 3; - pub const SOCK_DGRAM: ::c_int = 1; -+pub const SOCK_RAW: ::c_int = 2; -+pub const SOCK_RDM: ::c_int = 0x40000; -+pub const SOCK_SEQPACKET: ::c_int = 3; -+pub const PF_IPX: ::c_int = 10; -+pub const PF_ISDN: ::c_int = 11; -+pub const PF_PACKET: ::c_int = 13; -+pub const PF_SNA: ::c_int = 12; - pub const SOCK_STREAM: ::c_int = 4; - pub const SOL_SOCKET: ::c_int = 1; - pub const SO_ACCEPTCONN: ::c_int = 1; -@@ -494,6 +888,8 @@ pub const SO_SNDLOWAT: ::c_int = 14; - pub const SO_SNDTIMEO: ::c_int = 15; - pub const SO_TYPE: ::c_int = 16; - pub const SO_SNDBUFFORCE: ::c_int = 17; -+pub const TCP_KEEPCNT: ::c_int = 6; -+pub const TCP_KEEPINTVL: ::c_int = 5; - pub const SO_PEERCRED: ::c_int = 18; - pub const SO_ATTACH_FILTER: ::c_int = 19; - pub const SO_PASSCRED: ::c_int = 20; -@@ -503,6 +899,12 @@ pub const SO_PROTOCOL: ::c_int = 23; - pub const SO_REUSEPORT: ::c_int = 24; - pub const SO_TIMESTAMP: ::c_int = 25; - -+// options/posix/include/sys/file.h -+pub const LOCK_EX: ::c_int = 2; -+pub const LOCK_NB: ::c_int = 4; -+pub const LOCK_SH: ::c_int = 1; -+pub const LOCK_UN: ::c_int = 8; -+ - // abis/mlibc/errno.h - pub const EDOM: ::c_int = 1; - pub const EILSEQ: ::c_int = 2; -@@ -592,15 +994,24 @@ pub const ENOTBLK: ::c_int = 1083; - - // options/posix/include/fcntl.h - pub const AT_FDCWD: ::c_int = -100; --pub const F_DUPFD: ::c_int = 1; - pub const F_DUPFD_CLOEXEC: ::c_int = 2; -+pub const AT_REMOVEDIR: ::c_int = 8; - pub const F_GETFD: ::c_int = 3; - pub const F_SETFD: ::c_int = 4; -+pub const AT_SYMLINK_FOLLOW: ::c_int = 2; -+pub const AT_SYMLINK_NOFOLLOW: ::c_int = 4; -+pub const F_DUPFD: ::c_int = 1; - pub const F_GETFL: ::c_int = 5; - pub const F_SETFL: ::c_int = 6; - pub const F_GETLK: ::c_int = 7; - pub const F_SETLK: ::c_int = 8; - pub const F_SETLKW: ::c_int = 9; -+pub const O_DIRECTORY: ::c_int = 0x00020; -+pub const O_NOFOLLOW: ::c_int = 0x100; -+pub const O_ASYNC: ::c_int = 0x40000; -+pub const O_NDELAY: ::c_int = 0x400; -+pub const O_NOCTTY: ::c_int = 0x80; -+pub const O_SYNC: ::c_int = 0x2000; - pub const F_GETOWN: ::c_int = 10; - pub const F_SETOWN: ::c_int = 11; - pub const O_ACCMODE: ::c_int = 7; -@@ -644,23 +1055,56 @@ pub const S_IXGRP: mode_t = 0o10; - pub const S_IXOTH: mode_t = 0o1; - pub const S_IXUSR: mode_t = 0o100; - -+// Used by utimensat() and friends -+pub const UTIME_NOW: c_long = (1 << 30) - 1; -+pub const UTIME_OMIT: c_long = (1 << 30) - 2; -+ - // options/posix/include/sys/wait.h - pub const WCOREFLAG: ::c_int = 0x80; - pub const WNOHANG: ::c_int = 2; - - // options/linux/include/sys/poll.h --// TODO: Port epoll! - pub const POLLHUP: ::c_short = 8; - pub const POLLIN: ::c_short = 1; - pub const POLLNVAL: ::c_short = 0x40; - pub const POLLOUT: ::c_short = 2; - -+// options/linux/include/sys/epoll.h -+pub const EPOLLERR: ::c_int = 8; -+pub const EPOLLET: ::c_int = 1 << 31; -+pub const EPOLLHUP: ::c_int = 0x10; -+pub const EPOLLIN: ::c_int = 1; -+pub const EPOLLMSG: ::c_int = 0x400; -+pub const EPOLLONESHOT: ::c_int = 1 << 30; -+pub const EPOLLOUT: ::c_int = 4; -+pub const EPOLLPRI: ::c_int = 2; -+pub const EPOLLRDBAND: ::c_int = 0x80; -+pub const EPOLLRDHUP: ::c_int = 0x2000; -+pub const EPOLLRDNORM: ::c_int = 0x40; -+pub const EPOLLWRBAND: ::c_int = 0x200; -+pub const EPOLLWRNORM: ::c_int = 0x100; -+pub const EPOLLWAKEUP: ::c_int = 1 << 29; -+pub const EPOLL_CLOEXEC: ::c_int = 1; -+pub const EPOLL_CTL_ADD: ::c_int = 1; -+pub const EPOLL_CTL_DEL: ::c_int = 2; -+pub const EPOLL_CTL_MOD: ::c_int = 3; -+ -+// options/linux/include/sys/eventfd.h -+pub const EFD_CLOEXEC: ::c_int = O_CLOEXEC; -+pub const EFD_NONBLOCK: ::c_int = O_NONBLOCK; -+ - // options/glibc/include/sys/ioctl.h - pub const FIOCLEX: ::c_ulong = 0x5451; - pub const FIONBIO: ::c_ulong = 0x5421; - - // options/ansi/include/limits.h - pub const PTHREAD_STACK_MIN: ::size_t = 16384; -+pub const PATH_MAX: ::size_t = 4096; -+ -+// abis/linux/ioctls.h -+pub const SIOCGIFHWADDR: ::c_ulong = 0x8927; -+pub const SIOCSIFADDR: ::c_ulong = 0x8916; -+pub const SIOCSIFNETMASK: ::c_ulong = 0x891c; - - // options/posix/include/pthread.h - align_const! { -@@ -668,9 +1112,12 @@ align_const! { - __mlibc_state: 0, - __mlibc_recursion: 0, - __mlibc_flags: 0, -+ __mlibc_prioceiling: 0, - }; - pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - __mlibc_seq: 0, -+ __mlibc_flags: 0, -+ __mlibc_clock: 0, - }; - pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - __mlibc_m: 0, -@@ -689,11 +1136,40 @@ pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 0; - pub const PTHREAD_PROCESS_SHARED: ::c_int = 1; - - extern "C" { -+ pub fn __errno_location() -> *mut ::c_int; -+ pub fn acct(filename: *const ::c_char) -> ::c_int; - pub fn bind(socket: ::c_int, address: *const ::sockaddr, address_len: ::socklen_t) -> ::c_int; - pub fn clock_gettime(clk_id: clockid_t, tp: *mut ::timespec) -> ::c_int; - pub fn clock_settime(clk_id: clockid_t, tp: *const ::timespec) -> ::c_int; - pub fn endpwent(); -+ pub fn epoll_create(size: ::c_int) -> ::c_int; -+ pub fn epoll_create1(flags: ::c_int) -> ::c_int; -+ pub fn epoll_ctl(epfd: ::c_int, op: ::c_int, fd: ::c_int, event: *mut ::epoll_event) -+ -> ::c_int; -+ pub fn epoll_wait( -+ epfd: ::c_int, -+ events: *mut ::epoll_event, -+ maxevents: ::c_int, -+ timeout: ::c_int, -+ ) -> ::c_int; -+ pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int; -+ pub fn forkpty( -+ amaster: *mut ::c_int, -+ name: *mut ::c_char, -+ termp: *mut termios, -+ winp: *mut ::winsize, -+ ) -> ::pid_t; -+ pub fn futimes(file: ::c_int, times: *const ::timeval) -> ::c_int; -+ pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; - pub fn getpwent() -> *mut passwd; -+ pub fn openpty( -+ amaster: *mut ::c_int, -+ aslave: *mut ::c_int, -+ name: *mut ::c_char, -+ termp: *const termios, -+ winp: *const ::winsize, -+ ) -> ::c_int; -+ pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; - pub fn getgrgid_r( - gid: ::gid_t, - grp: *mut ::group, -@@ -728,13 +1204,24 @@ extern "C" { - buflen: ::size_t, - result: *mut *mut passwd, - ) -> ::c_int; -+ pub fn initgroups(user: *const ::c_char, group: ::gid_t) -> ::c_int; - pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; -+ pub fn lutimes(file: *const ::c_char, times: *const ::timeval) -> ::c_int; - pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; -- pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; -- pub fn pthread_condattr_setclock( -- attr: *mut pthread_condattr_t, -- clock_id: ::clockid_t, -+ pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int; -+ pub fn shm_open(name: *const c_char, oflag: ::c_int, mode: mode_t) -> ::c_int; -+ pub fn shm_unlink(name: *const ::c_char) -> ::c_int; -+ pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; -+ pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t) -> ::c_int; -+ pub fn utimensat( -+ dirfd: ::c_int, -+ path: *const ::c_char, -+ times: *const ::timespec, -+ flag: ::c_int, - ) -> ::c_int; -+ pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int; -+ pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, clock_id: clockid_t) -+ -> ::c_int; - pub fn pthread_create( - thread: *mut ::pthread_t, - attr: *const ::pthread_attr_t, -@@ -752,7 +1239,16 @@ extern "C" { - addr: *mut ::sockaddr, - addrlen: *mut ::socklen_t, - ) -> ::ssize_t; -+ pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int) -> ::ssize_t; -+ pub fn sendmsg(fd: ::c_int, msg: *const ::msghdr, flags: ::c_int) -> ::ssize_t; - pub fn setgroups(ngroups: ::c_int, ptr: *const ::gid_t) -> ::c_int; - pub fn setpwent(); - pub fn writev(fd: ::c_int, iov: *const ::iovec, count: ::c_int) -> ::ssize_t; -+ -+ // Non standard extensions, also found on modern BSD's. -+ // -+ // options/posix/include/sys/uio.h -+ pub fn preadv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t; -+ pub fn pwritev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -+ -> ::ssize_t; - } --- -2.40.1 - diff --git a/patches/rust-libloading/rust-libloading.patch b/patches/rust-libloading/rust-libloading.patch index ac3ec05e6f1..743d6cedefc 100644 --- a/patches/rust-libloading/rust-libloading.patch +++ b/patches/rust-libloading/rust-libloading.patch @@ -1,14 +1,15 @@ -From f5fab150ee8fbfdef46888837b6e6d43fd3ec1c0 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Sun, 20 Nov 2022 13:39:51 +1100 +From d6dfe23ee9299412d8281dabb7f5d903e152b589 Mon Sep 17 00:00:00 2001 +From: Anhad Singh +Date: Tue, 10 Oct 2023 17:24:17 +1100 Subject: [PATCH] +Signed-off-by: Anhad Singh --- src/os/unix/consts.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/os/unix/consts.rs b/src/os/unix/consts.rs -index dbe4df9..fbdd2e3 100644 +index ed3edaf..61659ff 100644 --- a/src/os/unix/consts.rs +++ b/src/os/unix/consts.rs @@ -58,7 +58,7 @@ mod posix { @@ -18,9 +19,9 @@ index dbe4df9..fbdd2e3 100644 - if #[cfg(target_os = "haiku")] { + if #[cfg(any(target_os = "haiku", target_os = "aero"))] { pub(super) const RTLD_LAZY: c_int = 0; - } else if #[cfg(any( - target_os = "linux", -@@ -90,7 +90,7 @@ mod posix { + } else if #[cfg(target_os = "aix")] { + pub(super) const RTLD_LAZY: c_int = 4; +@@ -94,7 +94,7 @@ mod posix { } cfg_if! { @@ -29,7 +30,7 @@ index dbe4df9..fbdd2e3 100644 pub(super) const RTLD_NOW: c_int = 1; } else if #[cfg(any( target_os = "linux", -@@ -126,6 +126,7 @@ mod posix { +@@ -133,6 +133,7 @@ mod posix { cfg_if! { if #[cfg(any( target_os = "haiku", @@ -37,14 +38,14 @@ index dbe4df9..fbdd2e3 100644 all(target_os = "android",target_pointer_width = "32"), ))] { pub(super) const RTLD_GLOBAL: c_int = 2; -@@ -193,6 +194,7 @@ mod posix { - +@@ -210,6 +211,7 @@ mod posix { target_os = "fuchsia", target_os = "redox", + target_os = "hurd", + target_os = "aero", ))] { pub(super) const RTLD_LOCAL: c_int = 0; } else { -- -2.38.1 +2.42.0 diff --git a/patches/rust-nix/rust-nix.patch b/patches/rust-nix/rust-nix.patch index 6ff6e5acb49..0c124a2aa8e 100644 --- a/patches/rust-nix/rust-nix.patch +++ b/patches/rust-nix/rust-nix.patch @@ -1,20 +1,26 @@ -From 608f6dc307498272ec3a6317cac3bbbe2a8b74b1 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Sun, 20 Nov 2022 12:21:43 +1100 -Subject: [PATCH] +From 2ac82af89ae503c8743dcd96bca3dcbddccd1eea Mon Sep 17 00:00:00 2001 +From: Dennis Bonke +Date: Thu, 23 Feb 2023 00:41:07 +0100 +Subject: [PATCH] aero: initial port +Signed-off-by: Dennis Bonke --- - src/errno.rs | 217 +++++++++++++++++++++++++++++++++++++++++ - src/lib.rs | 12 ++- + src/errno.rs | 218 +++++++++++++++++++++++++++++++++++++++++ + src/features.rs | 2 +- + src/lib.rs | 10 +- src/sys/mod.rs | 10 +- - src/sys/socket/addr.rs | 16 +-- - src/sys/socket/mod.rs | 5 +- + src/sys/resource.rs | 2 + + src/sys/signal.rs | 16 +-- + src/sys/socket/addr.rs | 26 +++-- + src/sys/socket/mod.rs | 6 +- src/sys/termios.rs | 54 +++++++++- - src/unistd.rs | 27 +++++ - 7 files changed, 327 insertions(+), 14 deletions(-) + src/sys/time.rs | 3 +- + src/sys/timerfd.rs | 2 +- + src/unistd.rs | 30 ++++++ + 12 files changed, 350 insertions(+), 29 deletions(-) diff --git a/src/errno.rs b/src/errno.rs -index 9c2dfe4..d26d63d 100644 +index 41420e8..aedf294 100644 --- a/src/errno.rs +++ b/src/errno.rs @@ -22,6 +22,7 @@ cfg_if! { @@ -35,7 +41,7 @@ index 9c2dfe4..d26d63d 100644 match errno { UnknownErrno => "Unknown errno", EPERM => "Operation not permitted", -@@ -1557,6 +1561,219 @@ mod consts { +@@ -1562,6 +1566,220 @@ mod consts { } } @@ -111,7 +117,7 @@ index 9c2dfe4..d26d63d 100644 + // ENOTDIR = libc::ENOTDIR, + // ENOTEMPTY = libc::ENOTEMPTY, + // ENOTSOCK = libc::ENOTSOCK, -+ // ENOTSUP = libc::ENOTSUP, ++ ENOTSUP = libc::ENOTSUP, + ENOTTY = libc::ENOTTY, + // ENXIO = libc::ENXIO, + // EOPNOTSUPP = libc::EOPNOTSUPP, @@ -148,7 +154,7 @@ index 9c2dfe4..d26d63d 100644 + + // pub const EL2NSYNC: Errno = Errno::UnknownErrno; + -+ pub fn from_i32(e: i32) -> Errno { ++ pub const fn from_i32(e: i32) -> Errno { + use self::Errno::*; + + match e { @@ -218,7 +224,7 @@ index 9c2dfe4..d26d63d 100644 + // libc::ENOTDIR => ENOTDIR, + // libc::ENOTEMPTY => ENOTEMPTY, + // libc::ENOTSOCK => ENOTSOCK, -+ // libc::ENOTSUP => ENOTSUP, ++ libc::ENOTSUP => ENOTSUP, + // libc::ENOTTY => ENOTTY, + // libc::ENXIO => ENXIO, + // libc::EOPNOTSUPP => EOPNOTSUPP, @@ -252,126 +258,233 @@ index 9c2dfe4..d26d63d 100644 + } + } +} ++ #[cfg(target_os = "dragonfly")] mod consts { +diff --git a/src/features.rs b/src/features.rs +index 6108098..1f937e2 100644 +--- a/src/features.rs ++++ b/src/features.rs +@@ -1,7 +1,7 @@ + //! Feature tests for OS functionality + pub use self::os::*; + +-#[cfg(any(target_os = "linux", target_os = "android"))] ++#[cfg(any(target_os = "linux", target_os = "android", target_os = "aero"))] + mod os { + use std::os::unix::ffi::OsStrExt; + use crate::sys::utsname::uname; diff --git a/src/lib.rs b/src/lib.rs -index 3b534a5..f7c8495 100644 +index d4dcbc4..e5f03c7 100644 --- a/src/lib.rs +++ b/src/lib.rs -@@ -5,12 +5,13 @@ - #![crate_name = "nix"] +@@ -43,9 +43,10 @@ #![cfg(unix)] + #![cfg_attr(docsrs, doc(cfg(all())))] #![allow(non_camel_case_types)] +#![allow(non_snake_case)] - // latest bitflags triggers a rustc bug with cross-crate macro expansions causing dead_code - // warnings even though the macro expands into something with allow(dead_code) - #![allow(dead_code)] #![cfg_attr(test, deny(warnings))] #![recursion_limit = "500"] -#![deny(unused)] +// #![deny(unused)] + #![allow(unused_macros)] + #![cfg_attr(not(feature = "default"), allow(unused_imports))] #![deny(unstable_features)] - #![deny(missing_copy_implementations)] - #![deny(missing_debug_implementations)] -@@ -22,11 +23,13 @@ pub use libc; +@@ -62,12 +63,13 @@ pub use libc; #[macro_use] mod macros; // Public crates -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "aero")))] - pub mod dir; -+#[cfg(not(target_os = "aero"))] - pub mod env; - pub mod errno; - #[deny(missing_docs)] -+#[cfg(not(target_os = "aero"))] - pub mod features; - pub mod fcntl; - #[deny(missing_docs)] -@@ -54,15 +57,18 @@ pub mod mount; - target_os = "netbsd"))] - pub mod mqueue; - #[deny(missing_docs)] --#[cfg(not(target_os = "redox"))] -+#[cfg(not(any(target_os = "redox", target_os = "aero")))] - pub mod net; - #[deny(missing_docs)] + feature! { + #![feature = "dir"] + #[allow(missing_docs)] + pub mod dir; + } +#[cfg(not(target_os = "aero"))] - pub mod poll; - #[deny(missing_docs)] - #[cfg(not(any(target_os = "redox", target_os = "fuchsia")))] - pub mod pty; + feature! { + #![feature = "env"] + pub mod env; +@@ -96,7 +98,7 @@ feature! { + target_os = "openbsd"))] + #[deny(missing_docs)] + pub mod ifaddrs; +- #[cfg(not(target_os = "redox"))] ++ #[cfg(not(any(target_os = "redox", target_os = "aero")))] + #[deny(missing_docs)] + pub mod net; + } +@@ -124,6 +126,7 @@ feature! { + #[allow(missing_docs)] + pub mod mqueue; + } +#[cfg(not(target_os = "aero"))] - pub mod sched; - pub mod sys; + feature! { + #![feature = "poll"] + pub mod poll; +@@ -134,6 +137,7 @@ feature! { + #[deny(missing_docs)] + pub mod pty; + } +#[cfg(not(target_os = "aero"))] - pub mod time; - // This can be implemented for other platforms as soon as libc - // provides bindings for them. + feature! { + #![feature = "sched"] + pub mod sched; diff --git a/src/sys/mod.rs b/src/sys/mod.rs -index 43877a1..20dd8e5 100644 +index e5639f2..2cbdff5 100644 --- a/src/sys/mod.rs +++ b/src/sys/mod.rs -@@ -6,7 +6,7 @@ - target_os = "netbsd"))] - pub mod aio; +@@ -13,7 +13,7 @@ feature! { + feature! { + #![feature = "event"] --#[cfg(any(target_os = "android", target_os = "linux"))] -+#[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] - pub mod epoll; +- #[cfg(any(target_os = "android", target_os = "linux"))] ++ #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] + #[allow(missing_docs)] + pub mod epoll; - #[cfg(any(target_os = "dragonfly", -@@ -42,6 +42,7 @@ pub mod mman; - #[cfg(target_os = "linux")] - pub mod personality; +@@ -64,6 +64,7 @@ feature! { + pub mod personality; + } +#[cfg(not(target_os = "aero"))] - pub mod pthread; - - #[cfg(any(target_os = "android", -@@ -59,7 +60,8 @@ pub mod quota; - #[cfg(any(target_os = "linux"))] - pub mod reboot; + feature! { + #![feature = "pthread"] + pub mod pthread; +@@ -100,7 +101,7 @@ feature! { + pub mod resource; + } -#[cfg(not(target_os = "redox"))] -+// #[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "aero")))] - pub mod select; - - #[cfg(any(target_os = "android", -@@ -69,6 +71,7 @@ pub mod select; - target_os = "macos"))] - pub mod sendfile; - -+#[cfg(not(target_os = "aero"))] - pub mod signal; - - #[cfg(any(target_os = "android", target_os = "linux"))] -@@ -89,6 +92,7 @@ pub mod stat; - ))] - pub mod statfs; + feature! { + #![feature = "poll"] + pub mod select; +@@ -152,6 +153,7 @@ feature! { + pub mod statfs; + } +#[cfg(not(target_os = "aero"))] - pub mod statvfs; - - #[cfg(any(target_os = "android", target_os = "linux"))] -@@ -100,8 +104,10 @@ pub mod time; - - pub mod uio; + feature! { + #![feature = "fs"] + pub mod statvfs; +@@ -181,6 +183,7 @@ feature! { + pub mod utsname; + } +#[cfg(not(target_os = "aero"))] - pub mod utsname; + feature! { + #![feature = "process"] + pub mod wait; +@@ -192,7 +195,7 @@ feature! { + pub mod inotify; + } -+#[cfg(not(target_os = "aero"))] - pub mod wait; +-#[cfg(any(target_os = "android", target_os = "linux"))] ++#[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] + feature! { + #![feature = "time"] + pub mod timerfd; +@@ -203,6 +206,7 @@ feature! { + target_os = "freebsd", + target_os = "illumos", + target_os = "linux", ++ target_os = "aero", + target_os = "netbsd" + ), + feature = "time", +diff --git a/src/sys/resource.rs b/src/sys/resource.rs +index 76ceaf5..3457acd 100644 +--- a/src/sys/resource.rs ++++ b/src/sys/resource.rs +@@ -14,6 +14,7 @@ cfg_if! { + target_os = "openbsd", + target_os = "netbsd", + target_os = "macos", ++ target_os = "aero", + target_os = "ios", + target_os = "android", + target_os = "dragonfly", +@@ -48,6 +49,7 @@ libc_enum! { + target_os = "ios", + target_os = "android", + target_os = "dragonfly", ++ target_os = "aero", + all(target_os = "linux", not(any(target_env = "gnu", target_env = "uclibc"))) + ), repr(i32))] + #[non_exhaustive] +diff --git a/src/sys/signal.rs b/src/sys/signal.rs +index f982b4e..5621b6f 100644 +--- a/src/sys/signal.rs ++++ b/src/sys/signal.rs +@@ -99,13 +99,13 @@ libc_enum!{ + SIGSYS, + #[cfg(not(any(target_os = "android", target_os = "emscripten", + target_os = "fuchsia", target_os = "linux", +- target_os = "redox")))] ++ target_os = "redox", target_os = "aero")))] + #[cfg_attr(docsrs, doc(cfg(all())))] + /// Emulator trap + SIGEMT, + #[cfg(not(any(target_os = "android", target_os = "emscripten", + target_os = "fuchsia", target_os = "linux", +- target_os = "redox")))] ++ target_os = "redox", target_os = "aero")))] + #[cfg_attr(docsrs, doc(cfg(all())))] + /// Information request + SIGINFO, +@@ -157,11 +157,11 @@ impl FromStr for Signal { + "SIGSYS" => Signal::SIGSYS, + #[cfg(not(any(target_os = "android", target_os = "emscripten", + target_os = "fuchsia", target_os = "linux", +- target_os = "redox")))] ++ target_os = "redox", target_os = "aero")))] + "SIGEMT" => Signal::SIGEMT, + #[cfg(not(any(target_os = "android", target_os = "emscripten", + target_os = "fuchsia", target_os = "linux", +- target_os = "redox")))] ++ target_os = "redox", target_os = "aero")))] + "SIGINFO" => Signal::SIGINFO, + _ => return Err(Errno::EINVAL), + }) +@@ -215,11 +215,11 @@ impl Signal { + Signal::SIGSYS => "SIGSYS", + #[cfg(not(any(target_os = "android", target_os = "emscripten", + target_os = "fuchsia", target_os = "linux", +- target_os = "redox")))] ++ target_os = "redox", target_os = "aero")))] + Signal::SIGEMT => "SIGEMT", + #[cfg(not(any(target_os = "android", target_os = "emscripten", + target_os = "fuchsia", target_os = "linux", +- target_os = "redox")))] ++ target_os = "redox", target_os = "aero")))] + Signal::SIGINFO => "SIGINFO", + } + } +@@ -242,7 +242,7 @@ impl fmt::Display for Signal { + #[cfg(feature = "signal")] + pub use self::Signal::*; - #[cfg(any(target_os = "android", target_os = "linux"))] +-#[cfg(target_os = "redox")] ++#[cfg(any(target_os = "redox", target_os = "aero"))] + #[cfg(feature = "signal")] + const SIGNALS: [Signal; 29] = [ + SIGHUP, +@@ -349,7 +349,7 @@ const SIGNALS: [Signal; 30] = [ + SIGSYS]; + #[cfg(not(any(target_os = "linux", target_os = "android", + target_os = "fuchsia", target_os = "emscripten", +- target_os = "redox")))] ++ target_os = "redox", target_os = "aero")))] + #[cfg(feature = "signal")] + const SIGNALS: [Signal; 31] = [ + SIGHUP, diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs -index d486056..b367e18 100644 +index 4b8ab09..f23da26 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs -@@ -17,6 +17,7 @@ use std::os::unix::io::RawFd; +@@ -19,6 +19,7 @@ use std::os::unix::io::RawFd; use crate::sys::socket::addr::sys_control::SysControlAddr; #[cfg(any(target_os = "android", target_os = "dragonfly", @@ -379,7 +492,7 @@ index d486056..b367e18 100644 target_os = "freebsd", target_os = "ios", target_os = "linux", -@@ -46,6 +47,7 @@ pub enum AddressFamily { +@@ -76,6 +77,7 @@ pub enum AddressFamily { /// Low level packet interface (see [`packet(7)`](https://man7.org/linux/man-pages/man7/packet.7.html)) #[cfg(any(target_os = "android", target_os = "linux", @@ -387,7 +500,7 @@ index d486056..b367e18 100644 target_os = "illumos", target_os = "fuchsia", target_os = "solaris"))] -@@ -245,7 +247,7 @@ impl AddressFamily { +@@ -376,7 +378,7 @@ impl AddressFamily { libc::AF_NETLINK => Some(AddressFamily::Netlink), #[cfg(any(target_os = "macos", target_os = "macos"))] libc::AF_SYSTEM => Some(AddressFamily::System), @@ -396,7 +509,45 @@ index d486056..b367e18 100644 libc::AF_PACKET => Some(AddressFamily::Packet), #[cfg(any(target_os = "dragonfly", target_os = "freebsd", -@@ -653,6 +655,7 @@ pub enum SockAddr { +@@ -707,7 +709,8 @@ pub struct UnixAddr { + #[cfg(any(target_os = "android", + target_os = "fuchsia", + target_os = "illumos", +- target_os = "linux" ++ target_os = "linux", ++ target_os = "aero" + ))] + sun_len: u8 + } +@@ -842,7 +845,8 @@ impl UnixAddr { + if #[cfg(any(target_os = "android", + target_os = "fuchsia", + target_os = "illumos", +- target_os = "linux" ++ target_os = "linux", ++ target_os = "aero" + ))] + { + UnixAddr { sun, sun_len } +@@ -900,7 +904,8 @@ impl UnixAddr { + if #[cfg(any(target_os = "android", + target_os = "fuchsia", + target_os = "illumos", +- target_os = "linux" ++ target_os = "linux", ++ target_os = "aero" + ))] + { + self.sun_len +@@ -940,6 +945,7 @@ impl SockaddrLike for UnixAddr { + cfg_if!{ + if #[cfg(any(target_os = "android", + target_os = "fuchsia", ++ target_os = "aero", + target_os = "illumos", + target_os = "linux" + ))] { +@@ -1817,6 +1823,7 @@ pub enum SockAddr { /// Datalink address (MAC) #[cfg(any(target_os = "android", target_os = "dragonfly", @@ -404,64 +555,64 @@ index d486056..b367e18 100644 target_os = "freebsd", target_os = "ios", target_os = "linux", -@@ -705,7 +708,7 @@ impl SockAddr { - SockAddr::Alg(..) => AddressFamily::Alg, - #[cfg(any(target_os = "ios", target_os = "macos"))] +@@ -1886,7 +1893,7 @@ impl SockAddr { + #[cfg(all(feature = "ioctl", + any(target_os = "ios", target_os = "macos")))] SockAddr::SysControl(..) => AddressFamily::System, - #[cfg(any(target_os = "android", target_os = "linux"))] + #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] + #[cfg(feature = "net")] SockAddr::Link(..) => AddressFamily::Packet, #[cfg(any(target_os = "dragonfly", - target_os = "freebsd", -@@ -738,7 +741,7 @@ impl SockAddr { +@@ -1923,7 +1930,7 @@ impl SockAddr { if addr.is_null() { None } else { - match AddressFamily::from_i32(i32::from((*addr).sa_family)) { + match AddressFamily::from_i32((*addr).sa_family as i32) { Some(AddressFamily::Unix) => None, + #[cfg(feature = "net")] Some(AddressFamily::Inet) => Some(SockAddr::Inet( - InetAddr::V4(*(addr as *const libc::sockaddr_in)))), -@@ -750,7 +753,7 @@ impl SockAddr { - #[cfg(any(target_os = "ios", target_os = "macos"))] +@@ -1938,7 +1945,7 @@ impl SockAddr { + any(target_os = "ios", target_os = "macos")))] Some(AddressFamily::System) => Some(SockAddr::SysControl( SysControlAddr(*(addr as *const libc::sockaddr_ctl)))), - #[cfg(any(target_os = "android", target_os = "linux"))] + #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] + #[cfg(feature = "net")] Some(AddressFamily::Packet) => Some(SockAddr::Link( LinkAddr(*(addr as *const libc::sockaddr_ll)))), - #[cfg(any(target_os = "dragonfly", -@@ -833,7 +836,7 @@ impl SockAddr { +@@ -2026,7 +2033,7 @@ impl SockAddr { mem::size_of_val(sa) as libc::socklen_t ), - #[cfg(any(target_os = "android", target_os = "linux"))] + #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] + #[cfg(feature = "net")] SockAddr::Link(LinkAddr(ref addr)) => ( // This cast is always allowed in C - unsafe { -@@ -879,6 +882,7 @@ impl fmt::Display for SockAddr { - #[cfg(any(target_os = "ios", target_os = "macos"))] +@@ -2077,6 +2084,7 @@ impl fmt::Display for SockAddr { + any(target_os = "ios", target_os = "macos")))] SockAddr::SysControl(ref sc) => sc.fmt(f), #[cfg(any(target_os = "android", + target_os = "aero", target_os = "dragonfly", target_os = "freebsd", target_os = "ios", -@@ -1064,7 +1068,7 @@ pub mod sys_control { +@@ -2381,7 +2389,7 @@ pub mod sys_control { } -#[cfg(any(target_os = "android", target_os = "linux", target_os = "fuchsia"))] -+#[cfg(any(target_os = "android", target_os = "linux", target_os = "aero", target_os = "fuchsia"))] ++#[cfg(any(target_os = "android", target_os = "linux", target_os = "fuchsia", target_os = "aero"))] + #[cfg_attr(docsrs, doc(cfg(all())))] mod datalink { - use super::{fmt, AddressFamily}; - + feature! { diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs -index da5573c..3bac136 100644 +index 3f26ccf..c83182b 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs -@@ -251,6 +251,7 @@ libc_bitflags!{ +@@ -344,6 +344,7 @@ libc_bitflags!{ /// /// Only used in [`recvmsg`](fn.recvmsg.html) function. #[cfg(any(target_os = "android", @@ -469,7 +620,15 @@ index da5573c..3bac136 100644 target_os = "dragonfly", target_os = "freebsd", target_os = "linux", -@@ -866,13 +867,13 @@ impl<'a> ControlMessage<'a> { +@@ -355,6 +356,7 @@ libc_bitflags!{ + /// (For more details, see [send(2)](https://linux.die.net/man/2/send)). + #[cfg(any(target_os = "android", + target_os = "dragonfly", ++ target_os = "aero", + target_os = "freebsd", + target_os = "fuchsia", + target_os = "haiku", +@@ -1139,13 +1141,13 @@ impl<'a> ControlMessage<'a> { /// The value of CMSG_LEN on this message. /// Safe because CMSG_LEN is always safe @@ -486,10 +645,10 @@ index da5573c..3bac136 100644 fn cmsg_len(&self) -> libc::c_uint { unsafe{CMSG_LEN(self.len() as libc::c_uint)} diff --git a/src/sys/termios.rs b/src/sys/termios.rs -index 36a3601..c7bddc3 100644 +index a107f8b..6a9453e 100644 --- a/src/sys/termios.rs +++ b/src/sys/termios.rs -@@ -467,10 +467,19 @@ impl From for u32 { +@@ -375,10 +375,19 @@ impl From for u32 { } // TODO: Add TCSASOFT, which will require treating this as a bitfield. @@ -507,9 +666,9 @@ index 36a3601..c7bddc3 100644 +#[cfg(not(target_os = "aero"))] +libc_enum! { #[repr(i32)] + #[non_exhaustive] pub enum SetArg { - /// The change will occur immediately -@@ -482,10 +491,19 @@ libc_enum! { +@@ -391,10 +400,19 @@ libc_enum! { } } @@ -527,9 +686,9 @@ index 36a3601..c7bddc3 100644 +#[cfg(not(target_os = "aero"))] +libc_enum! { #[repr(i32)] + #[non_exhaustive] pub enum FlushArg { - /// Flush data that was received but not read -@@ -515,8 +533,17 @@ libc_enum! { +@@ -426,8 +444,17 @@ libc_enum! { } // TODO: Make this usable directly as a slice index. @@ -545,17 +704,18 @@ index 36a3601..c7bddc3 100644 +#[cfg(not(target_os = "aero"))] +libc_enum! { #[repr(usize)] + #[non_exhaustive] pub enum SpecialCharacterIndices { - VDISCARD, -@@ -601,13 +628,22 @@ libc_bitflags! { - IXOFF; +@@ -524,7 +551,7 @@ libc_bitflags! { #[cfg(not(target_os = "redox"))] + #[cfg_attr(docsrs, doc(cfg(all())))] IXANY; - #[cfg(not(target_os = "redox"))] + #[cfg(not(any(target_os = "redox", target_os = "aero")))] + #[cfg_attr(docsrs, doc(cfg(all())))] IMAXBEL; #[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))] - IUTF8; +@@ -533,6 +560,15 @@ libc_bitflags! { } } @@ -571,7 +731,7 @@ index 36a3601..c7bddc3 100644 libc_bitflags! { /// Flags for configuring the output mode of a terminal pub struct OutputFlags: tcflag_t { -@@ -791,8 +827,16 @@ libc_bitflags! { +@@ -744,8 +780,16 @@ libc_bitflags! { } } @@ -588,7 +748,7 @@ index 36a3601..c7bddc3 100644 pub struct ControlFlags: tcflag_t { #[cfg(any(target_os = "dragonfly", target_os = "freebsd", -@@ -859,8 +903,16 @@ libc_bitflags! { +@@ -824,8 +868,16 @@ libc_bitflags! { } } @@ -604,12 +764,46 @@ index 36a3601..c7bddc3 100644 +libc_bitflags! { pub struct LocalFlags: tcflag_t { #[cfg(not(target_os = "redox"))] - ECHOKE; + #[cfg_attr(docsrs, doc(cfg(all())))] +diff --git a/src/sys/time.rs b/src/sys/time.rs +index c1ab67b..f43cf63 100644 +--- a/src/sys/time.rs ++++ b/src/sys/time.rs +@@ -16,6 +16,7 @@ const TIMESPEC_ZERO: libc::timespec = unsafe { + target_os = "freebsd", + target_os = "illumos", + target_os = "linux", ++ target_os = "aero", + target_os = "netbsd" + ), + feature = "time", +@@ -82,7 +83,7 @@ pub(crate) mod timer { + Interval(TimeSpec), + } + +- #[cfg(any(target_os = "android", target_os = "linux"))] ++ #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] + bitflags! { + /// Flags that are used for arming the timer. + pub struct TimerSetTimeFlags: libc::c_int { +diff --git a/src/sys/timerfd.rs b/src/sys/timerfd.rs +index 18acbae..0005b24 100644 +--- a/src/sys/timerfd.rs ++++ b/src/sys/timerfd.rs +@@ -57,7 +57,7 @@ impl FromRawFd for TimerFd { + libc_enum! { + /// The type of the clock used to mark the progress of the timer. For more + /// details on each kind of clock, please refer to [timerfd_create(2)](https://man7.org/linux/man-pages/man2/timerfd_create.2.html). +- #[repr(i32)] ++ #[repr(i64)] + #[non_exhaustive] + pub enum ClockId { + /// A settable system-wide real-time clock. diff --git a/src/unistd.rs b/src/unistd.rs -index d94cb99..8e26266 100644 +index d6ccdf1..af3b4a0 100644 --- a/src/unistd.rs +++ b/src/unistd.rs -@@ -1081,6 +1081,7 @@ pub fn pipe() -> std::result::Result<(RawFd, RawFd), Error> { +@@ -1132,6 +1132,7 @@ feature! { /// See also [pipe(2)](https://man7.org/linux/man-pages/man2/pipe.2.html) #[cfg(any(target_os = "android", target_os = "dragonfly", @@ -617,7 +811,7 @@ index d94cb99..8e26266 100644 target_os = "emscripten", target_os = "freebsd", target_os = "illumos", -@@ -1478,6 +1479,7 @@ pub fn getgroups() -> Result> { +@@ -1550,6 +1551,7 @@ pub fn getgroups() -> Result> { pub fn setgroups(groups: &[Gid]) -> Result<()> { cfg_if! { if #[cfg(any(target_os = "dragonfly", @@ -625,7 +819,7 @@ index d94cb99..8e26266 100644 target_os = "freebsd", target_os = "illumos", target_os = "ios", -@@ -1799,6 +1801,14 @@ pub fn mkstemp(template: &P) -> Result<(RawFd, PathBuf)> { +@@ -1886,6 +1888,14 @@ feature! { /// - [pathconf(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pathconf.html) /// - [limits.h](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html) /// - [unistd.h](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html) @@ -639,8 +833,8 @@ index d94cb99..8e26266 100644 +#[cfg(not(target_os = "aero"))] #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] #[repr(i32)] - pub enum PathconfVar { -@@ -1978,6 +1988,17 @@ pub fn pathconf(path: &P, var: PathconfVar) -> Result for User { - gid: Gid::from_raw((*pw).pw_gid), +@@ -2913,18 +2937,21 @@ impl From<&libc::passwd> for User { + gid: Gid::from_raw(pw.pw_gid), #[cfg(not(any(target_os = "android", target_os = "fuchsia", + target_os = "aero", target_os = "illumos", target_os = "linux", target_os = "solaris")))] - class: CString::new(CStr::from_ptr((*pw).pw_class).to_bytes()).unwrap(), + class: CString::new(CStr::from_ptr(pw.pw_class).to_bytes()).unwrap(), #[cfg(not(any(target_os = "android", target_os = "fuchsia", + target_os = "aero", target_os = "illumos", target_os = "linux", target_os = "solaris")))] - change: (*pw).pw_change, + change: pw.pw_change, #[cfg(not(any(target_os = "android", target_os = "fuchsia", + target_os = "aero", target_os = "illumos", target_os = "linux", target_os = "solaris")))] +@@ -2960,18 +2987,21 @@ impl From for libc::passwd { + pw_gid: u.gid.0, + #[cfg(not(any(target_os = "android", + target_os = "fuchsia", ++ target_os = "aero", + target_os = "illumos", + target_os = "linux", + target_os = "solaris")))] + pw_class: u.class.into_raw(), + #[cfg(not(any(target_os = "android", + target_os = "fuchsia", ++ target_os = "aero", + target_os = "illumos", + target_os = "linux", + target_os = "solaris")))] + pw_change: u.change, + #[cfg(not(any(target_os = "android", + target_os = "fuchsia", ++ target_os = "aero", + target_os = "illumos", + target_os = "linux", + target_os = "solaris")))] -- -2.38.1 +2.39.1 diff --git a/patches/webkitgtk/webkitgtk.patch b/patches/webkitgtk/webkitgtk.patch index dc84db0ae41..f80e91ec667 100644 --- a/patches/webkitgtk/webkitgtk.patch +++ b/patches/webkitgtk/webkitgtk.patch @@ -37,37 +37,37 @@ index 7857bfc167..c14fbb5b6c 100644 @@ -346,7 +346,7 @@ static inline void*& framePointerImpl(mcontext_t& machineContext) #error Unknown Architecture #endif - + -#elif OS(FUCHSIA) || OS(LINUX) +#elif OS(FUCHSIA) || OS(LINUX) || OS(AERO) - + // The following sequence depends on glibc's sys/ucontext.h. #if CPU(X86) @@ -497,7 +497,7 @@ static inline void*& instructionPointerImpl(mcontext_t& machineContext) #error Unknown Architecture #endif - + -#elif OS(FUCHSIA) || OS(LINUX) +#elif OS(FUCHSIA) || OS(LINUX) || OS(AERO) - + // The following sequence depends on glibc's sys/ucontext.h. #if CPU(X86) @@ -655,7 +655,7 @@ inline void*& argumentPointer<1>(mcontext_t& machineContext) #error Unknown Architecture #endif - + -#elif OS(FUCHSIA) || OS(LINUX) +#elif OS(FUCHSIA) || OS(LINUX) || OS(AERO) - + // The following sequence depends on glibc's sys/ucontext.h. #if CPU(X86) @@ -772,7 +772,7 @@ inline void*& llintInstructionPointer(mcontext_t& machineContext) #error Unknown Architecture #endif - + -#elif OS(FUCHSIA) || OS(LINUX) +#elif OS(FUCHSIA) || OS(LINUX) || OS(AERO) - + // The following sequence depends on glibc's sys/ucontext.h. #if CPU(X86) diff --git a/Source/JavaScriptCore/runtime/Options.cpp b/Source/JavaScriptCore/runtime/Options.cpp @@ -102,7 +102,7 @@ index 8379a69659..8f7493769f 100644 @@ -43,11 +43,11 @@ #define THUMB_FUNC_PARAM(name) #endif - + -#if (OS(LINUX) || OS(FREEBSD)) && CPU(X86_64) +#if (OS(LINUX) || OS(FREEBSD) || OS(AERO)) && CPU(X86_64) #define GLOBAL_REFERENCE(name) #name "@plt" @@ -138,21 +138,21 @@ index 61f13c2b73..de93124ef8 100644 @@ -226,7 +226,7 @@ #define HAVE_HOSTED_CORE_ANIMATION 1 #endif - + -#if OS(DARWIN) || OS(FUCHSIA) || ((OS(FREEBSD) || OS(LINUX)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS))) +#if OS(DARWIN) || OS(FUCHSIA) || OS(AERO) || ((OS(FREEBSD) || OS(LINUX)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS))) #define HAVE_MACHINE_CONTEXT 1 #endif - + @@ -238,7 +238,7 @@ #define HAVE_BACKTRACE_SYMBOLS 1 #endif - + -#if OS(DARWIN) || OS(LINUX) +#if OS(DARWIN) || OS(LINUX) || OS(AERO) #define HAVE_DLADDR 1 #endif - + diff --git a/Source/WTF/wtf/PlatformOS.h b/Source/WTF/wtf/PlatformOS.h index e61715fb72..ed72f251a9 100644 --- a/Source/WTF/wtf/PlatformOS.h @@ -160,13 +160,13 @@ index e61715fb72..ed72f251a9 100644 @@ -118,6 +118,11 @@ #define WTF_OS_WINDOWS 1 #endif - + +/* OS(AERO) - Aero */ +#if defined(__aero__) +#define WTF_OS_AERO 1 +#endif + - + /* OS(UNIX) - Any Unix-like system */ #if OS(AIX) \ @@ -128,6 +133,7 @@ @@ -184,12 +184,12 @@ index 743ef3dc84..3a61bc1dc3 100644 @@ -148,8 +148,8 @@ bool SQLiteDatabase::open(const String& filename, OpenMode openMode) LOG_ERROR("SQLite database could not set temp_store to memory"); } - + - if (openMode != OpenMode::ReadOnly) - useWALJournalMode(); + // if (openMode != OpenMode::ReadOnly) + // useWALJournalMode(); - + auto shmFileName = makeString(filename, "-shm"_s); if (FileSystem::fileExists(shmFileName)) { @@ -727,7 +727,7 @@ Expected SQLiteDatabase::prepareStatement(ASCIILiteral que @@ -206,7 +206,7 @@ index efcd663f84..11e5467c10 100644 --- a/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp +++ b/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp @@ -46,7 +46,7 @@ - + // Although it's available on Darwin, SOCK_SEQPACKET seems to work differently // than in traditional Unix so fallback to STREAM on that platform. -#if defined(SOCK_SEQPACKET) && !OS(DARWIN) @@ -219,14 +219,14 @@ index 998a2a7679..a490b3fb5f 100644 --- a/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp +++ b/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp @@ -47,8 +47,10 @@ - + #if HAVE(LINUX_MEMFD_H) #include +#if !OS(AERO) #include #endif +#endif - + #if PLATFORM(PLAYSTATION) #include "ArgumentCoders.h" @@ -132,7 +134,7 @@ static int createSharedMemory() @@ -236,7 +236,8 @@ index 998a2a7679..a490b3fb5f 100644 - fileDescriptor = syscall(__NR_memfd_create, "WebKitSharedMemory", MFD_CLOEXEC); + fileDescriptor = memfd_create("WebKitSharedMemory", MFD_CLOEXEC); } while (fileDescriptor == -1 && errno == EINTR); - + if (fileDescriptor != -1) -- -2.40.0 \ No newline at end of file +2.40.0 + diff --git a/patches/xorg-server/xorg-server.patch b/patches/xorg-server/xorg-server.patch index 3ef2ef41b18..9dc515d75fd 100644 --- a/patches/xorg-server/xorg-server.patch +++ b/patches/xorg-server/xorg-server.patch @@ -1,100 +1,114 @@ -From b43c01a762f484fd03051b57724cdad82584c9aa Mon Sep 17 00:00:00 2001 -From: Anhad Singh -Date: Tue, 23 May 2023 19:10:14 +1000 -Subject: [PATCH] ^) +From 6f785e20e4034b9016aa7e6cebc204f95b7808d6 Mon Sep 17 00:00:00 2001 +From: mintsuki +Date: Sun, 20 Feb 2022 06:19:57 +0100 +Subject: [PATCH] Lyre specific changes -Signed-off-by: Anhad Singh --- + configure.ac | 2 ++ hw/xfree86/common/xf86Bus.c | 2 ++ hw/xfree86/common/xf86Config.c | 2 ++ - hw/xfree86/common/xf86Configure.c | 1 + - hw/xfree86/common/xf86Events.c | 1 + - hw/xfree86/common/xf86Helper.c | 1 + + hw/xfree86/common/xf86Configure.c | 2 ++ + hw/xfree86/common/xf86Events.c | 2 ++ + hw/xfree86/common/xf86Helper.c | 2 ++ hw/xfree86/common/xf86Init.c | 2 ++ - hw/xfree86/fbdevhw/fbdevhw.c | 36 +++++++++++++++--------- - hw/xfree86/fbdevhw/fbdevhw.h | 4 +-- - hw/xfree86/fbdevhw/meson.build | 2 +- - hw/xfree86/os-support/shared/posix_tty.c | 3 ++ - hw/xfree86/os-support/shared/sigio.c | 3 ++ + hw/xfree86/fbdevhw/fbdevhw.c | 26 +++++++++++------------- + hw/xfree86/fbdevhw/fbdevhw.h | 4 ++-- + hw/xfree86/os-support/shared/posix_tty.c | 3 +++ + hw/xfree86/os-support/shared/sigio.c | 3 +++ include/os.h | 1 + - meson.build | 3 +- mi/mibitblt.c | 2 ++ os/access.c | 2 +- os/ospoll.c | 2 ++ - os/utils.c | 4 +-- - 17 files changed, 50 insertions(+), 21 deletions(-) + os/utils.c | 4 ++-- + 16 files changed, 42 insertions(+), 19 deletions(-) +diff --git a/configure.ac b/configure.ac +index 0909cc5..f551571 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1966,6 +1966,8 @@ if test "x$XORG" = xyes; then + if test "x$DRM" = xyes; then + XORG_DRIVER_MODESETTING=yes + fi ++ ++ XORG_DRIVER_MODESETTING=no + + AC_SUBST([XORG_LIBS]) + AC_SUBST([XORG_SYS_LIBS]) diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c -index fd144db..b232e27 100644 +index a8f1073..1b1120a 100644 --- a/hw/xfree86/common/xf86Bus.c +++ b/hw/xfree86/common/xf86Bus.c -@@ -556,6 +556,7 @@ xf86GetDevFromEntity(int entityIndex, int instance) +@@ -536,6 +536,7 @@ xf86GetDevFromEntity(int entityIndex, int instance) void xf86PostProbe(void) { -+#if 0 ++/* if (fbSlotClaimed && ( #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) sbusSlotClaimed || -@@ -571,6 +572,7 @@ xf86PostProbe(void) +@@ -551,6 +552,7 @@ xf86PostProbe(void) )) FatalError("Cannot run in framebuffer mode. Please specify busIDs " " for all framebuffer devices\n"); -+#endif ++*/ } - Bool + int diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c -index 5d814c1..dabfec8 100644 +index 09d27ec..83be062 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c -@@ -47,6 +47,8 @@ - #endif - +@@ -49,6 +49,8 @@ #include -+#include -+ #include ++#include ++ #include "xf86.h" + #include "xf86Modes.h" + #include "xf86Parser.h" diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c -index 4347f6d..3a66af7 100644 +index 44e7591..86d48d5 100644 --- a/hw/xfree86/common/xf86Configure.c +++ b/hw/xfree86/common/xf86Configure.c -@@ -27,6 +27,7 @@ +@@ -27,6 +27,8 @@ #include #endif +#include ++ #include "xf86.h" #include "xf86Config.h" #include "xf86_OSlib.h" diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c -index 395bbc7..5937017 100644 +index 8a800bd..ec5d33d 100644 --- a/hw/xfree86/common/xf86Events.c +++ b/hw/xfree86/common/xf86Events.c -@@ -53,6 +53,7 @@ +@@ -53,6 +53,8 @@ #include #endif +#include ++ #include #include #include diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c -index 0389945..ac231bf 100644 +index 42a51dd..64af1dc 100644 --- a/hw/xfree86/common/xf86Helper.c +++ b/hw/xfree86/common/xf86Helper.c -@@ -38,6 +38,7 @@ +@@ -38,6 +38,8 @@ #include #endif +#include ++ #include - #include "mi.h" #include "os.h" + #include "servermd.h" diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c -index 5695e71..96c2d15 100644 +index 2ec6b2f..c1d9c24 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -37,6 +37,8 @@ @@ -107,58 +121,57 @@ index 5695e71..96c2d15 100644 #if !defined(WIN32) #define HAS_UTSNAME 1 diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c -index 3d8b92e..dae3960 100644 +index 9508951..bce130c 100644 --- a/hw/xfree86/fbdevhw/fbdevhw.c +++ b/hw/xfree86/fbdevhw/fbdevhw.c -@@ -10,12 +10,13 @@ +@@ -10,12 +10,12 @@ #include "xf86_OSproc.h" /* pci stuff */ -#include "xf86Pci.h" -+// #include "xf86Pci.h" ++//#include "xf86Pci.h" #include "xf86cmap.h" #include "fbdevhw.h" -#include "fbpriv.h" -+// #include "fbpriv.h" +#include #include "globals.h" #include -@@ -259,6 +260,7 @@ fbdev2xfree_timing(struct fb_var_screeninfo *var, DisplayModePtr mode) +@@ -259,6 +259,7 @@ fbdev2xfree_timing(struct fb_var_screeninfo *var, DisplayModePtr mode) /** * Try to find the framebuffer device for a given PCI device */ -+#if 0 ++/* static int fbdev_open_pci(struct pci_device *pPci, char **namep) { -@@ -303,6 +305,7 @@ fbdev_open_pci(struct pci_device *pPci, char **namep) +@@ -303,6 +304,7 @@ fbdev_open_pci(struct pci_device *pPci, char **namep) xf86DrvMsg(-1, X_ERROR, "Unable to find a valid framebuffer device\n"); return -1; } -+#endif ++*/ static int fbdev_open(int scrnIndex, const char *dev, char **namep) -@@ -330,6 +333,7 @@ fbdev_open(int scrnIndex, const char *dev, char **namep) +@@ -330,6 +332,7 @@ fbdev_open(int scrnIndex, const char *dev, char **namep) } /* only touch non-PCI devices on this path */ -+#if 0 ++/* { - char buf[PATH_MAX] = {0}; + char buf[PATH_MAX]; char *sysfs_path = NULL; -@@ -344,6 +348,7 @@ fbdev_open(int scrnIndex, const char *dev, char **namep) +@@ -344,6 +347,7 @@ fbdev_open(int scrnIndex, const char *dev, char **namep) } free(sysfs_path); } -+#endif ++*/ if (namep) { if (-1 == ioctl(fd, FBIOGET_FSCREENINFO, (void *) (&fix))) { -@@ -363,14 +368,16 @@ fbdev_open(int scrnIndex, const char *dev, char **namep) +@@ -363,14 +367,11 @@ fbdev_open(int scrnIndex, const char *dev, char **namep) /* -------------------------------------------------------------------- */ Bool @@ -171,16 +184,11 @@ index 3d8b92e..dae3960 100644 - fd = fbdev_open_pci(pPci, namep); - else - fd = fbdev_open(-1, device, namep); -+ // if (pPci) -+ // fd = fbdev_open_pci(pPci, namep); -+ // else -+ // fd = fbdev_open(-1, device, namep); -+ + fd = fbdev_open(-1, device, namep); if (-1 == fd) return FALSE; -@@ -379,7 +386,7 @@ fbdevHWProbe(struct pci_device *pPci, char *device, char **namep) +@@ -379,7 +380,7 @@ fbdevHWProbe(struct pci_device *pPci, char *device, char **namep) } Bool @@ -189,7 +197,7 @@ index 3d8b92e..dae3960 100644 { fbdevHWPtr fPtr; -@@ -387,10 +394,11 @@ fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device *pPci, char *device) +@@ -387,10 +388,7 @@ fbdevHWInit(ScrnInfoPtr pScrn, struct pci_device *pPci, char *device) fPtr = FBDEVHWPTR(pScrn); /* open device */ @@ -197,15 +205,11 @@ index 3d8b92e..dae3960 100644 - fPtr->fd = fbdev_open_pci(pPci, NULL); - else - fPtr->fd = fbdev_open(pScrn->scrnIndex, device, NULL); -+ // if (pPci) -+ // fPtr->fd = fbdev_open_pci(pPci, NULL); -+ // else -+ // fPtr->fd = fbdev_open(pScrn->scrnIndex, device, NULL); + fPtr->fd = fbdev_open(pScrn->scrnIndex, device, NULL); if (-1 == fPtr->fd) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to open framebuffer device, consult warnings" -@@ -881,7 +889,7 @@ RETRY: +@@ -881,7 +879,7 @@ RETRY: "FBIOBLANK: %s\n", strerror(errno)); break; case EINTR: @@ -214,7 +218,7 @@ index 3d8b92e..dae3960 100644 goto RETRY; default: fPtr->unsupported_ioctls |= (1 << FBIOBLANK_UNSUPPORTED); -@@ -915,7 +923,7 @@ RETRY: +@@ -915,7 +913,7 @@ RETRY: "FBIOBLANK: %s\n", strerror(errno)); break; case EINTR: @@ -239,16 +243,6 @@ index 4984ccf..bb3e2f8 100644 char *device); extern _X_EXPORT char *fbdevHWGetName(ScrnInfoPtr pScrn); -diff --git a/hw/xfree86/fbdevhw/meson.build b/hw/xfree86/fbdevhw/meson.build -index f3146f3..5e5e6e8 100644 ---- a/hw/xfree86/fbdevhw/meson.build -+++ b/hw/xfree86/fbdevhw/meson.build -@@ -1,4 +1,4 @@ --if host_machine.system() == 'linux' -+if host_machine.system() == 'linux' or host_machine.system() == 'aero' - srcs_fbdevhw = 'fbdevhw.c' - else - srcs_fbdevhw = 'fbdevhwstub.c' diff --git a/hw/xfree86/os-support/shared/posix_tty.c b/hw/xfree86/os-support/shared/posix_tty.c index 0cb9788..e8cac5d 100644 --- a/hw/xfree86/os-support/shared/posix_tty.c @@ -264,7 +258,7 @@ index 0cb9788..e8cac5d 100644 #include #include "xf86.h" diff --git a/hw/xfree86/os-support/shared/sigio.c b/hw/xfree86/os-support/shared/sigio.c -index ad8af60..6f81278 100644 +index 247bec7..216e8cd 100644 --- a/hw/xfree86/os-support/shared/sigio.c +++ b/hw/xfree86/os-support/shared/sigio.c @@ -56,6 +56,9 @@ @@ -278,7 +272,7 @@ index ad8af60..6f81278 100644 #include #include "xf86.h" diff --git a/include/os.h b/include/os.h -index bb3348b..64b04dc 100644 +index 2a1c29e..2a7fc76 100644 --- a/include/os.h +++ b/include/os.h @@ -51,6 +51,7 @@ SOFTWARE. @@ -289,22 +283,8 @@ index bb3348b..64b04dc 100644 #ifdef MONOTONIC_CLOCK #include #endif -diff --git a/meson.build b/meson.build -index 637938a..b5d761c 100644 ---- a/meson.build -+++ b/meson.build -@@ -439,7 +439,8 @@ if not libdrm_dep.found() and libdrm_required - error('DRI requested, but LIBDRM not found') - endif - --build_modesetting = libdrm_dep.found() and dri2proto_dep.found() -+# build_modesetting = libdrm_dep.found() and dri2proto_dep.found() -+build_modesetting = false - - build_vgahw = false - if get_option('vgahw') == 'auto' diff --git a/mi/mibitblt.c b/mi/mibitblt.c -index 0b13e49..aff6539 100644 +index 43d9bd9..740c0d2 100644 --- a/mi/mibitblt.c +++ b/mi/mibitblt.c @@ -49,6 +49,8 @@ SOFTWARE. @@ -317,11 +297,11 @@ index 0b13e49..aff6539 100644 #include diff --git a/os/access.c b/os/access.c -index 61ee8e3..24cabae 100644 +index 9724616..3c4376a 100644 --- a/os/access.c +++ b/os/access.c -@@ -120,7 +120,7 @@ SOFTWARE. - #include +@@ -117,7 +117,7 @@ SOFTWARE. + #endif #endif -#if defined(SVR4) || (defined(SYSV) && defined(__i386__)) || defined(__GNU__) @@ -330,28 +310,28 @@ index 61ee8e3..24cabae 100644 #endif #if defined(SYSV) && defined(__i386__) diff --git a/os/ospoll.c b/os/ospoll.c -index c68aabc..19006c3 100644 +index c68aabc..a3217dc 100644 --- a/os/ospoll.c +++ b/os/ospoll.c @@ -45,11 +45,13 @@ #define HAVE_OSPOLL 1 #endif -+#if 0 ++/* #if !HAVE_OSPOLL && defined(HAVE_EPOLL_CREATE1) #include #define EPOLL 1 #define HAVE_OSPOLL 1 #endif -+#endif ++*/ #if !HAVE_OSPOLL #include "xserver_poll.h" diff --git a/os/utils.c b/os/utils.c -index 92a66e8..646722e 100644 +index 2ba1c80..63dedc6 100644 --- a/os/utils.c +++ b/os/utils.c -@@ -1403,7 +1403,7 @@ System(const char *command) +@@ -1402,7 +1402,7 @@ System(const char *command) return -1; } @@ -360,7 +340,7 @@ index 92a66e8..646722e 100644 } static struct pid { -@@ -1633,7 +1633,7 @@ Pclose(void *iop) +@@ -1632,7 +1632,7 @@ Pclose(void *iop) } #endif @@ -370,5 +350,4 @@ index 92a66e8..646722e 100644 int -- -2.40.1 - +2.35.1 diff --git a/src/aero_kernel/src/arch/x86_64/task.rs b/src/aero_kernel/src/arch/x86_64/task.rs index 65dbe30a927..f6370fdbca8 100644 --- a/src/aero_kernel/src/arch/x86_64/task.rs +++ b/src/aero_kernel/src/arch/x86_64/task.rs @@ -77,6 +77,7 @@ pub enum AuxvType { PhEnt = 4, PhNum = 5, Entry = 9, + Secure = 23, } /// Returns the first address outside the user range. @@ -401,7 +402,7 @@ impl ArchTask { let p2_header = loaded_binary.elf.header.pt2; unsafe { - let hdr: [(AuxvType, usize); 4] = [ + let hdr: [(AuxvType, usize); 5] = [ ( AuxvType::Phdr, (p2_header.ph_offset() + loaded_binary.base_addr.as_u64()) as usize, @@ -409,6 +410,7 @@ impl ArchTask { (AuxvType::PhEnt, p2_header.ph_entry_size() as usize), (AuxvType::PhNum, p2_header.ph_count() as usize), (AuxvType::Entry, p2_header.entry_point() as usize), + (AuxvType::Secure, 0), ]; stack.write(0usize); // Make it 16 bytes aligned diff --git a/src/aero_kernel/src/fs/block/mod.rs b/src/aero_kernel/src/fs/block/mod.rs index 6f230b56f49..c7589fec014 100644 --- a/src/aero_kernel/src/fs/block/mod.rs +++ b/src/aero_kernel/src/fs/block/mod.rs @@ -247,6 +247,7 @@ pub trait CachedAccess: BlockDeviceInterface { ); page.mark_dirty(); + page.sync(); loc += size; offset = align_down(offset as u64 + Size4KiB::SIZE, Size4KiB::SIZE) as usize; diff --git a/src/aero_kernel/src/fs/eventfd.rs b/src/aero_kernel/src/fs/eventfd.rs index 19972372a38..06dd3a78789 100644 --- a/src/aero_kernel/src/fs/eventfd.rs +++ b/src/aero_kernel/src/fs/eventfd.rs @@ -37,7 +37,7 @@ impl EventFd { impl INodeInterface for EventFd { fn read_at(&self, _offset: usize, buffer: &mut [u8]) -> super::Result { let size = core::mem::size_of::(); - assert!(buffer.len() == size); + assert!(buffer.len() >= size); // SAFETY: We have above verified that it is safe to dereference // the value. @@ -53,7 +53,7 @@ impl INodeInterface for EventFd { fn write_at(&self, _offset: usize, buffer: &[u8]) -> super::Result { let size = core::mem::size_of::(); - assert!(buffer.len() == size); + assert!(buffer.len() >= size); // SAFETY: We have above verified that it is safe to dereference // the value. diff --git a/src/aero_kernel/src/fs/ext2/group_desc.rs b/src/aero_kernel/src/fs/ext2/group_desc.rs index 3380add761a..d3552158ba2 100644 --- a/src/aero_kernel/src/fs/ext2/group_desc.rs +++ b/src/aero_kernel/src/fs/ext2/group_desc.rs @@ -204,14 +204,16 @@ impl Bitmap { /// Allocates a free bit in the bitmap and returns its index. pub fn alloc(&mut self) -> Option { - for (i, e) in self.bitmap.iter_mut().enumerate() { - if *e != u8::MAX { - for bit in 0..8 { - if !e.get_bit(bit) { - e.set_bit(bit, true); - - return Some(i * 8 + bit); - } + for (i, byte) in self.bitmap.iter_mut().enumerate() { + if *byte == u8::MAX { + continue; + } + + for bit in 0..8 { + if !byte.get_bit(bit) { + byte.set_bit(bit, true); + + return Some(i * 8 + bit); } } } diff --git a/src/aero_kernel/src/fs/ext2/mod.rs b/src/aero_kernel/src/fs/ext2/mod.rs index 817d09a570e..2c0a22ae82e 100644 --- a/src/aero_kernel/src/fs/ext2/mod.rs +++ b/src/aero_kernel/src/fs/ext2/mod.rs @@ -211,12 +211,17 @@ impl INode { if block_ptrs == 0 { block_ptrs = fs.bgdt.alloc_block_ptr()?; + self.inode.write().data_ptr[12] = block_ptrs as u32; } let block_ptrs = block_ptrs * block_size; - let offset = block_ptrs + (new_block * core::mem::size_of::()); + let offset = block_ptrs + (next_block_num * core::mem::size_of::()); fs.block.write(offset, &new_block.to_le_bytes()); + + let mut inode = self.inode.write(); + let inode_size = inode.size() + block_size; + inode.set_size(inode_size); } Some(new_block) @@ -303,7 +308,7 @@ impl INode { proxy: Option>, ) -> super::Result { if !self.metadata()?.is_directory() { - return Err(FileSystemError::NotSupported); + return Err(FileSystemError::NotDirectory); } if DirEntryIter::new(self.sref()).any(|(e, _)| e == name) { @@ -479,7 +484,7 @@ impl INodeInterface for INode { fn touch(&self, parent: DirCacheItem, name: &str) -> super::Result { if !self.metadata()?.is_directory() { - return Err(FileSystemError::NotSupported); + return Err(FileSystemError::NotDirectory); } let inode = self.make_inode(name, FileType::File, None)?; @@ -488,7 +493,7 @@ impl INodeInterface for INode { fn mkdir(&self, name: &str) -> super::Result { if !self.metadata()?.is_directory() { - return Err(FileSystemError::NotSupported); + return Err(FileSystemError::NotDirectory); } self.make_inode(name, FileType::Directory, None) @@ -532,7 +537,7 @@ impl INodeInterface for INode { assert!(self.proxy.is_none()); // TODO: support shared file mappings. - assert!(!flags.contains(MMapFlags::MAP_SHARED)); + // assert!(!flags.contains(MMapFlags::MAP_SHARED)); let private_cp: PhysFrame = FRAME_ALLOCATOR.allocate_frame().unwrap(); private_cp.as_slice_mut().fill(0); diff --git a/src/aero_kernel/src/fs/mod.rs b/src/aero_kernel/src/fs/mod.rs index cc3327fbaa3..230b12a4532 100644 --- a/src/aero_kernel/src/fs/mod.rs +++ b/src/aero_kernel/src/fs/mod.rs @@ -21,6 +21,7 @@ use aero_syscall::SyscallError; use alloc::collections::BTreeMap; use alloc::sync::Arc; +use crate::fs::cache::DirCacheImpl; use crate::userland::scheduler; use crate::utils::sync::Mutex; use spin::Once; @@ -198,7 +199,7 @@ impl Path { } } -#[derive(Debug, PartialEq)] +#[derive(Debug, Copy, Clone, PartialEq)] pub enum LookupMode { None, /// Creates the file if it does not exist. @@ -248,8 +249,17 @@ pub fn lookup_path_with( } else { // todo: fix this shit cwd.inode().mkdir(component)?; - cwd = - lookup_path_with(cwd, Path::new(component), LookupMode::None)?; + cwd = match lookup_path_with( + cwd.clone(), + Path::new(component), + LookupMode::None, + ) { + Ok(x) => x, + Err(e) => { + dbg!(component, cwd.absolute_path_str()); + return Err(dbg!(e)); + } + }; } } diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index e0c73d006cd..125db66fd92 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -75,6 +75,7 @@ mod prelude { pub use alloc::string::String; + pub use crate::rendy::dbg; pub use static_assertions::*; } } diff --git a/src/aero_kernel/src/mem/paging/mapper.rs b/src/aero_kernel/src/mem/paging/mapper.rs index 94d863cf5ff..169a01bd093 100644 --- a/src/aero_kernel/src/mem/paging/mapper.rs +++ b/src/aero_kernel/src/mem/paging/mapper.rs @@ -1189,8 +1189,11 @@ impl<'a> OffsetPageTable<'a> { let last_level_fork = |entry: &mut PageTableEntry, n1: &mut PageTable, i: usize| { let mut flags = entry.flags(); - // Setup copy on write page. - flags.remove(PageTableFlags::WRITABLE); + // Check if the mapping is shared. + if !flags.contains(PageTableFlags::BIT_10) { + // Setup copy on write page. + flags.remove(PageTableFlags::WRITABLE); + } entry.set_flags(flags); n1[i].set_frame(entry.frame().unwrap(), flags); diff --git a/src/aero_kernel/src/rendy.rs b/src/aero_kernel/src/rendy.rs index 0bb171e7a65..30a13e7c29d 100644 --- a/src/aero_kernel/src/rendy.rs +++ b/src/aero_kernel/src/rendy.rs @@ -897,7 +897,7 @@ pub macro println { pub macro dbg { () => { - $crate::rendy::println!("[{}:{}]", $crate::file!(), $crate::line!()); + log::debug!("[{}:{}]", $crate::file!(), $crate::line!()); }, ($val:expr $(,)?) => { @@ -905,8 +905,7 @@ pub macro dbg { // of temporaries - https://stackoverflow.com/a/48732525/1063961 match $val { tmp => { - $crate::rendy::println!("[{}:{}] {} = {:#?}", - core::file!(), core::line!(), core::stringify!($val), &tmp); + log::debug!("[{}:{}] {} = {:#?}", core::file!(), core::line!(), core::stringify!($val), &tmp); tmp } } diff --git a/src/aero_kernel/src/syscall/fs.rs b/src/aero_kernel/src/syscall/fs.rs index f0e9a81d149..a861e0f133f 100644 --- a/src/aero_kernel/src/syscall/fs.rs +++ b/src/aero_kernel/src/syscall/fs.rs @@ -410,7 +410,10 @@ pub fn fcntl(fd: usize, command: usize, arg: usize) -> Result unimplemented!("fcntl: unknown command {command}"), + _ => { + log::error!("fcntl: unknown command {command}"); + Ok(0) + } } } diff --git a/src/aero_kernel/src/syscall/mod.rs b/src/aero_kernel/src/syscall/mod.rs index 7c1941b6a26..db3ff553376 100644 --- a/src/aero_kernel/src/syscall/mod.rs +++ b/src/aero_kernel/src/syscall/mod.rs @@ -157,6 +157,10 @@ impl SysLog { result.push_str(alloc::format!(") = {:?}", self.result.unwrap()).as_str()); log::trace!("{result}"); + + if self.result.unwrap().is_err() { + crate::unwind::unwind_stack_trace(); + } } } diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs index fbc0fe723e8..7fe895cc29a 100644 --- a/src/aero_kernel/src/userland/vm.rs +++ b/src/aero_kernel/src/userland/vm.rs @@ -432,17 +432,17 @@ impl Mapping { .mmap(offset as _, size as _, self.flags) .expect("handle_pf_file: file does not support mmap"); - unsafe { - offset_table.map_to( - Page::containing_address(address), - frame, - PageTableFlags::PRESENT - | PageTableFlags::USER_ACCESSIBLE - | self.protection.into(), - ) + let mut flags = PageTableFlags::PRESENT + | PageTableFlags::USER_ACCESSIBLE + | self.protection.into(); + + if self.flags.contains(MMapFlags::MAP_SHARED) { + flags |= PageTableFlags::BIT_10; } - .expect("failed to map allocated frame for private file read") - .flush(); + + unsafe { offset_table.map_to(Page::containing_address(address), frame, flags) } + .expect("failed to map allocated frame for private file read") + .flush(); true } else if reason.contains(PageFaultErrorCode::CAUSED_BY_WRITE) { diff --git a/src/aero_proc/src/syscall.rs b/src/aero_proc/src/syscall.rs index 6f8751e5106..cbd5089c522 100644 --- a/src/aero_proc/src/syscall.rs +++ b/src/aero_proc/src/syscall.rs @@ -275,21 +275,22 @@ fn process_call_args(args: &Punctuated) -> Vec { let len_ident = Ident::new(&format!("{}_len", ident), Span::call_site()); match arg_type { - ArgType::Slice(is_mut) => { - let slice_expr: Expr = if is_mut { - syn::parse_quote! { - crate::utils::validate_slice_mut(#data_ident as *mut _, #len_ident)? - } - } else { - syn::parse_quote! { - crate::utils::validate_slice(#data_ident as *const _, #len_ident)? - } - }; - - result.push(slice_expr); - } - ArgType::Array(is_mut) => { - let array_expr: Expr = if is_mut { + ArgType::Slice(is_mut) => { + let slice_expr: Expr = if is_mut { + syn::parse_quote! { + crate::utils::validate_slice_mut(#data_ident as *mut _, #len_ident)? + } + } else { + syn::parse_quote! { + crate::utils::validate_slice(#data_ident as *const _, #len_ident)? + } + }; + + result.push(slice_expr); + } + + ArgType::Array(is_mut) => { + let array_expr: Expr = if is_mut { syn::parse_quote! { crate::utils::validate_array_mut(#data_ident as *mut _)? } @@ -299,6 +300,7 @@ fn process_call_args(args: &Punctuated) -> Vec { result.push(array_expr); } + ArgType::Pointer(is_mut) => { let ptr_expr: Expr = if is_mut { syn::parse_quote!(#ident as *mut _) diff --git a/tools/cargo-inject-patches.py b/tools/cargo-inject-patches.py index 6d2d6fe48b3..7d046383d9d 100644 --- a/tools/cargo-inject-patches.py +++ b/tools/cargo-inject-patches.py @@ -9,17 +9,19 @@ patched_libs = { "backtrace": "0.3.64", "calloop": "0.9.3", - "libc": "0.2.139", - "libloading": "0.7.3", + "libc": "0.2.149", + "getrandom": "0.2.9", + "libloading": "0.8.1", "mio": ["0.6.23", "0.8.3"], - "nix": "0.22.3", - "num_cpus": "1.13.0", + "nix": "0.24.3", + "num_cpus": "1.15.0", "users": "0.11.0", "winit": "0.26.1", "glutin": "0.28.0", "glutin_glx_sys": "0.1.7", "glutin_egl_sys": "0.1.5", "shared_library": "0.1.9", + "rustix": "0.38.13" } parser = argparse.ArgumentParser(description="Inject patched Rust libraries into Cargo lockfiles") diff --git a/userland/apps/init/src/main.rs b/userland/apps/init/src/main.rs index ecbaef5d8c2..fc30f33b071 100644 --- a/userland/apps/init/src/main.rs +++ b/userland/apps/init/src/main.rs @@ -53,21 +53,21 @@ fn main() -> Result<(), Box> { let stdout = OpenOptions::new().write(true).open(TTY_PATH)?; // fd=1 let stderr = OpenOptions::new().write(true).open(TTY_PATH)?; // fd=2 - { - let stdset = FileSet::new([stdin, stdout, stderr]); - stdset.remove_cloexec(); + // { + let stdset = FileSet::new([stdin, stdout, stderr]); + stdset.remove_cloexec(); - Command::new("dhcpd").spawn()?; - } + Command::new("dhcpd").spawn()?; + // } - // Swap the `/dev/tty` std{in,out,err} file descriptors with `/dev/null` to suppress the Xorg - // server logs. - let stdin = OpenOptions::new().read(true).open(DEV_NULL)?; // fd=0 - let stdout = OpenOptions::new().write(true).open(DEV_NULL)?; // fd=1 - let stderr = OpenOptions::new().write(true).open(DEV_NULL)?; // fd=2 + // // Swap the `/dev/tty` std{in,out,err} file descriptors with `/dev/null` to suppress the Xorg + // // server logs. + // let stdin = OpenOptions::new().read(true).open(DEV_NULL)?; // fd=0 + // let stdout = OpenOptions::new().write(true).open(DEV_NULL)?; // fd=1 + // let stderr = OpenOptions::new().write(true).open(DEV_NULL)?; // fd=2 - let stdset = FileSet::new([stdin, stdout, stderr]); - stdset.remove_cloexec(); + // let stdset = FileSet::new([stdin, stdout, stderr]); + // stdset.remove_cloexec(); Command::new("startx") .env("RUST_BACKTRACE", "full") From 6b2f4e75f7535b11f63457b709c4d2a3d4f6b9e4 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sun, 15 Oct 2023 21:18:04 +1100 Subject: [PATCH 008/112] update Signed-off-by: Anhad Singh --- bootstrap.yml | 14 +- bootstrap/vcs.yml | 92 ++-- bootstrap/xorg.yml | 91 ++-- patched.txt | 5 + patches/glib/{glib.patch => 0001-glib.patch} | 0 ...ch-out-assert-in-g_io_unix_get_flags.patch | 30 ++ patches/mlibc/mlibc.patch | 138 +++-- patches/rust-libloading/rust-libloading.patch | 23 +- patches/rust-nix/rust-nix.patch | 507 +++++------------- ....patch => 0001-Initial-Aero-support.patch} | 22 +- patches/webkitgtk/0002-xxx.patch | 181 +++++++ .../src/arch/x86_64/interrupts/exceptions.rs | 17 + src/aero_kernel/src/arch/x86_64/mod.rs | 4 +- src/aero_kernel/src/arch/x86_64/task.rs | 182 +++++-- src/aero_kernel/src/mem/mod.rs | 10 +- src/aero_kernel/src/mem/paging/mapper.rs | 8 +- src/aero_kernel/src/syscall/process.rs | 5 +- src/aero_kernel/src/userland/task/mod.rs | 1 + src/aero_kernel/src/userland/vm.rs | 53 +- tools/cargo-inject-patches.py | 2 +- userland/apps/init/src/main.rs | 24 +- 21 files changed, 783 insertions(+), 626 deletions(-) create mode 100644 patched.txt rename patches/glib/{glib.patch => 0001-glib.patch} (100%) create mode 100644 patches/glib/0002-Patch-out-assert-in-g_io_unix_get_flags.patch rename patches/webkitgtk/{webkitgtk.patch => 0001-Initial-Aero-support.patch} (95%) create mode 100644 patches/webkitgtk/0002-xxx.patch diff --git a/bootstrap.yml b/bootstrap.yml index dd8b37f0753..90ef0bb5961 100644 --- a/bootstrap.yml +++ b/bootstrap.yml @@ -125,8 +125,8 @@ sources: - name: rust-nix subdir: 'bundled' git: 'https://github.com/nix-rust/nix.git' - tag: 'v0.24.3' - version: '0.24.3' + tag: 'v0.22.3' + version: '0.22.3' - name: rust-mio-0.6 subdir: 'bundled' @@ -150,8 +150,8 @@ sources: - name: rust-libloading subdir: 'bundled' git: 'https://github.com/nagisa/rust_libloading.git' - tag: '0.8.1' - version: '0.8.1' + tag: '0.7.3' + version: '0.7.3' - name: rust-getrandom subdir: 'bundled' @@ -966,7 +966,7 @@ packages: - '--libdir=lib' - '-Dmlibc_no_headers=true' - '-Ddisable_iconv_option=true' - - '--buildtype=release' + - '--buildtype=debug' - '-Dlinux_kernel_headers=@BUILD_ROOT@/packages/linux-headers/usr/include' - '@THIS_SOURCE_DIR@' build: @@ -2202,6 +2202,10 @@ packages: - '-Dxattr=false' - '@THIS_SOURCE_DIR@' environ: + # The warning is false positive and the more recent versions of GCC. Workaround and disable the warning. + # + # Bug 1744: https://gitlab.gnome.org/GNOME/glib/-/issues/1744 + CFLAGS: '-Wno-error=format-nonliteral' PKG_CONFIG_SYSROOT_DIR: '@BUILD_ROOT@/system-root' PKG_CONFIG_LIBDIR: '@BUILD_ROOT@/system-root/usr/lib/pkgconfig:@BUILD_ROOT@/system-root/usr/share/pkgconfig' build: diff --git a/bootstrap/vcs.yml b/bootstrap/vcs.yml index 8b477baa697..31b040ad96d 100644 --- a/bootstrap/vcs.yml +++ b/bootstrap/vcs.yml @@ -3,49 +3,49 @@ packages: # # Git is one of the most used version control systems designed to # handle large projects efficiently. - - name: git - source: - subdir: 'bundled' - git: 'https://github.com/git/git.git' - tag: 'v2.32.0' - version: '2.32.0' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - regenerate: - - args: ['autoreconf'] - tools_required: - - host-pkg-config - - host-gcc - - virtual: pkgconfig-for-target - triple: "x86_64-aero" - pkgs_required: - - mlibc - - python - - libexpat - - zlib - - openssl - - curl - - libiconv - - pcre - configure: - - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] - - args: - - './configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--with-python=python3' - - '--with-gitconfig=/etc/gitconfig' - - '--with-curl=@SYSROOT_DIR@/usr' - - '--without-iconv' - - '--with-libpcre' - - 'ac_cv_fread_reads_directories=1' - - 'ac_cv_snprintf_returns_bogus=1' - environ: - CURL_CONFIG: '@SYSROOT_DIR@/usr/bin/curl-config' - build: - - args: ['make', 'NO_GETTEXT=YesPlease', '-j@PARALLELISM@'] - - args: ['make', 'NO_GETTEXT=YesPlease', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' + # - name: git + # source: + # subdir: 'bundled' + # git: 'https://github.com/git/git.git' + # tag: 'v2.32.0' + # version: '2.32.0' + # tools_required: + # - host-autoconf-v2.69 + # - host-automake-v1.16 + # - host-libtool + # regenerate: + # - args: ['autoreconf'] + # tools_required: + # - host-pkg-config + # - host-gcc + # - virtual: pkgconfig-for-target + # triple: "x86_64-aero" + # pkgs_required: + # - mlibc + # - python + # - libexpat + # - zlib + # - openssl + # - curl + # - libiconv + # - pcre + # configure: + # - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] + # - args: + # - './configure' + # - '--host=x86_64-aero' + # - '--prefix=/usr' + # - '--with-python=python3' + # - '--with-gitconfig=/etc/gitconfig' + # - '--with-curl=@SYSROOT_DIR@/usr' + # - '--without-iconv' + # - '--with-libpcre' + # - 'ac_cv_fread_reads_directories=1' + # - 'ac_cv_snprintf_returns_bogus=1' + # environ: + # CURL_CONFIG: '@SYSROOT_DIR@/usr/bin/curl-config' + # build: + # - args: ['make', 'NO_GETTEXT=YesPlease', '-j@PARALLELISM@'] + # - args: ['make', 'NO_GETTEXT=YesPlease', 'install'] + # environ: + # DESTDIR: '@THIS_COLLECT_DIR@' diff --git a/bootstrap/xorg.yml b/bootstrap/xorg.yml index 2c9f9a4b604..2078bb2a9b1 100644 --- a/bootstrap/xorg.yml +++ b/bootstrap/xorg.yml @@ -237,6 +237,7 @@ packages: - mlibc - xorg-util-macros - xorg-proto + - libxcb-util configure: - args: - '@THIS_SOURCE_DIR@/configure' @@ -564,44 +565,44 @@ packages: environ: DESTDIR: '@THIS_COLLECT_DIR@' - - name: mesa-demos - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/mesa/demos.git/' - branch: 'master' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - 'NOCONFIGURE': 'yes' - tools_required: - - host-gcc - pkgs_required: - - mlibc - - mesa - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - - '--disable-gles1' # Requires some linux header that we don't have - - '--disable-vg' - - '--disable-osmesa' - - '--disable-rbug' - - '--with-system-data-files' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' + # - name: mesa-demos + # source: + # subdir: 'bundled' + # git: 'https://gitlab.freedesktop.org/mesa/demos.git/' + # branch: 'master' + # tools_required: + # - host-autoconf-v2.69 + # - host-automake-v1.16 + # - host-libtool + # - host-pkg-config + # - host-xorg-macros + # regenerate: + # - args: ['./autogen.sh'] + # environ: + # 'NOCONFIGURE': 'yes' + # tools_required: + # - host-gcc + # pkgs_required: + # - mlibc + # - mesa + # configure: + # - args: + # - '@THIS_SOURCE_DIR@/configure' + # - '--host=x86_64-aero' + # - '--prefix=/usr' + # - '--sysconfdir=/etc' + # - '--localstatedir=/var' + # - '--disable-static' + # - '--disable-gles1' # Requires some linux header that we don't have + # - '--disable-vg' + # - '--disable-osmesa' + # - '--disable-rbug' + # - '--with-system-data-files' + # build: + # - args: ['make', '-j@PARALLELISM@'] + # - args: ['make', 'install'] + # environ: + # DESTDIR: '@THIS_COLLECT_DIR@' - name: mesa source: @@ -868,8 +869,8 @@ packages: source: subdir: 'bundled' git: 'https://gitlab.freedesktop.org/pixman/pixman.git' - tag: 'pixman-0.40.0' - version: '0.40.0' + tag: 'pixman-0.42.2' + version: '0.42.2' tools_required: - host-autoconf-v2.69 - host-automake-v1.16 @@ -2202,8 +2203,8 @@ packages: source: subdir: 'bundled' git: 'https://gitlab.gnome.org/GNOME/pango.git' - tag: '1.50.11' - version: '1.50.11' + tag: '1.50.14' + version: '1.50.14' tools_required: - host-pkg-config - host-gcc @@ -2223,8 +2224,12 @@ packages: - libxext - harfbuzz - libxft - revision: 2 + revision: 3 configure: + # False positive with GCC 13 and -O3, see bug #903259 + # + # https://gitlab.gnome.org/GNOME/pango/-/issues/740 + - args: ['sed', '-i', '-e', '/\-Werror=array-bounds/d', '@THIS_SOURCE_DIR@/meson.build'] - args: - 'meson' - '--cross-file' diff --git a/patched.txt b/patched.txt new file mode 100644 index 00000000000..f1b4bdf79af --- /dev/null +++ b/patched.txt @@ -0,0 +1,5 @@ +bootstrap-host-gcc +llvm +rust-libc +webkitgtk +pixman diff --git a/patches/glib/glib.patch b/patches/glib/0001-glib.patch similarity index 100% rename from patches/glib/glib.patch rename to patches/glib/0001-glib.patch diff --git a/patches/glib/0002-Patch-out-assert-in-g_io_unix_get_flags.patch b/patches/glib/0002-Patch-out-assert-in-g_io_unix_get_flags.patch new file mode 100644 index 00000000000..fa109fc2557 --- /dev/null +++ b/patches/glib/0002-Patch-out-assert-in-g_io_unix_get_flags.patch @@ -0,0 +1,30 @@ +From fe2c4357d753d3a5baed7e2354f3542a1e87b46d Mon Sep 17 00:00:00 2001 +From: Dennis Bonke +Date: Wed, 12 Oct 2022 02:54:15 +0200 +Subject: [PATCH 2/2] Patch out assert in g_io_unix_get_flags + +We don't implement the neccesary bits to fully support this, so in case of doubt, return readable and writeable. + +Signed-off-by: Dennis Bonke +--- + glib/giounix.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/glib/giounix.c b/glib/giounix.c +index ad3aba2..e0237fc 100644 +--- a/glib/giounix.c ++++ b/glib/giounix.c +@@ -436,7 +436,10 @@ g_io_unix_get_flags (GIOChannel *channel) + channel->is_writeable = TRUE; + break; + default: +- g_assert_not_reached (); ++ channel->is_readable = TRUE; ++ channel->is_writeable = TRUE; ++ break; ++ //g_assert_not_reached (); + } + + return flags; +-- +2.37.2 diff --git a/patches/mlibc/mlibc.patch b/patches/mlibc/mlibc.patch index 924b3edfad2..a72e9f7fe37 100644 --- a/patches/mlibc/mlibc.patch +++ b/patches/mlibc/mlibc.patch @@ -1,17 +1,19 @@ -From d33a19a85fd625a2acf53f95f32c369b7f91e230 Mon Sep 17 00:00:00 2001 +From ea350e347faaa97e0499d34582ff068510809542 Mon Sep 17 00:00:00 2001 From: Anhad Singh -Date: Thu, 3 Aug 2023 16:36:12 +1000 -Subject: [PATCH] socket: implement shutdown(2) +Date: Fri, 13 Oct 2023 22:50:34 +1100 +Subject: [PATCH] Signed-off-by: Anhad Singh --- - options/glibc/generic/execinfo.cpp | 5 ++-- - options/posix/generic/sys-socket-stubs.cpp | 9 ++++++-- - options/posix/include/mlibc/posix-sysdeps.hpp | 1 + - sysdeps/aero/generic/signals.cpp | 19 ++++++--------- - sysdeps/aero/generic/sockets.cpp | 23 +++++++++++++++++++ - sysdeps/aero/include/aero/syscall.h | 3 +++ - 6 files changed, 44 insertions(+), 16 deletions(-) + options/glibc/generic/execinfo.cpp | 5 +++-- + options/posix/generic/posix_stdlib.cpp | 2 +- + options/rtdl/generic/linker.cpp | 2 +- + sysdeps/aero/generic/aero.cpp | 9 ++++++--- + sysdeps/aero/generic/filesystem.cpp | 10 ++++++++++ + sysdeps/aero/generic/signals.cpp | 19 +++++++------------ + sysdeps/aero/generic/sockets.cpp | 16 ++++++++++++++++ + sysdeps/aero/include/aero/syscall.h | 2 ++ + 8 files changed, 46 insertions(+), 19 deletions(-) diff --git a/options/glibc/generic/execinfo.cpp b/options/glibc/generic/execinfo.cpp index 3474615..aaf593a 100644 @@ -30,38 +32,74 @@ index 3474615..aaf593a 100644 } char **backtrace_symbols(void *const *, int) { -diff --git a/options/posix/generic/sys-socket-stubs.cpp b/options/posix/generic/sys-socket-stubs.cpp -index 1674945..037a994 100644 ---- a/options/posix/generic/sys-socket-stubs.cpp -+++ b/options/posix/generic/sys-socket-stubs.cpp -@@ -187,8 +187,13 @@ int setsockopt(int fd, int layer, int number, - return mlibc::sys_setsockopt(fd, layer, number, buffer, size); +diff --git a/options/posix/generic/posix_stdlib.cpp b/options/posix/generic/posix_stdlib.cpp +index 76b85dc..4b783b3 100644 +--- a/options/posix/generic/posix_stdlib.cpp ++++ b/options/posix/generic/posix_stdlib.cpp +@@ -464,7 +464,7 @@ int grantpt(int) { } --int shutdown(int, int) { -- mlibc::infoLogger() << "mlibc: shutdown() is a no-op!" << frg::endlog; -+int shutdown(int sockfd, int how) { -+ auto sysdep = MLIBC_CHECK_OR_ENOSYS(mlibc::sys_shutdown, -1); -+ if(int e = sysdep(sockfd, how); e) { -+ errno = e; -+ return -1; -+ } -+ - return 0; + double strtod_l(const char *__restrict__ nptr, char ** __restrict__ endptr, locale_t) { +- mlibc::infoLogger() << "mlibc: strtod_l ignores locale!" << frg::endlog; ++ // mlibc::infoLogger() << "mlibc: strtod_l ignores locale!" << frg::endlog; + return strtod(nptr, endptr); + } + +diff --git a/options/rtdl/generic/linker.cpp b/options/rtdl/generic/linker.cpp +index c604a50..eec0b7b 100644 +--- a/options/rtdl/generic/linker.cpp ++++ b/options/rtdl/generic/linker.cpp +@@ -18,7 +18,7 @@ uintptr_t libraryBase = 0x41000000; + + constexpr bool verbose = false; + constexpr bool stillSlightlyVerbose = false; +-constexpr bool logBaseAddresses = false; ++constexpr bool logBaseAddresses = true; + constexpr bool logRpath = false; + constexpr bool eagerBinding = true; + +diff --git a/sysdeps/aero/generic/aero.cpp b/sysdeps/aero/generic/aero.cpp +index e6bd277..a341fcf 100644 +--- a/sysdeps/aero/generic/aero.cpp ++++ b/sysdeps/aero/generic/aero.cpp +@@ -303,10 +303,13 @@ int sys_clone(void *tcb, pid_t *tid_out, void *stack) { + return 0; + } + +-void sys_thread_exit() UNIMPLEMENTED("sys_thread_exit") ++void sys_thread_exit() { ++ syscall(SYS_EXIT); ++ __builtin_trap(); ++} + +- int sys_waitpid(pid_t pid, int *status, int flags, struct rusage *ru, +- pid_t *ret_pid) { ++int sys_waitpid(pid_t pid, int *status, int flags, struct rusage *ru, ++ pid_t *ret_pid) { + if (ru) { + mlibc::infoLogger() + << "mlibc: struct rusage in sys_waitpid is unsupported" +diff --git a/sysdeps/aero/generic/filesystem.cpp b/sysdeps/aero/generic/filesystem.cpp +index fa5a369..33a11f4 100644 +--- a/sysdeps/aero/generic/filesystem.cpp ++++ b/sysdeps/aero/generic/filesystem.cpp +@@ -39,6 +39,16 @@ int sys_read(int fd, void *buf, size_t count, ssize_t *bytes_read) { + return 0; } -diff --git a/options/posix/include/mlibc/posix-sysdeps.hpp b/options/posix/include/mlibc/posix-sysdeps.hpp -index 9918188..c694079 100644 ---- a/options/posix/include/mlibc/posix-sysdeps.hpp -+++ b/options/posix/include/mlibc/posix-sysdeps.hpp -@@ -159,6 +159,7 @@ int sys_vm_unmap(void *pointer, size_t size); - void *__restrict buffer, socklen_t *__restrict size); - [[gnu::weak]] int sys_setsockopt(int fd, int layer, int number, - const void *buffer, socklen_t size); -+[[gnu::weak]] int sys_shutdown(int sockfd, int how); - [[gnu::weak]] int sys_sigprocmask(int how, const sigset_t *__restrict set, - sigset_t *__restrict retrieve); - [[gnu::weak]] int sys_sigaction(int, const struct sigaction *__restrict, ++int sys_fsync(int) { ++ mlibc::infoLogger() << "\e[35mmlibc: fsync is a stub\e[39m" << frg::endlog; ++ return 0; ++} ++ ++int sys_fdatasync(int) { ++ mlibc::infoLogger() << "\e[35mmlibc: fdatasync() is a no-op\e[39m" << frg::endlog; ++ return 0; ++} ++ + // clang-format off + int sys_pwrite(int fd, const void *buffer, size_t count, off_t off, + ssize_t *written) UNIMPLEMENTED("sys_pwrite") diff --git a/sysdeps/aero/generic/signals.cpp b/sysdeps/aero/generic/signals.cpp index a6f69ff..611db69 100644 --- a/sysdeps/aero/generic/signals.cpp @@ -101,20 +139,13 @@ index a6f69ff..611db69 100644 } // namespace mlibc \ No newline at end of file diff --git a/sysdeps/aero/generic/sockets.cpp b/sysdeps/aero/generic/sockets.cpp -index 2db218c..ed3fc06 100644 +index 0cce3c0..10af36a 100644 --- a/sysdeps/aero/generic/sockets.cpp +++ b/sysdeps/aero/generic/sockets.cpp -@@ -221,6 +221,29 @@ int sys_setsockopt(int fd, int layer, int number, const void *buffer, +@@ -221,6 +221,22 @@ int sys_setsockopt(int fd, int layer, int number, const void *buffer, } } -+int sys_shutdown(int sockfd, int how) { -+ auto ret = syscall(SYS_SOCK_SHUTDOWN, sockfd, how); -+ if(int e = sc_error(ret); e) -+ return e; -+ return 0; -+} -+ +int sys_peername(int fd, struct sockaddr *addr_ptr, socklen_t max_addr_length, socklen_t *actual_length) { + auto ret = syscall(SYS_GETPEERNAME, fd, addr_ptr, &max_addr_length); + if (int e = sc_error(ret); e) @@ -131,18 +162,17 @@ index 2db218c..ed3fc06 100644 + return 0; +} + - int sys_if_nametoindex(const char *name, unsigned int *ret) { - int fd = 0; - int r = sys_socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, AF_UNSPEC, &fd); + int sys_shutdown(int sockfd, int how) { + auto ret = syscall(SYS_SOCK_SHUTDOWN, sockfd, how); + if(int e = sc_error(ret); e) diff --git a/sysdeps/aero/include/aero/syscall.h b/sysdeps/aero/include/aero/syscall.h -index d8bf99e..39c5b65 100644 +index 3f36e4d..39c5b65 100644 --- a/sysdeps/aero/include/aero/syscall.h +++ b/sysdeps/aero/include/aero/syscall.h -@@ -79,6 +79,9 @@ - #define SYS_SETPGID 72 +@@ -80,6 +80,8 @@ #define SYS_SETSID 73 #define SYS_GETPGID 74 -+#define SYS_SOCK_SHUTDOWN 75 + #define SYS_SOCK_SHUTDOWN 75 +#define SYS_GETPEERNAME 76 +#define SYS_GETSOCKNAME 77 diff --git a/patches/rust-libloading/rust-libloading.patch b/patches/rust-libloading/rust-libloading.patch index 743d6cedefc..ac3ec05e6f1 100644 --- a/patches/rust-libloading/rust-libloading.patch +++ b/patches/rust-libloading/rust-libloading.patch @@ -1,15 +1,14 @@ -From d6dfe23ee9299412d8281dabb7f5d903e152b589 Mon Sep 17 00:00:00 2001 -From: Anhad Singh -Date: Tue, 10 Oct 2023 17:24:17 +1100 +From f5fab150ee8fbfdef46888837b6e6d43fd3ec1c0 Mon Sep 17 00:00:00 2001 +From: Andy-Python-Programmer +Date: Sun, 20 Nov 2022 13:39:51 +1100 Subject: [PATCH] -Signed-off-by: Anhad Singh --- src/os/unix/consts.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/os/unix/consts.rs b/src/os/unix/consts.rs -index ed3edaf..61659ff 100644 +index dbe4df9..fbdd2e3 100644 --- a/src/os/unix/consts.rs +++ b/src/os/unix/consts.rs @@ -58,7 +58,7 @@ mod posix { @@ -19,9 +18,9 @@ index ed3edaf..61659ff 100644 - if #[cfg(target_os = "haiku")] { + if #[cfg(any(target_os = "haiku", target_os = "aero"))] { pub(super) const RTLD_LAZY: c_int = 0; - } else if #[cfg(target_os = "aix")] { - pub(super) const RTLD_LAZY: c_int = 4; -@@ -94,7 +94,7 @@ mod posix { + } else if #[cfg(any( + target_os = "linux", +@@ -90,7 +90,7 @@ mod posix { } cfg_if! { @@ -30,7 +29,7 @@ index ed3edaf..61659ff 100644 pub(super) const RTLD_NOW: c_int = 1; } else if #[cfg(any( target_os = "linux", -@@ -133,6 +133,7 @@ mod posix { +@@ -126,6 +126,7 @@ mod posix { cfg_if! { if #[cfg(any( target_os = "haiku", @@ -38,14 +37,14 @@ index ed3edaf..61659ff 100644 all(target_os = "android",target_pointer_width = "32"), ))] { pub(super) const RTLD_GLOBAL: c_int = 2; -@@ -210,6 +211,7 @@ mod posix { +@@ -193,6 +194,7 @@ mod posix { + target_os = "fuchsia", target_os = "redox", - target_os = "hurd", + target_os = "aero", ))] { pub(super) const RTLD_LOCAL: c_int = 0; } else { -- -2.42.0 +2.38.1 diff --git a/patches/rust-nix/rust-nix.patch b/patches/rust-nix/rust-nix.patch index 0c124a2aa8e..32bf6442d21 100644 --- a/patches/rust-nix/rust-nix.patch +++ b/patches/rust-nix/rust-nix.patch @@ -1,26 +1,20 @@ -From 2ac82af89ae503c8743dcd96bca3dcbddccd1eea Mon Sep 17 00:00:00 2001 -From: Dennis Bonke -Date: Thu, 23 Feb 2023 00:41:07 +0100 -Subject: [PATCH] aero: initial port +From 608f6dc307498272ec3a6317cac3bbbe2a8b74b1 Mon Sep 17 00:00:00 2001 +From: Andy-Python-Programmer +Date: Sun, 20 Nov 2022 12:21:43 +1100 +Subject: [PATCH] -Signed-off-by: Dennis Bonke --- - src/errno.rs | 218 +++++++++++++++++++++++++++++++++++++++++ - src/features.rs | 2 +- - src/lib.rs | 10 +- + src/errno.rs | 217 +++++++++++++++++++++++++++++++++++++++++ + src/lib.rs | 12 ++- src/sys/mod.rs | 10 +- - src/sys/resource.rs | 2 + - src/sys/signal.rs | 16 +-- - src/sys/socket/addr.rs | 26 +++-- - src/sys/socket/mod.rs | 6 +- + src/sys/socket/addr.rs | 16 +-- + src/sys/socket/mod.rs | 5 +- src/sys/termios.rs | 54 +++++++++- - src/sys/time.rs | 3 +- - src/sys/timerfd.rs | 2 +- - src/unistd.rs | 30 ++++++ - 12 files changed, 350 insertions(+), 29 deletions(-) + src/unistd.rs | 27 +++++ + 7 files changed, 327 insertions(+), 14 deletions(-) diff --git a/src/errno.rs b/src/errno.rs -index 41420e8..aedf294 100644 +index 9c2dfe4..d26d63d 100644 --- a/src/errno.rs +++ b/src/errno.rs @@ -22,6 +22,7 @@ cfg_if! { @@ -41,7 +35,7 @@ index 41420e8..aedf294 100644 match errno { UnknownErrno => "Unknown errno", EPERM => "Operation not permitted", -@@ -1562,6 +1566,220 @@ mod consts { +@@ -1557,6 +1561,219 @@ mod consts { } } @@ -117,7 +111,7 @@ index 41420e8..aedf294 100644 + // ENOTDIR = libc::ENOTDIR, + // ENOTEMPTY = libc::ENOTEMPTY, + // ENOTSOCK = libc::ENOTSOCK, -+ ENOTSUP = libc::ENOTSUP, ++ // ENOTSUP = libc::ENOTSUP, + ENOTTY = libc::ENOTTY, + // ENXIO = libc::ENXIO, + // EOPNOTSUPP = libc::EOPNOTSUPP, @@ -154,7 +148,7 @@ index 41420e8..aedf294 100644 + + // pub const EL2NSYNC: Errno = Errno::UnknownErrno; + -+ pub const fn from_i32(e: i32) -> Errno { ++ pub fn from_i32(e: i32) -> Errno { + use self::Errno::*; + + match e { @@ -224,7 +218,7 @@ index 41420e8..aedf294 100644 + // libc::ENOTDIR => ENOTDIR, + // libc::ENOTEMPTY => ENOTEMPTY, + // libc::ENOTSOCK => ENOTSOCK, -+ libc::ENOTSUP => ENOTSUP, ++ // libc::ENOTSUP => ENOTSUP, + // libc::ENOTTY => ENOTTY, + // libc::ENXIO => ENXIO, + // libc::EOPNOTSUPP => EOPNOTSUPP, @@ -258,233 +252,126 @@ index 41420e8..aedf294 100644 + } + } +} -+ #[cfg(target_os = "dragonfly")] mod consts { -diff --git a/src/features.rs b/src/features.rs -index 6108098..1f937e2 100644 ---- a/src/features.rs -+++ b/src/features.rs -@@ -1,7 +1,7 @@ - //! Feature tests for OS functionality - pub use self::os::*; - --#[cfg(any(target_os = "linux", target_os = "android"))] -+#[cfg(any(target_os = "linux", target_os = "android", target_os = "aero"))] - mod os { - use std::os::unix::ffi::OsStrExt; - use crate::sys::utsname::uname; diff --git a/src/lib.rs b/src/lib.rs -index d4dcbc4..e5f03c7 100644 +index 3b534a5..f7c8495 100644 --- a/src/lib.rs +++ b/src/lib.rs -@@ -43,9 +43,10 @@ +@@ -5,12 +5,13 @@ + #![crate_name = "nix"] #![cfg(unix)] - #![cfg_attr(docsrs, doc(cfg(all())))] #![allow(non_camel_case_types)] +#![allow(non_snake_case)] + // latest bitflags triggers a rustc bug with cross-crate macro expansions causing dead_code + // warnings even though the macro expands into something with allow(dead_code) + #![allow(dead_code)] #![cfg_attr(test, deny(warnings))] #![recursion_limit = "500"] -#![deny(unused)] +// #![deny(unused)] - #![allow(unused_macros)] - #![cfg_attr(not(feature = "default"), allow(unused_imports))] #![deny(unstable_features)] -@@ -62,12 +63,13 @@ pub use libc; + #![deny(missing_copy_implementations)] + #![deny(missing_debug_implementations)] +@@ -22,11 +23,13 @@ pub use libc; #[macro_use] mod macros; // Public crates -#[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "aero")))] - feature! { - #![feature = "dir"] - #[allow(missing_docs)] - pub mod dir; - } + pub mod dir; +#[cfg(not(target_os = "aero"))] - feature! { - #![feature = "env"] - pub mod env; -@@ -96,7 +98,7 @@ feature! { - target_os = "openbsd"))] - #[deny(missing_docs)] - pub mod ifaddrs; -- #[cfg(not(target_os = "redox"))] -+ #[cfg(not(any(target_os = "redox", target_os = "aero")))] - #[deny(missing_docs)] - pub mod net; - } -@@ -124,6 +126,7 @@ feature! { - #[allow(missing_docs)] - pub mod mqueue; - } + pub mod env; + pub mod errno; + #[deny(missing_docs)] +#[cfg(not(target_os = "aero"))] - feature! { - #![feature = "poll"] - pub mod poll; -@@ -134,6 +137,7 @@ feature! { - #[deny(missing_docs)] - pub mod pty; - } + pub mod features; + pub mod fcntl; + #[deny(missing_docs)] +@@ -54,15 +57,18 @@ pub mod mount; + target_os = "netbsd"))] + pub mod mqueue; + #[deny(missing_docs)] +-#[cfg(not(target_os = "redox"))] ++#[cfg(not(any(target_os = "redox", target_os = "aero")))] + pub mod net; + #[deny(missing_docs)] ++#[cfg(not(target_os = "aero"))] + pub mod poll; + #[deny(missing_docs)] + #[cfg(not(any(target_os = "redox", target_os = "fuchsia")))] + pub mod pty; +#[cfg(not(target_os = "aero"))] - feature! { - #![feature = "sched"] - pub mod sched; + pub mod sched; + pub mod sys; ++#[cfg(not(target_os = "aero"))] + pub mod time; + // This can be implemented for other platforms as soon as libc + // provides bindings for them. diff --git a/src/sys/mod.rs b/src/sys/mod.rs -index e5639f2..2cbdff5 100644 +index 43877a1..20dd8e5 100644 --- a/src/sys/mod.rs +++ b/src/sys/mod.rs -@@ -13,7 +13,7 @@ feature! { - feature! { - #![feature = "event"] +@@ -6,7 +6,7 @@ + target_os = "netbsd"))] + pub mod aio; -- #[cfg(any(target_os = "android", target_os = "linux"))] -+ #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] - #[allow(missing_docs)] - pub mod epoll; +-#[cfg(any(target_os = "android", target_os = "linux"))] ++#[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] + pub mod epoll; -@@ -64,6 +64,7 @@ feature! { - pub mod personality; - } + #[cfg(any(target_os = "dragonfly", +@@ -42,6 +42,7 @@ pub mod mman; + #[cfg(target_os = "linux")] + pub mod personality; +#[cfg(not(target_os = "aero"))] - feature! { - #![feature = "pthread"] - pub mod pthread; -@@ -100,7 +101,7 @@ feature! { - pub mod resource; - } + pub mod pthread; + + #[cfg(any(target_os = "android", +@@ -59,7 +60,8 @@ pub mod quota; + #[cfg(any(target_os = "linux"))] + pub mod reboot; -#[cfg(not(target_os = "redox"))] ++// #[cfg(not(target_os = "redox"))] +#[cfg(not(any(target_os = "redox", target_os = "aero")))] - feature! { - #![feature = "poll"] - pub mod select; -@@ -152,6 +153,7 @@ feature! { - pub mod statfs; - } + pub mod select; + + #[cfg(any(target_os = "android", +@@ -69,6 +71,7 @@ pub mod select; + target_os = "macos"))] + pub mod sendfile; +#[cfg(not(target_os = "aero"))] - feature! { - #![feature = "fs"] - pub mod statvfs; -@@ -181,6 +183,7 @@ feature! { - pub mod utsname; - } + pub mod signal; + + #[cfg(any(target_os = "android", target_os = "linux"))] +@@ -89,6 +92,7 @@ pub mod stat; + ))] + pub mod statfs; +#[cfg(not(target_os = "aero"))] - feature! { - #![feature = "process"] - pub mod wait; -@@ -192,7 +195,7 @@ feature! { - pub mod inotify; - } + pub mod statvfs; --#[cfg(any(target_os = "android", target_os = "linux"))] -+#[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] - feature! { - #![feature = "time"] - pub mod timerfd; -@@ -203,6 +206,7 @@ feature! { - target_os = "freebsd", - target_os = "illumos", - target_os = "linux", -+ target_os = "aero", - target_os = "netbsd" - ), - feature = "time", -diff --git a/src/sys/resource.rs b/src/sys/resource.rs -index 76ceaf5..3457acd 100644 ---- a/src/sys/resource.rs -+++ b/src/sys/resource.rs -@@ -14,6 +14,7 @@ cfg_if! { - target_os = "openbsd", - target_os = "netbsd", - target_os = "macos", -+ target_os = "aero", - target_os = "ios", - target_os = "android", - target_os = "dragonfly", -@@ -48,6 +49,7 @@ libc_enum! { - target_os = "ios", - target_os = "android", - target_os = "dragonfly", -+ target_os = "aero", - all(target_os = "linux", not(any(target_env = "gnu", target_env = "uclibc"))) - ), repr(i32))] - #[non_exhaustive] -diff --git a/src/sys/signal.rs b/src/sys/signal.rs -index f982b4e..5621b6f 100644 ---- a/src/sys/signal.rs -+++ b/src/sys/signal.rs -@@ -99,13 +99,13 @@ libc_enum!{ - SIGSYS, - #[cfg(not(any(target_os = "android", target_os = "emscripten", - target_os = "fuchsia", target_os = "linux", -- target_os = "redox")))] -+ target_os = "redox", target_os = "aero")))] - #[cfg_attr(docsrs, doc(cfg(all())))] - /// Emulator trap - SIGEMT, - #[cfg(not(any(target_os = "android", target_os = "emscripten", - target_os = "fuchsia", target_os = "linux", -- target_os = "redox")))] -+ target_os = "redox", target_os = "aero")))] - #[cfg_attr(docsrs, doc(cfg(all())))] - /// Information request - SIGINFO, -@@ -157,11 +157,11 @@ impl FromStr for Signal { - "SIGSYS" => Signal::SIGSYS, - #[cfg(not(any(target_os = "android", target_os = "emscripten", - target_os = "fuchsia", target_os = "linux", -- target_os = "redox")))] -+ target_os = "redox", target_os = "aero")))] - "SIGEMT" => Signal::SIGEMT, - #[cfg(not(any(target_os = "android", target_os = "emscripten", - target_os = "fuchsia", target_os = "linux", -- target_os = "redox")))] -+ target_os = "redox", target_os = "aero")))] - "SIGINFO" => Signal::SIGINFO, - _ => return Err(Errno::EINVAL), - }) -@@ -215,11 +215,11 @@ impl Signal { - Signal::SIGSYS => "SIGSYS", - #[cfg(not(any(target_os = "android", target_os = "emscripten", - target_os = "fuchsia", target_os = "linux", -- target_os = "redox")))] -+ target_os = "redox", target_os = "aero")))] - Signal::SIGEMT => "SIGEMT", - #[cfg(not(any(target_os = "android", target_os = "emscripten", - target_os = "fuchsia", target_os = "linux", -- target_os = "redox")))] -+ target_os = "redox", target_os = "aero")))] - Signal::SIGINFO => "SIGINFO", - } - } -@@ -242,7 +242,7 @@ impl fmt::Display for Signal { - #[cfg(feature = "signal")] - pub use self::Signal::*; + #[cfg(any(target_os = "android", target_os = "linux"))] +@@ -100,8 +104,10 @@ pub mod time; + + pub mod uio; + ++#[cfg(not(target_os = "aero"))] + pub mod utsname; + ++#[cfg(not(target_os = "aero"))] + pub mod wait; --#[cfg(target_os = "redox")] -+#[cfg(any(target_os = "redox", target_os = "aero"))] - #[cfg(feature = "signal")] - const SIGNALS: [Signal; 29] = [ - SIGHUP, -@@ -349,7 +349,7 @@ const SIGNALS: [Signal; 30] = [ - SIGSYS]; - #[cfg(not(any(target_os = "linux", target_os = "android", - target_os = "fuchsia", target_os = "emscripten", -- target_os = "redox")))] -+ target_os = "redox", target_os = "aero")))] - #[cfg(feature = "signal")] - const SIGNALS: [Signal; 31] = [ - SIGHUP, + #[cfg(any(target_os = "android", target_os = "linux"))] diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs -index 4b8ab09..f23da26 100644 +index d486056..b367e18 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs -@@ -19,6 +19,7 @@ use std::os::unix::io::RawFd; +@@ -17,6 +17,7 @@ use std::os::unix::io::RawFd; use crate::sys::socket::addr::sys_control::SysControlAddr; #[cfg(any(target_os = "android", target_os = "dragonfly", @@ -492,7 +379,7 @@ index 4b8ab09..f23da26 100644 target_os = "freebsd", target_os = "ios", target_os = "linux", -@@ -76,6 +77,7 @@ pub enum AddressFamily { +@@ -46,6 +47,7 @@ pub enum AddressFamily { /// Low level packet interface (see [`packet(7)`](https://man7.org/linux/man-pages/man7/packet.7.html)) #[cfg(any(target_os = "android", target_os = "linux", @@ -500,7 +387,7 @@ index 4b8ab09..f23da26 100644 target_os = "illumos", target_os = "fuchsia", target_os = "solaris"))] -@@ -376,7 +378,7 @@ impl AddressFamily { +@@ -245,7 +247,7 @@ impl AddressFamily { libc::AF_NETLINK => Some(AddressFamily::Netlink), #[cfg(any(target_os = "macos", target_os = "macos"))] libc::AF_SYSTEM => Some(AddressFamily::System), @@ -509,45 +396,7 @@ index 4b8ab09..f23da26 100644 libc::AF_PACKET => Some(AddressFamily::Packet), #[cfg(any(target_os = "dragonfly", target_os = "freebsd", -@@ -707,7 +709,8 @@ pub struct UnixAddr { - #[cfg(any(target_os = "android", - target_os = "fuchsia", - target_os = "illumos", -- target_os = "linux" -+ target_os = "linux", -+ target_os = "aero" - ))] - sun_len: u8 - } -@@ -842,7 +845,8 @@ impl UnixAddr { - if #[cfg(any(target_os = "android", - target_os = "fuchsia", - target_os = "illumos", -- target_os = "linux" -+ target_os = "linux", -+ target_os = "aero" - ))] - { - UnixAddr { sun, sun_len } -@@ -900,7 +904,8 @@ impl UnixAddr { - if #[cfg(any(target_os = "android", - target_os = "fuchsia", - target_os = "illumos", -- target_os = "linux" -+ target_os = "linux", -+ target_os = "aero" - ))] - { - self.sun_len -@@ -940,6 +945,7 @@ impl SockaddrLike for UnixAddr { - cfg_if!{ - if #[cfg(any(target_os = "android", - target_os = "fuchsia", -+ target_os = "aero", - target_os = "illumos", - target_os = "linux" - ))] { -@@ -1817,6 +1823,7 @@ pub enum SockAddr { +@@ -653,6 +655,7 @@ pub enum SockAddr { /// Datalink address (MAC) #[cfg(any(target_os = "android", target_os = "dragonfly", @@ -555,64 +404,64 @@ index 4b8ab09..f23da26 100644 target_os = "freebsd", target_os = "ios", target_os = "linux", -@@ -1886,7 +1893,7 @@ impl SockAddr { - #[cfg(all(feature = "ioctl", - any(target_os = "ios", target_os = "macos")))] +@@ -705,7 +708,7 @@ impl SockAddr { + SockAddr::Alg(..) => AddressFamily::Alg, + #[cfg(any(target_os = "ios", target_os = "macos"))] SockAddr::SysControl(..) => AddressFamily::System, - #[cfg(any(target_os = "android", target_os = "linux"))] + #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] - #[cfg(feature = "net")] SockAddr::Link(..) => AddressFamily::Packet, #[cfg(any(target_os = "dragonfly", -@@ -1923,7 +1930,7 @@ impl SockAddr { + target_os = "freebsd", +@@ -738,7 +741,7 @@ impl SockAddr { if addr.is_null() { None } else { - match AddressFamily::from_i32(i32::from((*addr).sa_family)) { + match AddressFamily::from_i32((*addr).sa_family as i32) { Some(AddressFamily::Unix) => None, - #[cfg(feature = "net")] Some(AddressFamily::Inet) => Some(SockAddr::Inet( -@@ -1938,7 +1945,7 @@ impl SockAddr { - any(target_os = "ios", target_os = "macos")))] + InetAddr::V4(*(addr as *const libc::sockaddr_in)))), +@@ -750,7 +753,7 @@ impl SockAddr { + #[cfg(any(target_os = "ios", target_os = "macos"))] Some(AddressFamily::System) => Some(SockAddr::SysControl( SysControlAddr(*(addr as *const libc::sockaddr_ctl)))), - #[cfg(any(target_os = "android", target_os = "linux"))] + #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] - #[cfg(feature = "net")] Some(AddressFamily::Packet) => Some(SockAddr::Link( LinkAddr(*(addr as *const libc::sockaddr_ll)))), -@@ -2026,7 +2033,7 @@ impl SockAddr { + #[cfg(any(target_os = "dragonfly", +@@ -833,7 +836,7 @@ impl SockAddr { mem::size_of_val(sa) as libc::socklen_t ), - #[cfg(any(target_os = "android", target_os = "linux"))] + #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] - #[cfg(feature = "net")] SockAddr::Link(LinkAddr(ref addr)) => ( // This cast is always allowed in C -@@ -2077,6 +2084,7 @@ impl fmt::Display for SockAddr { - any(target_os = "ios", target_os = "macos")))] + unsafe { +@@ -879,6 +882,7 @@ impl fmt::Display for SockAddr { + #[cfg(any(target_os = "ios", target_os = "macos"))] SockAddr::SysControl(ref sc) => sc.fmt(f), #[cfg(any(target_os = "android", + target_os = "aero", target_os = "dragonfly", target_os = "freebsd", target_os = "ios", -@@ -2381,7 +2389,7 @@ pub mod sys_control { +@@ -1064,7 +1068,7 @@ pub mod sys_control { } -#[cfg(any(target_os = "android", target_os = "linux", target_os = "fuchsia"))] -+#[cfg(any(target_os = "android", target_os = "linux", target_os = "fuchsia", target_os = "aero"))] - #[cfg_attr(docsrs, doc(cfg(all())))] ++#[cfg(any(target_os = "android", target_os = "linux", target_os = "aero", target_os = "fuchsia"))] mod datalink { - feature! { + use super::{fmt, AddressFamily}; + diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs -index 3f26ccf..c83182b 100644 +index da5573c..3bac136 100644 --- a/src/sys/socket/mod.rs +++ b/src/sys/socket/mod.rs -@@ -344,6 +344,7 @@ libc_bitflags!{ +@@ -251,6 +251,7 @@ libc_bitflags!{ /// /// Only used in [`recvmsg`](fn.recvmsg.html) function. #[cfg(any(target_os = "android", @@ -620,15 +469,7 @@ index 3f26ccf..c83182b 100644 target_os = "dragonfly", target_os = "freebsd", target_os = "linux", -@@ -355,6 +356,7 @@ libc_bitflags!{ - /// (For more details, see [send(2)](https://linux.die.net/man/2/send)). - #[cfg(any(target_os = "android", - target_os = "dragonfly", -+ target_os = "aero", - target_os = "freebsd", - target_os = "fuchsia", - target_os = "haiku", -@@ -1139,13 +1141,13 @@ impl<'a> ControlMessage<'a> { +@@ -866,13 +867,13 @@ impl<'a> ControlMessage<'a> { /// The value of CMSG_LEN on this message. /// Safe because CMSG_LEN is always safe @@ -645,10 +486,10 @@ index 3f26ccf..c83182b 100644 fn cmsg_len(&self) -> libc::c_uint { unsafe{CMSG_LEN(self.len() as libc::c_uint)} diff --git a/src/sys/termios.rs b/src/sys/termios.rs -index a107f8b..6a9453e 100644 +index 36a3601..c7bddc3 100644 --- a/src/sys/termios.rs +++ b/src/sys/termios.rs -@@ -375,10 +375,19 @@ impl From for u32 { +@@ -467,10 +467,19 @@ impl From for u32 { } // TODO: Add TCSASOFT, which will require treating this as a bitfield. @@ -666,9 +507,9 @@ index a107f8b..6a9453e 100644 +#[cfg(not(target_os = "aero"))] +libc_enum! { #[repr(i32)] - #[non_exhaustive] pub enum SetArg { -@@ -391,10 +400,19 @@ libc_enum! { + /// The change will occur immediately +@@ -482,10 +491,19 @@ libc_enum! { } } @@ -686,9 +527,9 @@ index a107f8b..6a9453e 100644 +#[cfg(not(target_os = "aero"))] +libc_enum! { #[repr(i32)] - #[non_exhaustive] pub enum FlushArg { -@@ -426,8 +444,17 @@ libc_enum! { + /// Flush data that was received but not read +@@ -515,8 +533,17 @@ libc_enum! { } // TODO: Make this usable directly as a slice index. @@ -704,18 +545,17 @@ index a107f8b..6a9453e 100644 +#[cfg(not(target_os = "aero"))] +libc_enum! { #[repr(usize)] - #[non_exhaustive] pub enum SpecialCharacterIndices { -@@ -524,7 +551,7 @@ libc_bitflags! { + VDISCARD, +@@ -601,13 +628,22 @@ libc_bitflags! { + IXOFF; #[cfg(not(target_os = "redox"))] - #[cfg_attr(docsrs, doc(cfg(all())))] IXANY; - #[cfg(not(target_os = "redox"))] + #[cfg(not(any(target_os = "redox", target_os = "aero")))] - #[cfg_attr(docsrs, doc(cfg(all())))] IMAXBEL; #[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))] -@@ -533,6 +560,15 @@ libc_bitflags! { + IUTF8; } } @@ -731,7 +571,7 @@ index a107f8b..6a9453e 100644 libc_bitflags! { /// Flags for configuring the output mode of a terminal pub struct OutputFlags: tcflag_t { -@@ -744,8 +780,16 @@ libc_bitflags! { +@@ -791,8 +827,16 @@ libc_bitflags! { } } @@ -748,7 +588,7 @@ index a107f8b..6a9453e 100644 pub struct ControlFlags: tcflag_t { #[cfg(any(target_os = "dragonfly", target_os = "freebsd", -@@ -824,8 +868,16 @@ libc_bitflags! { +@@ -859,8 +903,16 @@ libc_bitflags! { } } @@ -764,46 +604,12 @@ index a107f8b..6a9453e 100644 +libc_bitflags! { pub struct LocalFlags: tcflag_t { #[cfg(not(target_os = "redox"))] - #[cfg_attr(docsrs, doc(cfg(all())))] -diff --git a/src/sys/time.rs b/src/sys/time.rs -index c1ab67b..f43cf63 100644 ---- a/src/sys/time.rs -+++ b/src/sys/time.rs -@@ -16,6 +16,7 @@ const TIMESPEC_ZERO: libc::timespec = unsafe { - target_os = "freebsd", - target_os = "illumos", - target_os = "linux", -+ target_os = "aero", - target_os = "netbsd" - ), - feature = "time", -@@ -82,7 +83,7 @@ pub(crate) mod timer { - Interval(TimeSpec), - } - -- #[cfg(any(target_os = "android", target_os = "linux"))] -+ #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] - bitflags! { - /// Flags that are used for arming the timer. - pub struct TimerSetTimeFlags: libc::c_int { -diff --git a/src/sys/timerfd.rs b/src/sys/timerfd.rs -index 18acbae..0005b24 100644 ---- a/src/sys/timerfd.rs -+++ b/src/sys/timerfd.rs -@@ -57,7 +57,7 @@ impl FromRawFd for TimerFd { - libc_enum! { - /// The type of the clock used to mark the progress of the timer. For more - /// details on each kind of clock, please refer to [timerfd_create(2)](https://man7.org/linux/man-pages/man2/timerfd_create.2.html). -- #[repr(i32)] -+ #[repr(i64)] - #[non_exhaustive] - pub enum ClockId { - /// A settable system-wide real-time clock. + ECHOKE; diff --git a/src/unistd.rs b/src/unistd.rs -index d6ccdf1..af3b4a0 100644 +index d94cb99..8e26266 100644 --- a/src/unistd.rs +++ b/src/unistd.rs -@@ -1132,6 +1132,7 @@ feature! { +@@ -1081,6 +1081,7 @@ pub fn pipe() -> std::result::Result<(RawFd, RawFd), Error> { /// See also [pipe(2)](https://man7.org/linux/man-pages/man2/pipe.2.html) #[cfg(any(target_os = "android", target_os = "dragonfly", @@ -811,7 +617,7 @@ index d6ccdf1..af3b4a0 100644 target_os = "emscripten", target_os = "freebsd", target_os = "illumos", -@@ -1550,6 +1551,7 @@ pub fn getgroups() -> Result> { +@@ -1478,6 +1479,7 @@ pub fn getgroups() -> Result> { pub fn setgroups(groups: &[Gid]) -> Result<()> { cfg_if! { if #[cfg(any(target_os = "dragonfly", @@ -819,7 +625,7 @@ index d6ccdf1..af3b4a0 100644 target_os = "freebsd", target_os = "illumos", target_os = "ios", -@@ -1886,6 +1888,14 @@ feature! { +@@ -1799,6 +1801,14 @@ pub fn mkstemp(template: &P) -> Result<(RawFd, PathBuf)> { /// - [pathconf(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pathconf.html) /// - [limits.h](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html) /// - [unistd.h](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html) @@ -833,8 +639,8 @@ index d6ccdf1..af3b4a0 100644 +#[cfg(not(target_os = "aero"))] #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] #[repr(i32)] - #[non_exhaustive] -@@ -2082,6 +2092,17 @@ feature! { + pub enum PathconfVar { +@@ -1978,6 +1988,17 @@ pub fn pathconf(path: &P, var: PathconfVar) -> Result for User { - gid: Gid::from_raw(pw.pw_gid), +@@ -2668,18 +2692,21 @@ impl From<&libc::passwd> for User { + gid: Gid::from_raw((*pw).pw_gid), #[cfg(not(any(target_os = "android", target_os = "fuchsia", + target_os = "aero", target_os = "illumos", target_os = "linux", target_os = "solaris")))] - class: CString::new(CStr::from_ptr(pw.pw_class).to_bytes()).unwrap(), + class: CString::new(CStr::from_ptr((*pw).pw_class).to_bytes()).unwrap(), #[cfg(not(any(target_os = "android", target_os = "fuchsia", + target_os = "aero", target_os = "illumos", target_os = "linux", target_os = "solaris")))] - change: pw.pw_change, + change: (*pw).pw_change, #[cfg(not(any(target_os = "android", target_os = "fuchsia", + target_os = "aero", target_os = "illumos", target_os = "linux", target_os = "solaris")))] -@@ -2960,18 +2987,21 @@ impl From for libc::passwd { - pw_gid: u.gid.0, - #[cfg(not(any(target_os = "android", - target_os = "fuchsia", -+ target_os = "aero", - target_os = "illumos", - target_os = "linux", - target_os = "solaris")))] - pw_class: u.class.into_raw(), - #[cfg(not(any(target_os = "android", - target_os = "fuchsia", -+ target_os = "aero", - target_os = "illumos", - target_os = "linux", - target_os = "solaris")))] - pw_change: u.change, - #[cfg(not(any(target_os = "android", - target_os = "fuchsia", -+ target_os = "aero", - target_os = "illumos", - target_os = "linux", - target_os = "solaris")))] -- -2.39.1 - +2.38.1 diff --git a/patches/webkitgtk/webkitgtk.patch b/patches/webkitgtk/0001-Initial-Aero-support.patch similarity index 95% rename from patches/webkitgtk/webkitgtk.patch rename to patches/webkitgtk/0001-Initial-Aero-support.patch index f80e91ec667..82db1c0a73e 100644 --- a/patches/webkitgtk/webkitgtk.patch +++ b/patches/webkitgtk/0001-Initial-Aero-support.patch @@ -1,7 +1,7 @@ -From 9c3401a68d96016e19aafc60897ae450db07ead7 Mon Sep 17 00:00:00 2001 +From 610aa0dbb9c661c87172c0cf93de06efb019f80b Mon Sep 17 00:00:00 2001 From: Dennis Bonke Date: Sun, 2 Jan 2022 00:19:17 +0100 -Subject: [PATCH] Initial Aero support +Subject: [PATCH 1/2] Initial Aero support Signed-off-by: Dennis Bonke --- @@ -18,7 +18,7 @@ Signed-off-by: Dennis Bonke 10 files changed, 27 insertions(+), 16 deletions(-) diff --git a/Source/JavaScriptCore/heap/BlockDirectory.cpp b/Source/JavaScriptCore/heap/BlockDirectory.cpp -index e2a3540f86..d58513333e 100644 +index e2a3540f86..8b14455772 100644 --- a/Source/JavaScriptCore/heap/BlockDirectory.cpp +++ b/Source/JavaScriptCore/heap/BlockDirectory.cpp @@ -60,7 +60,7 @@ void BlockDirectory::setSubspace(Subspace* subspace) @@ -31,7 +31,7 @@ index e2a3540f86..d58513333e 100644 ASSERT(!(MarkedBlock::blockSize % pageSize)); auto numberOfPagesInMarkedBlock = MarkedBlock::blockSize / pageSize; diff --git a/Source/JavaScriptCore/runtime/MachineContext.h b/Source/JavaScriptCore/runtime/MachineContext.h -index 7857bfc167..c14fbb5b6c 100644 +index 7857bfc167..4e396fa853 100644 --- a/Source/JavaScriptCore/runtime/MachineContext.h +++ b/Source/JavaScriptCore/runtime/MachineContext.h @@ -346,7 +346,7 @@ static inline void*& framePointerImpl(mcontext_t& machineContext) @@ -83,7 +83,7 @@ index e54387ef28..d159806731 100644 #include #include diff --git a/Source/ThirdParty/ANGLE/src/common/platform.h b/Source/ThirdParty/ANGLE/src/common/platform.h -index 41f3cf4ff7..77c4a91f29 100644 +index 41f3cf4ff7..745e1f4a56 100644 --- a/Source/ThirdParty/ANGLE/src/common/platform.h +++ b/Source/ThirdParty/ANGLE/src/common/platform.h @@ -28,7 +28,7 @@ @@ -96,7 +96,7 @@ index 41f3cf4ff7..77c4a91f29 100644 #else # error Unsupported platform. diff --git a/Source/WTF/wtf/InlineASM.h b/Source/WTF/wtf/InlineASM.h -index 8379a69659..8f7493769f 100644 +index 8379a69659..f2780b7947 100644 --- a/Source/WTF/wtf/InlineASM.h +++ b/Source/WTF/wtf/InlineASM.h @@ -43,11 +43,11 @@ @@ -132,7 +132,7 @@ index 8379a69659..8f7493769f 100644 // GNU as-compatible syntax. #define LOCAL_LABEL_STRING(name) ".L" #name diff --git a/Source/WTF/wtf/PlatformHave.h b/Source/WTF/wtf/PlatformHave.h -index 61f13c2b73..de93124ef8 100644 +index 61f13c2b73..c4ff4a6252 100644 --- a/Source/WTF/wtf/PlatformHave.h +++ b/Source/WTF/wtf/PlatformHave.h @@ -226,7 +226,7 @@ @@ -154,7 +154,7 @@ index 61f13c2b73..de93124ef8 100644 #endif diff --git a/Source/WTF/wtf/PlatformOS.h b/Source/WTF/wtf/PlatformOS.h -index e61715fb72..ed72f251a9 100644 +index e61715fb72..28cf97f28f 100644 --- a/Source/WTF/wtf/PlatformOS.h +++ b/Source/WTF/wtf/PlatformOS.h @@ -118,6 +118,11 @@ @@ -202,7 +202,7 @@ index 743ef3dc84..3a61bc1dc3 100644 } return SQLiteStatement { *this, sqlStatement.value() }; diff --git a/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp b/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp -index efcd663f84..11e5467c10 100644 +index efcd663f84..81a425a037 100644 --- a/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp +++ b/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp @@ -46,7 +46,7 @@ @@ -215,7 +215,7 @@ index efcd663f84..11e5467c10 100644 #else #if USE(GLIB) diff --git a/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp b/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp -index 998a2a7679..a490b3fb5f 100644 +index 998a2a7679..51c5d38573 100644 --- a/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp +++ b/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp @@ -47,8 +47,10 @@ @@ -239,5 +239,5 @@ index 998a2a7679..a490b3fb5f 100644 if (fileDescriptor != -1) -- -2.40.0 +2.42.0 diff --git a/patches/webkitgtk/0002-xxx.patch b/patches/webkitgtk/0002-xxx.patch new file mode 100644 index 00000000000..ae6402e7784 --- /dev/null +++ b/patches/webkitgtk/0002-xxx.patch @@ -0,0 +1,181 @@ +From 4a70595e159ee5cc7336ed10c78f7f34284506e1 Mon Sep 17 00:00:00 2001 +From: Anhad Singh +Date: Sat, 14 Oct 2023 16:58:18 +1100 +Subject: [PATCH 2/2] + +Signed-off-by: Anhad Singh +--- + .../ANGLE/include/GLSLANG/ShaderVars.h | 1 + + Source/WTF/wtf/MallocPtr.h | 1 + + .../WTF/wtf/text/IntegerToStringConversion.h | 25 ++++++++++--------- + .../WebCore/accessibility/AXObjectCache.cpp | 2 ++ + .../graphics/BifurcatedGraphicsContext.cpp | 2 ++ + .../platform/graphics/x11/XUniqueResource.h | 2 ++ + 6 files changed, 21 insertions(+), 12 deletions(-) + +diff --git a/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderVars.h b/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderVars.h +index 68dc7e2e32..e127de3373 100644 +--- a/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderVars.h ++++ b/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderVars.h +@@ -14,6 +14,7 @@ + #include + #include + #include ++#include + + // This type is defined here to simplify ANGLE's integration with glslang for SPIRv. + using ShCompileOptions = uint64_t; +diff --git a/Source/WTF/wtf/MallocPtr.h b/Source/WTF/wtf/MallocPtr.h +index 2cbd861efd..57e8e66100 100644 +--- a/Source/WTF/wtf/MallocPtr.h ++++ b/Source/WTF/wtf/MallocPtr.h +@@ -25,6 +25,7 @@ + + #pragma once + ++#include + #include + #include + +diff --git a/Source/WTF/wtf/text/IntegerToStringConversion.h b/Source/WTF/wtf/text/IntegerToStringConversion.h +index 03f5861c33..666e53e564 100644 +--- a/Source/WTF/wtf/text/IntegerToStringConversion.h ++++ b/Source/WTF/wtf/text/IntegerToStringConversion.h +@@ -21,15 +21,17 @@ + + #pragma once + ++#include + #include + + namespace WTF { + +-enum PositiveOrNegativeNumber { PositiveNumber, NegativeNumber }; ++enum PositiveOrNegativeNumber { PositiveNumber, ++ NegativeNumber }; + +-template struct IntegerToStringConversionTrait; ++template struct IntegerToStringConversionTrait; + +-template ++template + static typename IntegerToStringConversionTrait::ReturnType numberToStringImpl(UnsignedIntegerType number, AdditionalArgumentType additionalArgument) + { + LChar buf[sizeof(UnsignedIntegerType) * 3 + 1]; +@@ -47,7 +49,7 @@ static typename IntegerToStringConversionTrait::ReturnType numberToStringImpl + return IntegerToStringConversionTrait::flush(p, static_cast(end - p), additionalArgument); + } + +-template ++template + inline typename IntegerToStringConversionTrait::ReturnType numberToStringSigned(SignedIntegerType number, typename IntegerToStringConversionTrait::AdditionalArgumentType* additionalArgument = nullptr) + { + if (number < 0) +@@ -55,13 +57,13 @@ inline typename IntegerToStringConversionTrait::ReturnType numberToStringSign + return numberToStringImpl, PositiveNumber>(number, additionalArgument); + } + +-template ++template + inline typename IntegerToStringConversionTrait::ReturnType numberToStringUnsigned(UnsignedIntegerType number, typename IntegerToStringConversionTrait::AdditionalArgumentType* additionalArgument = nullptr) + { + return numberToStringImpl(number, additionalArgument); + } + +-template ++template + static void writeIntegerToBufferImpl(UnsignedIntegerType number, CharacterType* destination) + { + static_assert(!std::is_same_v>, "'bool' not supported"); +@@ -76,12 +78,12 @@ static void writeIntegerToBufferImpl(UnsignedIntegerType number, CharacterType* + + if (NumberType == NegativeNumber) + *--p = '-'; +- ++ + while (p < end) + *destination++ = static_cast(*p++); + } + +-template ++template + inline void writeIntegerToBuffer(IntegerType integer, CharacterType* destination) + { + static_assert(std::is_integral_v); +@@ -95,7 +97,7 @@ inline void writeIntegerToBuffer(IntegerType integer, CharacterType* destination + return writeIntegerToBufferImpl(integer, destination); + } + +-template ++template + constexpr unsigned lengthOfIntegerAsStringImpl(UnsignedIntegerType number) + { + unsigned length = 0; +@@ -111,15 +113,14 @@ constexpr unsigned lengthOfIntegerAsStringImpl(UnsignedIntegerType number) + return length; + } + +-template ++template + constexpr unsigned lengthOfIntegerAsString(IntegerType integer) + { + static_assert(std::is_integral_v); + if constexpr (std::is_same_v) { + UNUSED_PARAM(integer); + return 1; +- } +- else if constexpr (std::is_signed_v) { ++ } else if constexpr (std::is_signed_v) { + if (integer < 0) + return lengthOfIntegerAsStringImpl, NegativeNumber>(-integer); + return lengthOfIntegerAsStringImpl, PositiveNumber>(integer); +diff --git a/Source/WebCore/accessibility/AXObjectCache.cpp b/Source/WebCore/accessibility/AXObjectCache.cpp +index a7a867f60d..a08ce5078d 100644 +--- a/Source/WebCore/accessibility/AXObjectCache.cpp ++++ b/Source/WebCore/accessibility/AXObjectCache.cpp +@@ -528,9 +528,11 @@ static bool isSimpleImage(const RenderObject& renderer) + || (is(node) && downcast(node)->hasAttributeWithoutSynchronization(usemapAttr))) + return false; + ++#if ENABLE(VIDEO) + // Exclude video and audio elements. + if (is(node)) + return false; ++#endif + + return true; + } +diff --git a/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp b/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp +index c0ce72c5ff..a2a58df7eb 100644 +--- a/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp ++++ b/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp +@@ -269,11 +269,13 @@ void BifurcatedGraphicsContext::drawPattern(NativeImage& nativeImage, const Floa + m_secondaryContext.drawPattern(nativeImage, imageSize, destRect, tileRect, patternTransform, phase, spacing, options); + } + ++#if ENABLE(VIDEO) + void BifurcatedGraphicsContext::paintFrameForMedia(MediaPlayer& player, const FloatRect& destination) + { + m_primaryContext.paintFrameForMedia(player, destination); + m_secondaryContext.paintFrameForMedia(player, destination); + } ++#endif + + void BifurcatedGraphicsContext::scale(const FloatSize& scale) + { +diff --git a/Source/WebCore/platform/graphics/x11/XUniqueResource.h b/Source/WebCore/platform/graphics/x11/XUniqueResource.h +index 0da8b0c9c0..9296efca23 100644 +--- a/Source/WebCore/platform/graphics/x11/XUniqueResource.h ++++ b/Source/WebCore/platform/graphics/x11/XUniqueResource.h +@@ -26,6 +26,8 @@ + #ifndef XUniqueResource_h + #define XUniqueResource_h + ++#include ++ + #if PLATFORM(X11) + + #if USE(GLX) +-- +2.42.0 + diff --git a/src/aero_kernel/src/arch/x86_64/interrupts/exceptions.rs b/src/aero_kernel/src/arch/x86_64/interrupts/exceptions.rs index 579e1d9c860..315d0f65105 100644 --- a/src/aero_kernel/src/arch/x86_64/interrupts/exceptions.rs +++ b/src/aero_kernel/src/arch/x86_64/interrupts/exceptions.rs @@ -33,7 +33,24 @@ macro interrupt_exception(fn $name:ident() => $message:expr) { unwind::prepare_panic(); log::error!("EXCEPTION: {}", $message); + log::error!("FS={:#x}", unsafe { io::rdmsr(io::IA32_FS_BASE) },); + log::error!("GS={:#x}", unsafe { io::rdmsr(io::IA32_GS_BASE) }); log::error!("Stack: {:#x?}", stack); + dbg!( + scheduler::get_scheduler() + .current_task() + .arch_task() + .fpu_storage + ); + + if stack.stack.iret.rip != 0 { + unsafe { + log::error!( + "RIP={:?}", + core::slice::from_raw_parts(stack.stack.iret.rip as *const u8, 512) + ); + } + } unwind::unwind_stack_trace(); diff --git a/src/aero_kernel/src/arch/x86_64/mod.rs b/src/aero_kernel/src/arch/x86_64/mod.rs index b864b6269c7..d66038d474c 100644 --- a/src/aero_kernel/src/arch/x86_64/mod.rs +++ b/src/aero_kernel/src/arch/x86_64/mod.rs @@ -247,7 +247,9 @@ fn enable_xsave() { unsafe { controlregs::write_cr4(cr4) } let mut xcr0 = controlregs::read_xcr0(); - xcr0.insert(XCr0Flags::X87 | XCr0Flags::SSE); + xcr0.insert(XCr0Flags::X87 | XCr0Flags::SSE | XCr0Flags::AVX); + // xcr0.insert(XCr0Flags::BNDREG | XCr0Flags::BNDCSR); + // xcr0.insert(XCr0Flags::ZMM_HI256 | XCr0Flags::HI16_ZMM | XCr0Flags::OPMASK); unsafe { controlregs::write_xcr0(xcr0) } } diff --git a/src/aero_kernel/src/arch/x86_64/task.rs b/src/aero_kernel/src/arch/x86_64/task.rs index f6370fdbca8..c2aa7bfa6a5 100644 --- a/src/aero_kernel/src/arch/x86_64/task.rs +++ b/src/aero_kernel/src/arch/x86_64/task.rs @@ -126,7 +126,7 @@ pub struct ArchTask { fs_base: VirtAddr, gs_base: VirtAddr, - fpu_storage: Option>, + pub fpu_storage: Option, } impl ArchTask { @@ -212,14 +212,15 @@ impl ArchTask { let old_registers_frame = unsafe { old_stack.offset::() }; let registers_frame = unsafe { new_stack.offset::() }; - *registers_frame = InterruptErrorStack::default(); + *registers_frame = *old_registers_frame; - registers_frame.stack.iret.cs = old_registers_frame.stack.iret.cs; - registers_frame.stack.iret.ss = old_registers_frame.stack.iret.ss; + // registers_frame.stack.iret.cs = old_registers_frame.stack.iret.cs; + // registers_frame.stack.iret.ss = old_registers_frame.stack.iret.ss; + // registers_frame.stack.iret.rflags = old_registers_frame.stack.iret.rflags; registers_frame.stack.iret.rip = entry as _; registers_frame.stack.iret.rsp = usr_stack as _; - registers_frame.stack.iret.rflags = 0x200; + // registers_frame.stack.iret.rflags = 0x200; let context = unsafe { new_stack.offset::() }; @@ -231,8 +232,7 @@ impl ArchTask { context.rip = fork_init as _; context.cr3 = address_space.cr3().start_address().as_u64(); - let mut fpu_storage = alloc_boxed_buffer::(xsave_size() as usize); - fpu_storage.copy_from_slice(self.fpu_storage.as_ref().unwrap()); + let mut fpu_storage = self.fpu_storage.unwrap().clone(); Ok(Self { context: unsafe { Unique::new_unchecked(context) }, @@ -241,7 +241,7 @@ impl ArchTask { user: true, // The FS and GS bases are inherited from the parent process. - fs_base: self.fs_base, + fs_base: VirtAddr::new(1), gs_base: self.gs_base, fpu_storage: Some(fpu_storage), @@ -287,8 +287,7 @@ impl ArchTask { context.rip = fork_init as u64; context.cr3 = new_address_space.cr3().start_address().as_u64(); - let mut fpu_storage = alloc_boxed_buffer::(xsave_size() as usize); - fpu_storage.copy_from_slice(self.fpu_storage.as_ref().unwrap()); + let fpu_storage = self.fpu_storage.unwrap().clone(); Ok(Self { context: unsafe { Unique::new_unchecked(context) }, @@ -344,30 +343,30 @@ impl ArchTask { self.fs_base = VirtAddr::zero(); self.gs_base = VirtAddr::zero(); - let mut fpu_storage = alloc_boxed_buffer::(xsave_size() as usize); - - unsafe { - xrstor(&fpu_storage); - - // The x87 FPU control word is set to 0x37f (default), which masks all - // floating-point exceptions, sets rounding to nearest, and sets the x87 - // FPU precision to 64 bits (as documented in Intel SDM volume 1 section - // 8.1.5). - const DEFAULT_FPU_CWORD: u16 = 0x37f; - asm!("fldcw [{}]", in(reg) &DEFAULT_FPU_CWORD, options(nomem)); - - // Set the default MXCSR value at reset as documented in Intel SDM volume 2A. - controlregs::write_mxcsr( - MxCsr::INVALID_OPERATION_MASK - | MxCsr::DENORMAL_MASK - | MxCsr::DIVIDE_BY_ZERO_MASK - | MxCsr::OVERFLOW_MASK - | MxCsr::UNDERFLOW_MASK - | MxCsr::PRECISION_MASK, - ); - - xsave(&mut fpu_storage); - } + let mut fpu_storage = FpuState::default(); + + // unsafe { + // xrstor(&fpu_storage); + + // // The x87 FPU control word is set to 0x37f (default), which masks all + // // floating-point exceptions, sets rounding to nearest, and sets the x87 + // // FPU precision to 64 bits (as documented in Intel SDM volume 1 section + // // 8.1.5). + // const DEFAULT_FPU_CWORD: u16 = 0x37f; + // asm!("fldcw [{}]", in(reg) &DEFAULT_FPU_CWORD, options(nomem)); + + // // Set the default MXCSR value at reset as documented in Intel SDM volume 2A. + // controlregs::write_mxcsr( + // MxCsr::INVALID_OPERATION_MASK + // | MxCsr::DENORMAL_MASK + // | MxCsr::DIVIDE_BY_ZERO_MASK + // | MxCsr::OVERFLOW_MASK + // | MxCsr::UNDERFLOW_MASK + // | MxCsr::PRECISION_MASK, + // ); + + // xsave(&mut fpu_storage); + // } self.fpu_storage = Some(fpu_storage); @@ -446,11 +445,9 @@ impl ArchTask { /// Allocates a new context switch stack for the process and returns the stack /// top address. See the module level documentation for more information. fn alloc_switch_stack() -> Result> { - let frame: PhysFrame = FRAME_ALLOCATOR - .allocate_frame() - .ok_or(MapToError::FrameAllocationFailed)?; + let frame = FRAME_ALLOCATOR.alloc_zeroed(4096 * 4).unwrap(); - Ok(frame.start_address().as_hhdm_virt() + Size4KiB::SIZE) + Ok(frame.as_hhdm_virt() + (4096u64 * 4)) } fn unref_pt(&mut self) { @@ -500,6 +497,7 @@ impl ArchTask { /// belongs to. This is required since we also update the GS base register with the /// `base` immediately (not waiting for a switch). pub unsafe fn set_gs_base(&mut self, base: VirtAddr) { + self.gs_base = base; io::set_inactive_gsbase(base); } @@ -515,13 +513,14 @@ impl ArchTask { /// belongs to. This is required since we also update the FS base register with the /// `base` immediately (not waiting for a switch). pub unsafe fn set_fs_base(&mut self, base: VirtAddr) { + self.fs_base = base; io::set_fsbase(base); } } fn xsave_size() -> u32 { - static XSAVE_SIZE: Option = None; - XSAVE_SIZE.unwrap_or_else(|| { + static XSAVE_SIZE: spin::Once = spin::Once::new(); + *XSAVE_SIZE.call_once(|| { CpuId::new() .get_extended_state_info() .expect("xsave: cpuid extended state info unavailable") @@ -529,18 +528,91 @@ fn xsave_size() -> u32 { }) } -fn xsave(fpu: &mut Box<[u8]>) { - unsafe { - asm!("xsave [{}]", in(reg) fpu.as_ptr(), in("eax") 0xffffffffu32, in("edx") 0xffffffffu32) - } +#[derive(Debug, Copy, Clone)] +#[repr(C, align(16))] +pub struct FpuState { + /// x87 FPU Control Word (16 bits). See Figure 8-6 in the Intel® 64 and IA-32 Architectures + /// Software Developer’s Manual Volume 1, for the layout of the x87 FPU control word. + pub fcw: u16, + /// x87 FPU Status Word (16 bits). + pub fsw: u16, + /// x87 FPU Tag Word (8 bits) + reserved (8 bits). + pub ftw: u16, + /// x87 FPU Opcode (16 bits). + pub fop: u16, + /// x87 FPU Instruction Pointer Offset ([31:0]). The contents of this field differ depending on + /// the current addressing mode (32-bit, 16-bit, or 64-bit) of the processor when the + /// FXSAVE instruction was executed: 32-bit mode — 32-bit IP offset. 16-bit mode — low 16 + /// bits are IP offset; high 16 bits are reserved. 64-bit mode with REX.W — 64-bit IP + /// offset. 64-bit mode without REX.W — 32-bit IP offset. + pub fip: u32, + /// x87 FPU Instruction Pointer Selector (16 bits) + reserved (16 bits). + pub fcs: u32, + /// x87 FPU Instruction Operand (Data) Pointer Offset ([31:0]). The contents of this field + /// differ depending on the current addressing mode (32-bit, 16-bit, or 64-bit) of the + /// processor when the FXSAVE instruction was executed: 32-bit mode — 32-bit DP offset. + /// 16-bit mode — low 16 bits are DP offset; high 16 bits are reserved. 64-bit mode + /// with REX.W — 64-bit DP offset. 64-bit mode without REX.W — 32-bit DP offset. + pub fdp: u32, + /// x87 FPU Instruction Operand (Data) Pointer Selector (16 bits) + reserved. + pub fds: u32, + /// MXCSR Register State (32 bits). + pub mxcsr: u32, + /// This mask can be used to adjust values written to the MXCSR register, ensuring that + /// reserved bits are set to 0. Set the mask bits and flags in MXCSR to the mode of + /// operation desired for SSE and SSE2 SIMD floating-point instructions. + pub mxcsr_mask: u32, + /// x87 FPU or MMX technology registers. Layout: [12 .. 9 | 9 ... 0] LHS = reserved; RHS = mm. + pub mm: [u128; 8], + /// XMM registers (128 bits per field). + pub xmm: [u128; 16], + /// reserved. + pub _pad: [u64; 12], } -fn xrstor(fpu: &Box<[u8]>) { - unsafe { - asm!("xrstor [{}]", in(reg) fpu.as_ptr(), in("eax") 0xffffffffu32, in("edx") 0xffffffffu32); +impl Default for FpuState { + fn default() -> Self { + Self { + mxcsr: 0x1f80, + mxcsr_mask: 0x037f, + // rest are zeroed + fcw: 0, + fsw: 0, + ftw: 0, + fop: 0, + fip: 0, + fcs: 0, + fdp: 0, + fds: 0, + mm: [0; 8], + xmm: [u128::MAX; 16], + _pad: [0; 12], + } } } +fn xsave(fpu: &mut FpuState) { + // The implicit EDX:EAX register pair specifies a 64-bit instruction mask. The specific state + // components saved correspond to the bits set in the requested-feature bitmap (RFBM), which is + // the logical-AND of EDX:EAX and XCR0. + // unsafe { + // asm!("xsave64 [{}]", in(reg) fpu.as_ptr(), in("eax") u32::MAX, in("edx") u32::MAX, + // options(nomem, nostack)) } + + use core::arch::x86_64::_fxsave64; + + unsafe { _fxsave64(fpu as *mut FpuState as *mut _) } +} + +fn xrstor(fpu: &FpuState) { + // unsafe { + // asm!("xrstor [{}]", in(reg) fpu.as_ptr(), in("eax") u32::MAX, in("edx") u32::MAX, + // options(nomem, nostack)); } + use core::arch::x86_64::_fxrstor64; + + unsafe { _fxrstor64(fpu as *const FpuState as *const _) } +} + /// Check out the module level documentation for more information. pub fn arch_task_spinup(from: &mut ArchTask, to: &ArchTask) { extern "C" { @@ -548,6 +620,14 @@ pub fn arch_task_spinup(from: &mut ArchTask, to: &ArchTask) { } unsafe { + if let Some(fpu) = from.fpu_storage.as_mut() { + xsave(fpu); + } + + if let Some(fpu) = to.fpu_storage.as_ref() { + xrstor(fpu); + } + // Load the new thread's kernel stack pointer everywhere it's needed. let kstackp = to.context_switch_rsp.as_u64(); super::gdt::TSS.rsp[0] = kstackp; @@ -560,14 +640,6 @@ pub fn arch_task_spinup(from: &mut ArchTask, to: &ArchTask) { io::set_fsbase(to.fs_base); io::set_inactive_gsbase(to.gs_base); - if let Some(fpu) = from.fpu_storage.as_mut() { - xsave(fpu); - } - - if let Some(fpu) = to.fpu_storage.as_ref() { - xrstor(fpu); - } - task_spinup(&mut from.context, to.context.as_ref()); } } diff --git a/src/aero_kernel/src/mem/mod.rs b/src/aero_kernel/src/mem/mod.rs index 41f68d04780..ba75081a434 100644 --- a/src/aero_kernel/src/mem/mod.rs +++ b/src/aero_kernel/src/mem/mod.rs @@ -128,13 +128,5 @@ impl AddressSpace { } pub fn alloc_boxed_buffer(size: usize) -> Box<[T]> { - if size == 0 { - return >::default(); - } - - let layout = unsafe { Layout::from_size_align_unchecked(size, 8) }; - let ptr = unsafe { ::alloc::alloc::alloc_zeroed(layout) as *mut T }; - let slice_ptr = core::ptr::slice_from_raw_parts_mut(ptr, size); - - unsafe { Box::from_raw(slice_ptr) } + unsafe { Box::new_zeroed_slice(size).assume_init() } } diff --git a/src/aero_kernel/src/mem/paging/mapper.rs b/src/aero_kernel/src/mem/paging/mapper.rs index 169a01bd093..aa36e7eabe5 100644 --- a/src/aero_kernel/src/mem/paging/mapper.rs +++ b/src/aero_kernel/src/mem/paging/mapper.rs @@ -1190,10 +1190,10 @@ impl<'a> OffsetPageTable<'a> { let mut flags = entry.flags(); // Check if the mapping is shared. - if !flags.contains(PageTableFlags::BIT_10) { - // Setup copy on write page. - flags.remove(PageTableFlags::WRITABLE); - } + // if !flags.contains(PageTableFlags::BIT_10) { + // Setup copy on write page. + flags.remove(PageTableFlags::WRITABLE); + // } entry.set_flags(flags); n1[i].set_frame(entry.frame().unwrap(), flags); diff --git a/src/aero_kernel/src/syscall/process.rs b/src/aero_kernel/src/syscall/process.rs index 8b76e1fc5c0..826c8667dd1 100644 --- a/src/aero_kernel/src/syscall/process.rs +++ b/src/aero_kernel/src/syscall/process.rs @@ -61,7 +61,8 @@ pub fn uname(buffer: &mut Utsname) -> Result { let init_bytes = init.as_bytes(); let len = init.len(); - fixed[..len].copy_from_slice(init_bytes) + fixed[..len].copy_from_slice(init_bytes); + fixed[len..].fill(0); } init_array(&mut buffer.sysname, "Aero"); @@ -103,6 +104,8 @@ pub fn clone(entry: usize, stack: usize) -> Result { pub fn kill(pid: usize, signal: usize) -> Result { // If pid is positive, then signal is sent to the process with that pid. if pid > 0 { + crate::unwind::unwind_stack_trace(); + let task = scheduler::get_scheduler() .find_task(TaskId::new(pid)) .ok_or(SyscallError::ESRCH)?; diff --git a/src/aero_kernel/src/userland/task/mod.rs b/src/aero_kernel/src/userland/task/mod.rs index b0ffb6db0f1..a2387ff7d22 100644 --- a/src/aero_kernel/src/userland/task/mod.rs +++ b/src/aero_kernel/src/userland/task/mod.rs @@ -400,6 +400,7 @@ impl Task { pending_io: AtomicBool::new(false), children: Mutex::new(Default::default()), + // sus? fixme? parent: Mutex::new(None), cwd: RwLock::new(Some(self.cwd.read().as_ref().unwrap().fork())), diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs index 7fe895cc29a..1da5b1f0325 100644 --- a/src/aero_kernel/src/userland/vm.rs +++ b/src/aero_kernel/src/userland/vm.rs @@ -436,9 +436,9 @@ impl Mapping { | PageTableFlags::USER_ACCESSIBLE | self.protection.into(); - if self.flags.contains(MMapFlags::MAP_SHARED) { - flags |= PageTableFlags::BIT_10; - } + // if self.flags.contains(MMapFlags::MAP_SHARED) { + // flags |= PageTableFlags::BIT_10; + // } unsafe { offset_table.map_to(Page::containing_address(address), frame, flags) } .expect("failed to map allocated frame for private file read") @@ -784,45 +784,47 @@ impl VmProtected { ) -> Option { // Offset is required to be a multiple of page size. if (offset as u64 & (Size4KiB::SIZE - 1)) != 0 { + log::warn!("mmap: offset is not a multiple of page size"); return None; } // The provided size should be non-zero. if size == 0 { + log::warn!("mmap: size is zero"); return None; } if file.is_some() { - // SAFETY: We cannot mmap a file with the anonymous flag. if flags.contains(MMapFlags::MAP_ANONYOMUS) { + log::warn!("mmap: cannot map a file with the anonymous flag"); return None; } } else { - // SAFETY: Mappings not backed by a file must be anonymous. if !flags.contains(MMapFlags::MAP_ANONYOMUS) { + log::warn!("mmap: mappings not backed by a file cannot be anonymous"); return None; } - // SAFETY: We cannot have a shared and an anonymous mapping. if flags.contains(MMapFlags::MAP_SHARED) { + log::warn!("mmap: anonymous mappings cannot be shared"); return None; } } let size_aligned = align_up(size as _, Size4KiB::SIZE); - if address == VirtAddr::zero() { + let x = if address == VirtAddr::zero() { // We need to find a free mapping above 0x7000_0000_0000. self.find_any_above(VirtAddr::new(0x7000_0000_0000), size_aligned as _) } else if flags.contains(MMapFlags::MAP_FIXED) { // SAFETY: The provided address should be page aligned. if !address.is_aligned(Size4KiB::SIZE) { + log::warn!("mmap: fixed mapping address is not page aligned"); return None; } - // SAFETY: The provided (address + size) should be less then - // the userland max address. if (address + size_aligned) > userland_last_address() { + log::warn!("mmap: fixed mapping address is out of range"); return None; } @@ -857,7 +859,38 @@ impl VmProtected { }); addr - }) + }); + + if x.is_none() { + log::warn!("mmap failed"); + self.log(); + } + + x + } + + fn log(&self) { + for mmap in &self.mappings { + if let Some(file) = mmap.file.as_ref() { + log::debug!( + "{:?}..{:?} => {:?}, {:?} (offset={:#x}, size={:#x})", + mmap.start_addr, + mmap.end_addr, + mmap.protection, + mmap.flags, + file.offset, + file.size, + ); + } else { + log::debug!( + "{:?}..{:?} => {:?}, {:?}", + mmap.start_addr, + mmap.end_addr, + mmap.protection, + mmap.flags, + ); + } + } } fn load_bin<'header>( diff --git a/tools/cargo-inject-patches.py b/tools/cargo-inject-patches.py index 7d046383d9d..18be0cf7d05 100644 --- a/tools/cargo-inject-patches.py +++ b/tools/cargo-inject-patches.py @@ -11,7 +11,7 @@ "calloop": "0.9.3", "libc": "0.2.149", "getrandom": "0.2.9", - "libloading": "0.8.1", + "libloading": "0.7.3", "mio": ["0.6.23", "0.8.3"], "nix": "0.24.3", "num_cpus": "1.15.0", diff --git a/userland/apps/init/src/main.rs b/userland/apps/init/src/main.rs index fc30f33b071..ecbaef5d8c2 100644 --- a/userland/apps/init/src/main.rs +++ b/userland/apps/init/src/main.rs @@ -53,21 +53,21 @@ fn main() -> Result<(), Box> { let stdout = OpenOptions::new().write(true).open(TTY_PATH)?; // fd=1 let stderr = OpenOptions::new().write(true).open(TTY_PATH)?; // fd=2 - // { - let stdset = FileSet::new([stdin, stdout, stderr]); - stdset.remove_cloexec(); + { + let stdset = FileSet::new([stdin, stdout, stderr]); + stdset.remove_cloexec(); - Command::new("dhcpd").spawn()?; - // } + Command::new("dhcpd").spawn()?; + } - // // Swap the `/dev/tty` std{in,out,err} file descriptors with `/dev/null` to suppress the Xorg - // // server logs. - // let stdin = OpenOptions::new().read(true).open(DEV_NULL)?; // fd=0 - // let stdout = OpenOptions::new().write(true).open(DEV_NULL)?; // fd=1 - // let stderr = OpenOptions::new().write(true).open(DEV_NULL)?; // fd=2 + // Swap the `/dev/tty` std{in,out,err} file descriptors with `/dev/null` to suppress the Xorg + // server logs. + let stdin = OpenOptions::new().read(true).open(DEV_NULL)?; // fd=0 + let stdout = OpenOptions::new().write(true).open(DEV_NULL)?; // fd=1 + let stderr = OpenOptions::new().write(true).open(DEV_NULL)?; // fd=2 - // let stdset = FileSet::new([stdin, stdout, stderr]); - // stdset.remove_cloexec(); + let stdset = FileSet::new([stdin, stdout, stderr]); + stdset.remove_cloexec(); Command::new("startx") .env("RUST_BACKTRACE", "full") From 2b30079096dca239bab670ac5ead764c88e70200 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 19 Oct 2023 21:56:46 +1100 Subject: [PATCH 009/112] feat(bootstrap): upgrade llvm to 17.0.3 * Upgrade LLVM to 17.0.3 * Build LLVM, clang and clang-tools-extra Signed-off-by: Anhad Singh --- bootstrap.yml | 6 +- ...patch => 0001-feat-targets-add-aero.patch} | 343 ++++++++---------- 2 files changed, 163 insertions(+), 186 deletions(-) rename patches/llvm/{llvm.patch => 0001-feat-targets-add-aero.patch} (82%) diff --git a/bootstrap.yml b/bootstrap.yml index 90ef0bb5961..5754cdc09d2 100644 --- a/bootstrap.yml +++ b/bootstrap.yml @@ -80,8 +80,8 @@ sources: - name: llvm subdir: 'bundled' git: 'https://github.com/llvm/llvm-project.git' - tag: 'llvmorg-14.0.1' - version: '14.0.1' + tag: 'llvmorg-17.0.3' + version: '17.0.3' - name: glib subdir: 'bundled' @@ -595,7 +595,7 @@ tools: # Building it in debug mode produces tens of GiB of debugging info. - '-DCMAKE_BUILD_TYPE=Release' - '-DLLVM_TARGETS_TO_BUILD=X86' - - '-DLLVM_ENABLE_PROJECTS=llvm' + - '-DLLVM_ENABLE_PROJECTS=llvm;clang;clang-tools-extra' - '-DLLVM_ENABLE_Z3_SOLVER=OFF' # clang configuration options. - '-DDEFAULT_SYSROOT=@SYSROOT_DIR@' diff --git a/patches/llvm/llvm.patch b/patches/llvm/0001-feat-targets-add-aero.patch similarity index 82% rename from patches/llvm/llvm.patch rename to patches/llvm/0001-feat-targets-add-aero.patch index 17987cb2a11..d765ad6c9e7 100644 --- a/patches/llvm/llvm.patch +++ b/patches/llvm/0001-feat-targets-add-aero.patch @@ -1,66 +1,69 @@ -From 20cff6e42171169bd1b78d7ccffec0ab608e1eaa Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Thu, 16 Feb 2023 17:54:52 +1100 -Subject: [PATCH] targets: add aero +From bc36fc2f014463a6baa37512c708bca46dbd55c5 Mon Sep 17 00:00:00 2001 +From: Anhad Singh +Date: Thu, 19 Oct 2023 21:54:42 +1100 +Subject: [PATCH] feat(targets): add aero -Signed-off-by: Andy-Python-Programmer +Signed-off-by: Anhad Singh --- - clang/lib/Basic/Targets.cpp | 6 + - clang/lib/Basic/Targets/OSTargets.h | 28 ++ + clang/lib/Basic/Targets.cpp | 10 + + clang/lib/Basic/Targets/OSTargets.h | 31 ++ clang/lib/Driver/CMakeLists.txt | 1 + clang/lib/Driver/Driver.cpp | 4 + - clang/lib/Driver/ToolChains/Aero.cpp | 438 ++++++++++++++++++++++ + clang/lib/Driver/ToolChains/Aero.cpp | 432 ++++++++++++++++++++++ clang/lib/Driver/ToolChains/Aero.h | 49 +++ clang/lib/Driver/ToolChains/Gnu.cpp | 13 +- llvm/cmake/modules/CrossCompile.cmake | 4 +- - llvm/include/llvm/ADT/Triple.h | 5 +- llvm/include/llvm/Support/SwapByteOrder.h | 2 +- - llvm/lib/Support/Triple.cpp | 6 + + llvm/include/llvm/TargetParser/Triple.h | 5 +- llvm/lib/Support/Unix/Path.inc | 6 +- llvm/lib/Support/Unix/Program.inc | 1 + - llvm/tools/llvm-dwarfdump/Statistics.cpp | 2 + + llvm/lib/TargetParser/Triple.cpp | 6 + llvm/tools/llvm-shlib/CMakeLists.txt | 1 + - 15 files changed, 556 insertions(+), 10 deletions(-) + 14 files changed, 555 insertions(+), 10 deletions(-) create mode 100644 clang/lib/Driver/ToolChains/Aero.cpp create mode 100644 clang/lib/Driver/ToolChains/Aero.h diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp -index 994a491cdd..098b0d5fb7 100644 +index 636b59fd1..9e1e08ec5 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp -@@ -149,6 +149,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple, - return new NetBSDTargetInfo(Triple, Opts); - case llvm::Triple::OpenBSD: - return new OpenBSDTargetInfo(Triple, Opts); +@@ -151,6 +151,10 @@ std::unique_ptr AllocateTarget(const llvm::Triple &Triple, + case llvm::Triple::Fuchsia: + return std::make_unique>(Triple, + Opts); + case llvm::Triple::Aero: -+ return new AeroTargetInfo(Triple, Opts); - case llvm::Triple::Win32: - switch (Triple.getEnvironment()) { - case llvm::Triple::GNU: -@@ -420,6 +422,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple, - return new FuchsiaTargetInfo(Triple, Opts); ++ return std::make_unique>(Triple, ++ Opts); ++ case llvm::Triple::Linux: - return new LinuxTargetInfo(Triple, Opts); + switch (Triple.getEnvironment()) { + default: +@@ -455,6 +459,9 @@ std::unique_ptr AllocateTarget(const llvm::Triple &Triple, + case llvm::Triple::Fuchsia: + return std::make_unique>(Triple, + Opts); + case llvm::Triple::Aero: -+ return new AeroTargetInfo(Triple, Opts); - default: - return new RISCV64TargetInfo(Triple, Opts); - } -@@ -586,6 +590,8 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple, - } - case llvm::Triple::Haiku: - return new HaikuTargetInfo(Triple, Opts); ++ return std::make_unique>(Triple, ++ Opts); + case llvm::Triple::Linux: + switch (Triple.getEnvironment()) { + default: +@@ -636,6 +643,9 @@ std::unique_ptr AllocateTarget(const llvm::Triple &Triple, + case llvm::Triple::Fuchsia: + return std::make_unique>(Triple, + Opts); + case llvm::Triple::Aero: -+ return new AeroTargetInfo(Triple, Opts); - case llvm::Triple::NaCl: - return new NaClTargetInfo(Triple, Opts); - case llvm::Triple::PS4: ++ return std::make_unique>(Triple, ++ Opts); + case llvm::Triple::KFreeBSD: + return std::make_unique>(Triple, + Opts); diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h -index 3c1830d5f8..2123019378 100644 +index 8f4331b02..bacb1e071 100644 --- a/clang/lib/Basic/Targets/OSTargets.h +++ b/clang/lib/Basic/Targets/OSTargets.h -@@ -338,6 +338,34 @@ public: - : OSTargetInfo(Triple, Opts) {} +@@ -278,6 +278,37 @@ public: + using OSTargetInfo::OSTargetInfo; }; +// Aero Target @@ -75,6 +78,8 @@ index 3c1830d5f8..2123019378 100644 + Builder.defineMacro("_REENTRANT"); + if (Opts.CPlusPlus) + Builder.defineMacro("_GNU_SOURCE"); ++ // if (this->HasFloat128) ++ // Builder.defineMacro("__FLOAT128__"); + } + +public: @@ -91,34 +96,35 @@ index 3c1830d5f8..2123019378 100644 + } +}; + - // Minix Target ++ + // Haiku Target template - class LLVM_LIBRARY_VISIBILITY MinixTargetInfo : public OSTargetInfo { + class LLVM_LIBRARY_VISIBILITY HaikuTargetInfo : public OSTargetInfo { diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt -index 78e8fd1852..8a53a0a7ab 100644 +index a6bd2d41e..132da8bbe 100644 --- a/clang/lib/Driver/CMakeLists.txt +++ b/clang/lib/Driver/CMakeLists.txt @@ -59,6 +59,7 @@ add_clang_library(clangDriver - ToolChains/Hexagon.cpp - ToolChains/Hurd.cpp - ToolChains/Linux.cpp + ToolChains/Flang.cpp + ToolChains/FreeBSD.cpp + ToolChains/Fuchsia.cpp + ToolChains/Aero.cpp - ToolChains/MipsLinux.cpp - ToolChains/MinGW.cpp - ToolChains/Minix.cpp + ToolChains/Gnu.cpp + ToolChains/Haiku.cpp + ToolChains/HIPUtility.cpp diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp -index 3bfddeefc7..9773e5efd1 100644 +index bdbdad936..bc194b1f5 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp -@@ -30,6 +30,7 @@ - #include "ToolChains/Hurd.h" - #include "ToolChains/Lanai.h" - #include "ToolChains/Linux.h" +@@ -24,6 +24,7 @@ + #include "ToolChains/DragonFly.h" + #include "ToolChains/FreeBSD.h" + #include "ToolChains/Fuchsia.h" +#include "ToolChains/Aero.h" - #include "ToolChains/MSP430.h" - #include "ToolChains/MSVC.h" - #include "ToolChains/MinGW.h" -@@ -5564,6 +5565,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, + #include "ToolChains/Gnu.h" + #include "ToolChains/HIPAMD.h" + #include "ToolChains/HIPSPV.h" +@@ -6225,6 +6226,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, case llvm::Triple::Fuchsia: TC = std::make_unique(*this, Target, Args); break; @@ -130,10 +136,10 @@ index 3bfddeefc7..9773e5efd1 100644 break; diff --git a/clang/lib/Driver/ToolChains/Aero.cpp b/clang/lib/Driver/ToolChains/Aero.cpp new file mode 100644 -index 0000000000..4cd7765aeb +index 000000000..580d85cde --- /dev/null +++ b/clang/lib/Driver/ToolChains/Aero.cpp -@@ -0,0 +1,438 @@ +@@ -0,0 +1,432 @@ +//===--- Aero.h - Aero ToolChain Implementations --------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure @@ -247,13 +253,13 @@ index 0000000000..4cd7765aeb + // to the link paths. + path_list &Paths = getFilePaths(); + -+ const std::string OSLibDir = getOSLibDir(Triple, Args); ++ const std::string OSLibDir = std::string(getOSLibDir(Triple, Args)); + const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot); + + // Add the multilib suffixed paths where they are available. + if (GCCInstallation.isValid()) { + const llvm::Triple &GCCTriple = GCCInstallation.getTriple(); -+ const std::string &LibPath = GCCInstallation.getParentLibPath(); ++ const std::string &LibPath = std::string(GCCInstallation.getParentLibPath()); + const Multilib &Multilib = GCCInstallation.getMultilib(); + const MultilibSet &Multilibs = GCCInstallation.getMultilibs(); + @@ -336,7 +342,7 @@ index 0000000000..4cd7765aeb + + // See comments above on the multilib variant for details of why this is + // included even from outside the sysroot. -+ const std::string &LibPath = GCCInstallation.getParentLibPath(); ++ const std::string &LibPath = std::string(GCCInstallation.getParentLibPath()); + const llvm::Triple &GCCTriple = GCCInstallation.getTriple(); + const Multilib &Multilib = GCCInstallation.getMultilib(); + addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib" + @@ -495,11 +501,9 @@ index 0000000000..4cd7765aeb + getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot); + const GCCVersion &Version = GCCInstallation.getVersion(); + -+ // The primary search for libstdc++ supports multiarch variants. -+ if (addLibStdCXXIncludePaths(LibDir.str() + "/../include", -+ "/c++/" + Version.Text, TripleStr, -+ GCCMultiarchTriple, TargetMultiarchTriple, -+ Multilib.includeSuffix(), DriverArgs, CC1Args)) ++ // Try generic GCC detection first. ++ if (Generic_GCC::addGCCLibStdCxxIncludePaths(DriverArgs, CC1Args, ++ TripleStr)) + return; + + // Otherwise, fall back on a bunch of options which don't use multiarch @@ -519,10 +523,7 @@ index 0000000000..4cd7765aeb + }; + + for (const auto &IncludePath : LibStdCXXIncludePathCandidates) { -+ if (addLibStdCXXIncludePaths(IncludePath, /*Suffix*/ "", TripleStr, -+ /*GCCMultiarchTriple*/ "", -+ /*TargetMultiarchTriple*/ "", -+ Multilib.includeSuffix(), DriverArgs, CC1Args)) ++ if (addLibStdCXXIncludePaths(IncludePath, TripleStr, Multilib.includeSuffix(), DriverArgs, CC1Args)) + break; + } +} @@ -571,10 +572,9 @@ index 0000000000..4cd7765aeb + Res |= SanitizerKind::MemTag; + return Res; +} -+ diff --git a/clang/lib/Driver/ToolChains/Aero.h b/clang/lib/Driver/ToolChains/Aero.h new file mode 100644 -index 0000000000..e9016f4a81 +index 000000000..a7b0b4da2 --- /dev/null +++ b/clang/lib/Driver/ToolChains/Aero.h @@ -0,0 +1,49 @@ @@ -587,8 +587,8 @@ index 0000000000..e9016f4a81 +// +//===----------------------------------------------------------------------===// + -+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MANAGARM_H -+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MANAGARM_H ++#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AERO_H ++#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AERO_H + +#include "Gnu.h" +#include "clang/Driver/ToolChain.h" @@ -611,9 +611,9 @@ index 0000000000..e9016f4a81 + const llvm::opt::ArgList &DriverArgs, + llvm::opt::ArgStringList &CC1Args) const override; + SanitizerMask getSupportedSanitizers() const override; -+ virtual std::string computeSysRoot() const; + -+ virtual std::string getDynamicLinker(const llvm::opt::ArgList &Args) const; ++ virtual std::string computeSysRoot() const override; ++ virtual std::string getDynamicLinker(const llvm::opt::ArgList &Args) const override; + + std::vector ExtraOpts; + @@ -626,12 +626,12 @@ index 0000000000..e9016f4a81 +} // end namespace driver +} // end namespace clang + -+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MANAGARM_H ++#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AERO_H diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp -index 7a9570a686..8114baabb0 100644 +index 40038dce4..f9e92ba87 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp -@@ -246,6 +246,8 @@ static const char *getLDMOption(const llvm::Triple &T, const ArgList &Args) { +@@ -227,6 +227,8 @@ static const char *getLDMOption(const llvm::Triple &T, const ArgList &Args) { return "elf_iamcu"; return "elf_i386"; case llvm::Triple::aarch64: @@ -640,27 +640,27 @@ index 7a9570a686..8114baabb0 100644 return "aarch64linux"; case llvm::Triple::aarch64_be: return "aarch64linuxb"; -@@ -2073,7 +2075,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( +@@ -2298,7 +2300,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( static const char *const AArch64LibDirs[] = {"/lib64", "/lib"}; static const char *const AArch64Triples[] = { "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux", - "aarch64-suse-linux"}; -+ "aarch64-suse-linux", "aarch64-aero", "aarch64-aero-system", ++ "aarch64-suse-linux", "aarch64-aero", "aarch64-aero-system", + "aarch64-aero-kernel"}; static const char *const AArch64beLibDirs[] = {"/lib"}; static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu", "aarch64_be-linux-gnu"}; -@@ -2099,7 +2102,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( +@@ -2328,7 +2331,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( "x86_64-redhat-linux", "x86_64-suse-linux", "x86_64-manbo-linux-gnu", "x86_64-linux-gnu", "x86_64-slackware-linux", "x86_64-unknown-linux", - "x86_64-amazon-linux"}; -+ "x86_64-amazon-linux", "x86_64-aero", "x86_64-aero-system", -+ "x86_64-aero-kernel"}; ++ "x86_64-amazon-linux", "x86_64-aero", ++ "x86_64-aero-system", "x86_64-aero-kernel"}; static const char *const X32Triples[] = {"x86_64-linux-gnux32", "x86_64-pc-linux-gnux32"}; static const char *const X32LibDirs[] = {"/libx32", "/lib"}; -@@ -2171,7 +2175,10 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( +@@ -2404,7 +2408,10 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( static const char *const RISCV64LibDirs[] = {"/lib64", "/lib"}; static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu", "riscv64-linux-gnu", @@ -673,12 +673,12 @@ index 7a9570a686..8114baabb0 100644 static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"}; static const char *const SPARCv8Triples[] = {"sparc-linux-gnu", diff --git a/llvm/cmake/modules/CrossCompile.cmake b/llvm/cmake/modules/CrossCompile.cmake -index 2a39b6a40a..ceceb2aab9 100644 +index 6af47b51d..78983fa16 100644 --- a/llvm/cmake/modules/CrossCompile.cmake +++ b/llvm/cmake/modules/CrossCompile.cmake @@ -17,8 +17,8 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype) -DCMAKE_TOOLCHAIN_FILE=\"${LLVM_MAIN_SRC_DIR}/cmake/platforms/${toolchain}.cmake\") - else() + elseif (NOT CMAKE_CROSSCOMPILING) set(CROSS_TOOLCHAIN_FLAGS_INIT - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} @@ -687,35 +687,12 @@ index 2a39b6a40a..ceceb2aab9 100644 ) endif() set(CROSS_TOOLCHAIN_FLAGS_${target_name} ${CROSS_TOOLCHAIN_FLAGS_INIT} -diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h -index 42277c0130..35516ec5af 100644 ---- a/llvm/include/llvm/ADT/Triple.h -+++ b/llvm/include/llvm/ADT/Triple.h -@@ -181,6 +181,7 @@ public: - Linux, - Lv2, // PS3 - MacOSX, -+ Aero, - NetBSD, - OpenBSD, - Solaris, -@@ -232,7 +233,9 @@ public: - CoreCLR, - Simulator, // Simulator variants of other systems, e.g., Apple's iOS - MacABI, // Mac Catalyst variant of Apple's iOS deployment target. -- LastEnvironmentType = MacABI -+ Kernel, -+ System, -+ LastEnvironmentType = System - }; - enum ObjectFormatType { - UnknownObjectFormat, diff --git a/llvm/include/llvm/Support/SwapByteOrder.h b/llvm/include/llvm/Support/SwapByteOrder.h -index e8612ba665..7c4e941bd2 100644 +index 1bbc2e2f9..4b41da767 100644 --- a/llvm/include/llvm/Support/SwapByteOrder.h +++ b/llvm/include/llvm/Support/SwapByteOrder.h -@@ -22,7 +22,7 @@ - #endif +@@ -20,7 +20,7 @@ + #include #if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) || \ - defined(__Fuchsia__) || defined(__EMSCRIPTEN__) @@ -723,56 +700,31 @@ index e8612ba665..7c4e941bd2 100644 #include #elif defined(_AIX) #include -diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp -index a9afcc9db9..ccb0ca0601 100644 ---- a/llvm/lib/Support/Triple.cpp -+++ b/llvm/lib/Support/Triple.cpp -@@ -195,6 +195,7 @@ StringRef Triple::getOSTypeName(OSType Kind) { - case UnknownOS: return "unknown"; - - case AIX: return "aix"; -+ case Aero: return "aero"; - case AMDHSA: return "amdhsa"; - case AMDPAL: return "amdpal"; - case Ananas: return "ananas"; -@@ -251,6 +252,7 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) { - case GNUX32: return "gnux32"; - case GNUILP32: return "gnu_ilp32"; - case Itanium: return "itanium"; -+ case Kernel: return "kernel"; - case MSVC: return "msvc"; - case MacABI: return "macabi"; - case Musl: return "musl"; -@@ -258,6 +260,7 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) { - case MuslEABIHF: return "musleabihf"; - case MuslX32: return "muslx32"; - case Simulator: return "simulator"; -+ case System: return "system"; - } - - llvm_unreachable("Invalid EnvironmentType!"); -@@ -512,6 +515,7 @@ static Triple::VendorType parseVendor(StringRef VendorName) { - - static Triple::OSType parseOS(StringRef OSName) { - return StringSwitch(OSName) -+ .StartsWith("aero", Triple::Aero) - .StartsWith("ananas", Triple::Ananas) - .StartsWith("cloudabi", Triple::CloudABI) - .StartsWith("darwin", Triple::Darwin) -@@ -570,9 +574,11 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) { - .StartsWith("musl", Triple::Musl) - .StartsWith("msvc", Triple::MSVC) - .StartsWith("itanium", Triple::Itanium) -+ .StartsWith("kernel", Triple::Kernel) - .StartsWith("cygnus", Triple::Cygnus) - .StartsWith("coreclr", Triple::CoreCLR) - .StartsWith("simulator", Triple::Simulator) -+ .StartsWith("system", Triple::System) - .StartsWith("macabi", Triple::MacABI) - .Default(Triple::UnknownEnvironment); - } +diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h +index 79ccd644a..82520d0e0 100644 +--- a/llvm/include/llvm/TargetParser/Triple.h ++++ b/llvm/include/llvm/TargetParser/Triple.h +@@ -194,6 +194,7 @@ public: + IOS, + KFreeBSD, + Linux, ++ Aero, + Lv2, // PS3 + MacOSX, + NetBSD, +@@ -276,7 +277,9 @@ public: + Mesh, + Amplification, + OpenHOS, +- LastEnvironmentType = OpenHOS ++ Kernel, ++ System, ++ LastEnvironmentType = System + }; + enum ObjectFormatType { + UnknownObjectFormat, diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc -index 788460d657..85d46701e2 100644 +index e2aece49c..cc19a25a4 100644 --- a/llvm/lib/Support/Unix/Path.inc +++ b/llvm/lib/Support/Unix/Path.inc @@ -74,7 +74,7 @@ extern char **environ; @@ -793,7 +745,7 @@ index 788460d657..85d46701e2 100644 #if defined(HAVE_LINUX_MAGIC_H) #include #else -@@ -478,7 +478,7 @@ std::error_code remove(const Twine &path, bool IgnoreNonExisting) { +@@ -472,7 +472,7 @@ std::error_code remove(const Twine &path, bool IgnoreNonExisting) { } static bool is_local_impl(struct STATVFS &Vfs) { @@ -803,7 +755,7 @@ index 788460d657..85d46701e2 100644 #define NFS_SUPER_MAGIC 0x6969 #endif diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc -index 089342030b..0616096541 100644 +index 897e22711..02f74d7eb 100644 --- a/llvm/lib/Support/Unix/Program.inc +++ b/llvm/lib/Support/Unix/Program.inc @@ -41,6 +41,7 @@ @@ -814,31 +766,56 @@ index 089342030b..0616096541 100644 #ifdef HAVE_POSIX_SPAWN #include -diff --git a/llvm/tools/llvm-dwarfdump/Statistics.cpp b/llvm/tools/llvm-dwarfdump/Statistics.cpp -index 5c08e43b4b..a19c74e82c 100644 ---- a/llvm/tools/llvm-dwarfdump/Statistics.cpp -+++ b/llvm/tools/llvm-dwarfdump/Statistics.cpp -@@ -6,6 +6,8 @@ - // - //===----------------------------------------------------------------------===// +diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp +index a3d6a06af..3825a2a06 100644 +--- a/llvm/lib/TargetParser/Triple.cpp ++++ b/llvm/lib/TargetParser/Triple.cpp +@@ -205,6 +205,7 @@ StringRef Triple::getOSTypeName(OSType Kind) { + switch (Kind) { + case UnknownOS: return "unknown"; -+#include -+ - #include "llvm-dwarfdump.h" - #include "llvm/ADT/DenseMap.h" - #include "llvm/ADT/StringSet.h" ++ case Aero: return "aero"; + case AIX: return "aix"; + case AMDHSA: return "amdhsa"; + case AMDPAL: return "amdpal"; +@@ -270,6 +271,8 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) { + case GNUX32: return "gnux32"; + case GNUILP32: return "gnu_ilp32"; + case Itanium: return "itanium"; ++ case Kernel: return "kernel"; ++ case System: return "system"; + case MSVC: return "msvc"; + case MacABI: return "macabi"; + case Musl: return "musl"; +@@ -575,6 +578,7 @@ static Triple::VendorType parseVendor(StringRef VendorName) { + + static Triple::OSType parseOS(StringRef OSName) { + return StringSwitch(OSName) ++ .StartsWith("aero", Triple::Aero) + .StartsWith("ananas", Triple::Ananas) + .StartsWith("cloudabi", Triple::CloudABI) + .StartsWith("darwin", Triple::Darwin) +@@ -641,6 +645,8 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) { + .StartsWith("musl", Triple::Musl) + .StartsWith("msvc", Triple::MSVC) + .StartsWith("itanium", Triple::Itanium) ++ .StartsWith("kernel", Triple::Kernel) ++ .StartsWith("system", Triple::System) + .StartsWith("cygnus", Triple::Cygnus) + .StartsWith("coreclr", Triple::CoreCLR) + .StartsWith("simulator", Triple::Simulator) diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt -index 8e2b78f1b8..e1bd74eaf7 100644 +index 4f6a2cbfb..559a35ab9 100644 --- a/llvm/tools/llvm-shlib/CMakeLists.txt +++ b/llvm/tools/llvm-shlib/CMakeLists.txt -@@ -36,6 +36,7 @@ if(LLVM_BUILD_LLVM_DYLIB) - if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU) - OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") +@@ -38,6 +38,7 @@ if(LLVM_BUILD_LLVM_DYLIB) OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "GNU") -+ OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "aero") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia") ++ OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "aero") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly") + OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "Android") + OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")) # FIXME: It should be "GNU ld for elf" -- -2.39.1 +2.42.0 From f198cd6149c45aaf7d337f7aa697cbe35f5c0796 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 19 Oct 2023 21:58:37 +1100 Subject: [PATCH 010/112] feat(rust): upgrade to 1.75.0-dev TODO: Update the Rust fork with the changes. Signed-off-by: Anhad Singh --- bootstrap.yml | 11 +- extra-files/rust/config.toml | 4 +- ...p-build-target-in-x.py-and-bootstrap.patch | 77 ++ patches/rust/rust.patch | 741 ------------------ 4 files changed, 85 insertions(+), 748 deletions(-) create mode 100644 patches/rust/0001-fix-bootstrap-build-target-in-x.py-and-bootstrap.patch delete mode 100644 patches/rust/rust.patch diff --git a/bootstrap.yml b/bootstrap.yml index 5754cdc09d2..1106bb426b2 100644 --- a/bootstrap.yml +++ b/bootstrap.yml @@ -73,9 +73,9 @@ sources: - name: rust subdir: 'bundled' - git: 'https://github.com/rust-lang/rust.git' + git: 'https://github.com/aero-os/rust.git' branch: 'master' - commit: '0416b1a6f6d5c42696494e1a3a33580fd3f669d8' + commit: 'dee2030a44019048171c03d7ddcb134b945df8c5' - name: llvm subdir: 'bundled' @@ -386,19 +386,20 @@ tools: compile: - args: | cat << EOF > config.toml - changelog-seen = 2 + change-id = 115898 [llvm] download-ci-llvm = false targets = "X86" [build] - target = ["x86_64-unknown-aero-system", "x86_64-unknown-linux-gnu"] + target = ["x86_64-unknown-aero", "x86_64-unknown-linux-gnu"] build-dir = "@THIS_BUILD_DIR@" docs = false [install] prefix = "@PREFIX@" + sysconfdir = "@PREFIX@/etc" [rust] codegen-tests = false @@ -407,7 +408,7 @@ tools: [target.x86_64-unknown-linux-gnu] llvm-config = "@BUILD_ROOT@/tools/host-llvm/bin/llvm-config" - [target.x86_64-unknown-aero-system] + [target.x86_64-unknown-aero] llvm-config = "@BUILD_ROOT@/tools/host-llvm/bin/llvm-config" EOF - args: ['python3', '@THIS_SOURCE_DIR@/x.py', 'build', '--stage', '2', '-j', '@PARALLELISM@'] diff --git a/extra-files/rust/config.toml b/extra-files/rust/config.toml index 40913d37e88..54f3a75dc53 100644 --- a/extra-files/rust/config.toml +++ b/extra-files/rust/config.toml @@ -3,10 +3,10 @@ patch-in-config = true [build] rustc = "@BUILD_ROOT@/tools/host-rust/bin/rustc" -target = "x86_64-unknown-aero-system" +target = "x86_64-unknown-aero" rustflags = ["-C", "link-args=-no-pie"] -[target.x86_64-unknown-aero-system] +[target.x86_64-unknown-aero] linker = "@BUILD_ROOT@/tools/host-gcc/bin/x86_64-aero-gcc" [patch.crates-io] diff --git a/patches/rust/0001-fix-bootstrap-build-target-in-x.py-and-bootstrap.patch b/patches/rust/0001-fix-bootstrap-build-target-in-x.py-and-bootstrap.patch new file mode 100644 index 00000000000..2a474c60f55 --- /dev/null +++ b/patches/rust/0001-fix-bootstrap-build-target-in-x.py-and-bootstrap.patch @@ -0,0 +1,77 @@ +From 1f0ded570575781c7e8dbd0d60c57a2ec72ec987 Mon Sep 17 00:00:00 2001 +From: Anhad Singh +Date: Wed, 18 Oct 2023 19:23:49 +1100 +Subject: [PATCH] fix(bootstrap): build target in x.py and bootstrap + +Signed-off-by: Anhad Singh +--- + src/bootstrap/bootstrap.py | 7 +++++-- + src/bootstrap/src/core/builder.rs | 6 ++++-- + 2 files changed, 9 insertions(+), 4 deletions(-) + +diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py +index 1a1125a107f..3f3171a9ddf 100644 +--- a/src/bootstrap/bootstrap.py ++++ b/src/bootstrap/bootstrap.py +@@ -881,7 +881,7 @@ class RustBuild(object): + ... "debug", "bootstrap") + True + """ +- return os.path.join(self.build_dir, "bootstrap", "debug", "bootstrap") ++ return os.path.join(self.build_dir, "bootstrap", self.build, "debug", "bootstrap") + + def build_bootstrap(self): + """Build bootstrap""" +@@ -903,7 +903,7 @@ class RustBuild(object): + build_dir = os.path.join(self.build_dir, "bootstrap") + if self.clean and os.path.exists(build_dir): + shutil.rmtree(build_dir) +- # `CARGO_BUILD_TARGET` breaks bootstrap build. ++ # `CARGO_BUILD_TARGET` and `build.target` breaks bootstrap build. + # See also: . + if "CARGO_BUILD_TARGET" in env: + del env["CARGO_BUILD_TARGET"] +@@ -987,6 +987,9 @@ class RustBuild(object): + except KeyError: + pass + ++ args.append("--target") ++ args.append(self.build) ++ + return args + + def build_triple(self): +diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs +index 039a87e760d..cbbbce4f515 100644 +--- a/src/bootstrap/src/core/builder.rs ++++ b/src/bootstrap/src/core/builder.rs +@@ -1587,6 +1587,8 @@ pub fn cargo( + self.clear_if_dirty(&out_dir, &self.rustc(compiler)); + } + ++ let artifact_dir = self.out.join("bootstrap/").join(self.build.build.triple).join("debug/"); ++ + // Customize the compiler we're running. Specify the compiler to cargo + // as our shim and then pass it some various options used to configure + // how the actual compiler itself is called. +@@ -1599,7 +1601,7 @@ pub fn cargo( + .env("RUSTC_STAGE", stage.to_string()) + .env("RUSTC_SYSROOT", &sysroot) + .env("RUSTC_LIBDIR", &libdir) +- .env("RUSTDOC", self.bootstrap_out.join("rustdoc")) ++ .env("RUSTDOC", artifact_dir.join("rustdoc")) + .env( + "RUSTDOC_REAL", + if cmd == "doc" || cmd == "rustdoc" || (cmd == "test" && want_rustdoc) { +@@ -1613,7 +1615,7 @@ pub fn cargo( + // Clippy support is a hack and uses the default `cargo-clippy` in path. + // Don't override RUSTC so that the `cargo-clippy` in path will be run. + if cmd != "clippy" { +- cargo.env("RUSTC", self.bootstrap_out.join("rustc")); ++ cargo.env("RUSTC", artifact_dir.join("rustc")); + } + + // Dealing with rpath here is a little special, so let's go into some +-- +2.42.0 + diff --git a/patches/rust/rust.patch b/patches/rust/rust.patch deleted file mode 100644 index e8d5de44a4d..00000000000 --- a/patches/rust/rust.patch +++ /dev/null @@ -1,741 +0,0 @@ -From be8fa0845294e187d6f41004a6967c8ce299fbbe Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Fri, 17 Feb 2023 18:28:24 +1100 -Subject: [PATCH] update to latest nightly - -Signed-off-by: Andy-Python-Programmer ---- - Cargo.lock | 4 +- - Cargo.toml | 1 + - .../rustc_target/src/spec/aero_system_base.rs | 34 +++++ - compiler/rustc_target/src/spec/mod.rs | 3 + - .../src/spec/x86_64_unknown_aero_system.rs | 19 +++ - library/std/Cargo.toml | 2 +- - library/std/build.rs | 1 + - library/std/src/os/aero/fs.rs | 144 ++++++++++++++++++ - library/std/src/os/aero/mod.rs | 6 + - library/std/src/os/aero/raw.rs | 66 ++++++++ - library/std/src/os/mod.rs | 2 + - library/std/src/os/unix/mod.rs | 2 + - library/std/src/sys/unix/args.rs | 3 +- - library/std/src/sys/unix/env.rs | 11 ++ - library/std/src/sys/unix/fs.rs | 5 +- - library/std/src/sys/unix/os.rs | 34 ++++- - library/std/src/sys/unix/thread.rs | 7 + - library/std/src/sys/unix/thread_local_dtor.rs | 2 +- - library/unwind/build.rs | 18 +++ - src/bootstrap/Cargo.lock | 40 ++++- - src/bootstrap/bootstrap.py | 7 +- - src/bootstrap/builder.rs | 6 +- - 22 files changed, 399 insertions(+), 18 deletions(-) - create mode 100644 compiler/rustc_target/src/spec/aero_system_base.rs - create mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_aero_system.rs - create mode 100644 library/std/src/os/aero/fs.rs - create mode 100644 library/std/src/os/aero/mod.rs - create mode 100644 library/std/src/os/aero/raw.rs - -diff --git a/Cargo.lock b/Cargo.lock -index 15f051d0cff..f3548683f44 100644 ---- a/Cargo.lock -+++ b/Cargo.lock -@@ -2326,9 +2326,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - - [[package]] - name = "libc" --version = "0.2.138" --source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" -+version = "0.2.139" - dependencies = [ - "rustc-std-workspace-core", - ] -diff --git a/Cargo.toml b/Cargo.toml -index 15cbb2659c9..098e8227659 100644 ---- a/Cargo.toml -+++ b/Cargo.toml -@@ -114,6 +114,7 @@ rustc-workspace-hack = { path = 'src/tools/rustc-workspace-hack' } - rustc-std-workspace-core = { path = 'library/rustc-std-workspace-core' } - rustc-std-workspace-alloc = { path = 'library/rustc-std-workspace-alloc' } - rustc-std-workspace-std = { path = 'library/rustc-std-workspace-std' } -+libc = { path = '../rust-libc' } - - [patch."https://github.com/rust-lang/rust-clippy"] - clippy_lints = { path = "src/tools/clippy/clippy_lints" } -diff --git a/compiler/rustc_target/src/spec/aero_system_base.rs b/compiler/rustc_target/src/spec/aero_system_base.rs -new file mode 100644 -index 00000000000..1237a432e76 ---- /dev/null -+++ b/compiler/rustc_target/src/spec/aero_system_base.rs -@@ -0,0 +1,34 @@ -+use crate::spec::{cvs, LinkArgs, LinkerFlavor, RelroLevel, TargetOptions, Cc, Lld}; -+ -+pub fn opts() -> TargetOptions { -+ let mut args = LinkArgs::new(); -+ args.insert( -+ LinkerFlavor::Gnu(Cc::Yes, Lld::No), -+ vec![ -+ // We want to be able to strip as much executable code as possible -+ // from the linker command line, and this flag indicates to the -+ // linker that it can avoid linking in dynamic libraries that don't -+ // actually satisfy any symbols up to that point (as with many other -+ // resolutions the linker does). This option only applies to all -+ // following libraries so we're sure to pass it as one of the first -+ // arguments. -+ "-Wl,--as-needed".into(), -+ // Always enable NX protection when it is available -+ "-Wl,-z,noexecstack".into(), -+ ], -+ ); -+ -+ TargetOptions { -+ os: "aero".into(), -+ dynamic_linking: true, -+ executables: true, -+ families: cvs!["unix"], -+ has_rpath: true, -+ pre_link_args: args, -+ position_independent_executables: true, -+ relro_level: RelroLevel::Full, -+ has_thread_local: true, -+ crt_static_respected: true, -+ ..Default::default() -+ } -+} -diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs -index bc1920e3424..d4d049a8631 100644 ---- a/compiler/rustc_target/src/spec/mod.rs -+++ b/compiler/rustc_target/src/spec/mod.rs -@@ -65,6 +65,7 @@ - mod freebsd_base; - mod fuchsia_base; - mod haiku_base; -+mod aero_system_base; - mod hermit_base; - mod illumos_base; - mod l4re_base; -@@ -1105,6 +1106,8 @@ fn $module() { - ("i686-unknown-haiku", i686_unknown_haiku), - ("x86_64-unknown-haiku", x86_64_unknown_haiku), - -+ ("x86_64-unknown-aero-system", x86_64_unknown_aero_system), -+ - ("aarch64-apple-darwin", aarch64_apple_darwin), - ("x86_64-apple-darwin", x86_64_apple_darwin), - ("i686-apple-darwin", i686_apple_darwin), -diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_aero_system.rs b/compiler/rustc_target/src/spec/x86_64_unknown_aero_system.rs -new file mode 100644 -index 00000000000..d4e4097fb4b ---- /dev/null -+++ b/compiler/rustc_target/src/spec/x86_64_unknown_aero_system.rs -@@ -0,0 +1,19 @@ -+use crate::spec::{LinkerFlavor, StackProbeType, Target, Cc, Lld}; -+ -+pub fn target() -> Target { -+ let mut base = super::aero_system_base::opts(); -+ base.cpu = "x86-64".into(); -+ base.max_atomic_width = Some(64); -+ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); -+ // don't use probe-stack=inline-asm until rust-lang/rust#83139 is resolved. -+ base.stack_probes = StackProbeType::Call; -+ -+ Target { -+ llvm_target: "x86_64-unknown-aero-system".into(), -+ pointer_width: 64, -+ data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" -+ .into(), -+ arch: "x86_64".into(), -+ options: base, -+ } -+} -diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml -index 349cd91c89e..aa84feaec7b 100644 ---- a/library/std/Cargo.toml -+++ b/library/std/Cargo.toml -@@ -15,7 +15,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] } - panic_unwind = { path = "../panic_unwind", optional = true } - panic_abort = { path = "../panic_abort" } - core = { path = "../core" } --libc = { version = "0.2.138", default-features = false, features = ['rustc-dep-of-std'] } -+libc = { path = "../../../rust-libc", default-features = false, features = ['rustc-dep-of-std'] } - compiler_builtins = { version = "0.1.87" } - profiler_builtins = { path = "../profiler_builtins", optional = true } - unwind = { path = "../unwind" } -diff --git a/library/std/build.rs b/library/std/build.rs -index 8b1a06ee750..683976b2a47 100644 ---- a/library/std/build.rs -+++ b/library/std/build.rs -@@ -24,6 +24,7 @@ fn main() { - || target.contains("l4re") - || target.contains("redox") - || target.contains("haiku") -+ || target.contains("aero") - || target.contains("vxworks") - || target.contains("wasm32") - || target.contains("wasm64") -diff --git a/library/std/src/os/aero/fs.rs b/library/std/src/os/aero/fs.rs -new file mode 100644 -index 00000000000..a3c953ca169 ---- /dev/null -+++ b/library/std/src/os/aero/fs.rs -@@ -0,0 +1,144 @@ -+#![stable(feature = "raw_ext", since = "1.1.0")] -+ -+use crate::fs::Metadata; -+use crate::sys_common::AsInner; -+ -+#[allow(deprecated)] -+use crate::os::aero::raw; -+ -+/// OS-specific extensions to [`fs::Metadata`]. -+/// -+/// [`fs::Metadata`]: crate::fs::Metadata -+#[stable(feature = "metadata_ext", since = "1.1.0")] -+pub trait MetadataExt { -+ /// Gain a reference to the underlying `stat` structure which contains -+ /// the raw information returned by the OS. -+ /// -+ /// The contents of the returned `stat` are **not** consistent across -+ /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the -+ /// cross-Unix abstractions contained within the raw stat. -+ #[stable(feature = "metadata_ext", since = "1.1.0")] -+ #[deprecated(since = "1.8.0", note = "other methods of this trait are now preferred")] -+ #[allow(deprecated)] -+ fn as_raw_stat(&self) -> &raw::stat; -+ -+ #[stable(feature = "metadata_ext2", since = "1.8.0")] -+ fn st_dev(&self) -> u64; -+ -+ #[stable(feature = "metadata_ext2", since = "1.8.0")] -+ fn st_ino(&self) -> u64; -+ -+ #[stable(feature = "metadata_ext2", since = "1.8.0")] -+ fn st_mode(&self) -> u32; -+ -+ #[stable(feature = "metadata_ext2", since = "1.8.0")] -+ fn st_nlink(&self) -> u64; -+ -+ #[stable(feature = "metadata_ext2", since = "1.8.0")] -+ fn st_uid(&self) -> u32; -+ -+ #[stable(feature = "metadata_ext2", since = "1.8.0")] -+ fn st_gid(&self) -> u32; -+ -+ #[stable(feature = "metadata_ext2", since = "1.8.0")] -+ fn st_rdev(&self) -> u64; -+ -+ #[stable(feature = "metadata_ext2", since = "1.8.0")] -+ fn st_size(&self) -> u64; -+ -+ #[stable(feature = "metadata_ext2", since = "1.8.0")] -+ fn st_atime(&self) -> i64; -+ -+ #[stable(feature = "metadata_ext2", since = "1.8.0")] -+ fn st_atime_nsec(&self) -> i64; -+ -+ #[stable(feature = "metadata_ext2", since = "1.8.0")] -+ fn st_mtime(&self) -> i64; -+ -+ #[stable(feature = "metadata_ext2", since = "1.8.0")] -+ fn st_mtime_nsec(&self) -> i64; -+ -+ #[stable(feature = "metadata_ext2", since = "1.8.0")] -+ fn st_ctime(&self) -> i64; -+ -+ #[stable(feature = "metadata_ext2", since = "1.8.0")] -+ fn st_ctime_nsec(&self) -> i64; -+ -+ #[stable(feature = "metadata_ext2", since = "1.8.0")] -+ fn st_blksize(&self) -> u64; -+ -+ #[stable(feature = "metadata_ext2", since = "1.8.0")] -+ fn st_blocks(&self) -> u64; -+} -+ -+#[stable(feature = "metadata_ext", since = "1.1.0")] -+impl MetadataExt for Metadata { -+ #[allow(deprecated)] -+ fn as_raw_stat(&self) -> &raw::stat { -+ unsafe { &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat) } -+ } -+ -+ fn st_dev(&self) -> u64 { -+ self.as_inner().as_inner().st_dev as u64 -+ } -+ -+ fn st_ino(&self) -> u64 { -+ self.as_inner().as_inner().st_ino as u64 -+ } -+ -+ fn st_mode(&self) -> u32 { -+ self.as_inner().as_inner().st_mode as u32 -+ } -+ -+ fn st_nlink(&self) -> u64 { -+ self.as_inner().as_inner().st_nlink as u64 -+ } -+ -+ fn st_uid(&self) -> u32 { -+ self.as_inner().as_inner().st_uid as u32 -+ } -+ -+ fn st_gid(&self) -> u32 { -+ self.as_inner().as_inner().st_gid as u32 -+ } -+ -+ fn st_rdev(&self) -> u64 { -+ self.as_inner().as_inner().st_rdev as u64 -+ } -+ -+ fn st_size(&self) -> u64 { -+ self.as_inner().as_inner().st_size as u64 -+ } -+ -+ fn st_atime(&self) -> i64 { -+ self.as_inner().as_inner().st_atime as i64 -+ } -+ -+ fn st_atime_nsec(&self) -> i64 { -+ self.as_inner().as_inner().st_atime_nsec as i64 -+ } -+ -+ fn st_mtime(&self) -> i64 { -+ self.as_inner().as_inner().st_mtime as i64 -+ } -+ -+ fn st_mtime_nsec(&self) -> i64 { -+ self.as_inner().as_inner().st_mtime_nsec as i64 -+ } -+ -+ fn st_ctime(&self) -> i64 { -+ self.as_inner().as_inner().st_ctime as i64 -+ } -+ -+ fn st_ctime_nsec(&self) -> i64 { -+ self.as_inner().as_inner().st_ctime_nsec as i64 -+ } -+ -+ fn st_blksize(&self) -> u64 { -+ self.as_inner().as_inner().st_blksize as u64 -+ } -+ -+ fn st_blocks(&self) -> u64 { -+ self.as_inner().as_inner().st_blocks as u64 -+ } -+} -diff --git a/library/std/src/os/aero/mod.rs b/library/std/src/os/aero/mod.rs -new file mode 100644 -index 00000000000..ea3291a2f18 ---- /dev/null -+++ b/library/std/src/os/aero/mod.rs -@@ -0,0 +1,6 @@ -+//! Aero-specific definitions -+ -+#![stable(feature = "raw_ext", since = "1.1.0")] -+ -+pub mod fs; -+pub mod raw; -diff --git a/library/std/src/os/aero/raw.rs b/library/std/src/os/aero/raw.rs -new file mode 100644 -index 00000000000..c5e56b8b7b9 ---- /dev/null -+++ b/library/std/src/os/aero/raw.rs -@@ -0,0 +1,66 @@ -+#![stable(feature = "raw_ext", since = "1.1.0")] -+ -+#[stable(feature = "pthread_t", since = "1.8.0")] -+pub type pthread_t = usize; // TODO: This is completely wrong tbh -+ -+#[stable(feature = "raw_ext", since = "1.1.0")] -+pub type dev_t = libc::dev_t; -+ -+#[stable(feature = "raw_ext", since = "1.1.0")] -+pub type ino_t = libc::ino_t; -+ -+#[stable(feature = "raw_ext", since = "1.1.0")] -+pub type mode_t = libc::mode_t; -+ -+#[stable(feature = "raw_ext", since = "1.1.0")] -+pub type nlink_t = libc::nlink_t; -+ -+#[stable(feature = "raw_ext", since = "1.1.0")] -+pub type off_t = libc::off_t; -+ -+#[stable(feature = "raw_ext", since = "1.1.0")] -+pub type time_t = libc::time_t; -+ -+#[stable(feature = "raw_ext", since = "1.1.0")] -+pub type blkcnt_t = libc::blkcnt_t; -+ -+#[stable(feature = "raw_ext", since = "1.1.0")] -+pub type blksize_t = libc::blksize_t; -+ -+#[repr(C)] -+#[derive(Clone)] -+#[stable(feature = "raw_ext", since = "1.1.0")] -+pub struct stat { -+ #[stable(feature = "raw_ext", since = "1.1.0")] -+ pub st_dev: libc::dev_t, -+ #[stable(feature = "raw_ext", since = "1.1.0")] -+ pub st_ino: libc::ino_t, -+ #[stable(feature = "raw_ext", since = "1.1.0")] -+ pub st_mode: libc::mode_t, -+ #[stable(feature = "raw_ext", since = "1.1.0")] -+ pub st_nlink: libc::nlink_t, -+ #[stable(feature = "raw_ext", since = "1.1.0")] -+ pub st_uid: libc::uid_t, -+ #[stable(feature = "raw_ext", since = "1.1.0")] -+ pub st_gid: libc::gid_t, -+ #[stable(feature = "raw_ext", since = "1.1.0")] -+ pub st_rdev: libc::dev_t, -+ #[stable(feature = "raw_ext", since = "1.1.0")] -+ pub st_size: libc::off_t, -+ #[stable(feature = "raw_ext", since = "1.1.0")] -+ pub st_atime: libc::time_t, -+ #[stable(feature = "raw_ext", since = "1.1.0")] -+ pub st_atime_nsec: libc::c_long, -+ #[stable(feature = "raw_ext", since = "1.1.0")] -+ pub st_mtime: libc::time_t, -+ #[stable(feature = "raw_ext", since = "1.1.0")] -+ pub st_mtime_nsec: libc::c_long, -+ #[stable(feature = "raw_ext", since = "1.1.0")] -+ pub st_ctime: libc::time_t, -+ #[stable(feature = "raw_ext", since = "1.1.0")] -+ pub st_ctime_nsec: libc::c_long, -+ #[stable(feature = "raw_ext", since = "1.1.0")] -+ pub st_blksize: libc::blksize_t, -+ #[stable(feature = "raw_ext", since = "1.1.0")] -+ pub st_blocks: libc::blkcnt_t, -+} -diff --git a/library/std/src/os/mod.rs b/library/std/src/os/mod.rs -index 42773805cdb..24158d5da87 100644 ---- a/library/std/src/os/mod.rs -+++ b/library/std/src/os/mod.rs -@@ -133,6 +133,8 @@ pub mod windows {} - pub mod l4re; - #[cfg(target_os = "macos")] - pub mod macos; -+#[cfg(target_os = "aero")] -+pub mod aero; - #[cfg(target_os = "netbsd")] - pub mod netbsd; - #[cfg(target_os = "openbsd")] -diff --git a/library/std/src/os/unix/mod.rs b/library/std/src/os/unix/mod.rs -index f97fa0fb06f..9174b0da9a3 100644 ---- a/library/std/src/os/unix/mod.rs -+++ b/library/std/src/os/unix/mod.rs -@@ -37,6 +37,8 @@ - - #[cfg(not(doc))] - mod platform { -+ #[cfg(target_os = "aero")] -+ pub use crate::os::aero::*; - #[cfg(target_os = "android")] - pub use crate::os::android::*; - #[cfg(target_os = "dragonfly")] -diff --git a/library/std/src/sys/unix/args.rs b/library/std/src/sys/unix/args.rs -index a5ce6d5120d..3dfe759830f 100644 ---- a/library/std/src/sys/unix/args.rs -+++ b/library/std/src/sys/unix/args.rs -@@ -69,7 +69,8 @@ fn next_back(&mut self) -> Option { - target_os = "fuchsia", - target_os = "redox", - target_os = "vxworks", -- target_os = "horizon" -+ target_os = "horizon", -+ target_os = "aero" - ))] - mod imp { - use super::Args; -diff --git a/library/std/src/sys/unix/env.rs b/library/std/src/sys/unix/env.rs -index c9ba661c829..5894baf74f2 100644 ---- a/library/std/src/sys/unix/env.rs -+++ b/library/std/src/sys/unix/env.rs -@@ -217,3 +217,14 @@ pub mod os { - pub const EXE_SUFFIX: &str = ""; - pub const EXE_EXTENSION: &str = ""; - } -+ -+#[cfg(target_os = "aero")] -+pub mod os { -+ pub const FAMILY: &str = "unix"; -+ pub const OS: &str = "aero"; -+ pub const DLL_PREFIX: &str = "lib"; -+ pub const DLL_SUFFIX: &str = ".so"; -+ pub const DLL_EXTENSION: &str = "so"; -+ pub const EXE_SUFFIX: &str = ""; -+ pub const EXE_EXTENSION: &str = ""; -+} -diff --git a/library/std/src/sys/unix/fs.rs b/library/std/src/sys/unix/fs.rs -index 8e1f35d6cc9..18910365f20 100644 ---- a/library/std/src/sys/unix/fs.rs -+++ b/library/std/src/sys/unix/fs.rs -@@ -834,7 +834,8 @@ pub fn file_type(&self) -> io::Result { - target_os = "redox", - target_os = "vxworks", - target_os = "espidf", -- target_os = "horizon" -+ target_os = "horizon", -+ target_os = "aero" - ))] - pub fn ino(&self) -> u64 { - self.entry.d_ino as u64 -@@ -887,7 +888,7 @@ fn name_bytes(&self) -> &[u8] { - target_os = "solaris", - target_os = "illumos", - target_os = "fuchsia", -- target_os = "redox" -+ target_os = "redox", - )))] - fn name_cstr(&self) -> &CStr { - unsafe { CStr::from_ptr(self.entry.d_name.as_ptr()) } -diff --git a/library/std/src/sys/unix/os.rs b/library/std/src/sys/unix/os.rs -index 2f2663db607..5a4b2bc6b10 100644 ---- a/library/std/src/sys/unix/os.rs -+++ b/library/std/src/sys/unix/os.rs -@@ -41,7 +41,7 @@ - } - - extern "C" { -- #[cfg(not(any(target_os = "dragonfly", target_os = "vxworks")))] -+ #[cfg(not(any(target_os = "dragonfly", target_os = "vxworks", target_os = "aero")))] - #[cfg_attr( - any( - target_os = "linux", -@@ -71,13 +71,13 @@ - } - - /// Returns the platform-specific value of errno --#[cfg(not(any(target_os = "dragonfly", target_os = "vxworks")))] -+#[cfg(not(any(target_os = "dragonfly", target_os = "vxworks", target_os = "aero")))] - pub fn errno() -> i32 { - unsafe { (*errno_location()) as i32 } - } - - /// Sets the platform-specific value of errno --#[cfg(all(not(target_os = "dragonfly"), not(target_os = "vxworks")))] // needed for readdir and syscall! -+#[cfg(all(not(target_os = "dragonfly"), not(target_os = "vxworks"), not(target_os = "aero")))] // needed for readdir and syscall! - #[allow(dead_code)] // but not all target cfgs actually end up using it - pub fn set_errno(e: i32) { - unsafe { *errno_location() = e as c_int } -@@ -111,6 +111,29 @@ pub fn set_errno(e: i32) { - } - } - -+#[cfg(target_os = "aero")] -+pub fn errno() -> i32 { -+ extern "C" { -+ #[thread_local] -+ static __mlibc_errno: c_int; -+ } -+ -+ unsafe { __mlibc_errno as i32 } -+} -+ -+#[cfg(target_os = "aero")] -+#[allow(dead_code)] -+pub fn set_errno(e: i32) { -+ extern "C" { -+ #[thread_local] -+ static mut __mlibc_errno: c_int; -+ } -+ -+ unsafe { -+ __mlibc_errno = e; -+ } -+} -+ - /// Gets a detailed string description for the given error number. - pub fn error_string(errno: i32) -> String { - extern "C" { -@@ -471,6 +494,11 @@ pub fn current_exe() -> io::Result { - if !path.is_absolute() { getcwd().map(|cwd| cwd.join(path)) } else { Ok(path) } - } - -+#[cfg(target_os = "aero")] -+pub fn current_exe() -> io::Result { -+ unimplemented!() -+} -+ - pub struct Env { - iter: vec::IntoIter<(OsString, OsString)>, - } -diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs -index cc0e5929569..b952e199aa2 100644 ---- a/library/std/src/sys/unix/thread.rs -+++ b/library/std/src/sys/unix/thread.rs -@@ -160,6 +160,13 @@ pub fn set_name(name: &CStr) { - } - } - -+ #[cfg(target_os = "aero")] -+ pub fn set_name(name: &CStr) { -+ unsafe { -+ libc::pthread_setname_np(libc::pthread_self(), name.as_ptr()); -+ } -+ } -+ - #[cfg(target_os = "netbsd")] - pub fn set_name(name: &CStr) { - unsafe { -diff --git a/library/std/src/sys/unix/thread_local_dtor.rs b/library/std/src/sys/unix/thread_local_dtor.rs -index 236d2f2ee29..30008fc151d 100644 ---- a/library/std/src/sys/unix/thread_local_dtor.rs -+++ b/library/std/src/sys/unix/thread_local_dtor.rs -@@ -11,7 +11,7 @@ - // Note, however, that we run on lots older linuxes, as well as cross - // compiling from a newer linux to an older linux, so we also have a - // fallback implementation to use as well. --#[cfg(any(target_os = "linux", target_os = "fuchsia", target_os = "redox"))] -+#[cfg(any(target_os = "linux", target_os = "fuchsia", target_os = "redox", target_os = "aero"))] - pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { - use crate::mem; - use crate::sys_common::thread_local_dtor::register_dtor_fallback; -diff --git a/library/unwind/build.rs b/library/unwind/build.rs -index 5c3c02fb6ad..9071008e3b9 100644 ---- a/library/unwind/build.rs -+++ b/library/unwind/build.rs -@@ -21,5 +21,23 @@ fn main() { - if has_unwind { - println!("cargo:rustc-cfg=feature=\"system-llvm-libunwind\""); - } -+ } else if target.contains("solaris") { -+ println!("cargo:rustc-link-lib=gcc_s"); -+ } else if target.contains("illumos") { -+ println!("cargo:rustc-link-lib=gcc_s"); -+ } else if target.contains("dragonfly") { -+ println!("cargo:rustc-link-lib=gcc_pic"); -+ } else if target.contains("pc-windows-gnu") { -+ // This is handled in the target spec with late_link_args_[static|dynamic] -+ } else if target.contains("uwp-windows-gnu") { -+ println!("cargo:rustc-link-lib=unwind"); -+ } else if target.contains("fuchsia") { -+ println!("cargo:rustc-link-lib=unwind"); -+ } else if target.contains("haiku") { -+ println!("cargo:rustc-link-lib=gcc_s"); -+ } else if target.contains("redox") { -+ // redox is handled in lib.rs -+ } else if target.contains("aero") { -+ println!("cargo:rustc-link-lib=gcc_s"); - } - } -diff --git a/src/bootstrap/Cargo.lock b/src/bootstrap/Cargo.lock -index 4a0ba592577..d7b4d646308 100644 ---- a/src/bootstrap/Cargo.lock -+++ b/src/bootstrap/Cargo.lock -@@ -335,9 +335,7 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - - [[package]] - name = "libc" --version = "0.2.137" --source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" -+version = "0.2.139" - - [[package]] - name = "linux-raw-sys" -@@ -802,3 +800,39 @@ name = "yansi" - version = "0.5.1" - source = "registry+https://github.com/rust-lang/crates.io-index" - checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" -+ -+[[patch.unused]] -+name = "glutin" -+version = "0.28.0" -+ -+[[patch.unused]] -+name = "libloading" -+version = "0.7.3" -+ -+[[patch.unused]] -+name = "mio" -+version = "0.6.23" -+ -+[[patch.unused]] -+name = "mio" -+version = "0.8.3" -+ -+[[patch.unused]] -+name = "nix" -+version = "0.22.3" -+ -+[[patch.unused]] -+name = "num_cpus" -+version = "1.13.0" -+ -+[[patch.unused]] -+name = "shared_library" -+version = "0.1.9" -+ -+[[patch.unused]] -+name = "users" -+version = "0.11.0" -+ -+[[patch.unused]] -+name = "winit" -+version = "0.26.1" -diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py -index 013d1ab525b..624c8070fca 100644 ---- a/src/bootstrap/bootstrap.py -+++ b/src/bootstrap/bootstrap.py -@@ -717,7 +717,7 @@ class RustBuild(object): - ... "debug", "bootstrap") - True - """ -- return os.path.join(self.build_dir, "bootstrap", "debug", "bootstrap") -+ return os.path.join(self.build_dir, "bootstrap", self.build, "debug", "bootstrap") - - def build_bootstrap(self, color, verbose_count): - """Build bootstrap""" -@@ -726,7 +726,7 @@ class RustBuild(object): - if self.clean and os.path.exists(build_dir): - shutil.rmtree(build_dir) - env = os.environ.copy() -- # `CARGO_BUILD_TARGET` breaks bootstrap build. -+ # `CARGO_BUILD_TARGET` and 'build.target' break bootstrap build. - # See also: . - if "CARGO_BUILD_TARGET" in env: - del env["CARGO_BUILD_TARGET"] -@@ -791,6 +791,9 @@ class RustBuild(object): - elif color == "never": - args.append("--color=never") - -+ args.append("--target") -+ args.append(self.build) -+ - # Run this from the source directory so cargo finds .cargo/config - run(args, env=env, verbose=self.verbose, cwd=self.rust_root) - -diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs -index b4fc1d4f28d..7ef092488fe 100644 ---- a/src/bootstrap/builder.rs -+++ b/src/bootstrap/builder.rs -@@ -1479,6 +1479,8 @@ pub fn cargo( - self.clear_if_dirty(&out_dir, &self.rustc(compiler)); - } - -+ let artifact_dir = self.out.join("bootstrap/").join(self.build.build.triple).join("debug/"); -+ - // Customize the compiler we're running. Specify the compiler to cargo - // as our shim and then pass it some various options used to configure - // how the actual compiler itself is called. -@@ -1491,7 +1493,7 @@ pub fn cargo( - .env("RUSTC_STAGE", stage.to_string()) - .env("RUSTC_SYSROOT", &sysroot) - .env("RUSTC_LIBDIR", &libdir) -- .env("RUSTDOC", self.bootstrap_out.join("rustdoc")) -+ .env("RUSTDOC", artifact_dir.join("rustdoc")) - .env( - "RUSTDOC_REAL", - if cmd == "doc" || cmd == "rustdoc" || (cmd == "test" && want_rustdoc) { -@@ -1505,7 +1507,7 @@ pub fn cargo( - // Clippy support is a hack and uses the default `cargo-clippy` in path. - // Don't override RUSTC so that the `cargo-clippy` in path will be run. - if cmd != "clippy" { -- cargo.env("RUSTC", self.bootstrap_out.join("rustc")); -+ cargo.env("RUSTC", artifact_dir.join("rustc")); - } - - // Dealing with rpath here is a little special, so let's go into some --- -2.39.1 - From f4add34bfe1d914e92b2a2e7f2806c96e4cda2b1 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 19 Oct 2023 22:00:48 +1100 Subject: [PATCH 011/112] misc(aero.py): update to the new target triple * Update to the new target triple (`x86_64-unknown-aero-system` to `x86_64-unknown-aero`) Signed-off-by: Anhad Singh --- aero.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aero.py b/aero.py index 98ebbbd67d0..8dfee005dbc 100755 --- a/aero.py +++ b/aero.py @@ -341,13 +341,13 @@ def get_mlibc(): return os.path.join("..", pkg_dir, PACKAGE_MLIBC) command = 'build' # TODO: handle the unbased architectures. - cmd_args = ["--target", "x86_64-unknown-aero-system", + cmd_args = ["--target", "x86_64-unknown-aero", # cargo config "--config", f"build.rustc = '{get_rustc()}'", - "--config", "build.target = 'x86_64-unknown-aero-system'", + "--config", "build.target = 'x86_64-unknown-aero'", "--config", f"build.rustflags = ['-C', 'link-args=-no-pie -B {get_binutils()} --sysroot {get_mlibc()}', '-lc']", - "--config", f"target.x86_64-unknown-aero-system.linker = '{get_gcc()}'", + "--config", f"target.x86_64-unknown-aero.linker = '{get_gcc()}'", "-Z", "unstable-options"] From 4cbc29e02fd20a0f544fe02f69044a2e6e357d7e Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 20 Oct 2023 19:51:12 +1100 Subject: [PATCH 012/112] misc: cleanups and minor fixes for webkitgtk * cleanup: remove the unused flags argument in INode::open() * cleanup: make `flags` on `FileHandle` private and use getter and setter functions to set the flags. * feat: add initial netlink socket support * feat(unix): implement get_{sockname, peername} * fix: the ABI for `MessageHeader` was wrong, i.e, {name_len, control_len} are supposed to be a u32 instead of a usize. Signed-off-by: Anhad Singh --- patches/mlibc/mlibc.patch | 183 ---------- src/Cargo.lock | 1 + src/aero_kernel/src/drivers/pty.rs | 6 +- src/aero_kernel/src/drivers/tty/vtty.rs | 1 - src/aero_kernel/src/fs/devfs.rs | 8 +- src/aero_kernel/src/fs/eventfd.rs | 47 ++- src/aero_kernel/src/fs/file_table.rs | 27 +- src/aero_kernel/src/fs/inode.rs | 2 +- src/aero_kernel/src/fs/pipe.rs | 15 +- src/aero_kernel/src/fs/ramfs.rs | 8 +- src/aero_kernel/src/socket/mod.rs | 7 + src/aero_kernel/src/socket/netlink.rs | 315 ++++++++++++++++++ src/aero_kernel/src/socket/tcp.rs | 8 +- src/aero_kernel/src/socket/udp.rs | 9 +- src/aero_kernel/src/socket/unix.rs | 37 +- src/aero_kernel/src/syscall/fs.rs | 29 +- src/aero_kernel/src/syscall/net.rs | 44 ++- src/aero_kernel/src/userland/scheduler/mod.rs | 4 + .../src/userland/scheduler/round_robin.rs | 1 + src/aero_kernel/src/userland/task/mod.rs | 48 ++- src/aero_syscall/Cargo.toml | 1 + src/aero_syscall/src/lib.rs | 1 + src/aero_syscall/src/netlink.rs | 230 +++++++++++++ src/aero_syscall/src/socket.rs | 10 +- userland/Cargo.lock | 7 + 25 files changed, 774 insertions(+), 275 deletions(-) delete mode 100644 patches/mlibc/mlibc.patch create mode 100644 src/aero_kernel/src/socket/netlink.rs create mode 100644 src/aero_syscall/src/netlink.rs diff --git a/patches/mlibc/mlibc.patch b/patches/mlibc/mlibc.patch deleted file mode 100644 index a72e9f7fe37..00000000000 --- a/patches/mlibc/mlibc.patch +++ /dev/null @@ -1,183 +0,0 @@ -From ea350e347faaa97e0499d34582ff068510809542 Mon Sep 17 00:00:00 2001 -From: Anhad Singh -Date: Fri, 13 Oct 2023 22:50:34 +1100 -Subject: [PATCH] - -Signed-off-by: Anhad Singh ---- - options/glibc/generic/execinfo.cpp | 5 +++-- - options/posix/generic/posix_stdlib.cpp | 2 +- - options/rtdl/generic/linker.cpp | 2 +- - sysdeps/aero/generic/aero.cpp | 9 ++++++--- - sysdeps/aero/generic/filesystem.cpp | 10 ++++++++++ - sysdeps/aero/generic/signals.cpp | 19 +++++++------------ - sysdeps/aero/generic/sockets.cpp | 16 ++++++++++++++++ - sysdeps/aero/include/aero/syscall.h | 2 ++ - 8 files changed, 46 insertions(+), 19 deletions(-) - -diff --git a/options/glibc/generic/execinfo.cpp b/options/glibc/generic/execinfo.cpp -index 3474615..aaf593a 100644 ---- a/options/glibc/generic/execinfo.cpp -+++ b/options/glibc/generic/execinfo.cpp -@@ -1,9 +1,10 @@ - #include - #include -+#include - - int backtrace(void **, int) { -- __ensure(!"Not implemented"); -- __builtin_unreachable(); -+ mlibc::infoLogger() << "backtrace: Not implemented" << frg::endlog; -+ return 0; - } - - char **backtrace_symbols(void *const *, int) { -diff --git a/options/posix/generic/posix_stdlib.cpp b/options/posix/generic/posix_stdlib.cpp -index 76b85dc..4b783b3 100644 ---- a/options/posix/generic/posix_stdlib.cpp -+++ b/options/posix/generic/posix_stdlib.cpp -@@ -464,7 +464,7 @@ int grantpt(int) { - } - - double strtod_l(const char *__restrict__ nptr, char ** __restrict__ endptr, locale_t) { -- mlibc::infoLogger() << "mlibc: strtod_l ignores locale!" << frg::endlog; -+ // mlibc::infoLogger() << "mlibc: strtod_l ignores locale!" << frg::endlog; - return strtod(nptr, endptr); - } - -diff --git a/options/rtdl/generic/linker.cpp b/options/rtdl/generic/linker.cpp -index c604a50..eec0b7b 100644 ---- a/options/rtdl/generic/linker.cpp -+++ b/options/rtdl/generic/linker.cpp -@@ -18,7 +18,7 @@ uintptr_t libraryBase = 0x41000000; - - constexpr bool verbose = false; - constexpr bool stillSlightlyVerbose = false; --constexpr bool logBaseAddresses = false; -+constexpr bool logBaseAddresses = true; - constexpr bool logRpath = false; - constexpr bool eagerBinding = true; - -diff --git a/sysdeps/aero/generic/aero.cpp b/sysdeps/aero/generic/aero.cpp -index e6bd277..a341fcf 100644 ---- a/sysdeps/aero/generic/aero.cpp -+++ b/sysdeps/aero/generic/aero.cpp -@@ -303,10 +303,13 @@ int sys_clone(void *tcb, pid_t *tid_out, void *stack) { - return 0; - } - --void sys_thread_exit() UNIMPLEMENTED("sys_thread_exit") -+void sys_thread_exit() { -+ syscall(SYS_EXIT); -+ __builtin_trap(); -+} - -- int sys_waitpid(pid_t pid, int *status, int flags, struct rusage *ru, -- pid_t *ret_pid) { -+int sys_waitpid(pid_t pid, int *status, int flags, struct rusage *ru, -+ pid_t *ret_pid) { - if (ru) { - mlibc::infoLogger() - << "mlibc: struct rusage in sys_waitpid is unsupported" -diff --git a/sysdeps/aero/generic/filesystem.cpp b/sysdeps/aero/generic/filesystem.cpp -index fa5a369..33a11f4 100644 ---- a/sysdeps/aero/generic/filesystem.cpp -+++ b/sysdeps/aero/generic/filesystem.cpp -@@ -39,6 +39,16 @@ int sys_read(int fd, void *buf, size_t count, ssize_t *bytes_read) { - return 0; - } - -+int sys_fsync(int) { -+ mlibc::infoLogger() << "\e[35mmlibc: fsync is a stub\e[39m" << frg::endlog; -+ return 0; -+} -+ -+int sys_fdatasync(int) { -+ mlibc::infoLogger() << "\e[35mmlibc: fdatasync() is a no-op\e[39m" << frg::endlog; -+ return 0; -+} -+ - // clang-format off - int sys_pwrite(int fd, const void *buffer, size_t count, off_t off, - ssize_t *written) UNIMPLEMENTED("sys_pwrite") -diff --git a/sysdeps/aero/generic/signals.cpp b/sysdeps/aero/generic/signals.cpp -index a6f69ff..611db69 100644 ---- a/sysdeps/aero/generic/signals.cpp -+++ b/sysdeps/aero/generic/signals.cpp -@@ -29,25 +29,20 @@ int sys_sigaction(int how, const struct sigaction *__restrict action, - #endif - - auto sigreturn = (sc_word_t)__mlibc_signal_restore; -- -- auto res = syscall(SYS_SIGACTION, how, (sc_word_t)action, sigreturn, -+ auto ret = syscall(SYS_SIGACTION, how, (sc_word_t)action, sigreturn, - (sc_word_t)old_action); - -- if (res < 0) { -- return -res; -- } -- -+ if(int e = sc_error(ret); e) -+ return e; - return 0; - } - - int sys_sigprocmask(int how, const sigset_t *__restrict set, - sigset_t *__restrict retrieve) { -- auto result = syscall(SYS_SIGPROCMASK, how, set, retrieve); - -- if (result < 0) { -- return -result; -- } -- -- return 0; -+ auto ret = syscall(SYS_SIGPROCMASK, how, set, retrieve); -+ if(int e = sc_error(ret); e) -+ return e; -+ return 0; - } - } // namespace mlibc -\ No newline at end of file -diff --git a/sysdeps/aero/generic/sockets.cpp b/sysdeps/aero/generic/sockets.cpp -index 0cce3c0..10af36a 100644 ---- a/sysdeps/aero/generic/sockets.cpp -+++ b/sysdeps/aero/generic/sockets.cpp -@@ -221,6 +221,22 @@ int sys_setsockopt(int fd, int layer, int number, const void *buffer, - } - } - -+int sys_peername(int fd, struct sockaddr *addr_ptr, socklen_t max_addr_length, socklen_t *actual_length) { -+ auto ret = syscall(SYS_GETPEERNAME, fd, addr_ptr, &max_addr_length); -+ if (int e = sc_error(ret); e) -+ return e; -+ *actual_length = max_addr_length; -+ return 0; -+} -+ -+int sys_sockname(int fd, struct sockaddr *addr_ptr, socklen_t max_addr_length, socklen_t *actual_length) { -+ auto ret = syscall(SYS_GETSOCKNAME, fd, addr_ptr, &max_addr_length); -+ if (int e = sc_error(ret); e) -+ return e; -+ *actual_length = max_addr_length; -+ return 0; -+} -+ - int sys_shutdown(int sockfd, int how) { - auto ret = syscall(SYS_SOCK_SHUTDOWN, sockfd, how); - if(int e = sc_error(ret); e) -diff --git a/sysdeps/aero/include/aero/syscall.h b/sysdeps/aero/include/aero/syscall.h -index 3f36e4d..39c5b65 100644 ---- a/sysdeps/aero/include/aero/syscall.h -+++ b/sysdeps/aero/include/aero/syscall.h -@@ -80,6 +80,8 @@ - #define SYS_SETSID 73 - #define SYS_GETPGID 74 - #define SYS_SOCK_SHUTDOWN 75 -+#define SYS_GETPEERNAME 76 -+#define SYS_GETSOCKNAME 77 - - // Invalid syscall used to trigger a log error in the kernel (as a hint) - // so, that we can implement the syscall in the kernel. --- -2.42.0 - diff --git a/src/Cargo.lock b/src/Cargo.lock index 773f4b49eac..4cf67a98a94 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -52,6 +52,7 @@ dependencies = [ "byte_endian", "num-derive", "num-traits", + "static_assertions", ] [[package]] diff --git a/src/aero_kernel/src/drivers/pty.rs b/src/aero_kernel/src/drivers/pty.rs index 9ecfb87709b..790765d49b4 100644 --- a/src/aero_kernel/src/drivers/pty.rs +++ b/src/aero_kernel/src/drivers/pty.rs @@ -330,11 +330,7 @@ impl devfs::Device for Ptmx { } impl INodeInterface for Ptmx { - fn open( - &self, - _flags: aero_syscall::OpenFlags, - _handle: Arc, - ) -> fs::Result> { + fn open(&self, _handle: Arc) -> fs::Result> { let master = Arc::new(Master::new()); let slave = Slave::new(master.clone()); let inode = DirEntry::from_inode(master, String::from("")); diff --git a/src/aero_kernel/src/drivers/tty/vtty.rs b/src/aero_kernel/src/drivers/tty/vtty.rs index 236714639a0..7edb0c53add 100644 --- a/src/aero_kernel/src/drivers/tty/vtty.rs +++ b/src/aero_kernel/src/drivers/tty/vtty.rs @@ -229,7 +229,6 @@ impl Tty { impl INodeInterface for Tty { fn open( &self, - _flags: aero_syscall::OpenFlags, _handle: Arc, ) -> fs::Result> { let connected = self.connected.fetch_add(1, Ordering::SeqCst); diff --git a/src/aero_kernel/src/fs/devfs.rs b/src/aero_kernel/src/fs/devfs.rs index 15d2f07bd4f..73b383b6fcf 100644 --- a/src/aero_kernel/src/fs/devfs.rs +++ b/src/aero_kernel/src/fs/devfs.rs @@ -129,12 +129,8 @@ impl INodeInterface for DevINode { self.0.inode().poll(table) } - fn open( - &self, - flags: aero_syscall::OpenFlags, - handle: Arc, - ) -> Result> { - self.0.inode().open(flags, handle) + fn open(&self, handle: Arc) -> Result> { + self.0.inode().open(handle) } } diff --git a/src/aero_kernel/src/fs/eventfd.rs b/src/aero_kernel/src/fs/eventfd.rs index 06dd3a78789..caea7aa24a7 100644 --- a/src/aero_kernel/src/fs/eventfd.rs +++ b/src/aero_kernel/src/fs/eventfd.rs @@ -15,14 +15,22 @@ // You should have received a copy of the GNU General Public License // along with Aero. If not, see . +use aero_syscall::OpenFlags; use alloc::sync::Arc; +use spin::Once; +use super::file_table::FileHandle; use super::inode::{INodeInterface, PollFlags, PollTable}; +use crate::fs::FileSystemError; use crate::utils::sync::{Mutex, WaitQueue}; pub struct EventFd { wq: WaitQueue, + /// Every write(2) on an eventfd, the value written is added to `count` and a wakeup + /// is performed on `wq`. count: Mutex, + // FIXME: https://github.com/Andy-Python-Programmer/aero/issues/113 + handle: Once>, } impl EventFd { @@ -30,11 +38,22 @@ impl EventFd { Arc::new(Self { wq: WaitQueue::new(), count: Mutex::new(0), + handle: Once::new(), }) } + + fn is_nonblock(&self) -> bool { + let handle = self.handle.get().expect("file handle is not initialized"); + handle.flags().contains(OpenFlags::O_NONBLOCK) + } } impl INodeInterface for EventFd { + fn open(&self, handle: Arc) -> super::Result> { + self.handle.call_once(|| handle); + Ok(None) + } + fn read_at(&self, _offset: usize, buffer: &mut [u8]) -> super::Result { let size = core::mem::size_of::(); assert!(buffer.len() >= size); @@ -52,16 +71,28 @@ impl INodeInterface for EventFd { } fn write_at(&self, _offset: usize, buffer: &[u8]) -> super::Result { - let size = core::mem::size_of::(); - assert!(buffer.len() >= size); + let chunk_size = core::mem::size_of::(); + assert!(buffer.len() >= chunk_size); - // SAFETY: We have above verified that it is safe to dereference - // the value. - let value = unsafe { *(buffer.as_ptr() as *const u64) }; + // TODO: use bytemuck to remove the unsafe. + let target = unsafe { *(buffer.as_ptr() as *const u64) }; + + if target == u64::MAX { + return Err(FileSystemError::NotSupported); + } + + let mut count = self.count.lock(); + + if u64::MAX - *count > target { + *count += target; + } else if !self.is_nonblock() { + unimplemented!() + } else { + return Ok(0); + }; - *self.count.lock_irq() += value; self.wq.notify_all(); - Ok(size) + Ok(chunk_size) } fn poll(&self, table: Option<&mut PollTable>) -> super::Result { @@ -70,7 +101,7 @@ impl INodeInterface for EventFd { if let Some(e) = table { e.insert(&self.wq) - } // listen for changes + } if *count > 0 { events.insert(PollFlags::IN); diff --git a/src/aero_kernel/src/fs/file_table.rs b/src/aero_kernel/src/fs/file_table.rs index 05997abbc35..e1cbb04ef88 100644 --- a/src/aero_kernel/src/fs/file_table.rs +++ b/src/aero_kernel/src/fs/file_table.rs @@ -42,7 +42,7 @@ pub struct FileHandle { // We need to store the `offset` behind an Arc since when the file handle // is duplicated, the `offset` needs to be in sync with the parent. pub offset: Arc, - pub flags: RwLock, + flags: RwLock, } impl FileHandle { @@ -56,6 +56,14 @@ impl FileHandle { } } + pub fn flags(&self) -> OpenFlags { + *self.flags.read() + } + + pub fn set_flags(&self, flags: OpenFlags) { + *self.flags.write() = flags; + } + pub fn read(&self, buffer: &mut [u8]) -> super::Result { let offset = self.offset.load(Ordering::SeqCst); let new_offset = self.inode.inode().read_at(offset, buffer)?; @@ -126,7 +134,7 @@ impl FileHandle { flags: RwLock::new(flags), }); - new.inode.inode().open(flags, new.clone())?; + new.inode.inode().open(new.clone())?; Ok(new) } @@ -299,13 +307,18 @@ impl FileTable { handle .inode .inode() - .open(flags, handle.clone()) + .open(handle.clone()) .expect("FileTable::clone: failed to open file"); } Self(RwLock::new(files.clone())) } + pub fn debug_open_file(&self, dirent: DirCacheItem, flags: OpenFlags) -> super::Result { + self.log(); + self.open_file(dirent, flags) + } + pub fn open_file(&self, dentry: DirCacheItem, mut flags: OpenFlags) -> super::Result { let mut files = self.0.write(); @@ -317,7 +330,7 @@ impl FileTable { if let Some((i, f)) = files.iter_mut().enumerate().find(|e| e.1.is_none()) { let mut handle = Arc::new(FileHandle::new(i, dentry, flags)); - if let Some(inode) = handle.inode.inode().open(flags, handle.clone())? { + if let Some(inode) = handle.inode.inode().open(handle.clone())? { // TODO: should open be called on the inner file as well??? handle = Arc::new(FileHandle::new(i, inode, flags)) } @@ -329,7 +342,7 @@ impl FileTable { let fd = files.len(); let mut handle = Arc::new(FileHandle::new(fd, dentry, flags)); - if let Some(inode) = handle.inode.inode().open(flags, handle.clone())? { + if let Some(inode) = handle.inode.inode().open(handle.clone())? { // TODO: should open be called on the inner file as well??? handle = Arc::new(FileHandle::new(fd, inode, flags)) } @@ -346,6 +359,10 @@ impl FileTable { /// and can be reused. This function will return false if the provided file /// descriptor index was invalid. pub fn close_file(&self, fd: usize) -> bool { + // log::warn!("closing filedescriptor {fd} ---- START"); + // crate::unwind::unwind_stack_trace(); + // log::warn!("closing filedescriptor {fd} ---- END"); + let mut files = self.0.write(); if let Some(file) = files.get_mut(fd) { diff --git a/src/aero_kernel/src/fs/inode.rs b/src/aero_kernel/src/fs/inode.rs index 5c03caf0471..0ad62ff6530 100644 --- a/src/aero_kernel/src/fs/inode.rs +++ b/src/aero_kernel/src/fs/inode.rs @@ -189,7 +189,7 @@ pub trait INodeInterface: Send + Sync { Err(FileSystemError::NotSupported) } - fn open(&self, _flags: OpenFlags, _handle: Arc) -> Result> { + fn open(&self, _handle: Arc) -> Result> { Ok(None) } diff --git a/src/aero_kernel/src/fs/pipe.rs b/src/aero_kernel/src/fs/pipe.rs index 5533a6bccef..9cf196b95db 100644 --- a/src/aero_kernel/src/fs/pipe.rs +++ b/src/aero_kernel/src/fs/pipe.rs @@ -45,13 +45,9 @@ impl Pipe { } impl INodeInterface for Pipe { - fn open( - &self, - flags: OpenFlags, - handle: Arc, - ) -> super::Result> { + fn open(&self, handle: Arc) -> super::Result> { // Write end of the pipe: - if flags.contains(OpenFlags::O_WRONLY) { + if handle.flags().contains(OpenFlags::O_WRONLY) { self.num_writers.fetch_add(1, Ordering::SeqCst); self.handle.call_once(|| handle); } @@ -72,12 +68,7 @@ impl INodeInterface for Pipe { } fn read_at(&self, _offset: usize, buf: &mut [u8]) -> super::Result { - let flags = *self - .handle - .get() - .expect("pipe: internal error") - .flags - .read(); + let flags = self.handle.get().expect("pipe: internal error").flags(); let nonblock = flags.contains(OpenFlags::O_NONBLOCK); if nonblock && !self.queue.lock_irq().has_data() { diff --git a/src/aero_kernel/src/fs/ramfs.rs b/src/aero_kernel/src/fs/ramfs.rs index d1542c5778f..c8835be0b78 100644 --- a/src/aero_kernel/src/fs/ramfs.rs +++ b/src/aero_kernel/src/fs/ramfs.rs @@ -302,11 +302,7 @@ impl INodeInterface for LockedRamINode { } } - fn open( - &self, - flags: aero_syscall::OpenFlags, - handle: Arc, - ) -> Result> { + fn open(&self, handle: Arc) -> Result> { let this = self.0.read(); match &this.contents { @@ -314,7 +310,7 @@ impl INodeInterface for LockedRamINode { let device = device.clone(); drop(this); - device.open(flags, handle) + device.open(handle) } _ => Ok(None), diff --git a/src/aero_kernel/src/socket/mod.rs b/src/aero_kernel/src/socket/mod.rs index 28f49589a11..2d7a9903de4 100644 --- a/src/aero_kernel/src/socket/mod.rs +++ b/src/aero_kernel/src/socket/mod.rs @@ -18,9 +18,11 @@ pub mod ipv4; pub mod tcp; // pub mod tcp2; +pub mod netlink; pub mod udp; pub mod unix; +use aero_syscall::netlink::sockaddr_nl; use aero_syscall::prelude::IfReq; use aero_syscall::*; @@ -29,12 +31,16 @@ use crate::mem::paging::VirtAddr; #[derive(Debug)] pub enum SocketAddr { Inet(SocketAddrInet), + Netlink(sockaddr_nl), + Unix(SocketAddrUnix), } #[derive(Debug)] pub enum SocketAddrRef<'a> { Unix(&'a SocketAddrUnix), INet(&'a SocketAddrInet), + // TODO: https://docs.huihoo.com/doxygen/linux/kernel/3.7/structsockaddr__nl.html + Netlink, } impl<'a> SocketAddrRef<'a> { @@ -42,6 +48,7 @@ impl<'a> SocketAddrRef<'a> { match family { AF_UNIX => Ok(SocketAddrRef::Unix(address.read_mut::()?)), AF_INET => Ok(SocketAddrRef::INet(address.read_mut::()?)), + AF_NETLINK => Ok(SocketAddrRef::Netlink), _ => Err(SyscallError::EINVAL), } diff --git a/src/aero_kernel/src/socket/netlink.rs b/src/aero_kernel/src/socket/netlink.rs new file mode 100644 index 00000000000..dc180e638cf --- /dev/null +++ b/src/aero_kernel/src/socket/netlink.rs @@ -0,0 +1,315 @@ +//! Netlink Sockets +//! +//! Netlink sockets are used for inter-process communication (IPC) between both the kernel and +//! userspace processes, and between different userspace processes, in a way similar to the Unix +//! domain sockets. +//! +//! Netlink is designed and used for transferring miscellaneous networking information between the +//! kernel space and userspace processes. Networking utilities, such as the `iproute2` family use +//! Netlink to communicate with the kernel from userspace. + +use aero_syscall::netlink::{MessageFlags, MessageType, RtAttrType}; +use aero_syscall::socket::{self, MessageHeader}; +use aero_syscall::{netlink, AF_INET, AF_NETLINK, AF_UNSPEC}; +use alloc::sync::Arc; +use alloc::vec::Vec; +use crabnet::network::Ipv4Addr; + +use crate::fs; +use crate::fs::cache::DirCacheImpl; +use crate::fs::inode::{FileType, INodeInterface, Metadata, PollFlags, PollTable}; +use crate::utils::sync::{Mutex, WaitQueue}; + +use super::SocketAddrRef; + +// TODO(andypython): can we use crabnet to construct netlink packets(?) +struct NetlinkBuilder { + buffer: Vec, +} + +impl NetlinkBuilder { + fn new() -> Self { + // crate::scheduler::get_scheduler().for_each_task(|task| { + // if task + // .executable + // .lock() + // .as_ref() + // .map(|x| x.absolute_path_str().contains("kit")) + // .unwrap_or_default() + // { + // task.enable_systrace(); + // } + // }); + + Self { buffer: Vec::new() } + } + + fn header(&mut self, header: netlink::nlmsghdr) { + self.buffer.extend_from_slice(unsafe { + core::slice::from_raw_parts( + &header as *const _ as *const u8, + core::mem::size_of::(), + ) + }); + + self.buffer_align(); + } + + fn message(&mut self, message: netlink::rtmsg) { + self.buffer.extend_from_slice(unsafe { + core::slice::from_raw_parts( + &message as *const _ as *const u8, + core::mem::size_of::(), + ) + }); + + self.buffer_align(); + } + + fn rtattr(&mut self, ty: RtAttrType, data: T) { + let rta_len = netlink::rta_length(core::mem::size_of::() as u32); + + let attr = netlink::rtattr { + rta_len: rta_len.try_into().unwrap(), + rta_type: ty, + }; + + let padding = rta_len as usize - core::mem::size_of::(); + + self.buffer.extend_from_slice(unsafe { + core::slice::from_raw_parts( + &attr as *const _ as *const u8, + core::mem::size_of::(), + ) + }); + + self.buffer.extend_from_slice(unsafe { + core::slice::from_raw_parts(&data as *const _ as *const u8, core::mem::size_of::()) + }); + + self.buffer.resize(self.buffer.len() + padding, 0); + self.buffer_align(); + } + + /// Aligns the buffer to the netlink message alignment. + fn buffer_align(&mut self) { + let aligned_len = netlink::nlmsg_align(self.buffer.len() as u32); + + // Resize will not truncate the buffer since [`nlmsg_align`]` only rounds up. + self.buffer.resize(aligned_len as usize, 0); + } + + fn build(self) -> Vec { + let mut buffer = self.buffer; + + let msg_len = buffer.len(); + let msg_hdr = unsafe { &mut *buffer.as_mut_ptr().cast::() }; + + msg_hdr.nlmsg_len = msg_len as u32; + buffer + } +} + +pub struct NetLinkSocket { + recv_queue: Mutex>>, + recv_wq: WaitQueue, +} + +impl NetLinkSocket { + pub fn new() -> Arc { + Arc::new(Self { + recv_queue: Mutex::new(Vec::new()), + recv_wq: WaitQueue::new(), + }) + } + + fn validate_message<'a, T>(header: &'a netlink::nlmsghdr, payload: &'a [u8]) -> &'a T { + let hdr_len = core::mem::size_of::() as u32; + let msg_len = core::mem::size_of::() as u32; + + // TODO(andypython): send an error message instead of panicking. + assert!(header.nlmsg_len == hdr_len + msg_len); + + // FIXME(andypython): use bytemuck to cast the payload to T. + unsafe { &*payload.as_ptr().cast::() } + } + + fn send_route_packet(&self, header: &netlink::nlmsghdr) { + let mut builder = NetlinkBuilder::new(); + + builder.header(netlink::nlmsghdr { + nlmsg_type: MessageType::RtmNewRoute, + nlmsg_flags: MessageFlags::MULTI, + nlmsg_seq: header.nlmsg_seq, + nlmsg_pid: 0, + nlmsg_len: 0, + }); + + builder.message(netlink::rtmsg { + rtm_family: AF_INET as u8, + rtm_dst_len: 0, // FIXME + rtm_src_len: 0, + rtm_tos: 0, + rtm_table: netlink::RT_TABLE_MAIN, + + rtm_protocol: 0, + rtm_scope: 0, + rtm_type: 0, + rtm_flags: 0, + }); + + builder.rtattr(RtAttrType::Table, netlink::RT_TABLE_MAIN); + + // Qemu SLIRP + builder.rtattr(RtAttrType::Dst, Ipv4Addr::new(10, 0, 2, 15)); + builder.rtattr(RtAttrType::Gateway, Ipv4Addr::new(10, 0, 2, 2)); + + self.recv_queue.lock().push(builder.build()); + self.recv_wq.notify(); + } + + fn get_route(&self, header: &netlink::nlmsghdr, payload: &[u8]) { + assert!(header + .nlmsg_flags + .contains(MessageFlags::REQUEST | MessageFlags::DUMP)); + + let payload = Self::validate_message::(header, payload); + let rtgen_family = payload.rtgen_family as u32; + + assert!(rtgen_family == AF_UNSPEC || rtgen_family == AF_NETLINK); + + self.send_route_packet(header); + } +} + +impl INodeInterface for NetLinkSocket { + fn metadata(&self) -> fs::Result { + Ok(Metadata::with_file_type(FileType::Socket)) + } + + fn bind(&self, _addr: SocketAddrRef, _len: usize) -> fs::Result<()> { + Ok(()) + } + + fn connect(&self, _address: SocketAddrRef, _length: usize) -> fs::Result<()> { + unimplemented!() + } + + fn read_at(&self, _offset: usize, _buffer: &mut [u8]) -> fs::Result { + unimplemented!() + } + + fn write_at(&self, _offset: usize, _buffer: &[u8]) -> fs::Result { + unimplemented!() + } + + fn recv( + &self, + message_hdr: &mut MessageHeader, + flags: socket::MessageFlags, + ) -> fs::Result { + // FIXME(andypython): All of the message header and iovec logic should be moved to + // syscall::net::recvmsg() instead. + + if let Some(addr) = message_hdr.name_mut::() { + *addr = netlink::sockaddr_nl { + nl_family: AF_NETLINK, + nl_pad: 0, + nl_pid: 0, + nl_groups: 0, + }; + } + + let mut queue = self + .recv_wq + .block_on(&self.recv_queue, |queue| !queue.is_empty())?; + + let mut bytes_copied = 0; + dbg!(message_hdr.iovecs_mut()); + let mut iovecs = message_hdr.iovecs_mut().to_vec(); + + while let Some(data) = queue.pop() { + if let Some((index, ref mut iovec)) = iovecs + .iter_mut() + .enumerate() + .find(|(_, iovec)| iovec.len() >= data.len()) + { + let iovec = iovec.as_slice_mut(); + assert!(iovec.len() >= data.len()); + + let copy = core::cmp::min(iovec.len(), data.len()); + iovec[..copy].copy_from_slice(&data[..copy]); + + bytes_copied += copy; + iovecs.remove(index); + } else { + if flags.contains(socket::MessageFlags::TRUNC) && bytes_copied == 0 { + message_hdr.flags = socket::MessageFlags::TRUNC.bits() as i32; + return Ok(data.len()); + } else { + unimplemented!() + } + } + } + + Ok(bytes_copied) + } + + fn send( + &self, + message_hdr: &mut MessageHeader, + flags: socket::MessageFlags, + ) -> fs::Result { + log::warn!("netlink::send(flags={flags:?})"); + + // FIXME(andypython): figure out the message header stuff... + let data = message_hdr + .iovecs() + .iter() + .flat_map(|e| e.as_slice()) + .copied() + .collect::>(); + + let hdr_size = core::mem::size_of::(); + + let mut offset = 0; + + while offset + hdr_size <= data.len() { + let header = unsafe { &*(data.as_ptr().add(offset) as *const netlink::nlmsghdr) }; + let payload = &data[offset + hdr_size..]; + + match header.nlmsg_type { + MessageType::Done => break, + MessageType::Error => { + unimplemented!("netlink::send: error message received"); + } + + MessageType::RtmGetRoute => self.get_route(header, payload), + + ty => unimplemented!("netlink::send: unknown message type {ty:?}"), + } + + offset += header.nlmsg_len as usize; + } + + Ok(data.len()) + } + + fn poll(&self, _table: Option<&mut PollTable>) -> fs::Result { + unimplemented!() + } + + fn get_peername(&self) -> fs::Result { + unimplemented!() + } + + fn get_sockname(&self) -> fs::Result { + // TODO(andypython): fill in `nl_groups` and `nl_pid`. + Ok(super::SocketAddr::Netlink(netlink::sockaddr_nl { + nl_family: AF_NETLINK, + nl_pad: 0, + nl_pid: 0, + nl_groups: 0, + })) + } +} diff --git a/src/aero_kernel/src/socket/tcp.rs b/src/aero_kernel/src/socket/tcp.rs index 34d29602714..05acb9700d7 100644 --- a/src/aero_kernel/src/socket/tcp.rs +++ b/src/aero_kernel/src/socket/tcp.rs @@ -79,7 +79,7 @@ impl TcpSocket { pub fn non_blocking(&self) -> bool { self.handle .get() - .map(|handle| handle.flags.read().contains(OpenFlags::O_NONBLOCK)) + .map(|handle| handle.flags().contains(OpenFlags::O_NONBLOCK)) .unwrap_or_default() } @@ -150,11 +150,7 @@ impl INodeInterface for TcpSocket { Ok(()) } - fn open( - &self, - _flags: aero_syscall::OpenFlags, - handle: Arc, - ) -> fs::Result> { + fn open(&self, handle: Arc) -> fs::Result> { self.handle.call_once(|| handle); Ok(None) } diff --git a/src/aero_kernel/src/socket/udp.rs b/src/aero_kernel/src/socket/udp.rs index 0409073d0bf..3d751466688 100644 --- a/src/aero_kernel/src/socket/udp.rs +++ b/src/aero_kernel/src/socket/udp.rs @@ -104,18 +104,13 @@ impl UdpSocket { self.handle .get() .expect("inet: not bound to an fd") - .flags - .read() + .flags() .contains(OpenFlags::O_NONBLOCK) } } impl INodeInterface for UdpSocket { - fn open( - &self, - _flags: aero_syscall::OpenFlags, - handle: Arc, - ) -> fs::Result> { + fn open(&self, handle: Arc) -> fs::Result> { self.handle.call_once(|| handle); Ok(None) } diff --git a/src/aero_kernel/src/socket/unix.rs b/src/aero_kernel/src/socket/unix.rs index f8d635e4e4e..3d0d0e64e90 100644 --- a/src/aero_kernel/src/socket/unix.rs +++ b/src/aero_kernel/src/socket/unix.rs @@ -232,8 +232,7 @@ impl UnixSocket { self.handle .get() .expect("unix: not bound to an fd") - .flags - .read() + .flags() .contains(OpenFlags::O_NONBLOCK) } } @@ -248,11 +247,7 @@ impl INodeInterface for UnixSocket { }) } - fn open( - &self, - _flags: aero_syscall::OpenFlags, - handle: Arc, - ) -> fs::Result> { + fn open(&self, handle: Arc) -> fs::Result> { self.handle.call_once(|| handle); Ok(None) } @@ -385,7 +380,7 @@ impl INodeInterface for UnixSocket { } fn recv(&self, header: &mut MessageHeader, flags: MessageFlags) -> fs::Result { - assert!(flags.is_empty()); + // assert!(flags.is_empty()); let inner = self.inner.lock_irq(); @@ -451,4 +446,30 @@ impl INodeInterface for UnixSocket { log::warn!("shutdown how={how}"); Ok(()) } + + fn get_sockname(&self) -> fs::Result { + let inner = self.inner.lock_irq(); + let address = inner.address.as_ref().cloned().unwrap_or(SocketAddrUnix { + family: AF_UNIX, + path: [0; 108], + }); + + Ok(super::SocketAddr::Unix(address.clone())) + } + + fn get_peername(&self) -> fs::Result { + let inner = self.inner.lock_irq(); + let peer = match &inner.state { + UnixSocketState::Connected(peer) => peer, + _ => return Err(FileSystemError::NotConnected), + }; + + let peer = peer.inner.lock_irq(); + let address = peer.address.as_ref().cloned().unwrap_or(SocketAddrUnix { + family: AF_UNIX, + path: [0; 108], + }); + + Ok(super::SocketAddr::Unix(address.clone())) + } } diff --git a/src/aero_kernel/src/syscall/fs.rs b/src/aero_kernel/src/syscall/fs.rs index a861e0f133f..3677d7bdb91 100644 --- a/src/aero_kernel/src/syscall/fs.rs +++ b/src/aero_kernel/src/syscall/fs.rs @@ -93,10 +93,9 @@ pub fn open(_fd: usize, path: &Path, mode: usize) -> Result inode.inode().truncate(0)?; } - Ok(scheduler::get_scheduler() - .current_task() + Ok(scheduler::current_thread() .file_table - .open_file(inode, flags)?) + .open_file(inode.clone(), flags)?) } #[syscall] @@ -234,12 +233,14 @@ pub fn ioctl(fd: usize, command: usize, argument: usize) -> Result { - handle.flags.write().insert(OpenFlags::O_CLOEXEC); + let flags = handle.flags(); + handle.set_flags(flags | OpenFlags::O_CLOEXEC); Ok(0) } FIONBIO => { - handle.flags.write().insert(OpenFlags::O_NONBLOCK); + let flags = handle.flags(); + handle.set_flags(flags | OpenFlags::O_NONBLOCK); Ok(0) } @@ -354,7 +355,7 @@ pub fn fcntl(fd: usize, command: usize, arg: usize) -> Result scheduler::get_scheduler() .current_task() .file_table - .duplicate(fd, DuplicateHint::GreatorOrEqual(arg), *handle.flags.read()), + .duplicate(fd, DuplicateHint::GreatorOrEqual(arg), handle.flags()), aero_syscall::prelude::F_DUPFD_CLOEXEC => scheduler::get_scheduler() .current_task() @@ -362,12 +363,12 @@ pub fn fcntl(fd: usize, command: usize, arg: usize) -> Result { - let flags = handle.flags.read(); + let flags = handle.flags(); let mut result = FdFlags::empty(); if flags.contains(OpenFlags::O_CLOEXEC) { @@ -379,7 +380,7 @@ pub fn fcntl(fd: usize, command: usize, arg: usize) -> Result { - let mut flags = handle.flags.write(); + let mut flags = handle.flags(); let fd_flags = FdFlags::from_bits_truncate(arg); if fd_flags.contains(FdFlags::CLOEXEC) { @@ -388,19 +389,17 @@ pub fn fcntl(fd: usize, command: usize, arg: usize) -> Result { - let flags = handle.flags.read().bits(); - Ok(flags) - } + aero_syscall::prelude::F_GETFL => Ok(handle.flags().bits()), aero_syscall::prelude::F_SETFL => { let flags = OpenFlags::from_bits_truncate(arg); - let old_flags = *handle.flags.read(); - *handle.flags.write() = (flags & SETFL_MASK) | (old_flags & !SETFL_MASK); + let old_flags = handle.flags(); + handle.set_flags((flags & SETFL_MASK) | (old_flags & !SETFL_MASK)); Ok(0) } diff --git a/src/aero_kernel/src/syscall/net.rs b/src/aero_kernel/src/syscall/net.rs index 4f864f20908..1e91ae7a8a5 100644 --- a/src/aero_kernel/src/syscall/net.rs +++ b/src/aero_kernel/src/syscall/net.rs @@ -1,3 +1,4 @@ +use aero_syscall::netlink::sockaddr_nl; use aero_syscall::socket::{MessageFlags, MessageHeader}; use aero_syscall::*; use alloc::sync::Arc; @@ -10,12 +11,14 @@ use crate::fs::inode::{DirEntry, INodeInterface}; use crate::mem::paging::VirtAddr; use crate::socket::ipv4::Ipv4Socket; +use crate::socket::netlink::NetLinkSocket; use crate::socket::tcp::TcpSocket; use crate::socket::udp::UdpSocket; use crate::socket::unix::*; use crate::socket::{SocketAddr, SocketAddrRef}; use crate::userland::scheduler; +use crate::userland::task::TaskId; /// Creates a [`SocketAddr`] from the provided userland socket structure address. This /// is done by looking at the family field present in every socket address structure. @@ -151,6 +154,8 @@ fn create_socket( } }, + AF_NETLINK => ("netlink", NetLinkSocket::new() as Arc), + _ => { log::warn!( "unsupported socket type: domain={domain}, socket_type={socket_type}, protocol={protocol:?}" @@ -159,6 +164,7 @@ fn create_socket( return Err(SyscallError::EINVAL); } }; + log::warn!("<{name}_socket> -EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"); let entry = DirEntry::from_inode(socket, alloc::format!("<{name}_socket>")); Ok(entry) @@ -171,7 +177,13 @@ pub fn socket(domain: usize, socket_type: usize, protocol: usize) -> Result Result unimplemented!("{:?}", peer), + SocketAddr::Unix(peer) => { + // let size = core::mem::size_of::() as u32; + // assert!(*len >= size); + + // let mut target = unsafe { UserRef::::new(VirtAddr::new(addr as u64)) + // }; *target = peer; + // *len = size; + return Err(SyscallError::ENOSYS); + } } Ok(0) @@ -242,6 +265,7 @@ pub fn get_sockname(fd: usize, addr: usize, len: &mut u32) -> Result { let size = core::mem::size_of::() as u32; @@ -251,6 +275,24 @@ pub fn get_sockname(fd: usize, addr: usize, len: &mut u32) -> Result { + let size = core::mem::size_of::() as u32; + assert!(*len >= size); + + let mut target = unsafe { UserRef::::new(VirtAddr::new(addr as u64)) }; + *target = name; + *len = size; + } + + SocketAddr::Unix(name) => { + let size = core::mem::size_of::() as u32; + assert!(*len >= size); + + let mut target = unsafe { UserRef::::new(VirtAddr::new(addr as u64)) }; + *target = name; + *len = size; + } } Ok(0) diff --git a/src/aero_kernel/src/userland/scheduler/mod.rs b/src/aero_kernel/src/userland/scheduler/mod.rs index c9272b551a6..3691ee879ac 100644 --- a/src/aero_kernel/src/userland/scheduler/mod.rs +++ b/src/aero_kernel/src/userland/scheduler/mod.rs @@ -139,6 +139,10 @@ impl Scheduler { }); } + pub fn for_each_task)>(&self, mut f: F) { + self.tasks.0.lock().iter().for_each(|(_, task)| f(task)); + } + /// Lookup a task by ID #[inline] pub fn find_task(&self, task_id: TaskId) -> Option> { diff --git a/src/aero_kernel/src/userland/scheduler/round_robin.rs b/src/aero_kernel/src/userland/scheduler/round_robin.rs index fe1f2e59375..a4d6d3d421a 100644 --- a/src/aero_kernel/src/userland/scheduler/round_robin.rs +++ b/src/aero_kernel/src/userland/scheduler/round_robin.rs @@ -124,6 +124,7 @@ impl RoundRobin { } else if let Some(task) = queue.dead.pop_front() { task.update_state(TaskState::Zombie); task.make_zombie(); + // TODO: assert strong count here } } diff --git a/src/aero_kernel/src/userland/task/mod.rs b/src/aero_kernel/src/userland/task/mod.rs index a2387ff7d22..2fa34574a1d 100644 --- a/src/aero_kernel/src/userland/task/mod.rs +++ b/src/aero_kernel/src/userland/task/mod.rs @@ -204,7 +204,7 @@ pub struct Task { sleep_duration: AtomicUsize, signals: Signals, - executable: Mutex>, + pub executable: Mutex>, pending_io: AtomicBool, pub(super) link: intrusive_collections::LinkedListLink, @@ -545,11 +545,47 @@ impl Task { pub(super) fn update_state(&self, state: TaskState) { if state == TaskState::Zombie { - self.file_table.0.read().iter().for_each(|file| { - if let Some(a) = file { - a.inode().close(*a.flags.read()); - } - }); + // [41] syscall/net.rs:178 (tid=33, pid=33) debug [aero_kernel/src/syscall/net.rs:178] + // current_task.file_table.open_file(entry, sockfd_flags) = Ok( 17, + // ) + // [41] syscall/process.rs:157 (tid=33, pid=33) debug mlibc: getsockopt() call with + // SOL_SOCKET and SO_TYPE is unimplemented, hardcoding SOCK_STREAM + // [41] syscall/process.rs:157 (tid=33, pid=33) debug mlibc: getsockopt() call with + // SOL_SOCKET and SO_KEEPALIVE is unimplemented, hardcoding 0 [41] syscall/ + // process.rs:157 (tid=33, pid=33) debug mlibc: setsockopt(SO_PASSCRED) is not + // implemented correctly [41] socket/netlink.rs:263 (tid=33, pid=33) warn + // netlink::send(flags=NOSIGNAL) [41] socket/netlink.rs:228 (tid=33, pid=33) + // debug [aero_kernel/src/socket/netlink.rs:228] message_hdr.iovecs_mut() = [ + // IoVec { + // base: 0x0000000000000000, + // len: 0, + // }, + // ] + // [42] syscall/process.rs:157 (tid=40, pid=40) debug mlibc: sys_setuid is a stub + // [42] syscall/process.rs:157 (tid=40, pid=40) debug In function mlock, file + // ../../../bundled/mlibc/options/posix/generic/sys-mman-stubs.cpp:22 + // __ensure(Library function fails due to missing sysdep) failed + // [42] syscall/process.rs:157 (tid=40, pid=40) debug mlibc: uselocale() is a no-op + // [42] syscall/process.rs:157 (tid=40, pid=40) debug mlibc: sys_setuid is a stub + // [42] syscall/process.rs:157 (tid=40, pid=40) debug mlibc: sys_seteuid is a stub + // [42] syscall/process.rs:157 (tid=40, pid=40) debug mlibc: sys_setgid is a stub + // [42] syscall/process.rs:157 (tid=40, pid=40) debug mlibc: sys_getegid is a stub + // [42] syscall/net.rs:178 (tid=40, pid=40) debug [aero_kernel/src/syscall/net.rs:178] + // current_task.file_table.open_file(entry, sockfd_flags) = Ok( 0, + // ) + // + // exit err 5 Input/output error + + // TODO: is_process_leader() && children.len() == 0 and then + // assert!(self.file_table.strong_count() == 1); + dbg!(Arc::strong_count(&self.file_table)); + if Arc::strong_count(&self.file_table) == 1 { + self.file_table.0.read().iter().for_each(|file| { + if let Some(handle) = file { + handle.inode().close(handle.flags()); + } + }); + } } // if state != TaskState::Runnable { diff --git a/src/aero_syscall/Cargo.toml b/src/aero_syscall/Cargo.toml index eab1f80e0aa..1aac85f20f0 100644 --- a/src/aero_syscall/Cargo.toml +++ b/src/aero_syscall/Cargo.toml @@ -9,3 +9,4 @@ bitflags = "1.2.1" num-derive = { version = "0.3", default-features = false } num-traits = { version = "0.2", default-features = false } byte_endian = { git = "https://github.com/aero-os/byte_endian" } +static_assertions = "1.1.0" diff --git a/src/aero_syscall/src/lib.rs b/src/aero_syscall/src/lib.rs index 34699ab5764..58b5552d6e9 100644 --- a/src/aero_syscall/src/lib.rs +++ b/src/aero_syscall/src/lib.rs @@ -24,6 +24,7 @@ extern crate num_derive; pub mod consts; +pub mod netlink; pub mod signal; pub mod socket; pub mod syscall; diff --git a/src/aero_syscall/src/netlink.rs b/src/aero_syscall/src/netlink.rs new file mode 100644 index 00000000000..23e2029f0bc --- /dev/null +++ b/src/aero_syscall/src/netlink.rs @@ -0,0 +1,230 @@ +#![allow(non_camel_case_types)] + +use static_assertions::const_assert_eq; + +const NLMSG_ALIGNTO: u32 = 4; + +/// Aligns `len` to the netlink message alignment. +/// +/// **Note**: This function only rounds up. +pub const fn nlmsg_align(len: u32) -> u32 { + (len + NLMSG_ALIGNTO - 1) & !(NLMSG_ALIGNTO - 1) +} + +const RTA_ALIGNTO: u32 = 4; + +pub const fn rta_align(len: u32) -> u32 { + (len + RTA_ALIGNTO - 1) & !(RTA_ALIGNTO - 1) +} + +pub const fn rta_length(len: u32) -> u32 { + rta_align(core::mem::size_of::() as u32) + len +} + +#[derive(Debug, Copy, Clone, PartialEq)] +#[repr(u16)] +pub enum RtAttrType { + Unspec, + Dst, + Src, + Iif, + Oif, + Gateway, + Priority, + PrefSrc, + Metrics, + Multipath, + ProtoInfo, // no longer used + Flow, + CacheInfo, + Session, // no longer used + MpAlgo, // no longer used + Table, + // RtaMARK, + // RtaMFC_STATS, + // RtaVIA, + // RtaNEWDST, + // RtaPREF, + // RtaENCAP_TYPE, + // RtaENCAP, + // RtaEXPIRES, + // RtaPAD, + // RtaUID, + // RtaTTL_PROPAGATE, + // RtaIP_PROTO, + // RtaSPORT, + // RtaDPORT, + // RtaNH_ID, +} + +#[derive(Debug, Copy, Clone, PartialEq)] +#[repr(u16)] +pub enum MessageType { + Noop, + Error, + Done, // end of a dump + Overrun, // data lost + + // RTM + RtmNewLink = 16, + RtmDelLink, + RtmGetLink, + RtmSetLink, + RtmNewAddr, + RtmDelAddr, + RtmGetAddr, + RtmNewRoute = 24, + RtmDelRoute, + RtmGetRoute, + RtmNewNeigh = 28, + RtmDelNeigh, + RtmGetNeigh, + RtmNewRule = 32, + RtmDelRule, + RtmGetRule, + RtmNewQDisc = 36, + RtmDelQDisc, + RtmGetQDisc, + RtmNewTClass = 40, + RtmDelTClass, + RtmGetTClass, + RtmNewTFilter = 44, + RtmDelTFilter, + RtmGetTFilter, + RtmNewAction = 48, + RtmDelAction, + RtmGetAction, + RtmNewPrefix = 52, + RtmGetMulticast = 58, + RtmGetAnyCast = 62, + RtmNewNeighTbl = 64, + RtmGetNeighTbl = 66, + RtmSetNeighTbl = 67, + RtmNewNdUserOpt = 68, + RtmNewAddrLabel = 72, + RtmDelAddrLabel, + RtmGetAddrLabel, + RtmGetDcb = 78, + RtmSetDcb, + RtmNewNetConf = 80, + RtmDelNetConf, + RtmGetNetConf, + RtmNewMdb = 84, + RtmDelMdb, + RtmGetMdb, + RtmNewNsid = 88, + RtmDelNsid, + RtmGetNsid, + RtmNewStats = 92, + RtmGetStats = 94, + RtmSetStats = 95, + RtmNewCacheReport = 96, + RtmNewChain = 100, + RtmDelChain, + RtmGetChain, + RtmNewNextHop = 104, + RtmDelNextHop, + RtmGetNextHop, + RtmNewLinkProp = 108, + RtmDelLinkProp, + RtmGetLinkProp, + RtmNewVlan = 112, + RtmDelVlan, + RtmGetVlan, + RtmNewNextHopBucket = 116, + RtmDelNextHopBucket, + RtmGetNextHopBucket, + RtmNewTunnel = 120, + RtmDelTunnel, + RtmGetTunnel, + + Unknown = u16::MAX, +} + +bitflags::bitflags! { + #[repr(transparent)] + pub struct MessageFlags: u16 { + const REQUEST = 0x1; // It is a request message. + const MULTI = 0x2; // Multipart message, terminated by NLMSG_DONE. + const ACK = 0x4; // Reply with ack, with zero or error code. + const ECHO = 0x8; // Echo this request. + const DUMP_INTR = 0x10; // Dump was inconsistent due to sequence change. + const DUMP_FILTERED = 0x20; // Dump was filtered as requested. + + // Modifers to GET request. + const ROOT = 0x100; // specify tree root. + const MATCH = 0x200; // return all matching. + const ATOMIC = 0x400; // atomic GET. + const DUMP = MessageFlags::ROOT.bits() | MessageFlags::MATCH.bits(); + } +} + +#[derive(Debug)] +#[repr(C)] +pub struct sockaddr_nl { + pub nl_family: u32, // AF_NETLINK + pub nl_pad: u16, // zero + pub nl_pid: u32, // port ID + pub nl_groups: u32, // multicast groups mask +} + +impl super::SocketAddr for sockaddr_nl {} + +/// Fixed format metadata header of Netlink messages. +#[derive(Debug)] +#[repr(C)] +pub struct nlmsghdr { + /// Length of message including header. + pub nlmsg_len: u32, + /// Message content type. + pub nlmsg_type: MessageType, + // Additional flags. + pub nlmsg_flags: MessageFlags, + /// Sequence number. + pub nlmsg_seq: u32, + /// Sending process port ID. + pub nlmsg_pid: u32, +} + +const_assert_eq!(core::mem::size_of::(), 16); + +/// General form of address family dependent message. +#[derive(Debug)] +#[repr(C)] +pub struct rtgenmsg { + pub rtgen_family: u8, +} + +const_assert_eq!(core::mem::size_of::(), 1); + +#[repr(C)] +#[derive(Debug)] +pub struct rtmsg { + pub rtm_family: u8, + pub rtm_dst_len: u8, + pub rtm_src_len: u8, + pub rtm_tos: u8, + pub rtm_table: u8, + pub rtm_protocol: u8, + pub rtm_scope: u8, + pub rtm_type: u8, + pub rtm_flags: u32, +} + +const_assert_eq!(core::mem::size_of::(), 12); + +// FIXME(andypython): This should be an enum. +// +// Reserved table identifiers. +pub const RT_TABLE_UNSPEC: u8 = 0; +// User defined values. +pub const RT_TABLE_DEFAULT: u8 = 253; +pub const RT_TABLE_MAIN: u8 = 254; +pub const RT_TABLE_LOCAL: u8 = 255; + +// Generic structure for encapsulation of optional route information. It is reminiscent of sockaddr, +// but with sa_family replaced with attribute type. +pub struct rtattr { + pub rta_len: u16, + pub rta_type: RtAttrType, +} diff --git a/src/aero_syscall/src/socket.rs b/src/aero_syscall/src/socket.rs index cbe997300da..8e7022fec84 100644 --- a/src/aero_syscall/src/socket.rs +++ b/src/aero_syscall/src/socket.rs @@ -29,15 +29,15 @@ pub struct MessageHeader { /// Pointer to the socket address structure. name: *mut u8, /// Size of the socket address structure. - name_len: usize, + name_len: u32, iovec: *mut IoVec, // todo: use Option> iovec_len: i32, // todo: use ffi::c_int control: *const u8, - control_len: usize, + control_len: u32, - flags: i32, // todo: use ffi::c_int + pub flags: i32, // todo: use ffi::c_int } impl MessageHeader { @@ -46,7 +46,7 @@ impl MessageHeader { return None; } - assert!(self.name_len == core::mem::size_of::()); + assert!(self.name_len >= core::mem::size_of::() as u32); // SAFETY: We know that the `name` pointer is valid and we have an exclusive reference to // it. The size of name is checked above with the size of `T` and `T` is a `SocketAddr` so, @@ -67,7 +67,7 @@ impl MessageHeader { } // options/posix/include/bits/posix/iovec.h -#[derive(Debug)] +#[derive(Debug, Clone)] #[repr(C)] pub struct IoVec { base: *mut u8, // todo: use Option> diff --git a/userland/Cargo.lock b/userland/Cargo.lock index efee3926e62..a3b9233381b 100644 --- a/userland/Cargo.lock +++ b/userland/Cargo.lock @@ -21,6 +21,7 @@ dependencies = [ "byte_endian", "num-derive", "num-traits", + "static_assertions", ] [[package]] @@ -282,6 +283,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "syn" version = "1.0.107" From 48b92bbabfe2fb905baa2b96a2dce985d837c47a Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 20 Oct 2023 20:51:36 +1100 Subject: [PATCH 013/112] feat(open): make use of the provided dirfd Signed-off-by: Anhad Singh --- src/aero_kernel/src/fs/mod.rs | 10 ---------- src/aero_kernel/src/syscall/fs.rs | 18 +++++++++++++++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/aero_kernel/src/fs/mod.rs b/src/aero_kernel/src/fs/mod.rs index 230b12a4532..d6f415aa526 100644 --- a/src/aero_kernel/src/fs/mod.rs +++ b/src/aero_kernel/src/fs/mod.rs @@ -291,16 +291,6 @@ pub fn lookup_path_with( Ok(cwd) } -pub fn lookup_path_with_mode(path: &Path, mode: LookupMode) -> Result { - let cwd = if !path.is_absolute() { - scheduler::get_scheduler().current_task().cwd_dirent() - } else { - root_dir().clone() - }; - - lookup_path_with(cwd, path, mode) -} - pub fn lookup_path(path: &Path) -> Result { let cwd = if !path.is_absolute() { scheduler::get_scheduler().current_task().cwd_dirent() diff --git a/src/aero_kernel/src/syscall/fs.rs b/src/aero_kernel/src/syscall/fs.rs index 3677d7bdb91..024af8f6be2 100644 --- a/src/aero_kernel/src/syscall/fs.rs +++ b/src/aero_kernel/src/syscall/fs.rs @@ -17,7 +17,7 @@ use aero_syscall::prelude::*; use aero_syscall::signal::SigProcMask; -use aero_syscall::{OpenFlags, Stat, SyscallError, TimeSpec}; +use aero_syscall::{OpenFlags, Stat, SyscallError, TimeSpec, AT_FDCWD}; use crate::fs::cache::{self, DirCacheImpl}; use crate::fs::epoll::EPoll; @@ -70,7 +70,19 @@ pub fn read(fd: usize, buffer: &mut [u8]) -> Result { } #[syscall] -pub fn open(_fd: usize, path: &Path, mode: usize) -> Result { +pub fn open(fd: usize, path: &Path, mode: usize) -> Result { + let dir = match fd as isize { + AT_FDCWD => { + if !path.is_absolute() { + scheduler::get_scheduler().current_task().cwd_dirent() + } else { + crate::fs::root_dir().clone() + } + } + + _ => todo!(), + }; + let mut flags = OpenFlags::from_bits(mode).ok_or(SyscallError::EINVAL)?; if !flags.intersects(OpenFlags::O_RDONLY | OpenFlags::O_RDWR | OpenFlags::O_WRONLY) { @@ -83,7 +95,7 @@ pub fn open(_fd: usize, path: &Path, mode: usize) -> Result lookup_mode = LookupMode::Create; } - let inode = fs::lookup_path_with_mode(path, lookup_mode)?; + let inode = fs::lookup_path_with(dir, path, lookup_mode)?; if flags.contains(OpenFlags::O_DIRECTORY) && !inode.inode().metadata()?.is_directory() { return Err(SyscallError::ENOTDIR); From 4cd1ba48d50bdd3077dc8663e326e6a4d5d3e251 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 28 Oct 2023 13:16:07 +1100 Subject: [PATCH 014/112] stash Signed-off-by: Anhad Singh --- .gitignore | 3 + bootstrap/net.yml | 4 +- src/aero_kernel/src/main.rs | 3 +- src/aero_kernel/src/socket/unix.rs | 6 +- src/aero_kernel/src/syscall/mod.rs | 18 +++ src/aero_kernel/src/syscall/net.rs | 25 ++-- src/aero_kernel/src/unwind.rs | 23 ++++ src/aero_kernel/src/userland/task/mod.rs | 14 +++ src/aero_kernel/src/userland/vm.rs | 13 +++ src/aero_syscall/src/consts.rs | 1 + src/aero_syscall/src/lib.rs | 16 +++ tools/mkimage.sh | 13 +++ userland/tests/unix_sock.cc | 142 +++++++++++++++++++++++ 13 files changed, 264 insertions(+), 17 deletions(-) create mode 100644 userland/tests/unix_sock.cc diff --git a/.gitignore b/.gitignore index c75223baf8c..20b37a745f4 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ base-files/doom1.wad # Wayland test client and server executables: (todo: remove these) base-files/client base-files/server + +# todo: remove these +debug diff --git a/bootstrap/net.yml b/bootstrap/net.yml index fb8a47a2d2c..118868d86f5 100644 --- a/bootstrap/net.yml +++ b/bootstrap/net.yml @@ -724,10 +724,10 @@ packages: - '-DUSE_SOUP2=ON' - '-DUSE_LCMS=OFF' - '@THIS_SOURCE_DIR@' + environ: + CXXFLAGS: '-DLOG_DISABLED=0' build: - args: ['ninja', '-j6'] - # environ: - # CXXFLAGS: '-std=c++11' - args: ['ninja', 'install'] environ: DESTDIR: '@THIS_COLLECT_DIR@' diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index 125db66fd92..4e32a73bf8f 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -48,7 +48,8 @@ trait_upcasting, // https://github.com/rust-lang/rust/issues/65991 naked_functions, // https://github.com/rust-lang/rust/issues/32408 cfg_match, // https://github.com/rust-lang/rust/issues/115585 - strict_provenance + strict_provenance, + offset_of )] // TODO(andypython): can we remove the dependency of "prelude_import" and "lang_items"? // `lang_items` => is currently used for the personality function (`rust_eh_personality`). diff --git a/src/aero_kernel/src/socket/unix.rs b/src/aero_kernel/src/socket/unix.rs index 3d0d0e64e90..063f8327d52 100644 --- a/src/aero_kernel/src/socket/unix.rs +++ b/src/aero_kernel/src/socket/unix.rs @@ -42,6 +42,7 @@ fn path_from_unix_sock(address: &SocketAddrUnix) -> fs::Result<&Path> { // connection which does not require a path to be created. let abstract_namespaced = address.path[0] == 0; assert!(!abstract_namespaced); + assert!(address.path[1] != 0, "unnamed UNIX socket"); let path_len = address .path @@ -351,6 +352,7 @@ impl INodeInterface for UnixSocket { let peer = queue.pop().expect("UnixSocket::accept(): backlog is empty"); let sock = Self::new(); + sock.inner.lock_irq().address = inner.address.clone(); { let mut sock_inner = sock.inner.lock_irq(); @@ -362,16 +364,18 @@ impl INodeInterface for UnixSocket { peer_data.state = UnixSocketState::Connected(sock.clone()); } + // THIS SHOULD NOT BE DONE HERE if let Some((address, length)) = address { let mut address = unsafe { UserRef::new(address) }; - if let Some(paddr) = peer.inner.lock_irq().address.as_ref() { + if let Some(paddr) = inner.address.as_ref() { *address = paddr.clone(); } else { *address = SocketAddrUnix::default(); address.family = AF_UNIX; } + // THIS IS WRONG use addr.name_len() + offset_of!(sockaddr_un, path) *length = core::mem::size_of::() as u32; } diff --git a/src/aero_kernel/src/syscall/mod.rs b/src/aero_kernel/src/syscall/mod.rs index db3ff553376..03eb64d8f1a 100644 --- a/src/aero_kernel/src/syscall/mod.rs +++ b/src/aero_kernel/src/syscall/mod.rs @@ -259,6 +259,8 @@ pub fn generic_do_syscall( // Syscall aliases (this should be handled in aero_syscall) SYS_MKDIR => fs::mkdirat(aero_syscall::AT_FDCWD as _, b, c), + SYS_DEBUG => tag_memory(b, c, d, e), + _ => { log::error!("invalid syscall: {:#x}", a); Err(SyscallError::ENOSYS) @@ -267,3 +269,19 @@ pub fn generic_do_syscall( aero_syscall::syscall_result_as_usize(result) } + +#[syscall] +pub fn tag_memory(ptr: *const u8, size: usize, tag: &str) -> Result { + use crate::userland::scheduler; + use alloc::string::ToString; + + let addr = ptr as usize; + + let thread = scheduler::current_thread(); + thread + .mem_tags + .lock() + .insert(addr..(addr + size), tag.to_string()); + + Ok(0) +} diff --git a/src/aero_kernel/src/syscall/net.rs b/src/aero_kernel/src/syscall/net.rs index 1e91ae7a8a5..ec2b8141eb6 100644 --- a/src/aero_kernel/src/syscall/net.rs +++ b/src/aero_kernel/src/syscall/net.rs @@ -178,12 +178,12 @@ pub fn socket(domain: usize, socket_type: usize, protocol: usize) -> Result Result unimplemented!("{:?}", peer), SocketAddr::Unix(peer) => { - // let size = core::mem::size_of::() as u32; - // assert!(*len >= size); + let size = core::mem::size_of::() as u32; + assert!(*len >= size); - // let mut target = unsafe { UserRef::::new(VirtAddr::new(addr as u64)) - // }; *target = peer; - // *len = size; - return Err(SyscallError::ENOSYS); + let mut target = unsafe { &mut *(addr as *mut SocketAddrUnix) }; + *len = peer.path_len() as u32 + core::mem::offset_of!(SocketAddrUnix, path) as u32; + *target = peer; } } @@ -290,8 +289,8 @@ pub fn get_sockname(fd: usize, addr: usize, len: &mut u32) -> Result= size); let mut target = unsafe { UserRef::::new(VirtAddr::new(addr as u64)) }; + *len = name.path_len() as u32 + core::mem::offset_of!(SocketAddrUnix, path) as u32; *target = name; - *len = size; } } diff --git a/src/aero_kernel/src/unwind.rs b/src/aero_kernel/src/unwind.rs index af3f49a7698..3416192d113 100644 --- a/src/aero_kernel/src/unwind.rs +++ b/src/aero_kernel/src/unwind.rs @@ -26,6 +26,7 @@ use xmas_elf::ElfFile; use crate::mem::paging::{Translate, VirtAddr}; use crate::mem::AddressSpace; +use crate::userland::scheduler; use crate::{logger, rendy}; use crate::arch::interrupts; @@ -145,6 +146,20 @@ pub fn unwind_stack_trace() { if let Some(name) = name { log::trace!("{:>2}: 0x{:016x} - {}", depth, rip, name); + } else if scheduler::is_initialized() { + if let Some((region, tag)) = scheduler::current_thread() + .mem_tags + .lock() + .iter() + .find(|(region, _tag)| region.contains(&rip)) + { + let resolved_addr = rip - region.start; + log::trace!( + "{depth:>2}: 0x{rip:016x} - " + ); + } else { + log::trace!("{depth:>2}: 0x{rip:016x} - "); + } } else { log::trace!("{:>2}: 0x{:016x} - ", depth, rip); } @@ -153,6 +168,14 @@ pub fn unwind_stack_trace() { break; } } + + let thread = scheduler::current_thread(); + let tags = thread.mem_tags.lock(); + let mut tags = tags.iter().collect::>(); + tags.sort_by(|x, y| x.0.start.cmp(&y.0.start)); + for (x, s) in tags.iter() { + log::trace!("{:#x}..{:#x} {s}", x.start, x.end); + } } #[cfg(feature = "ci")] diff --git a/src/aero_kernel/src/userland/task/mod.rs b/src/aero_kernel/src/userland/task/mod.rs index 2fa34574a1d..95bc3125dbc 100644 --- a/src/aero_kernel/src/userland/task/mod.rs +++ b/src/aero_kernel/src/userland/task/mod.rs @@ -20,9 +20,11 @@ pub mod sessions; use aero_syscall::WaitPidFlags; use alloc::sync::{Arc, Weak}; +use hashbrown::HashMap; use spin::{Once, RwLock}; use core::cell::UnsafeCell; +use core::ops::Range; use core::sync::atomic::{AtomicBool, AtomicU8, AtomicUsize, Ordering}; use crate::fs::cache::{DirCacheImpl, DirCacheItem}; @@ -221,6 +223,9 @@ pub struct Task { controlling_terminal: Mutex>>, systrace: AtomicBool, + + // for debugging only. may remove in the future. + pub mem_tags: Mutex, String>>, } impl Task { @@ -265,6 +270,8 @@ impl Task { systrace: AtomicBool::new(false), controlling_terminal: Mutex::new(None), + + mem_tags: Mutex::new(HashMap::new()), }) } @@ -307,6 +314,8 @@ impl Task { systrace: AtomicBool::new(false), controlling_terminal: Mutex::new(None), + + mem_tags: Mutex::new(HashMap::new()), }) } @@ -345,6 +354,8 @@ impl Task { systrace: AtomicBool::new(self.systrace()), controlling_terminal: Mutex::new(self.controlling_terminal.lock_irq().clone()), + + mem_tags: Mutex::new(self.mem_tags.lock().clone()), }); self.add_child(this.clone()); @@ -413,6 +424,8 @@ impl Task { .lock_irq() .clone(), ), + + mem_tags: Mutex::new(self.mem_tags.lock().clone()), }); self.add_child(this.clone()); @@ -514,6 +527,7 @@ impl Task { *self.cwd.write() = Some(Cwd::new()) } + *self.mem_tags.lock() = HashMap::new(); self.file_table.close_on_exec(); self.file_table.log(); diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs index 1da5b1f0325..b3acbe53587 100644 --- a/src/aero_kernel/src/userland/vm.rs +++ b/src/aero_kernel/src/userland/vm.rs @@ -782,6 +782,8 @@ impl VmProtected { offset: usize, file: Option, ) -> Option { + let z = file.clone(); + // Offset is required to be a multiple of page size. if (offset as u64 & (Size4KiB::SIZE - 1)) != 0 { log::warn!("mmap: offset is not a multiple of page size"); @@ -864,6 +866,17 @@ impl VmProtected { if x.is_none() { log::warn!("mmap failed"); self.log(); + + dbg!( + address, + size, + protection, + flags, + offset, + z.map(|f| f.absolute_path_str()) + ); + + crate::unwind::unwind_stack_trace(); } x diff --git a/src/aero_syscall/src/consts.rs b/src/aero_syscall/src/consts.rs index cdffd395147..0b4aed56351 100644 --- a/src/aero_syscall/src/consts.rs +++ b/src/aero_syscall/src/consts.rs @@ -98,6 +98,7 @@ pub const SYS_GETPGID: usize = 74; pub const SYS_SOCK_SHUTDOWN: usize = 75; pub const SYS_GETPEERNAME: usize = 76; pub const SYS_GETSOCKNAME: usize = 77; +pub const SYS_DEBUG: usize = 78; // constants for fcntl()'s command argument: pub const F_DUPFD: usize = 1; diff --git a/src/aero_syscall/src/lib.rs b/src/aero_syscall/src/lib.rs index 58b5552d6e9..ac39331fbdf 100644 --- a/src/aero_syscall/src/lib.rs +++ b/src/aero_syscall/src/lib.rs @@ -529,6 +529,22 @@ pub struct SocketAddrUnix { pub path: [u8; 108], } +impl SocketAddrUnix { + pub fn path_len(&self) -> u8 { + if self.path[0] == 0 { + if self.path[1] == 0 { + // address is unnamed + return 0; + } else { + // abstract socket address + unimplemented!() + } + } + + (self.path.iter().position(|&c| c == 0).unwrap_or(108) as u8) + 1 + } +} + impl Default for SocketAddrUnix { fn default() -> Self { Self { diff --git a/tools/mkimage.sh b/tools/mkimage.sh index dbcb9dce484..79d5a761c9b 100755 --- a/tools/mkimage.sh +++ b/tools/mkimage.sh @@ -2,6 +2,19 @@ set -x -e +ANSI_CLEAR="\033[0m" +ANSI_YELLOW="\033[1;34m" + +function warn() { + echo -e "${ANSI_YELLOW}$1${ANSI_CLEAR}" +} + +# check if the pkg-build directory is not newer than the system-root +if [[ ./sysroot/pkg-build -nt ./sysroot/system-root]]; then + warn "mkimage: pkg-build is newer than system-root, run `xbstrap install --all`" + exit 1 +fi + # sync the sysroot echo "sysroot: syncing base-files" cp -r base-files/. sysroot/system-root/ diff --git a/userland/tests/unix_sock.cc b/userland/tests/unix_sock.cc new file mode 100644 index 00000000000..3730799bf48 --- /dev/null +++ b/userland/tests/unix_sock.cc @@ -0,0 +1,142 @@ +// test copied from managarm + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NAMED_PATH "/tmp/sockname" + +#define DEFINE_TEST(s, f) static test_case test_##s{#s, f}; + +struct abstract_test_case { +private: + static void register_case(abstract_test_case *tcp); + +public: + abstract_test_case(const char *name) : name_{name} { register_case(this); } + + abstract_test_case(const abstract_test_case &) = delete; + + virtual ~abstract_test_case() = default; + + abstract_test_case &operator=(const abstract_test_case &) = delete; + + const char *name() { return name_; } + + virtual void run() = 0; + +private: + const char *name_; +}; + +template struct test_case : abstract_test_case { + test_case(const char *name, F functor) + : abstract_test_case{name}, functor_{std::move(functor)} {} + + void run() override { functor_(); } + +private: + F functor_; +}; + +#define clean_errno() (errno == 0 ? "None" : strerror(errno)) + +#define log_error(M, ...) \ + fprintf(stderr, "[ERROR] %s:%d: errno: %s) " M "\n", __FILE__, __LINE__, \ + clean_errno(), ##__VA_ARGS__) + +#define assertf(A, M, ...) \ + if (!(A)) { \ + log_error(M, ##__VA_ARGS__); \ + assert(A); \ + } + +// clang-format off +DEFINE_TEST(unix_getname, ([] { + int server_fd = socket(AF_UNIX, SOCK_STREAM, 0); + if(server_fd == -1) + assert(!"server socket() failed"); + + struct sockaddr_un server_addr; + memset(&server_addr, 0, sizeof(struct sockaddr_un)); + server_addr.sun_family = AF_UNIX; + strncpy(server_addr.sun_path, NAMED_PATH, sizeof(server_addr.sun_path) - 1); + + if(bind(server_fd, (struct sockaddr *)&server_addr, sizeof(struct sockaddr_un))) + assert(!"bind() failed"); + if(listen(server_fd, 50)) + assert(!"listen() failed"); + + pid_t child = fork(); + if(!child) { + int client_fd = socket(AF_UNIX, SOCK_STREAM, 0); + if(client_fd == -1) + assert(!"client socket() failed"); + if(connect(client_fd, (struct sockaddr *)&server_addr, sizeof(struct sockaddr_un))) + assert(!"connect() to server failed"); + + char buf[1]; + if (recv(client_fd, buf, 1, 0) < 0) + assert(!"recv() failed"); + exit(0); + } else { + int peer_fd = accept(server_fd, nullptr, nullptr); + if(peer_fd == -1) + assert(!"accept() failed"); + + struct sockaddr_un peer_addr; + socklen_t peer_length = sizeof(struct sockaddr_un); + if(getsockname(server_fd, (struct sockaddr *)&peer_addr, &peer_length)) + assert(!"getsockname(server) failed"); + assert(peer_length == (offsetof(sockaddr_un, sun_path) + 14)); + assert(!strcmp(peer_addr.sun_path, NAMED_PATH)); + + memset(&peer_addr, 0, sizeof(struct sockaddr)); + peer_length = sizeof(struct sockaddr_un); + if(getsockname(peer_fd, (struct sockaddr *)&peer_addr, &peer_length)) + assert(!"getsockname(peer) failed"); + printf("peer_len=%d\n", peer_length); + printf("wanted=%d\n", offsetof(sockaddr_un, sun_path) + 14); + assert(peer_length == (offsetof(sockaddr_un, sun_path) + 14)); + assert(!strcmp(peer_addr.sun_path, NAMED_PATH)); + + memset(&peer_addr, 0, sizeof(struct sockaddr)); + peer_length = sizeof(struct sockaddr_un); + if(getpeername(peer_fd, (struct sockaddr *)&peer_addr, &peer_length)) + assert(!"getpeername(peer) failed"); + printf("peer_len=%d\n", peer_length); + printf("wanted=%d\n", offsetof(sockaddr_un, sun_path) ); + assert(peer_length == offsetof(sockaddr_un, sun_path)); + + char buf[1]{0}; + if (send(peer_fd, buf, 1, 0) < 0) + assert(!"send() failed"); + } + unlink(NAMED_PATH); +})); + +std::vector &test_case_ptrs() { + static std::vector singleton; + return singleton; +} + +void abstract_test_case::register_case(abstract_test_case *tcp) { + test_case_ptrs().push_back(tcp); +} + +int main() { + // Go through all tests and run them. + for(abstract_test_case *tcp : test_case_ptrs()) { + std::cout << "tests: Running " << tcp->name() << std::endl; + tcp->run(); + } +} \ No newline at end of file From 4a4b89923d7db431b18775a3fc4228b8a641b9ce Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 28 Oct 2023 13:55:58 +1100 Subject: [PATCH 015/112] misc(aero_proc): fix formatting Signed-off-by: Anhad Singh --- src/aero_proc/src/syscall.rs | 89 ++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 50 deletions(-) diff --git a/src/aero_proc/src/syscall.rs b/src/aero_proc/src/syscall.rs index cbd5089c522..876caaf81de 100644 --- a/src/aero_proc/src/syscall.rs +++ b/src/aero_proc/src/syscall.rs @@ -277,63 +277,52 @@ fn process_call_args(args: &Punctuated) -> Vec { match arg_type { ArgType::Slice(is_mut) => { let slice_expr: Expr = if is_mut { - syn::parse_quote! { - crate::utils::validate_slice_mut(#data_ident as *mut _, #len_ident)? - } + syn::parse_quote!(crate::utils::validate_slice_mut(#data_ident as *mut _, #len_ident)?) } else { - syn::parse_quote! { - crate::utils::validate_slice(#data_ident as *const _, #len_ident)? - } + syn::parse_quote!(crate::utils::validate_slice(#data_ident as *const _, #len_ident)?) }; result.push(slice_expr); } - + ArgType::Array(is_mut) => { let array_expr: Expr = if is_mut { - syn::parse_quote! { - crate::utils::validate_array_mut(#data_ident as *mut _)? - } - } else { - unimplemented!() - }; - - result.push(array_expr); - } - - ArgType::Pointer(is_mut) => { - let ptr_expr: Expr = if is_mut { - syn::parse_quote!(#ident as *mut _) - } else { - syn::parse_quote!(#ident as *const _) - }; - - result.push(ptr_expr); - } - ArgType::Reference(is_mut) => { - let ref_expr: Expr = if is_mut { - syn::parse_quote!({ - crate::utils::validate_mut_ptr(#ident as *mut _)? - }) - } else { - syn::parse_quote!({ - crate::utils::validate_ptr(#ident as *const _)? - }) - }; - - result.push(ref_expr); - } - ArgType::String => result.push(syn::parse_quote! { - crate::utils::validate_str(#data_ident as *const _, #len_ident)? - }), - ArgType::Path => result.push(syn::parse_quote! { - { - let string = crate::utils::validate_str(#data_ident as *const _, #len_ident)?; - let path = Path::new(string); - path - } - }), - } + syn::parse_quote!(crate::utils::validate_array_mut(#data_ident as *mut _)?) + } else { + unimplemented!() + }; + + result.push(array_expr); + } + + ArgType::Pointer(is_mut) => { + let ptr_expr: Expr = if is_mut { + syn::parse_quote!(#ident as *mut _) + } else { + syn::parse_quote!(#ident as *const _) + }; + + result.push(ptr_expr); + } + + ArgType::Reference(is_mut) => { + let ref_expr: Expr = if is_mut { + syn::parse_quote!(crate::utils::validate_mut_ptr(#ident as *mut _)?) + } else { + syn::parse_quote!(crate::utils::validate_ptr(#ident as *const _)?) + }; + + result.push(ref_expr); + } + + ArgType::String => result.push(syn::parse_quote!(crate::utils::validate_str(#data_ident as *const _, #len_ident)?)), + ArgType::Path => { + result.push(syn::parse_quote!({ + let string = crate::utils::validate_str(#data_ident as *const _, #len_ident)?; + Path::new(string) + })) + } + } } else { result.push(syn::parse_quote!(#ident)); } From 1d7b17106b969f522444947da3d56660b25e10e4 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 28 Oct 2023 14:34:05 +1100 Subject: [PATCH 016/112] feat(syscall): cleanup fd handling Signed-off-by: Anhad Singh --- src/aero_kernel/src/fs/ext2/mod.rs | 13 +- src/aero_kernel/src/socket/mod.rs | 4 +- src/aero_kernel/src/syscall/fs.rs | 170 ++++++++++----------- src/aero_kernel/src/syscall/mod.rs | 11 ++ src/aero_kernel/src/syscall/net.rs | 38 ++--- src/aero_kernel/src/syscall/process.rs | 58 ++++--- src/aero_proc/src/syscall.rs | 7 +- src/aero_syscall/src/lib.rs | 14 +- userland/servers/system_server/src/main.rs | 2 +- 9 files changed, 156 insertions(+), 161 deletions(-) diff --git a/src/aero_kernel/src/fs/ext2/mod.rs b/src/aero_kernel/src/fs/ext2/mod.rs index 2c0a22ae82e..01326f34f6a 100644 --- a/src/aero_kernel/src/fs/ext2/mod.rs +++ b/src/aero_kernel/src/fs/ext2/mod.rs @@ -477,8 +477,17 @@ impl INodeInterface for INode { Ok(()) } - fn truncate(&self, _size: usize) -> super::Result<()> { - log::warn!("ext2::truncate is a stub!"); + fn truncate(&self, size: usize) -> super::Result<()> { + let inode = self.inode.read(); + + if inode.size() > size { + // grow inode + log::warn!("ext2::truncate(at=grow) is a stub!"); + } else if inode.size() < size { + log::warn!("ext2::truncate(at=shrink) is a stub!"); + // shrink inode + } + Ok(()) } diff --git a/src/aero_kernel/src/socket/mod.rs b/src/aero_kernel/src/socket/mod.rs index 2d7a9903de4..1cb73d4c53f 100644 --- a/src/aero_kernel/src/socket/mod.rs +++ b/src/aero_kernel/src/socket/mod.rs @@ -44,7 +44,7 @@ pub enum SocketAddrRef<'a> { } impl<'a> SocketAddrRef<'a> { - pub fn from_family(address: VirtAddr, family: u32) -> Result { + pub fn from_family(address: VirtAddr, family: u32) -> Result { match family { AF_UNIX => Ok(SocketAddrRef::Unix(address.read_mut::()?)), AF_INET => Ok(SocketAddrRef::INet(address.read_mut::()?)), @@ -54,7 +54,7 @@ impl<'a> SocketAddrRef<'a> { } } - pub fn from_ifreq(ifreq: &IfReq) -> Result { + pub fn from_ifreq(ifreq: &IfReq) -> Result { // SAFETY??? let family = unsafe { ifreq.data.addr.sa_family }; SocketAddrRef::from_family( diff --git a/src/aero_kernel/src/syscall/fs.rs b/src/aero_kernel/src/syscall/fs.rs index 024af8f6be2..3eb0e3ec295 100644 --- a/src/aero_kernel/src/syscall/fs.rs +++ b/src/aero_kernel/src/syscall/fs.rs @@ -15,14 +15,17 @@ // You should have received a copy of the GNU General Public License // along with Aero. If not, see . +use core::fmt; + use aero_syscall::prelude::*; use aero_syscall::signal::SigProcMask; use aero_syscall::{OpenFlags, Stat, SyscallError, TimeSpec, AT_FDCWD}; +use alloc::sync::Arc; use crate::fs::cache::{self, DirCacheImpl}; use crate::fs::epoll::EPoll; use crate::fs::eventfd::EventFd; -use crate::fs::file_table::DuplicateHint; +use crate::fs::file_table::{DuplicateHint, FileHandle}; use crate::fs::inode::{DirEntry, PollTable}; use crate::fs::pipe::Pipe; use crate::fs::{self, lookup_path, LookupMode}; @@ -30,40 +33,68 @@ use crate::userland::scheduler; use crate::fs::Path; -#[syscall] -pub fn write(fd: usize, buffer: &[u8]) -> Result { - let handle = scheduler::get_scheduler() - .current_task() - .file_table - .get_handle(fd) - .ok_or(SyscallError::EBADFD)?; +#[derive(Debug, Copy, Clone)] +pub struct FileDescriptor(usize); + +impl FileDescriptor { + /// Returns the file handle associated with this file descriptor. + /// + /// ## Errors + /// * `EBADFD`: The file descriptor is not a valid open file descriptor. + pub fn handle(&self) -> aero_syscall::Result> { + scheduler::current_thread() + .file_table + .get_handle(self.0) + .ok_or(SyscallError::EBADFD) + } +} + +impl fmt::Display for FileDescriptor { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + if let Ok(file_handle) = self.handle() { + let path = file_handle.inode.absolute_path_str(); + write!(f, "{{ {} -> {} }}", self.0, path) + } else { + // invalid file descriptor + write!(f, "{{ {} -> INVALID }}", self.0) + } + } +} +impl super::SysArg for FileDescriptor { + fn from_usize(value: usize) -> Self { + Self(value) + } +} + +impl Into for FileDescriptor { + fn into(self) -> usize { + self.0 + } +} + +#[syscall] +pub fn write(fd: FileDescriptor, buffer: &[u8]) -> Result { // FIXME(heck for xeyes): fnctl should update the open flags! // // if handle // .flags // .intersects(OpenFlags::O_WRONLY | OpenFlags::O_RDWR) // { - Ok(handle.write(buffer)?) + Ok(fd.handle()?.write(buffer)?) // } else { // Err(SyscallError::EACCES) // } } #[syscall] -pub fn read(fd: usize, buffer: &mut [u8]) -> Result { - let handle = scheduler::get_scheduler() - .current_task() - .file_table - .get_handle(fd) - .ok_or(SyscallError::EBADFD)?; - +pub fn read(fd: FileDescriptor, buffer: &mut [u8]) -> Result { // if handle // .flags // .read() // .intersects(OpenFlags::O_RDONLY | OpenFlags::O_RDWR) // { - Ok(handle.read(buffer)?) + Ok(fd.handle()?.read(buffer)?) // } else { // Err(SyscallError::EACCES) // } @@ -111,42 +142,37 @@ pub fn open(fd: usize, path: &Path, mode: usize) -> Result } #[syscall] -pub fn dup(fd: usize, flags: usize) -> Result { +pub fn dup(fd: FileDescriptor, flags: usize) -> Result { let task = scheduler::get_scheduler().current_task(); let flags = OpenFlags::from_bits(flags).ok_or(SyscallError::EINVAL)? & OpenFlags::O_CLOEXEC; - task.file_table.duplicate(fd, DuplicateHint::Any, flags) + task.file_table + .duplicate(fd.into(), DuplicateHint::Any, flags) } #[syscall] -pub fn dup2(fd: usize, new_fd: usize, flags: usize) -> Result { +pub fn dup2(fd: FileDescriptor, new_fd: usize, flags: usize) -> Result { let task = scheduler::get_scheduler().current_task(); let flags = OpenFlags::from_bits(flags).ok_or(SyscallError::EINVAL)? & OpenFlags::O_CLOEXEC; task.file_table - .duplicate(fd, DuplicateHint::Exact(new_fd), flags) + .duplicate(fd.into(), DuplicateHint::Exact(new_fd), flags) } #[syscall] -pub fn getdents(fd: usize, buffer: &mut [u8]) -> Result { - let handle = scheduler::get_scheduler() - .current_task() - .file_table - .get_handle(fd) - .ok_or(SyscallError::EBADFD)?; - - Ok(handle.get_dents(buffer)?) +pub fn getdents(fd: FileDescriptor, buffer: &mut [u8]) -> Result { + Ok(fd.handle()?.get_dents(buffer)?) } #[syscall] -pub fn close(fd: usize) -> Result { +pub fn close(fd: FileDescriptor) -> Result { let res = scheduler::get_scheduler() .current_task() .file_table - .close_file(fd); + .close_file(fd.into()); if res { - Ok(0x00) + Ok(0) } else { // FD isn't a valid open file descriptor. Err(SyscallError::EBADFD) @@ -163,7 +189,7 @@ pub fn chdir(path: &str) -> Result { } scheduler::get_scheduler().current_task().set_cwd(inode); - Ok(0x00) + Ok(0) } #[syscall] @@ -234,12 +260,8 @@ pub fn getcwd(buffer: &mut [u8]) -> Result { } #[syscall] -pub fn ioctl(fd: usize, command: usize, argument: usize) -> Result { - let handle = scheduler::get_scheduler() - .current_task() - .file_table - .get_handle(fd) - .ok_or(SyscallError::EBADFD)?; +pub fn ioctl(fd: FileDescriptor, command: usize, argument: usize) -> Result { + let handle = fd.handle()?; match command { // Sets the close-on-exec file descriptor flag. This is equivalent @@ -262,13 +284,8 @@ pub fn ioctl(fd: usize, command: usize, argument: usize) -> Result Result { - let handle = scheduler::get_scheduler() - .current_task() - .file_table - .get_handle(fd) - .ok_or(SyscallError::EBADFD)?; - +pub fn seek(fd: FileDescriptor, offset: usize, whence: usize) -> Result { + let handle = fd.handle()?; Ok(handle.seek(offset as isize, aero_syscall::SeekWhence::from(whence))?) } @@ -347,12 +364,8 @@ const SETFL_MASK: OpenFlags = OpenFlags::from_bits_truncate( ); #[syscall] -pub fn fcntl(fd: usize, command: usize, arg: usize) -> Result { - let handle = scheduler::get_scheduler() - .current_task() - .file_table - .get_handle(fd) - .ok_or(SyscallError::EBADFD)?; +pub fn fcntl(fd: FileDescriptor, command: usize, arg: usize) -> Result { + let handle = fd.handle()?; match command { // F_DUPFD_CLOEXEC and F_DUPFD: @@ -364,19 +377,17 @@ pub fn fcntl(fd: usize, command: usize, arg: usize) -> Result scheduler::get_scheduler() - .current_task() - .file_table - .duplicate(fd, DuplicateHint::GreatorOrEqual(arg), handle.flags()), - - aero_syscall::prelude::F_DUPFD_CLOEXEC => scheduler::get_scheduler() - .current_task() - .file_table - .duplicate( - fd, - DuplicateHint::GreatorOrEqual(arg), - handle.flags() | OpenFlags::O_CLOEXEC, - ), + aero_syscall::prelude::F_DUPFD => scheduler::current_thread().file_table.duplicate( + fd.into(), + DuplicateHint::GreatorOrEqual(arg), + handle.flags(), + ), + + aero_syscall::prelude::F_DUPFD_CLOEXEC => scheduler::current_thread().file_table.duplicate( + fd.into(), + DuplicateHint::GreatorOrEqual(arg), + handle.flags() | OpenFlags::O_CLOEXEC, + ), // Get the value of file descriptor flags. aero_syscall::prelude::F_GETFD => { @@ -429,24 +440,15 @@ pub fn fcntl(fd: usize, command: usize, arg: usize) -> Result Result { - let file = scheduler::get_scheduler() - .current_task() - .file_table - .get_handle(fd) - .ok_or(SyscallError::EBADFD)?; - - *stat = file.inode().stat()?; - +pub fn fstat(fd: FileDescriptor, stat: &mut Stat) -> Result { + *stat = fd.handle()?.inode().stat()?; Ok(0) } #[syscall] pub fn stat(path: &Path, stat: &mut Stat) -> Result { let file = fs::lookup_path(path)?; - *stat = file.inode().stat()?; - Ok(0) } @@ -480,16 +482,12 @@ pub fn epoll_create(flags: usize) -> Result { /// the operation be performed for the target file descriptor. #[syscall] pub fn epoll_ctl( - epfd: usize, + epfd: FileDescriptor, mode: usize, fd: usize, event: &mut EPollEvent, ) -> Result { - let epfd = scheduler::get_scheduler() - .current_task() - .file_table - .get_handle(epfd) - .ok_or(SyscallError::EBADFD)?; + let epfd = epfd.handle()?; let epoll = epfd .inode() @@ -518,7 +516,7 @@ pub fn epoll_ctl( #[syscall] pub fn epoll_pwait( - epfd: usize, + epfd: FileDescriptor, event: &mut [EPollEvent], timeout: usize, sigmask: usize, @@ -528,11 +526,7 @@ pub fn epoll_pwait( let current_task = scheduler::get_scheduler().current_task(); let signals = current_task.signals(); - let epfd = current_task - .file_table - .get_handle(epfd) - .ok_or(SyscallError::EBADFD)?; - + let epfd = epfd.handle()?; let epfd = epfd .inode() .downcast_arc::() diff --git a/src/aero_kernel/src/syscall/mod.rs b/src/aero_kernel/src/syscall/mod.rs index 03eb64d8f1a..7a3acd29ffa 100644 --- a/src/aero_kernel/src/syscall/mod.rs +++ b/src/aero_kernel/src/syscall/mod.rs @@ -17,6 +17,7 @@ //! System Calls are used to call a kernel service from userland. +use core::fmt::Display; use core::mem::MaybeUninit; use aero_syscall::prelude::*; @@ -98,6 +99,16 @@ pub fn exec_args_from_slice(args: usize, size: usize) -> ExecArgs { ExecArgs { inner: result } } +pub trait SysArg: Display { + fn from_usize(value: usize) -> Self; +} + +impl SysArg for usize { + fn from_usize(value: usize) -> Self { + value + } +} + pub(super) struct SysLog { name: &'static str, /// The result of the syscall. diff --git a/src/aero_kernel/src/syscall/net.rs b/src/aero_kernel/src/syscall/net.rs index ec2b8141eb6..35353225fe0 100644 --- a/src/aero_kernel/src/syscall/net.rs +++ b/src/aero_kernel/src/syscall/net.rs @@ -22,13 +22,13 @@ use crate::userland::task::TaskId; /// Creates a [`SocketAddr`] from the provided userland socket structure address. This /// is done by looking at the family field present in every socket address structure. -fn socket_addr_from_addr<'sys>(address: VirtAddr) -> Result, SyscallError> { +fn socket_addr_from_addr<'sys>(address: VirtAddr) -> Result> { let family = *address.read_mut::()?; SocketAddrRef::from_family(address, family) } #[syscall] -pub fn shutdown(fd: usize, how: usize) -> Result { +pub fn shutdown(fd: usize, how: usize) -> Result { let file_table = &scheduler::get_scheduler().current_task().file_table; let socket = file_table.get_handle(fd).ok_or(SyscallError::EINVAL)?; @@ -38,7 +38,7 @@ pub fn shutdown(fd: usize, how: usize) -> Result { /// Connects the socket to the specified address. #[syscall] -pub fn connect(fd: usize, address: usize, length: usize) -> Result { +pub fn connect(fd: usize, address: usize, length: usize) -> Result { let address = socket_addr_from_addr(VirtAddr::new(address as u64))?; let file = scheduler::get_scheduler() .current_task() @@ -52,7 +52,7 @@ pub fn connect(fd: usize, address: usize, length: usize) -> Result Result { +pub fn accept(fd: usize, address: usize, length: usize) -> Result { let file_table = scheduler::get_scheduler().current_task().file_table.clone(); let socket = file_table.get_handle(fd).ok_or(SyscallError::EINVAL)?; @@ -75,11 +75,7 @@ pub fn accept(fd: usize, address: usize, length: usize) -> Result Result { +pub fn sock_send(fd: usize, header: &mut MessageHeader, flags: usize) -> Result { let flags = MessageFlags::from_bits(flags).ok_or(SyscallError::EINVAL)?; let current_task = scheduler::get_scheduler().current_task(); @@ -92,11 +88,7 @@ pub fn sock_send( } #[syscall] -pub fn sock_recv( - sockfd: usize, - header: &mut MessageHeader, - flags: usize, -) -> Result { +pub fn sock_recv(sockfd: usize, header: &mut MessageHeader, flags: usize) -> Result { let flags = MessageFlags::from_bits(flags).ok_or(SyscallError::EINVAL)?; let current_task = scheduler::get_scheduler().current_task(); @@ -111,7 +103,7 @@ pub fn sock_recv( /// Marks the socket as a passive socket (i.e. as a socket that will be used to accept incoming /// connection requests). #[syscall] -pub fn listen(fd: usize, backlog: usize) -> Result { +pub fn listen(fd: usize, backlog: usize) -> Result { let file = scheduler::get_scheduler() .current_task() .file_table @@ -122,11 +114,7 @@ pub fn listen(fd: usize, backlog: usize) -> Result { Ok(0) } -fn create_socket( - domain: usize, - socket_type: usize, - protocol: usize, -) -> Result { +fn create_socket(domain: usize, socket_type: usize, protocol: usize) -> Result { let typ = SocketType::from_usize(socket_type & 0b1111).ok_or(SyscallError::EINVAL)?; let protocol = IpProtocol::from_usize(protocol).ok_or(SyscallError::EINVAL)?; @@ -171,7 +159,7 @@ fn create_socket( } #[syscall] -pub fn socket(domain: usize, socket_type: usize, protocol: usize) -> Result { +pub fn socket(domain: usize, socket_type: usize, protocol: usize) -> Result { let entry = create_socket(domain, socket_type, protocol)?; let current_task = scheduler::get_scheduler().current_task(); @@ -189,7 +177,7 @@ pub fn socket(domain: usize, socket_type: usize, protocol: usize) -> Result Result { +pub fn bind(fd: usize, address: usize, length: usize) -> Result { let address = socket_addr_from_addr(VirtAddr::new(address as u64))?; let current_task = scheduler::get_scheduler().current_task(); @@ -211,7 +199,7 @@ pub fn bind(fd: usize, address: usize, length: usize) -> Result Result { +pub fn get_peername(fd: usize, addr: usize, len: &mut u32) -> Result { let thread = scheduler::current_thread(); let file = thread .file_table @@ -250,7 +238,7 @@ pub fn get_peername(fd: usize, addr: usize, len: &mut u32) -> Result Result { +pub fn get_sockname(fd: usize, addr: usize, len: &mut u32) -> Result { let thread = scheduler::current_thread(); let file = thread .file_table @@ -307,7 +295,7 @@ pub fn socket_pair( type_and_flags: usize, protocol: usize, fds: &mut [i32; 2], -) -> Result { +) -> Result { let current_task = scheduler::get_scheduler().current_task(); let sockfd_flags = SocketFlags::from_bits_truncate(type_and_flags).into(); diff --git a/src/aero_kernel/src/syscall/process.rs b/src/aero_kernel/src/syscall/process.rs index 826c8667dd1..c943d437c78 100644 --- a/src/aero_kernel/src/syscall/process.rs +++ b/src/aero_kernel/src/syscall/process.rs @@ -38,7 +38,7 @@ fn hostname() -> &'static Mutex { } #[syscall(no_return)] -pub fn exit(status: usize) -> Result { +pub fn exit(status: usize) -> Result { #[cfg(all(test, feature = "ci"))] crate::emu::exit_qemu(crate::emu::ExitStatus::Success); @@ -56,7 +56,7 @@ pub fn exit(status: usize) -> Result { } #[syscall] -pub fn uname(buffer: &mut Utsname) -> Result { +pub fn uname(buffer: &mut Utsname) -> Result { fn init_array(fixed: &mut [u8; 65], init: &'static str) { let init_bytes = init.as_bytes(); let len = init.len(); @@ -83,7 +83,7 @@ pub fn uname(buffer: &mut Utsname) -> Result { } #[syscall] -pub fn fork() -> Result { +pub fn fork() -> Result { let scheduler = scheduler::get_scheduler(); let forked = scheduler.current_task().fork(); @@ -92,7 +92,7 @@ pub fn fork() -> Result { } #[syscall] -pub fn clone(entry: usize, stack: usize) -> Result { +pub fn clone(entry: usize, stack: usize) -> Result { let scheduler = scheduler::get_scheduler(); let cloned = scheduler.current_task().clone_process(entry, stack); @@ -101,7 +101,7 @@ pub fn clone(entry: usize, stack: usize) -> Result { } #[syscall] -pub fn kill(pid: usize, signal: usize) -> Result { +pub fn kill(pid: usize, signal: usize) -> Result { // If pid is positive, then signal is sent to the process with that pid. if pid > 0 { crate::unwind::unwind_stack_trace(); @@ -118,13 +118,7 @@ pub fn kill(pid: usize, signal: usize) -> Result { } #[syscall(no_return)] -pub fn exec( - path: &Path, - args: usize, - argc: usize, - envs: usize, - envc: usize, -) -> Result { +pub fn exec(path: &Path, args: usize, argc: usize, envs: usize, envc: usize) -> Result { let executable = fs::lookup_path(path)?; if executable.inode().metadata()?.is_directory() { @@ -153,14 +147,14 @@ pub fn exec( } #[syscall] -pub fn log(msg: &str) -> Result { +pub fn log(msg: &str) -> Result { log::debug!("{}", msg); Ok(0x00) } #[syscall] -pub fn waitpid(pid: usize, status: &mut u32, flags: usize) -> Result { +pub fn waitpid(pid: usize, status: &mut u32, flags: usize) -> Result { let flags = WaitPidFlags::from_bits_truncate(flags); let current_task = scheduler::get_scheduler().current_task(); @@ -175,7 +169,7 @@ pub fn mmap( flags: usize, fd: usize, offset: usize, -) -> Result { +) -> Result { let address = VirtAddr::new(address as u64); let protection = MMapProt::from_bits(protection).ok_or(SyscallError::EINVAL)?; let flags = MMapFlags::from_bits(flags).ok_or(SyscallError::EINVAL)?; @@ -205,7 +199,7 @@ pub fn mmap( } #[syscall] -pub fn munmap(address: usize, size: usize) -> Result { +pub fn munmap(address: usize, size: usize) -> Result { let address = VirtAddr::new(address as u64); if scheduler::get_scheduler() @@ -220,7 +214,7 @@ pub fn munmap(address: usize, size: usize) -> Result { } #[syscall] -pub fn mprotect(ptr: usize, size: usize, prot: usize) -> Result { +pub fn mprotect(ptr: usize, size: usize, prot: usize) -> Result { let ptr = VirtAddr::new(ptr as _); let prot = MMapProt::from_bits(prot).ok_or(SyscallError::EINVAL)?; @@ -231,7 +225,7 @@ pub fn mprotect(ptr: usize, size: usize, prot: usize) -> Result Result { +pub fn backtrace() -> Result { crate::unwind::unwind_stack_trace(); Ok(0) } @@ -241,18 +235,18 @@ pub fn backtrace() -> Result { /// When the tracer is enabled for a process, it also applies to any child processes spawned by the /// process. #[syscall] -pub fn trace() -> Result { +pub fn trace() -> Result { scheduler::get_scheduler().current_task().enable_systrace(); Ok(0) } #[syscall] -pub fn getpid() -> Result { +pub fn getpid() -> Result { Ok(scheduler::get_scheduler().current_task().pid().as_usize()) } #[syscall] -pub fn getppid() -> Result { +pub fn getppid() -> Result { Ok(scheduler::get_scheduler() .current_task() .parent_pid() @@ -260,12 +254,12 @@ pub fn getppid() -> Result { } #[syscall] -pub fn gettid() -> Result { +pub fn gettid() -> Result { Ok(scheduler::get_scheduler().current_task().tid().as_usize()) } #[syscall] -pub fn gethostname(buffer: &mut [u8]) -> Result { +pub fn gethostname(buffer: &mut [u8]) -> Result { let hostname = hostname().lock(); let bytes = hostname.as_bytes(); @@ -279,14 +273,14 @@ pub fn gethostname(buffer: &mut [u8]) -> Result { } #[syscall] -pub fn info(struc: &mut SysInfo) -> Result { +pub fn info(struc: &mut SysInfo) -> Result { struc.uptime = crate::arch::time::get_uptime_ticks() as i64; Ok(0x00) } #[syscall] -pub fn sethostname(name: &[u8]) -> Result { +pub fn sethostname(name: &[u8]) -> Result { match core::str::from_utf8(name) { Ok(name) => { *hostname().lock() = name.into(); @@ -298,7 +292,7 @@ pub fn sethostname(name: &[u8]) -> Result { } #[syscall] -pub fn sigprocmask(how: usize, set: *const u64, old_set: *mut u64) -> Result { +pub fn sigprocmask(how: usize, set: *const u64, old_set: *mut u64) -> Result { let set = if set.is_null() { None } else { @@ -327,7 +321,7 @@ pub fn sigaction( sigact: *mut SigAction, sigreturn: usize, old: *mut SigAction, -) -> Result { +) -> Result { let new = if sigact.is_null() { None } else { @@ -356,7 +350,7 @@ pub fn sigaction( } #[syscall(no_return)] -pub fn shutdown() -> Result { +pub fn shutdown() -> Result { fs::cache::dcache().log(); fs::cache::clear_inode_cache(); @@ -368,7 +362,7 @@ pub fn shutdown() -> Result { unreachable!("aml: failed to shutdown (enter state S5)") } -fn find_task_by_pid(pid: usize) -> Result, SyscallError> { +fn find_task_by_pid(pid: usize) -> Result> { let current_task = scheduler::get_scheduler().current_task(); // If `pid` is 0, the process ID of the calling process is used. @@ -382,7 +376,7 @@ fn find_task_by_pid(pid: usize) -> Result, SyscallError> { } #[syscall] -pub fn getpgid(pid: usize) -> Result { +pub fn getpgid(pid: usize) -> Result { let task = find_task_by_pid(pid)?; let group = SESSIONS.find_group(task).unwrap(); @@ -390,7 +384,7 @@ pub fn getpgid(pid: usize) -> Result { } #[syscall] -pub fn setpgid(pid: usize, pgid: usize) -> Result { +pub fn setpgid(pid: usize, pgid: usize) -> Result { let current_task = scheduler::get_scheduler().current_task(); let task = find_task_by_pid(pid)?; @@ -416,7 +410,7 @@ pub fn setpgid(pid: usize, pgid: usize) -> Result { } #[syscall] -pub fn setsid() -> Result { +pub fn setsid() -> Result { let current_task = scheduler::get_scheduler().current_task(); if current_task.is_group_leader() { return Err(SyscallError::EPERM); diff --git a/src/aero_proc/src/syscall.rs b/src/aero_proc/src/syscall.rs index 876caaf81de..935c48b6488 100644 --- a/src/aero_proc/src/syscall.rs +++ b/src/aero_proc/src/syscall.rs @@ -234,12 +234,9 @@ fn process_args(args: &Punctuated) -> Vec { result.push(syn::parse_quote!(#data: usize)); } - Some(ArgType::Pointer(_)) | Some(ArgType::Reference(_)) => { + _ => { result.push(syn::parse_quote!(#(#attrs)* #ident: usize)); } - None => { - result.push(syn::parse_quote!(#(#attrs)* #ident: #typ)); - } }; } _ => { @@ -324,7 +321,7 @@ fn process_call_args(args: &Punctuated) -> Vec { } } } else { - result.push(syn::parse_quote!(#ident)); + result.push(syn::parse_quote!(crate::syscall::SysArg::from_usize(#ident))); } } } diff --git a/src/aero_syscall/src/lib.rs b/src/aero_syscall/src/lib.rs index ac39331fbdf..d7b20a878f6 100644 --- a/src/aero_syscall/src/lib.rs +++ b/src/aero_syscall/src/lib.rs @@ -30,6 +30,8 @@ pub mod socket; pub mod syscall; pub mod time; +pub type Result = core::result::Result; + use byte_endian::BigEndian; pub use crate::syscall::*; @@ -466,7 +468,7 @@ pub struct SysInfo { pub _f: [i8; 0], } -pub fn syscall_result_as_usize(result: Result) -> usize { +pub fn syscall_result_as_usize(result: Result) -> usize { match result { Ok(value) => value as _, Err(error) => -(error as isize) as _, @@ -475,7 +477,7 @@ pub fn syscall_result_as_usize(result: Result) -> usize { /// Inner helper function that converts the syscall result value into the /// Rust [`Result`] type. -pub fn isize_as_syscall_result(value: isize) -> Result { +pub fn isize_as_syscall_result(value: isize) -> Result { if value >= 0 { Ok(value as usize) } else { @@ -484,7 +486,7 @@ pub fn isize_as_syscall_result(value: isize) -> Result { } } -pub fn sys_ipc_send(pid: usize, message: &[u8]) -> Result<(), SyscallError> { +pub fn sys_ipc_send(pid: usize, message: &[u8]) -> Result<()> { let value = syscall3( prelude::SYS_IPC_SEND, pid, @@ -498,7 +500,7 @@ pub fn sys_ipc_recv<'a>( pid: &mut usize, message: &'a mut [u8], block: bool, -) -> Result<&'a mut [u8], SyscallError> { +) -> Result<&'a mut [u8]> { let value = syscall4( prelude::SYS_IPC_RECV, pid as *mut usize as usize, @@ -509,12 +511,12 @@ pub fn sys_ipc_recv<'a>( isize_as_syscall_result(value as _).map(|size| &mut message[0..size]) } -pub fn sys_ipc_discover_root() -> Result { +pub fn sys_ipc_discover_root() -> Result { let value = syscall0(prelude::SYS_IPC_DISCOVER_ROOT); isize_as_syscall_result(value as _) } -pub fn sys_ipc_become_root() -> Result<(), SyscallError> { +pub fn sys_ipc_become_root() -> Result<()> { let value = syscall0(prelude::SYS_IPC_BECOME_ROOT); isize_as_syscall_result(value as _).map(|_| ()) } diff --git a/userland/servers/system_server/src/main.rs b/userland/servers/system_server/src/main.rs index b0a24cf5d94..4f300419c33 100644 --- a/userland/servers/system_server/src/main.rs +++ b/userland/servers/system_server/src/main.rs @@ -24,7 +24,7 @@ use hashbrown::hash_map::Entry; use hashbrown::HashMap; use spin::RwLock; -fn main() -> Result<(), Box> { +fn main() -> core::result::Result<(), Box> { sys_ipc_become_root().unwrap(); aero_ipc::listen(SystemService::handler(SystemServer::new())); From 592f96a8fdbeb5046ad5d9d6b3d2477a65a4f52f Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sun, 29 Oct 2023 20:16:10 +1100 Subject: [PATCH 017/112] feat: fix mmap memes * The end_address of a partial mapping needs to be set to the start address of the unmap range. * Similarly for unmap end, the end address needs to be set to the start address of the unmap range. Signed-off-by: Anhad Singh --- src/aero_kernel/src/fs/cache.rs | 8 + src/aero_kernel/src/socket/unix.rs | 4 +- src/aero_kernel/src/syscall/mod.rs | 1 + src/aero_kernel/src/syscall/net.rs | 37 +- src/aero_kernel/src/unwind.rs | 14 +- src/aero_kernel/src/userland/vm.rs | 9 +- src/aero_syscall/src/consts.rs | 2 + src/aero_syscall/src/socket.rs | 63 ++- tools/mkimage.sh | 22 +- userland/tests/test.cc | 619 +++++++++++++++++++++++++++++ userland/tests/unix_sock.cc | 142 ------- 11 files changed, 743 insertions(+), 178 deletions(-) create mode 100644 userland/tests/test.cc delete mode 100644 userland/tests/unix_sock.cc diff --git a/src/aero_kernel/src/fs/cache.rs b/src/aero_kernel/src/fs/cache.rs index 62f3f43764a..d20bd0fe4c7 100644 --- a/src/aero_kernel/src/fs/cache.rs +++ b/src/aero_kernel/src/fs/cache.rs @@ -314,6 +314,14 @@ pub type DirCacheKey = (usize, String); pub type DirCache = Cache; pub type DirCacheItem = CacheArc>; +impl Debug for DirCacheItem { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_tuple("DirCacheItem") + .field(&self.absolute_path_str()) + .finish() + } +} + pub struct CachedINode(Arc); impl CachedINode { diff --git a/src/aero_kernel/src/socket/unix.rs b/src/aero_kernel/src/socket/unix.rs index 063f8327d52..a7a91864aeb 100644 --- a/src/aero_kernel/src/socket/unix.rs +++ b/src/aero_kernel/src/socket/unix.rs @@ -410,9 +410,9 @@ impl INodeInterface for UnixSocket { .sum::()) } - fn send(&self, message_hdr: &mut MessageHeader, _flags: MessageFlags) -> fs::Result { + fn send(&self, header: &mut MessageHeader, _flags: MessageFlags) -> fs::Result { // FIXME(andyython): figure out the message header stuff... - let data = message_hdr + let data = header .iovecs() .iter() .flat_map(|e| e.as_slice()) diff --git a/src/aero_kernel/src/syscall/mod.rs b/src/aero_kernel/src/syscall/mod.rs index 7a3acd29ffa..e47f24e906c 100644 --- a/src/aero_kernel/src/syscall/mod.rs +++ b/src/aero_kernel/src/syscall/mod.rs @@ -252,6 +252,7 @@ pub fn generic_do_syscall( SYS_SOCK_SHUTDOWN => net::shutdown(b, c), SYS_GETPEERNAME => net::get_peername(b, c, d), SYS_GETSOCKNAME => net::get_sockname(b, c, d), + SYS_SETSOCKOPT => net::setopt(a, b, c, d, e), SYS_GETTIME => time::gettime(b, c), SYS_SLEEP => time::sleep(b), diff --git a/src/aero_kernel/src/syscall/net.rs b/src/aero_kernel/src/syscall/net.rs index 35353225fe0..fb6adb6a25f 100644 --- a/src/aero_kernel/src/syscall/net.rs +++ b/src/aero_kernel/src/syscall/net.rs @@ -1,5 +1,5 @@ use aero_syscall::netlink::sockaddr_nl; -use aero_syscall::socket::{MessageFlags, MessageHeader}; +use aero_syscall::socket::{MessageFlags, MessageHeader, SocketOptionLevel}; use aero_syscall::*; use alloc::sync::Arc; use num_traits::cast::FromPrimitive; @@ -20,6 +20,8 @@ use crate::socket::{SocketAddr, SocketAddrRef}; use crate::userland::scheduler; use crate::userland::task::TaskId; +use super::FileDescriptor; + /// Creates a [`SocketAddr`] from the provided userland socket structure address. This /// is done by looking at the family field present in every socket address structure. fn socket_addr_from_addr<'sys>(address: VirtAddr) -> Result> { @@ -76,6 +78,8 @@ pub fn accept(fd: usize, address: usize, length: usize) -> Result { #[syscall] pub fn sock_send(fd: usize, header: &mut MessageHeader, flags: usize) -> Result { + dbg!(header.control()); + let flags = MessageFlags::from_bits(flags).ok_or(SyscallError::EINVAL)?; let current_task = scheduler::get_scheduler().current_task(); @@ -100,17 +104,32 @@ pub fn sock_recv(sockfd: usize, header: &mut MessageHeader, flags: usize) -> Res Ok(socket.inode().recv(header, flags)?) } +#[syscall] +pub fn setopt(fd: FileDescriptor, layer: usize, number: usize, buf: &[u8]) -> Result { + let layer = SocketOptionLevel::from_usize(layer).ok_or(SyscallError::EINVAL)?; + + match layer { + SocketOptionLevel::Socket => { + unimplemented!( + "setsockopt(fd={:?}, layer={:?}, number={:?}, buf={:?})", + fd, + layer, + number, + buf + ) + } + + _ => todo!(), + } + + Ok(0) +} + /// Marks the socket as a passive socket (i.e. as a socket that will be used to accept incoming /// connection requests). #[syscall] -pub fn listen(fd: usize, backlog: usize) -> Result { - let file = scheduler::get_scheduler() - .current_task() - .file_table - .get_handle(fd) - .ok_or(SyscallError::EINVAL)?; - - file.inode().listen(backlog)?; +pub fn listen(fd: FileDescriptor, backlog: usize) -> Result { + fd.handle()?.inode().listen(backlog)?; Ok(0) } diff --git a/src/aero_kernel/src/unwind.rs b/src/aero_kernel/src/unwind.rs index 3416192d113..7ae349e7938 100644 --- a/src/aero_kernel/src/unwind.rs +++ b/src/aero_kernel/src/unwind.rs @@ -169,13 +169,13 @@ pub fn unwind_stack_trace() { } } - let thread = scheduler::current_thread(); - let tags = thread.mem_tags.lock(); - let mut tags = tags.iter().collect::>(); - tags.sort_by(|x, y| x.0.start.cmp(&y.0.start)); - for (x, s) in tags.iter() { - log::trace!("{:#x}..{:#x} {s}", x.start, x.end); - } + // let thread = scheduler::current_thread(); + // let tags = thread.mem_tags.lock(); + // let mut tags = tags.iter().collect::>(); + // tags.sort_by(|x, y| x.0.start.cmp(&y.0.start)); + // for (x, s) in tags.iter() { + // log::trace!("{:#x}..{:#x} {s}", x.start, x.end); + // } } #[cfg(feature = "ci")] diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs index b3acbe53587..884f870ad2d 100644 --- a/src/aero_kernel/src/userland/vm.rs +++ b/src/aero_kernel/src/userland/vm.rs @@ -319,7 +319,7 @@ pub struct LoadedBinary<'header> { pub envv: Option, } -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct MMapFile { offset: usize, file: DirCacheItem, @@ -333,7 +333,7 @@ impl MMapFile { } } -#[derive(Clone)] +#[derive(Debug, Clone)] struct Mapping { protection: MMapProt, flags: MMapFlags, @@ -584,8 +584,7 @@ impl Mapping { refresh_flags: true, }; - self.end_addr = end; - + self.end_addr = start; Ok(UnmapResult::Partial(new_mapping)) } else if start <= self.start_addr && end >= self.end_addr { // We are unmapping the whole region. @@ -610,7 +609,7 @@ impl Mapping { // Update the end address of the mapping since we have unmapped the // last chunk of the mapping. - self.end_addr = end; + self.end_addr = start; Ok(UnmapResult::End) } } diff --git a/src/aero_syscall/src/consts.rs b/src/aero_syscall/src/consts.rs index 0b4aed56351..6a2f55d7824 100644 --- a/src/aero_syscall/src/consts.rs +++ b/src/aero_syscall/src/consts.rs @@ -99,6 +99,8 @@ pub const SYS_SOCK_SHUTDOWN: usize = 75; pub const SYS_GETPEERNAME: usize = 76; pub const SYS_GETSOCKNAME: usize = 77; pub const SYS_DEBUG: usize = 78; +pub const SYS_SETSOCKOPT: usize = 79; +pub const SYS_GETSOCKOPT: usize = 80; // constants for fcntl()'s command argument: pub const F_DUPFD: usize = 1; diff --git a/src/aero_syscall/src/socket.rs b/src/aero_syscall/src/socket.rs index 8e7022fec84..c1c13378a30 100644 --- a/src/aero_syscall/src/socket.rs +++ b/src/aero_syscall/src/socket.rs @@ -1,12 +1,31 @@ +#![allow(non_camel_case_types)] + use crate::SocketAddr; +mod c { + // This should be bindgened. + pub type socklen_t = u32; + + pub const SCM_RIGHTS: i32 = 1; + pub const SCM_CREDENTIALS: i32 = 2; + + pub const SOL_SOCKET: i32 = 1; + pub const SOL_IPV6: i32 = 41; + pub const SOL_PACKET: i32 = 263; + pub const SOL_NETLINK: i32 = 270; +} + bitflags::bitflags! { // mlibc/abis/mlibc/socket.h pub struct MessageFlags: usize { + /// Indicates that some control data was discarded due to lack of space in the + /// buffer for ancillary data. const CTRUNC = 0x1; const DONTROUTE = 0x2; const EOR = 0x4; const OOB = 0x8; + /// Requests not to send `SIGPIPE` on errors on stream oriented sockets when the + /// other end breaks the connection. The `EPIPE` error is still returned. const NOSIGNAL = 0x10; const PEEK = 0x20; const TRUNC = 0x40; @@ -29,13 +48,13 @@ pub struct MessageHeader { /// Pointer to the socket address structure. name: *mut u8, /// Size of the socket address structure. - name_len: u32, + name_len: c::socklen_t, iovec: *mut IoVec, // todo: use Option> iovec_len: i32, // todo: use ffi::c_int control: *const u8, - control_len: u32, + control_len: c::socklen_t, pub flags: i32, // todo: use ffi::c_int } @@ -48,22 +67,21 @@ impl MessageHeader { assert!(self.name_len >= core::mem::size_of::() as u32); - // SAFETY: We know that the `name` pointer is valid and we have an exclusive reference to - // it. The size of name is checked above with the size of `T` and `T` is a `SocketAddr` so, - // its safe to create a mutable reference of `T` from the ptr. unsafe { Some(&mut *(self.name as *mut T)) } } pub fn iovecs(&self) -> &[IoVec] { - // SAFETY: We know that the `iovec` pointer is valid, initialized. unsafe { core::slice::from_raw_parts(self.iovec, self.iovec_len as usize) } } pub fn iovecs_mut(&mut self) -> &mut [IoVec] { - // SAFETY: We know that the `iovec` pointer is valid, initialized and we have exclusive - // access so, its safe to construct a mutable slice from it. unsafe { core::slice::from_raw_parts_mut(self.iovec, self.iovec_len as usize) } } + + pub fn control(&self) -> &[ControlMessage] { + assert!(self.control_len == 0); + &[] + } } // options/posix/include/bits/posix/iovec.h @@ -91,3 +109,32 @@ impl IoVec { self.len } } + +/// Control Message Header (`struct cmsghdr`). +#[derive(Debug)] +#[repr(C)] +pub struct ControlMessage { + /// Data byte count, including the header. + pub cmsg_len: c::socklen_t, + /// Originating protocol. + pub cmsg_level: SocketOptionLevel, + /// Protocol-specific type. + pub cmsg_type: ControlMessageType, + // followed by cmsg_data: [u8; cmsg_len - sizeof(struct cmsghdr)] +} + +#[derive(Debug, Copy, Clone, PartialEq)] +#[repr(i32)] +pub enum ControlMessageType { + Rights = c::SCM_RIGHTS, + Credentials = c::SCM_CREDENTIALS, +} + +#[derive(Debug, Copy, Clone, PartialEq, FromPrimitive)] +#[repr(i32)] +pub enum SocketOptionLevel { + Socket = c::SOL_SOCKET, + Ipv6 = c::SOL_IPV6, + Packet = c::SOL_PACKET, + Netlink = c::SOL_NETLINK, +} diff --git a/tools/mkimage.sh b/tools/mkimage.sh index 79d5a761c9b..e2d66af35f3 100755 --- a/tools/mkimage.sh +++ b/tools/mkimage.sh @@ -3,15 +3,27 @@ set -x -e ANSI_CLEAR="\033[0m" -ANSI_YELLOW="\033[1;34m" +ANSI_RED="\033[1;31m" +ANSI_BOLD="\033[1m" function warn() { - echo -e "${ANSI_YELLOW}$1${ANSI_CLEAR}" + echo -e "${ANSI_RED}error${ANSI_CLEAR}: ${ANSI_BOLD}$1${ANSI_CLEAR}" } -# check if the pkg-build directory is not newer than the system-root -if [[ ./sysroot/pkg-build -nt ./sysroot/system-root]]; then - warn "mkimage: pkg-build is newer than system-root, run `xbstrap install --all`" +function newest_file() { + local latest file + for file; do + [[ $file && $file -nt $latest ]] || latest=$file + done +} + +function has_newer_files_than() { + [[ "$(newest_file "$1"/*)" -nt "$(newest_file "$2" "$2"/*)" ]] +} + +# check if the packages directory is not newer than the system-root +if has_newer_files_than "./sysroot/packages" "./system/system-root"; then + warn "\`./sysroot/packages\` is newer than \`./sysroot/system-root\`, run \`xbstrap install --all\`" exit 1 fi diff --git a/userland/tests/test.cc b/userland/tests/test.cc new file mode 100644 index 00000000000..e7a01c6b7f8 --- /dev/null +++ b/userland/tests/test.cc @@ -0,0 +1,619 @@ +// clang-format off +// +// xbstrap runtool host-gcc -- x86_64-aero-g++ ../userland/tests/test.cc -o system-root/torture + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NAMED_PATH "/tmp/sockname" + +#define DEFINE_TEST(s, f) static test_case test_##s{#s, f}; + +struct abstract_test_case { +private: + static void register_case(abstract_test_case *tcp); + +public: + abstract_test_case(const char *name) : name_{name} { register_case(this); } + + abstract_test_case(const abstract_test_case &) = delete; + + virtual ~abstract_test_case() = default; + + abstract_test_case &operator=(const abstract_test_case &) = delete; + + const char *name() { return name_; } + + virtual void run() = 0; + +private: + const char *name_; +}; + +template struct test_case : abstract_test_case { + test_case(const char *name, F functor) + : abstract_test_case{name}, functor_{std::move(functor)} {} + + void run() override { functor_(); } + +private: + F functor_; +}; + +#define clean_errno() (errno == 0 ? "None" : strerror(errno)) + +#define log_error(M, ...) \ + fprintf(stderr, "[ERROR] %s:%d: errno: %s) " M "\n", __FILE__, __LINE__, \ + clean_errno(), ##__VA_ARGS__) + +#define assertf(A, M, ...) \ + if (!(A)) { \ + log_error(M, ##__VA_ARGS__); \ + assert(A); \ + } + + +#define PAGE_SIZE 4096 + +void enable_systrace() { +#define SYS_TRACE 71 + long ret; + asm volatile("syscall" : "=a"(ret) : "a"(SYS_TRACE) : "rcx", "r11", "memory"); +} + +#define assert_errno(fail_func, expr) ((void)(((expr) ? 1 : 0) || (assert_errno_fail(fail_func, #expr, __FILE__, __PRETTY_FUNCTION__, __LINE__), 0))) + +inline void assert_errno_fail(const char *fail_func, const char *expr, + const char *file, const char *func, int line) { + int err = errno; + fprintf(stderr, "In function %s, file %s:%d: Function %s failed with error '%s'; failing assertion: '%s'\n", + func, file, line, fail_func, strerror(err), expr); + abort(); + __builtin_unreachable(); +} + +DEFINE_TEST(unix_getname, ([] { + int server_fd = socket(AF_UNIX, SOCK_STREAM, 0); + if(server_fd == -1) + assert(!"server socket() failed"); + + struct sockaddr_un server_addr; + memset(&server_addr, 0, sizeof(struct sockaddr_un)); + server_addr.sun_family = AF_UNIX; + strncpy(server_addr.sun_path, NAMED_PATH, sizeof(server_addr.sun_path) - 1); + + if(bind(server_fd, (struct sockaddr *)&server_addr, sizeof(struct sockaddr_un))) + assert(!"bind() failed"); + if(listen(server_fd, 50)) + assert(!"listen() failed"); + + pid_t child = fork(); + if(!child) { + int client_fd = socket(AF_UNIX, SOCK_STREAM, 0); + if(client_fd == -1) + assert(!"client socket() failed"); + if(connect(client_fd, (struct sockaddr *)&server_addr, sizeof(struct sockaddr_un))) + assert(!"connect() to server failed"); + + char buf[1]; + if (recv(client_fd, buf, 1, 0) < 0) + assert(!"recv() failed"); + exit(0); + } else { + int peer_fd = accept(server_fd, nullptr, nullptr); + if(peer_fd == -1) + assert(!"accept() failed"); + + struct sockaddr_un peer_addr; + socklen_t peer_length = sizeof(struct sockaddr_un); + if(getsockname(server_fd, (struct sockaddr *)&peer_addr, &peer_length)) + assert(!"getsockname(server) failed"); + assert(peer_length == (offsetof(sockaddr_un, sun_path) + 14)); + assert(!strcmp(peer_addr.sun_path, NAMED_PATH)); + + memset(&peer_addr, 0, sizeof(struct sockaddr)); + peer_length = sizeof(struct sockaddr_un); + if(getsockname(peer_fd, (struct sockaddr *)&peer_addr, &peer_length)) + assert(!"getsockname(peer) failed"); + assert(peer_length == (offsetof(sockaddr_un, sun_path) + 14)); + assert(!strcmp(peer_addr.sun_path, NAMED_PATH)); + + memset(&peer_addr, 0, sizeof(struct sockaddr)); + peer_length = sizeof(struct sockaddr_un); + if(getpeername(peer_fd, (struct sockaddr *)&peer_addr, &peer_length)) + assert(!"getpeername(peer) failed"); + assert(peer_length == offsetof(sockaddr_un, sun_path)); + + char buf[1]{0}; + if (send(peer_fd, buf, 1, 0) < 0) + assert(!"send() failed"); + } + unlink(NAMED_PATH); +})); + +DEFINE_TEST(epoll_mod_active, ([] { + int e; + int pending; + + int fd = eventfd(0, 0); + assert(fd >= 0); + + int epfd = epoll_create1(0); + assert(epfd >= 0); + + epoll_event evt; + + memset(&evt, 0, sizeof(epoll_event)); + evt.events = 0; + e = epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &evt); + assert(!e); + + // Nothing should be pending. + memset(&evt, 0, sizeof(epoll_event)); + pending = epoll_wait(epfd, &evt, 1, 0); + assert(!pending); + + uint64_t n = 1; + auto written = write(fd, &n, sizeof(uint64_t)); + assert(written == sizeof(uint64_t)); + + memset(&evt, 0, sizeof(epoll_event)); + evt.events = EPOLLIN; + e = epoll_ctl(epfd, EPOLL_CTL_MOD, fd, &evt); + assert(!e); + + // The FD should be pending now. + memset(&evt, 0, sizeof(epoll_event)); + pending = epoll_wait(epfd, &evt, 1, 0); + assert(pending == 1); + assert(evt.events & EPOLLIN); + + close(epfd); + close(fd); +})) + +// Use mmap to change the protection flags instead of mprotect. +DEFINE_TEST(mmap_partial_remap, ([] { + enable_systrace(); + + const int bytes = PAGE_SIZE * 2; + + void *result = mmap(nullptr, bytes, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + assert(result != MAP_FAILED); + + void *x = mmap(result, PAGE_SIZE, PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0); + assert(x != MAP_FAILED); + + void *y = mmap(static_cast(result) + bytes - PAGE_SIZE, PAGE_SIZE, PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0); + assert(y != MAP_FAILED); +})) + +namespace { + void *offsetBy(void *ptr, ptrdiff_t n) { + return reinterpret_cast( + reinterpret_cast(ptr) + + n); + } + + sigjmp_buf restoreEnv; + + void signalHandler(int, siginfo_t *, void *) { + siglongjmp(restoreEnv, 1); + } + + bool ensureReadable(void *ptr) { + if (sigsetjmp(restoreEnv, 1)) { + return false; + } + + (void)(*reinterpret_cast(ptr)); + + return true; + } + + bool ensureWritable(void *ptr) { + if (sigsetjmp(restoreEnv, 1)) { + return false; + } + + *reinterpret_cast(ptr) = 0; + + return true; + } + + bool ensureNotReadable(void *ptr) { + if (sigsetjmp(restoreEnv, 1)) { + return true; + } + + (void)(*reinterpret_cast(ptr)); + + return false; + } + + bool ensureNotWritable(void *ptr) { + if (sigsetjmp(restoreEnv, 1)) { + return true; + } + + *reinterpret_cast(ptr) = 0; + + return false; + } + + template + void runChecks(Func &&f) { + // pid_t pid = fork(); + // assert_errno("fork", pid >= 0); + + // struct sigaction sa, old_sa; + // sigemptyset(&sa.sa_mask); + // sa.sa_sigaction = signalHandler; + // sa.sa_flags = SA_SIGINFO; + + // int ret = sigaction(SIGSEGV, &sa, &old_sa); + // assert_errno("sigaction", ret != -1); + + // if (pid == 0) { + // f(); + // exit(0); + // } else { + // int status = 0; + // while (waitpid(pid, &status, 0) == -1) { + // if (errno == EINTR) continue; + // assert_errno("waitpid", false); + // } + + // if (WIFSIGNALED(status) || WEXITSTATUS(status) != 0) { + // fprintf(stderr, "Test failed on subprocess!\n"); + // abort(); + // } + + // f(); + // } + + // ret = sigaction(SIGSEGV, &old_sa, nullptr); + // assert_errno("sigaction", ret != -1); + } + + const size_t pageSize = sysconf(_SC_PAGESIZE); +} // namespace anonymous + +DEFINE_TEST(mmap_fixed_replace_middle, ([] { + void *mem = mmap(nullptr, pageSize * 3, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + assert_errno("mmap", mem != MAP_FAILED); + + void *newPtr = mmap(offsetBy(mem, pageSize), pageSize, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + assert_errno("mmap", newPtr != MAP_FAILED); + assert(newPtr == offsetBy(mem, pageSize)); + + runChecks([&] { + assert(ensureReadable(mem)); + assert(ensureWritable(mem)); + + assert(ensureReadable(offsetBy(mem, pageSize))); + assert(ensureNotWritable(offsetBy(mem, pageSize))); + + assert(ensureReadable(offsetBy(mem, pageSize * 2))); + assert(ensureWritable(offsetBy(mem, pageSize * 2))); + }); + + int ret = munmap(mem, pageSize * 3); + assert_errno("munmap", ret != -1); + + runChecks([&] { + assert(ensureNotReadable(mem)); + assert(ensureNotWritable(mem)); + + assert(ensureNotReadable(offsetBy(mem, pageSize))); + assert(ensureNotWritable(offsetBy(mem, pageSize))); + + assert(ensureNotReadable(offsetBy(mem, pageSize * 2))); + assert(ensureNotWritable(offsetBy(mem, pageSize * 2))); + }); +})) + +DEFINE_TEST(mmap_fixed_replace_left, ([] { + void *mem = mmap(nullptr, pageSize * 2, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + assert_errno("mmap", mem != MAP_FAILED); + + void *newPtr = mmap(mem, pageSize, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + assert_errno("mmap", newPtr != MAP_FAILED); + assert(newPtr == mem); + + runChecks([&] { + assert(ensureReadable(mem)); + assert(ensureNotWritable(mem)); + + assert(ensureReadable(offsetBy(mem, pageSize))); + assert(ensureWritable(offsetBy(mem, pageSize))); + }); + + int ret = munmap(mem, pageSize * 2); + assert_errno("munmap", ret != -1); + + runChecks([&] { + assert(ensureNotReadable(mem)); + assert(ensureNotWritable(mem)); + + assert(ensureNotReadable(offsetBy(mem, pageSize))); + assert(ensureNotWritable(offsetBy(mem, pageSize))); + }); +})) + +DEFINE_TEST(mmap_fixed_replace_right, ([] { + void *mem = mmap(nullptr, pageSize * 2, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + assert_errno("mmap", mem != MAP_FAILED); + + void *newPtr = mmap(offsetBy(mem, pageSize), pageSize, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED, -1, 0); + assert_errno("mmap", newPtr != MAP_FAILED); + assert(newPtr == offsetBy(mem, pageSize)); + + runChecks([&] { + assert(ensureReadable(mem)); + assert(ensureWritable(mem)); + + assert(ensureReadable(offsetBy(mem, pageSize))); + assert(ensureNotWritable(offsetBy(mem, pageSize))); + }); + + int ret = munmap(mem, pageSize * 2); + assert_errno("munmap", ret != -1); + + runChecks([&] { + assert(ensureNotReadable(mem)); + assert(ensureNotWritable(mem)); + + assert(ensureNotReadable(offsetBy(mem, pageSize))); + assert(ensureNotWritable(offsetBy(mem, pageSize))); + }); +})) + +DEFINE_TEST(mmap_partial_protect_middle, ([] { + void *mem = mmap(nullptr, pageSize * 3, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + assert_errno("mmap", mem != MAP_FAILED); + + int ret = mprotect(offsetBy(mem, pageSize), pageSize, PROT_READ); + assert_errno("mprotect", ret != -1); + + runChecks([&] { + assert(ensureReadable(mem)); + assert(ensureWritable(mem)); + + assert(ensureReadable(offsetBy(mem, pageSize))); + assert(ensureNotWritable(offsetBy(mem, pageSize))); + + assert(ensureReadable(offsetBy(mem, pageSize * 2))); + assert(ensureWritable(offsetBy(mem, pageSize * 2))); + }); + + ret = munmap(mem, pageSize * 3); + assert_errno("munmap", ret != -1); + + runChecks([&] { + assert(ensureNotReadable(mem)); + assert(ensureNotWritable(mem)); + + assert(ensureNotReadable(offsetBy(mem, pageSize))); + assert(ensureNotWritable(offsetBy(mem, pageSize))); + + assert(ensureNotReadable(offsetBy(mem, pageSize * 2))); + assert(ensureNotWritable(offsetBy(mem, pageSize * 2))); + }); +})) + +DEFINE_TEST(mmap_partial_protect_left, ([] { + void *mem = mmap(nullptr, pageSize * 2, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + assert_errno("mmap", mem != MAP_FAILED); + + int ret = mprotect(mem, pageSize, PROT_READ); + assert_errno("mprotect", ret != -1); + + runChecks([&] { + assert(ensureReadable(mem)); + assert(ensureNotWritable(mem)); + + assert(ensureReadable(offsetBy(mem, pageSize))); + assert(ensureWritable(offsetBy(mem, pageSize))); + }); + + ret = munmap(mem, pageSize * 2); + assert_errno("munmap", ret != -1); + + runChecks([&] { + assert(ensureNotReadable(mem)); + assert(ensureNotWritable(mem)); + + assert(ensureNotReadable(offsetBy(mem, pageSize))); + assert(ensureNotWritable(offsetBy(mem, pageSize))); + }); +})) + +DEFINE_TEST(mmap_partial_protect_right, ([] { + void *mem = mmap(nullptr, pageSize * 2, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + assert_errno("mmap", mem != MAP_FAILED); + + int ret = mprotect(offsetBy(mem, pageSize), pageSize, PROT_READ); + assert_errno("mprotect", ret != -1); + + runChecks([&] { + assert(ensureReadable(mem)); + assert(ensureWritable(mem)); + + assert(ensureReadable(offsetBy(mem, pageSize))); + assert(ensureNotWritable(offsetBy(mem, pageSize))); + }); + + ret = munmap(mem, pageSize * 2); + assert_errno("munmap", ret != -1); + + runChecks([&] { + assert(ensureNotReadable(mem)); + assert(ensureNotWritable(mem)); + + assert(ensureNotReadable(offsetBy(mem, pageSize))); + assert(ensureNotWritable(offsetBy(mem, pageSize))); + }); +})) + +DEFINE_TEST(mmap_partial_unmap_middle, ([] { + void *mem = mmap(nullptr, pageSize * 3, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + assert_errno("mmap", mem != MAP_FAILED); + + int ret = munmap(offsetBy(mem, pageSize), pageSize); + assert_errno("munmap", ret != -1); + + runChecks([&] { + assert(ensureReadable(mem)); + assert(ensureWritable(mem)); + + assert(ensureNotReadable(offsetBy(mem, pageSize))); + assert(ensureNotWritable(offsetBy(mem, pageSize))); + + assert(ensureReadable(offsetBy(mem, pageSize * 2))); + assert(ensureWritable(offsetBy(mem, pageSize * 2))); + }); + + ret = munmap(mem, pageSize * 3); + assert_errno("munmap", ret != -1); + + runChecks([&] { + assert(ensureNotReadable(mem)); + assert(ensureNotWritable(mem)); + + assert(ensureNotReadable(offsetBy(mem, pageSize))); + assert(ensureNotWritable(offsetBy(mem, pageSize))); + + assert(ensureNotReadable(offsetBy(mem, pageSize * 2))); + assert(ensureNotWritable(offsetBy(mem, pageSize * 2))); + }); +})) + +DEFINE_TEST(mmap_partial_unmap_left, ([] { + void *mem = mmap(nullptr, pageSize * 2, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + assert_errno("mmap", mem != MAP_FAILED); + + int ret = munmap(mem, pageSize); + assert_errno("munmap", ret != -1); + + runChecks([&] { + assert(ensureNotReadable(mem)); + assert(ensureNotWritable(mem)); + + assert(ensureReadable(offsetBy(mem, pageSize))); + assert(ensureWritable(offsetBy(mem, pageSize))); + }); + + ret = munmap(mem, pageSize * 2); + assert_errno("munmap", ret != -1); + + runChecks([&] { + assert(ensureNotReadable(mem)); + assert(ensureNotWritable(mem)); + + assert(ensureNotReadable(offsetBy(mem, pageSize))); + assert(ensureNotWritable(offsetBy(mem, pageSize))); + }); +})) + +DEFINE_TEST(mmap_partial_unmap_right, ([] { + void *mem = mmap(nullptr, pageSize * 2, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + assert_errno("mmap", mem != MAP_FAILED); + + int ret = munmap(offsetBy(mem, pageSize), pageSize); + assert_errno("munmap", ret != -1); + + runChecks([&] { + assert(ensureReadable(mem)); + assert(ensureWritable(mem)); + + assert(ensureNotReadable(offsetBy(mem, pageSize))); + assert(ensureNotWritable(offsetBy(mem, pageSize))); + }); + + ret = munmap(mem, pageSize * 2); + assert_errno("munmap", ret != -1); + + runChecks([&] { + assert(ensureNotReadable(mem)); + assert(ensureNotWritable(mem)); + + assert(ensureNotReadable(offsetBy(mem, pageSize))); + assert(ensureNotWritable(offsetBy(mem, pageSize))); + }); +})) + +DEFINE_TEST(mmap_unmap_range_before_first, ([] { + void *mem = mmap(reinterpret_cast(0x100000 + pageSize * 2), pageSize, + PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + assert_errno("mmap", mem != MAP_FAILED); + + int ret = munmap(reinterpret_cast(0x100000 + pageSize), pageSize * 2); + assert_errno("munmap", ret != -1); + + runChecks([&] { + assert(ensureNotReadable(mem)); + assert(ensureNotWritable(mem)); + }); +})) + +DEFINE_TEST(mprotect_check_whether_split_mappings_get_protected_correctly, ([] { + void *mem = mmap(NULL, 0x6000, PROT_READ | PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + assert_errno("mmap", mem != MAP_FAILED); + int ret = mprotect(mem, 0x1000, PROT_READ | PROT_WRITE); + assert_errno("mprotect", ret != -1); + ret = mprotect(mem, 0x1000, PROT_READ | PROT_EXEC); + assert_errno("mprotect", ret != -1); + ret = mprotect(mem, 0x5000, PROT_READ | PROT_WRITE); + assert_errno("mprotect", ret != -1); + + runChecks([&] { + assert(ensureWritable(mem)); + }); +})) + +DEFINE_TEST(mprotect_check_whether_three_way_split_mappings_are_handled_correctly, ([] { + void *mem = mmap(NULL, pageSize * 3, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + assert_errno("mmap", mem != MAP_FAILED); + int ret = mprotect(offsetBy(mem, pageSize), pageSize, PROT_READ | PROT_WRITE); + assert_errno("mprotect", ret != -1); + + runChecks([&] { + assert(ensureNotWritable(mem)); + assert(ensureWritable(offsetBy(mem, pageSize))); + assert(ensureNotWritable(offsetBy(mem, pageSize * 2))); + }); +})) + +std::vector &test_case_ptrs() { + static std::vector singleton; + return singleton; +} + +void abstract_test_case::register_case(abstract_test_case *tcp) { + test_case_ptrs().push_back(tcp); +} + +int main() { + // Go through all tests and run them. + for(abstract_test_case *tcp : test_case_ptrs()) { + std::cout << "tests: Running " << tcp->name() << std::endl; + tcp->run(); + } +} diff --git a/userland/tests/unix_sock.cc b/userland/tests/unix_sock.cc deleted file mode 100644 index 3730799bf48..00000000000 --- a/userland/tests/unix_sock.cc +++ /dev/null @@ -1,142 +0,0 @@ -// test copied from managarm - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define NAMED_PATH "/tmp/sockname" - -#define DEFINE_TEST(s, f) static test_case test_##s{#s, f}; - -struct abstract_test_case { -private: - static void register_case(abstract_test_case *tcp); - -public: - abstract_test_case(const char *name) : name_{name} { register_case(this); } - - abstract_test_case(const abstract_test_case &) = delete; - - virtual ~abstract_test_case() = default; - - abstract_test_case &operator=(const abstract_test_case &) = delete; - - const char *name() { return name_; } - - virtual void run() = 0; - -private: - const char *name_; -}; - -template struct test_case : abstract_test_case { - test_case(const char *name, F functor) - : abstract_test_case{name}, functor_{std::move(functor)} {} - - void run() override { functor_(); } - -private: - F functor_; -}; - -#define clean_errno() (errno == 0 ? "None" : strerror(errno)) - -#define log_error(M, ...) \ - fprintf(stderr, "[ERROR] %s:%d: errno: %s) " M "\n", __FILE__, __LINE__, \ - clean_errno(), ##__VA_ARGS__) - -#define assertf(A, M, ...) \ - if (!(A)) { \ - log_error(M, ##__VA_ARGS__); \ - assert(A); \ - } - -// clang-format off -DEFINE_TEST(unix_getname, ([] { - int server_fd = socket(AF_UNIX, SOCK_STREAM, 0); - if(server_fd == -1) - assert(!"server socket() failed"); - - struct sockaddr_un server_addr; - memset(&server_addr, 0, sizeof(struct sockaddr_un)); - server_addr.sun_family = AF_UNIX; - strncpy(server_addr.sun_path, NAMED_PATH, sizeof(server_addr.sun_path) - 1); - - if(bind(server_fd, (struct sockaddr *)&server_addr, sizeof(struct sockaddr_un))) - assert(!"bind() failed"); - if(listen(server_fd, 50)) - assert(!"listen() failed"); - - pid_t child = fork(); - if(!child) { - int client_fd = socket(AF_UNIX, SOCK_STREAM, 0); - if(client_fd == -1) - assert(!"client socket() failed"); - if(connect(client_fd, (struct sockaddr *)&server_addr, sizeof(struct sockaddr_un))) - assert(!"connect() to server failed"); - - char buf[1]; - if (recv(client_fd, buf, 1, 0) < 0) - assert(!"recv() failed"); - exit(0); - } else { - int peer_fd = accept(server_fd, nullptr, nullptr); - if(peer_fd == -1) - assert(!"accept() failed"); - - struct sockaddr_un peer_addr; - socklen_t peer_length = sizeof(struct sockaddr_un); - if(getsockname(server_fd, (struct sockaddr *)&peer_addr, &peer_length)) - assert(!"getsockname(server) failed"); - assert(peer_length == (offsetof(sockaddr_un, sun_path) + 14)); - assert(!strcmp(peer_addr.sun_path, NAMED_PATH)); - - memset(&peer_addr, 0, sizeof(struct sockaddr)); - peer_length = sizeof(struct sockaddr_un); - if(getsockname(peer_fd, (struct sockaddr *)&peer_addr, &peer_length)) - assert(!"getsockname(peer) failed"); - printf("peer_len=%d\n", peer_length); - printf("wanted=%d\n", offsetof(sockaddr_un, sun_path) + 14); - assert(peer_length == (offsetof(sockaddr_un, sun_path) + 14)); - assert(!strcmp(peer_addr.sun_path, NAMED_PATH)); - - memset(&peer_addr, 0, sizeof(struct sockaddr)); - peer_length = sizeof(struct sockaddr_un); - if(getpeername(peer_fd, (struct sockaddr *)&peer_addr, &peer_length)) - assert(!"getpeername(peer) failed"); - printf("peer_len=%d\n", peer_length); - printf("wanted=%d\n", offsetof(sockaddr_un, sun_path) ); - assert(peer_length == offsetof(sockaddr_un, sun_path)); - - char buf[1]{0}; - if (send(peer_fd, buf, 1, 0) < 0) - assert(!"send() failed"); - } - unlink(NAMED_PATH); -})); - -std::vector &test_case_ptrs() { - static std::vector singleton; - return singleton; -} - -void abstract_test_case::register_case(abstract_test_case *tcp) { - test_case_ptrs().push_back(tcp); -} - -int main() { - // Go through all tests and run them. - for(abstract_test_case *tcp : test_case_ptrs()) { - std::cout << "tests: Running " << tcp->name() << std::endl; - tcp->run(); - } -} \ No newline at end of file From ee33d34a5aa952f690e29ab07772960371a050c5 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 3 Nov 2023 19:36:39 +1100 Subject: [PATCH 018/112] misc: minor pty fixes Signed-off-by: Anhad Singh --- aero.py | 11 ++- src/aero_kernel/src/drivers/gdbstub.rs | 4 + src/aero_kernel/src/drivers/mod.rs | 2 + src/aero_kernel/src/drivers/pty.rs | 93 ++++++++++-------------- src/aero_kernel/src/fs/file_table.rs | 2 - src/aero_kernel/src/mem/mod.rs | 2 - src/aero_kernel/src/mem/paging/mod.rs | 2 +- src/aero_kernel/src/userland/terminal.rs | 84 +++++++++++++++++++-- src/aero_syscall/src/lib.rs | 1 + userland/tests/getchar.cc | 18 +++++ 10 files changed, 149 insertions(+), 70 deletions(-) create mode 100644 src/aero_kernel/src/drivers/gdbstub.rs create mode 100644 userland/tests/getchar.cc diff --git a/aero.py b/aero.py index 8dfee005dbc..48a7af35540 100755 --- a/aero.py +++ b/aero.py @@ -24,11 +24,8 @@ import shutil import subprocess import sys -import tarfile import time -from typing import List - def log_info(msg): """ @@ -598,6 +595,14 @@ def main(): run_command(['cargo', 'fmt'], cwd="src") return + if os.path.exists(BUILD_DIR): + system_root = os.path.join(SYSROOT_DIR, 'system-root') + sysroot_mod = max(os.path.getmtime(os.path.join(system_root, file)) for file in os.listdir(system_root)) + build_mod = os.path.getmtime(BUILD_DIR) + if sysroot_mod > build_mod: + log_info("sysroot modified, rebuilding") + os.rmdir(BUILD_DIR) + t0 = time.time() # arch-aero_os target_arch = args.target.split('-')[0] diff --git a/src/aero_kernel/src/drivers/gdbstub.rs b/src/aero_kernel/src/drivers/gdbstub.rs new file mode 100644 index 00000000000..1e82aea22b1 --- /dev/null +++ b/src/aero_kernel/src/drivers/gdbstub.rs @@ -0,0 +1,4 @@ +// TODO: Is it worth adding a GDB stub to facilitate userland debugging? +pub fn init() {} + +crate::module_init!(init, ModuleType::Other); diff --git a/src/aero_kernel/src/drivers/mod.rs b/src/aero_kernel/src/drivers/mod.rs index 795bdb8985d..7d11c0bb4c0 100644 --- a/src/aero_kernel/src/drivers/mod.rs +++ b/src/aero_kernel/src/drivers/mod.rs @@ -27,6 +27,8 @@ pub mod keyboard; pub mod lai; // FIXME: aarch64 port pub mod e1000; +// #[cfg(feature = "gdbstub")] +pub mod gdbstub; pub mod mouse; #[cfg(target_arch = "x86_64")] pub mod pci; diff --git a/src/aero_kernel/src/drivers/pty.rs b/src/aero_kernel/src/drivers/pty.rs index 790765d49b4..40e0741ba70 100644 --- a/src/aero_kernel/src/drivers/pty.rs +++ b/src/aero_kernel/src/drivers/pty.rs @@ -35,7 +35,7 @@ use crate::mem::paging::VirtAddr; use crate::userland::scheduler; use crate::userland::scheduler::ExitStatus; use crate::userland::task::Task; -use crate::userland::terminal::{LineDiscipline, TerminalDevice}; +use crate::userland::terminal::{LineControl, LineDiscipline, TerminalDevice}; use crate::utils::sync::{Mutex, WaitQueue}; lazy_static::lazy_static! { @@ -50,8 +50,6 @@ struct Master { wq: WaitQueue, window_size: Mutex, buffer: Mutex>, - termios: Mutex, - discipline: LineDiscipline, } @@ -59,51 +57,14 @@ impl Master { pub fn new() -> Self { use aero_syscall::*; - // converts `^X` into `X` - let ctrl = |c| (c as u8 - 0x40); - - let mut termios = Termios { - c_iflag: aero_syscall::TermiosIFlag::empty(), - c_oflag: aero_syscall::TermiosOFlag::ONLCR, - c_cflag: aero_syscall::TermiosCFlag::empty(), - c_lflag: TermiosLFlag::ECHOKE - | TermiosLFlag::ECHOE - | TermiosLFlag::ECHOK - | TermiosLFlag::ECHO - | TermiosLFlag::ECHOCTL - | TermiosLFlag::ISIG - | TermiosLFlag::ICANON - | TermiosLFlag::IEXTEN, - c_line: 0, - c_cc: [0; 32], - c_ispeed: 0, - c_ospeed: 0, - }; - - termios.c_cc[VINTR] = ctrl('C'); - termios.c_cc[VQUIT] = ctrl('\\'); - termios.c_cc[VERASE] = 127; // DEL character - termios.c_cc[VKILL] = ctrl('U'); - termios.c_cc[VEOF] = ctrl('D'); - termios.c_cc[VMIN] = 1; - termios.c_cc[VSTART] = ctrl('Q'); - termios.c_cc[VSTOP] = ctrl('S'); - termios.c_cc[VSUSP] = ctrl('Z'); - Self { id: PTY_ID.fetch_add(1, Ordering::SeqCst), wq: WaitQueue::new(), window_size: Mutex::new(WinSize::default()), buffer: Mutex::new(Vec::new()), - termios: Mutex::new(termios), - discipline: LineDiscipline::new(), } } - - pub fn is_cooked(&self) -> bool { - self.termios.lock_irq().is_cooked() - } } impl INodeInterface for Master { @@ -120,7 +81,10 @@ impl INodeInterface for Master { } fn write_at(&self, _offset: usize, buffer: &[u8]) -> fs::Result { - self.discipline.write(buffer); + self.discipline.write(buffer, |ctrl| match ctrl { + LineControl::Echo(c) => self.buffer.lock_irq().push(c), + }); + self.wq.notify_all(); Ok(buffer.len()) } @@ -150,7 +114,7 @@ impl INodeInterface for Master { } _ => { - log::warn!("ptmx: unknown ioctl (command={command:#x})") + panic!("ptmx: unknown ioctl (command={command:#x})") } } @@ -168,13 +132,13 @@ impl TerminalDevice for Slave { use aero_syscall::signal::*; use aero_syscall::*; - if !self.master.is_cooked() { + if !self.master.discipline.termios.lock().is_cooked() { return; } if let ExitStatus::Signal(signo) = task.exit_status() { let mut buffer = self.master.buffer.lock_irq(); - let termios = self.master.termios.lock_irq(); + let termios = self.master.discipline.termios.lock(); // converts `X` into `^X` and pushes the result into the master PTY buffer. let mut ctrl = |c| { @@ -208,12 +172,7 @@ impl Slave { impl INodeInterface for Slave { fn metadata(&self) -> fs::Result { - Ok(fs::inode::Metadata { - id: 0, - file_type: FileType::Device, - children_len: 0, - size: 0, - }) + Ok(fs::inode::Metadata::with_file_type(FileType::Device)) } fn stat(&self) -> fs::Result { @@ -229,16 +188,32 @@ impl INodeInterface for Slave { Ok(0) } + aero_syscall::TIOCSWINSZ => { + *self.master.window_size.lock_irq() = *VirtAddr::new(arg as u64).read_mut()?; + Ok(0) + } + aero_syscall::TCGETS => { let termios = VirtAddr::new(arg as u64).read_mut::()?; - *termios = *self.master.termios.lock_irq(); + *termios = self.master.discipline.termios(); Ok(0) } aero_syscall::TCSETSF => { let termios = VirtAddr::new(arg as u64).read_mut::()?; - *self.master.termios.lock_irq() = *termios; + self.master.discipline.set_termios(termios.clone()); + + Ok(0) + } + + aero_syscall::TCSETSW => { + // TODO: Allow the output buffer to drain and then set the current serial port + // settings. + // + // Equivalent to tcsetattr(fd, TCSADRAIN, argp). + let termios = VirtAddr::new(arg as u64).read_mut::()?; + self.master.discipline.set_termios(termios.clone()); Ok(0) } @@ -251,7 +226,11 @@ impl INodeInterface for Slave { Ok(0) } - _ => Err(FileSystemError::NotSupported), + // TIOCGPGRP - Get the process group ID of the foreground process group on this + // terminal. + 0x540f => Err(FileSystemError::NotSupported), + + _ => panic!("pty: unknown ioctl: {command}"), } } @@ -271,14 +250,16 @@ impl INodeInterface for Slave { } fn read_at(&self, _offset: usize, buffer: &mut [u8]) -> fs::Result { - Ok(self.master.discipline.read(buffer)?) + let x = self.master.discipline.read(buffer)?; + dbg!(core::str::from_utf8(&buffer[..x])); + Ok(x) } fn write_at(&self, _offset: usize, buffer: &[u8]) -> fs::Result { if self .master - .termios - .lock_irq() + .discipline + .termios() .c_oflag .contains(aero_syscall::TermiosOFlag::ONLCR) { diff --git a/src/aero_kernel/src/fs/file_table.rs b/src/aero_kernel/src/fs/file_table.rs index e1cbb04ef88..66ac73890a9 100644 --- a/src/aero_kernel/src/fs/file_table.rs +++ b/src/aero_kernel/src/fs/file_table.rs @@ -302,8 +302,6 @@ impl FileTable { let files = self.0.read(); for handle in files.iter().flatten() { - let flags = *handle.flags.read(); - handle .inode .inode() diff --git a/src/aero_kernel/src/mem/mod.rs b/src/aero_kernel/src/mem/mod.rs index ba75081a434..cde30ef70d0 100644 --- a/src/aero_kernel/src/mem/mod.rs +++ b/src/aero_kernel/src/mem/mod.rs @@ -21,8 +21,6 @@ pub mod pti; mod slab; mod vmalloc; -use core::alloc::Layout; - use ::alloc::boxed::Box; use crate::mem::paging::*; diff --git a/src/aero_kernel/src/mem/paging/mod.rs b/src/aero_kernel/src/mem/paging/mod.rs index 2733b5ffc88..64857cfd5b7 100644 --- a/src/aero_kernel/src/mem/paging/mod.rs +++ b/src/aero_kernel/src/mem/paging/mod.rs @@ -23,7 +23,7 @@ mod page_table; pub use self::addr::*; pub use self::frame::*; -pub use self::mapper::{MapperFlush, *}; +pub use self::mapper::*; pub use self::page::*; pub use self::page_table::*; diff --git a/src/aero_kernel/src/userland/terminal.rs b/src/aero_kernel/src/userland/terminal.rs index 18527995dc4..899e69b0061 100644 --- a/src/aero_kernel/src/userland/terminal.rs +++ b/src/aero_kernel/src/userland/terminal.rs @@ -15,7 +15,7 @@ // You should have received a copy of the GNU General Public License // along with Aero. If not, see . -use aero_syscall::signal; +use aero_syscall::{signal, Termios, TermiosIFlag, TermiosLFlag}; use alloc::sync::{Arc, Weak}; use alloc::vec::Vec; @@ -40,6 +40,11 @@ pub trait TerminalDevice: Send + Sync + INodeInterface { fn detach(&self, task: Arc); } +#[derive(Debug, Copy, Clone)] +pub enum LineControl { + Echo(u8), +} + /// Line Discipline /// /// The middle terminal subsystem layer, used to implement behavior common to terminal devices. @@ -51,21 +56,66 @@ pub struct LineDiscipline { wq: WaitQueue, buffer: Mutex>, foreground: RwLock>, + // TODO: Make this private. + pub termios: Mutex, } impl LineDiscipline { /// Creates a new line discipline. pub fn new() -> Self { + use aero_syscall::{TermiosCFlag, TermiosOFlag}; + + // converts `^X` into `X` + let ctrl = |c| (c as u8 - 0x40); + + let mut termios = Termios { + c_iflag: TermiosIFlag::ICRNL | TermiosIFlag::IXON, + c_oflag: TermiosOFlag::OPOST | TermiosOFlag::ONLCR, + c_cflag: TermiosCFlag::CS6 | TermiosCFlag::CS7 | TermiosCFlag::CREAD, + c_lflag: TermiosLFlag::ECHOKE + | TermiosLFlag::ECHOE + | TermiosLFlag::ECHOK + | TermiosLFlag::ECHO + | TermiosLFlag::ECHOCTL + | TermiosLFlag::ISIG + | TermiosLFlag::ICANON + | TermiosLFlag::IEXTEN, + c_line: 0, + c_cc: [0; 32], + c_ispeed: 0, + c_ospeed: 0, + }; + + termios.c_cc[aero_syscall::VINTR] = ctrl('C'); + termios.c_cc[aero_syscall::VQUIT] = ctrl('\\'); + termios.c_cc[aero_syscall::VERASE] = 127; // DEL character + termios.c_cc[aero_syscall::VKILL] = ctrl('U'); + termios.c_cc[aero_syscall::VEOF] = ctrl('D'); + termios.c_cc[aero_syscall::VMIN] = 1; + termios.c_cc[aero_syscall::VSTART] = ctrl('Q'); + termios.c_cc[aero_syscall::VSTOP] = ctrl('S'); + termios.c_cc[aero_syscall::VSUSP] = ctrl('Z'); + Self { wq: WaitQueue::new(), buffer: Mutex::new(Vec::new()), foreground: RwLock::new(Weak::default()), + termios: Mutex::new(termios), } } - /// Reads data from the line discipline buffer. + #[inline] + pub fn termios(&self) -> Termios { + self.termios.lock().clone() + } + + #[inline] + pub fn set_termios(&self, termios: Termios) { + *self.termios.lock() = termios; + } + pub fn read(&self, target: &mut [u8]) -> Result { - let mut buffer = self.wq.block_on(&self.buffer, |e| !e.is_empty())?; + let mut buffer = self.wq.block_on(&self.buffer, |buf| !buf.is_empty())?; let size = core::cmp::min(target.len(), buffer.len()); target[..size].copy_from_slice(&buffer.drain(..size).collect::>()); @@ -73,19 +123,41 @@ impl LineDiscipline { Ok(size) } - /// Writes data to the line discipline buffer. - pub fn write(&self, target: &[u8]) { + pub fn write(&self, target: &[u8], callback: F) + where + F: Fn(LineControl), + { let mut buffer = self.buffer.lock_irq(); + let termios = self.termios.lock(); + let should_echo = termios.c_lflag.contains(TermiosLFlag::ECHO); for byte in target { match byte { // ETX: End of Text (`Ctrl+C`) - 0x3 => { + 0x3 if termios.is_cooked() => { if let Some(foreground) = self.foreground() { foreground.signal(signal::SIGINT); } } + b'\r' if termios.c_iflag.contains(TermiosIFlag::ICRNL) => { + buffer.push(b'\n'); + + if should_echo { + callback(LineControl::Echo(b'\r')); + callback(LineControl::Echo(b'\n')); + } + } + + byte if termios.is_cooked() => { + buffer.push(*byte); + + if should_echo { + callback(LineControl::Echo(*byte)) + } + } + + // In raw mode: _ => buffer.push(*byte), } } diff --git a/src/aero_syscall/src/lib.rs b/src/aero_syscall/src/lib.rs index d7b20a878f6..d74b44e85fa 100644 --- a/src/aero_syscall/src/lib.rs +++ b/src/aero_syscall/src/lib.rs @@ -294,6 +294,7 @@ impl From for SeekWhence { pub const TIOCGWINSZ: usize = 0x5413; pub const TIOCSWINSZ: usize = 0x5414; pub const TCGETS: usize = 0x5401; +pub const TCSETSW: usize = 0x5403; pub const TCSETSF: usize = 0x5404; pub const TIOCSCTTY: usize = 0x540e; pub const TIOCNOTTY: usize = 0x5422; diff --git a/userland/tests/getchar.cc b/userland/tests/getchar.cc new file mode 100644 index 00000000000..7b2ac57058e --- /dev/null +++ b/userland/tests/getchar.cc @@ -0,0 +1,18 @@ +#include +#include + +int main() { + std::string line; + char c; + + while ((c = getchar()) != EOF) { + std::cout << "Got: " << c << std::endl; + // FIXME: Should we also break on \r? + if (c == '\n') + break; + line.push_back(c); + } + + std::cout << line << std::endl; + return 0; +} From 83924ea70806b39ea09952e4c52b8cdc64c73056 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 4 Nov 2023 13:29:40 +1100 Subject: [PATCH 019/112] cleanup: Ioctl derive proc macro Signed-off-by: Anhad Singh --- src/aero_kernel/src/arch/x86_64/user_copy.rs | 28 +++++ src/aero_kernel/src/drivers/pty.rs | 119 ++++++++++++------- src/aero_kernel/src/main.rs | 3 +- src/aero_proc/src/ioctl.rs | 57 +++++++++ src/aero_proc/src/lib.rs | 7 ++ src/aero_syscall/src/lib.rs | 3 +- 6 files changed, 171 insertions(+), 46 deletions(-) create mode 100644 src/aero_proc/src/ioctl.rs diff --git a/src/aero_kernel/src/arch/x86_64/user_copy.rs b/src/aero_kernel/src/arch/x86_64/user_copy.rs index bc632787009..18c0509fd34 100644 --- a/src/aero_kernel/src/arch/x86_64/user_copy.rs +++ b/src/aero_kernel/src/arch/x86_64/user_copy.rs @@ -15,11 +15,13 @@ // You should have received a copy of the GNU General Public License // along with Aero. If not, see . +use core::fmt::{Debug, Display}; use core::mem::MaybeUninit; use core::ops::{Deref, DerefMut}; use crate::interrupts::exceptions::PF_RESUME; use crate::mem::paging::VirtAddr; +use crate::syscall::SysArg; use super::task::user_access_ok; @@ -131,6 +133,13 @@ impl UserRef { val: unsafe { val.assume_init() }, } } + + pub fn take(self) -> T + where + T: Clone, + { + self.val.clone() + } } impl Deref for UserRef { @@ -152,3 +161,22 @@ impl Drop for UserRef { assert!(copy_to_user(self.ptr, &self.val)); } } + +impl Display for UserRef { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + self.val.fmt(f) + } +} + +impl Debug for UserRef { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!(f, "UserRef({:?})", self.val) + } +} + +impl SysArg for UserRef { + fn from_usize(value: usize) -> Self { + // TODO: SAFETY + unsafe { Self::new(VirtAddr::new(value.try_into().unwrap())) } + } +} diff --git a/src/aero_kernel/src/drivers/pty.rs b/src/aero_kernel/src/drivers/pty.rs index 40e0741ba70..ae9b98d3148 100644 --- a/src/aero_kernel/src/drivers/pty.rs +++ b/src/aero_kernel/src/drivers/pty.rs @@ -17,7 +17,9 @@ use core::sync::atomic::{AtomicU32, Ordering}; +use aero_syscall as libc; use aero_syscall::{Termios, WinSize}; + use alloc::collections::BTreeMap; use alloc::string::ToString; use alloc::sync::{Arc, Weak}; @@ -26,6 +28,7 @@ use spin::{Once, RwLock}; use uapi::pty::*; +use crate::arch::user_copy::UserRef; use crate::fs::cache::*; use crate::fs::devfs::DEV_FILESYSTEM; use crate::fs::inode::{DirEntry, FileType, INodeInterface, PollFlags}; @@ -45,6 +48,55 @@ lazy_static::lazy_static! { static PTS_FS: Once> = Once::new(); static PTY_ID: AtomicU32 = AtomicU32::new(0); +#[derive(Debug, Ioctl)] +pub enum TermiosCmd { + /// Get window size. + #[command(libc::TIOCGWINSZ)] + GetWinSize(UserRef), + + /// Set window size. + #[command(libc::TIOCSWINSZ)] + SetWinSize(UserRef), + + /// Get the current serial port settings. + /// + /// Equivalent to `tcgetattr(fd, argp)`. + #[command(libc::TCGETS)] + TcGets(UserRef), + + /// Allow the output buffer to drain, discard pending input, and set the current serial + /// port settings. + /// + /// Equivalent to `tcsetattr(fd, TCSAFLUSH, argp)`. + #[command(libc::TCSETSF)] + TcSetsf(UserRef), + + /// Allow the output buffer to drain, and set the current serial port settings. + /// + /// Equivalent to `tcsetattr(fd, TCSADRAIN, argp)`. + #[command(libc::TCSETSW)] + TcSetsw(UserRef), + + /// Make the given terminal the controlling terminal of the calling process. The calling + /// process must be a session leader and not have a controlling terminal already. For this + /// case, arg should be specified as zero. + /// + /// If this terminal is already the controlling terminal of a different session group, then the + /// ioctl fails with EPERM, unless the caller has the CAP_SYS_ADMIN capability and arg equals + /// 1, in which case the terminal is stolen, and all processes that had it as controlling + /// terminal lose it. + // FIXME: argument usize + #[command(libc::TIOCSCTTY)] + SetCtrlTerm, + + /// Get the process group ID of the foreground process group on this terminal. + /// + /// When successful, equivalent to `*argp = tcgetpgrp(fd)`. + // FIXME: argument usize + #[command(libc::TIOCGPGRP)] + GetProcGroupId, +} + struct Master { id: u32, wq: WaitQueue, @@ -65,6 +117,16 @@ impl Master { discipline: LineDiscipline::new(), } } + + #[inline] + fn set_window_size(&self, size: WinSize) { + *self.window_size.lock_irq() = size; + } + + #[inline] + fn get_window_size(&self) -> WinSize { + *self.window_size.lock_irq() + } } impl INodeInterface for Master { @@ -180,58 +242,29 @@ impl INodeInterface for Slave { } fn ioctl(&self, command: usize, arg: usize) -> fs::Result { - match command { - aero_syscall::TIOCGWINSZ => { - let winsize = VirtAddr::new(arg as u64).read_mut::()?; - *winsize = *self.master.window_size.lock_irq(); - - Ok(0) - } - - aero_syscall::TIOCSWINSZ => { - *self.master.window_size.lock_irq() = *VirtAddr::new(arg as u64).read_mut()?; - Ok(0) - } - - aero_syscall::TCGETS => { - let termios = VirtAddr::new(arg as u64).read_mut::()?; - *termios = self.master.discipline.termios(); - - Ok(0) - } - - aero_syscall::TCSETSF => { - let termios = VirtAddr::new(arg as u64).read_mut::()?; - self.master.discipline.set_termios(termios.clone()); - - Ok(0) - } - - aero_syscall::TCSETSW => { + match TermiosCmd::from_command_arg(command, arg) { + TermiosCmd::GetWinSize(mut size) => *size = self.master.get_window_size(), + TermiosCmd::SetWinSize(size) => self.master.set_window_size(*size), + TermiosCmd::TcGets(mut termios) => *termios = self.master.discipline.termios(), + TermiosCmd::TcSetsf(termios) => self.master.discipline.set_termios(*termios), + TermiosCmd::TcSetsw(termios) => { // TODO: Allow the output buffer to drain and then set the current serial port // settings. - // - // Equivalent to tcsetattr(fd, TCSADRAIN, argp). - let termios = VirtAddr::new(arg as u64).read_mut::()?; - self.master.discipline.set_termios(termios.clone()); - - Ok(0) + self.master.discipline.set_termios(*termios) } - aero_syscall::TIOCSCTTY => { + TermiosCmd::SetCtrlTerm => { let current_task = scheduler::get_scheduler().current_task(); assert!(current_task.is_session_leader()); current_task.attach(self.sref()); - Ok(0) } - // TIOCGPGRP - Get the process group ID of the foreground process group on this - // terminal. - 0x540f => Err(FileSystemError::NotSupported), - - _ => panic!("pty: unknown ioctl: {command}"), + // FIXME: the following ioctls are not implemented. + TermiosCmd::GetProcGroupId => return Err(FileSystemError::NotSupported), } + + Ok(0) } fn poll(&self, table: Option<&mut fs::inode::PollTable>) -> fs::Result { @@ -250,9 +283,7 @@ impl INodeInterface for Slave { } fn read_at(&self, _offset: usize, buffer: &mut [u8]) -> fs::Result { - let x = self.master.discipline.read(buffer)?; - dbg!(core::str::from_utf8(&buffer[..x])); - Ok(x) + Ok(self.master.discipline.read(buffer)?) } fn write_at(&self, _offset: usize, buffer: &[u8]) -> fs::Result { diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index 4e32a73bf8f..58967ac1b36 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -49,7 +49,8 @@ naked_functions, // https://github.com/rust-lang/rust/issues/32408 cfg_match, // https://github.com/rust-lang/rust/issues/115585 strict_provenance, - offset_of + offset_of, + associated_type_defaults )] // TODO(andypython): can we remove the dependency of "prelude_import" and "lang_items"? // `lang_items` => is currently used for the personality function (`rust_eh_personality`). diff --git a/src/aero_proc/src/ioctl.rs b/src/aero_proc/src/ioctl.rs new file mode 100644 index 00000000000..38abcc1fdcc --- /dev/null +++ b/src/aero_proc/src/ioctl.rs @@ -0,0 +1,57 @@ +use proc_macro::TokenStream; +use syn::{Data, DeriveInput, Path}; + +fn make_command_enum(ast: &DeriveInput) -> TokenStream { + let name = &ast.ident; + let variants = match &ast.data { + Data::Enum(data) => &data.variants, + _ => panic!("`Ioctl` derive macro can only be used on enums."), + }; + + let mut pattern_match = vec![]; + + for variant in variants { + let attrs = &variant.attrs; + let ident = &variant.ident; + + for attr in attrs { + if attr.path.get_ident().unwrap() != "command" { + assert_eq!(attr.path.get_ident().unwrap(), "doc"); + continue; + } + + let path = attr.parse_args::().unwrap(); + + pattern_match.push(match &variant.fields { + syn::Fields::Unit => quote::quote!(#path => Self::#ident), + syn::Fields::Unnamed(fields) => { + assert!(fields.unnamed.len() == 1); + quote::quote!(#path => Self::#ident(crate::syscall::SysArg::from_usize(arg))) + } + + _ => panic!("`Ioctl` derive macro can only be used on enums with unit variants."), + }); + } + } + + // implement Ioctl::from_command_arg for the enum + + quote::quote! { + impl #name { + pub fn from_command_arg(cmd: usize, arg: usize) -> Self { + match cmd { + #(#pattern_match,)* + _ => unimplemented!("unknown command: {cmd:#x}") + } + } + } + } + .into() +} + +pub fn parse(item: TokenStream) -> TokenStream { + let ast: DeriveInput = syn::parse(item).unwrap(); + let cmd_enum = make_command_enum(&ast); + + cmd_enum +} diff --git a/src/aero_proc/src/lib.rs b/src/aero_proc/src/lib.rs index 2dfe0ac0c59..3809b200c32 100644 --- a/src/aero_proc/src/lib.rs +++ b/src/aero_proc/src/lib.rs @@ -23,6 +23,7 @@ extern crate proc_macro_error; mod cpu_local; mod downcastable; mod indirect; +mod ioctl; mod syscall; mod test; @@ -71,3 +72,9 @@ pub fn cpu_local(attr: TokenStream, item: TokenStream) -> TokenStream { pub fn indirect(attr: TokenStream, item: TokenStream) -> TokenStream { indirect::parse(attr, item) } + +#[proc_macro_derive(Ioctl, attributes(command))] +#[proc_macro_error] +pub fn ioctl(item: TokenStream) -> TokenStream { + ioctl::parse(item) +} diff --git a/src/aero_syscall/src/lib.rs b/src/aero_syscall/src/lib.rs index d74b44e85fa..fd0257445ff 100644 --- a/src/aero_syscall/src/lib.rs +++ b/src/aero_syscall/src/lib.rs @@ -298,8 +298,9 @@ pub const TCSETSW: usize = 0x5403; pub const TCSETSF: usize = 0x5404; pub const TIOCSCTTY: usize = 0x540e; pub const TIOCNOTTY: usize = 0x5422; +pub const TIOCGPGRP: usize = 0x540f; -#[derive(Default, Copy, Clone)] +#[derive(Default, Debug, Copy, Clone)] #[repr(C)] pub struct WinSize { pub ws_row: u16, From bcba90c05843aaea5caf54757682d14f4290a621 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 4 Nov 2023 15:08:39 +1100 Subject: [PATCH 020/112] feat(ports): add jq Signed-off-by: Anhad Singh --- bootstrap.yml | 1 + bootstrap/app-misc.yml | 31 +++++++++++++++++++++++++++++++ patches/jq/jq.patch | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 bootstrap/app-misc.yml create mode 100644 patches/jq/jq.patch diff --git a/bootstrap.yml b/bootstrap.yml index 1106bb426b2..89689e81971 100644 --- a/bootstrap.yml +++ b/bootstrap.yml @@ -5,6 +5,7 @@ imports: - file: bootstrap/vcs.yml - file: bootstrap/db.yml - file: bootstrap/editors.yml + - file: bootstrap/app-misc.yml general: cargo: diff --git a/bootstrap/app-misc.yml b/bootstrap/app-misc.yml new file mode 100644 index 00000000000..f8ca618882a --- /dev/null +++ b/bootstrap/app-misc.yml @@ -0,0 +1,31 @@ +packages: + # A lightweight and flexible command-line JSON processor + - name: jq + source: + url: 'https://github.com/jqlang/jq/releases/download/jq-1.7/jq-1.7.tar.gz' + format: 'tar.gz' + version: '1.7' + subdir: 'bundled' + patch-path-strip: 0 + tools_required: + - host-autoconf-v2.69 + - host-automake-v1.16 + - host-libtool + - host-gcc + pkgs_required: + - mlibc + configure: + - args: + - '@THIS_SOURCE_DIR@/jq-1.7/configure' + - '--disable-docs' + - '--disable-valgrind' + - '--disable-maintainer-mode' + - '--with-oniguruma=builtin' + - '--host=x86_64-aero' + - '--prefix=/usr' + - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. + build: + - args: ['make', '-j@PARALLELISM@'] + - args: ['make', 'install'] + environ: + DESTDIR: '@THIS_COLLECT_DIR@' diff --git a/patches/jq/jq.patch b/patches/jq/jq.patch new file mode 100644 index 00000000000..48435b6e0b3 --- /dev/null +++ b/patches/jq/jq.patch @@ -0,0 +1,40 @@ +diff -crB jq-1.7-orig/config/config.sub jq-1.7/config/config.sub +*** jq-1.7-orig/config/config.sub 2023-11-04 14:43:08.915178973 +1100 +--- jq-1.7/config/config.sub 2023-11-04 14:43:43.691560304 +1100 +*************** +*** 1754,1760 **** + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ +! | fiwix* ) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) +--- 1754,1760 ---- + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ +! | fiwix* | aero* ) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) +diff -crB jq-1.7-orig/modules/oniguruma/config.sub jq-1.7/modules/oniguruma/config.sub +*** jq-1.7-orig/modules/oniguruma/config.sub 2023-11-04 14:43:08.921845585 +1100 +--- jq-1.7/modules/oniguruma/config.sub 2023-11-04 14:44:17.544620423 +1100 +*************** +*** 1722,1728 **** + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ +! | nsk* | powerunix* | genode* | zvmoe* ) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) +--- 1722,1728 ---- + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ +! | nsk* | powerunix* | genode* | zvmoe* | aero* ) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) From 1e921f6297c23bed7446f6e909fb01c421985424 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 22 Nov 2023 18:22:37 +1100 Subject: [PATCH 021/112] stash Signed-off-by: Anhad Singh --- bootstrap.yml | 39 +++- bootstrap/xorg.yml | 21 +-- patches/mlibc/mlibc.patch | 291 +++++++++++++++++++++++++++++ src/aero_kernel/src/fs/procfs.rs | 32 +++- src/aero_kernel/src/userland/vm.rs | 21 ++- 5 files changed, 378 insertions(+), 26 deletions(-) create mode 100644 patches/mlibc/mlibc.patch diff --git a/bootstrap.yml b/bootstrap.yml index 89689e81971..9b8c3f297d0 100644 --- a/bootstrap.yml +++ b/bootstrap.yml @@ -943,6 +943,7 @@ packages: - '-Ddisable_iconv_option=true' - '--buildtype=release' - '-Dlinux_kernel_headers=@BUILD_ROOT@/packages/linux-headers/usr/include' + - '-Ddisable_intl_option=true' - '@THIS_SOURCE_DIR@' build: - args: ['ninja'] @@ -970,6 +971,7 @@ packages: - '-Ddisable_iconv_option=true' - '--buildtype=debug' - '-Dlinux_kernel_headers=@BUILD_ROOT@/packages/linux-headers/usr/include' + - '-Ddisable_intl_option=true' - '@THIS_SOURCE_DIR@' build: - args: ['ninja'] @@ -2132,13 +2134,43 @@ packages: environ: DESTDIR: '@THIS_COLLECT_DIR@' + - name: gettext + from_source: gettext + tools_required: + - host-gcc + - host-autoconf-v2.69 + - host-automake-v1.16 + pkgs_required: + - mlibc + configure: + - args: + - '@THIS_SOURCE_DIR@/configure' + - '--host=x86_64-aero' + - '--prefix=/usr' + - '--docdir=/usr/share/doc/gettext-0.22.3' + - '--enable-static=no' + - '--enable-shared=yes' + - '--disable-java' + - '--disable-nls' + - '--disable-acl' + - '--without-emacs' + - '--without-git' + - '--without-bzip2' + - '--without-xz' + - '--disable-curses' + build: + - args: ['make', '-j@PARALLELISM@'] + - args: ['make', 'install'] + environ: + DESTDIR: '@THIS_COLLECT_DIR@' + - name: libintl source: subdir: 'bundled' - url: 'https://ftp.gnu.org/gnu/gettext/gettext-0.21.1.tar.xz' + url: 'https://ftp.gnu.org/gnu/gettext/gettext-0.22.tar.xz' format: 'tar.xz' - extract_path: 'gettext-0.21.1' - version: '0.21.1' + extract_path: 'gettext-0.22' + version: '0.22' tools_required: - host-autoconf-v2.69 - host-automake-v1.16 @@ -2148,6 +2180,7 @@ packages: tools_required: - host-gcc pkgs_required: + - mlibc - libiconv configure: - args: diff --git a/bootstrap/xorg.yml b/bootstrap/xorg.yml index 2078bb2a9b1..3ce977b6aaf 100644 --- a/bootstrap/xorg.yml +++ b/bootstrap/xorg.yml @@ -32,18 +32,11 @@ sources: - name: gettext subdir: 'bundled' - git: 'https://git.savannah.gnu.org/git/gettext.git' - tag: 'v0.19.8' - version: '0.19.8' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' + url: 'https://ftp.gnu.org/pub/gnu/gettext/gettext-0.22.3.tar.gz' + checksum: blake2b:aebe85a82cb94c37ed81e9801acf1e89d150f5992fb9be42d53b3f2734c5c95804f0051fabc26b8d0892dfaf89d18df16d4bca6bcb2e9b95eef5d4ae93a64379 + extract_path: 'gettext-0.22.3' + format: 'tar.gz' + version: '0.22.3' - name: gobject-introspection subdir: 'bundled' @@ -2464,8 +2457,8 @@ packages: source: subdir: 'bundled' git: 'https://gitlab.gnome.org/GNOME/gtk.git' - tag: '3.24.23' - version: '3.24.23' + tag: '3.24.28' + version: '3.24.28' tools_required: - host-gcc - virtual: pkgconfig-for-target diff --git a/patches/mlibc/mlibc.patch b/patches/mlibc/mlibc.patch new file mode 100644 index 00000000000..9177a8cd494 --- /dev/null +++ b/patches/mlibc/mlibc.patch @@ -0,0 +1,291 @@ +From ea30fe59e091c87eb09d24c20946ee7a90d371c2 Mon Sep 17 00:00:00 2001 +From: Anhad Singh +Date: Tue, 14 Nov 2023 17:51:25 +1100 +Subject: [PATCH] + +Signed-off-by: Anhad Singh + +diff --git a/options/intl/generic/libintl-stubs.cpp b/options/intl/generic/libintl-stubs.cpp +index 8d4b28f..94ab421 100644 +--- a/options/intl/generic/libintl-stubs.cpp ++++ b/options/intl/generic/libintl-stubs.cpp +@@ -1,73 +1,57 @@ + #include ++#include ++#include ++#include + #include + ++static char *current_domain; ++ + char *gettext(const char *msgid) { +- (void)msgid; +- __ensure(!"Not implemented"); +- __builtin_unreachable(); ++ // (void)msgid; ++ // __ensure(!"Not implemented"); ++ // __builtin_unreachable(); ++ return (char*)""; + } + + char *dgettext(const char *domainname, const char *msgid) { +- (void)domainname; +- (void)msgid; +- __ensure(!"Not implemented"); +- __builtin_unreachable(); ++ return (char*)""; + } + + char *dcgettext(const char *domainname, const char *msgid, + int category) { +- (void)domainname; +- (void)msgid; +- (void)category; +- __ensure(!"Not implemented"); +- __builtin_unreachable(); ++ return (char*)""; ++ + } + + char *ngettext(const char *msgid, const char *msgid_plural, unsigned long int n) { +- (void)msgid; +- (void)msgid_plural; +- (void)n; +- __ensure(!"Not implemented"); +- __builtin_unreachable(); ++ return (char*)""; ++ + } + + char *dngettext(const char *domainname, const char *msgid, + const char *msgid_plural, unsigned long int n) { +- (void)domainname; +- (void)msgid; +- (void)msgid_plural; +- (void)n; +- __ensure(!"Not implemented"); +- __builtin_unreachable(); ++ return (char*)""; ++ + } + + char *dcngettext(const char *domainname, const char *msgid, + const char *msgid_plural, unsigned long int n, int category) { +- (void)domainname; +- (void)msgid; +- (void)msgid_plural; +- (void)n; +- (void)category; +- __ensure(!"Not implemented"); +- __builtin_unreachable(); ++ return (char*)""; ++ + } + + char *textdomain(const char *domainname) { +- (void)domainname; +- __ensure(!"Not implemented"); +- __builtin_unreachable(); ++ if(!domainname) ++ return current_domain ? current_domain : (char *)"messages"; ++ ++ return (char*)"messages"; + } + + char *bindtextdomain(const char *domainname, const char *dirname) { +- (void)domainname; +- (void)dirname; +- __ensure(!"Not implemented"); +- __builtin_unreachable(); ++ return (char*)""; ++ + } + + char *bind_textdomain_codeset(const char *domainname, const char *codeset) { +- (void)domainname; +- (void)codeset; +- __ensure(!"Not implemented"); +- __builtin_unreachable(); ++ return (char*)""; + } +diff --git a/options/posix/generic/pthread-stubs.cpp b/options/posix/generic/pthread-stubs.cpp +index 5618dc6..cd9350d 100644 +--- a/options/posix/generic/pthread-stubs.cpp ++++ b/options/posix/generic/pthread-stubs.cpp +@@ -299,7 +299,7 @@ int pthread_getattr_np(pthread_t thread, pthread_attr_t *attr) { + if (!tcb->stackAddr || !tcb->stackSize) { + // allocate stack + +- attr->__mlibc_stackaddr = 0x00; ++ attr->__mlibc_stackaddr = (void*)0x7ffffff9a000; + attr->__mlibc_stacksize = 0x20000; + // get_own_stackinfo(&attr->__mlibc_stackaddr, &attr->__mlibc_stacksize); + } else { +diff --git a/options/rtdl/generic/linker.cpp b/options/rtdl/generic/linker.cpp +index 50cca94..a095ab0 100644 +--- a/options/rtdl/generic/linker.cpp ++++ b/options/rtdl/generic/linker.cpp +@@ -438,6 +438,7 @@ void ObjectRepository::_fetchFromFile(SharedObject *object, int fd) { + + __ensure(!(object->baseAddress & (hugeSize - 1))); + ++ size_t tagSize = highest_address - object->baseAddress; + #if MLIBC_MMAP_ALLOCATE_DSO + void *mappedAddr = nullptr; + +@@ -457,9 +458,11 @@ void ObjectRepository::_fetchFromFile(SharedObject *object, int fd) { + libraryBase += (highest_address + (hugeSize - 1)) & ~(hugeSize - 1); + #endif + +- if(verbose || logBaseAddresses) ++ if(verbose || logBaseAddresses) { ++ mlibc::sys_tag_memory((void *)object->baseAddress, tagSize, object->name.data()); + mlibc::infoLogger() << "rtdl: Loading " << object->name + << " at " << (void *)object->baseAddress << frg::endlog; ++ } + + // Load all segments. + constexpr size_t pageSize = 0x1000; +diff --git a/options/rtdl/include/mlibc/rtdl-sysdeps.hpp b/options/rtdl/include/mlibc/rtdl-sysdeps.hpp +index c35271c..8a941b2 100644 +--- a/options/rtdl/include/mlibc/rtdl-sysdeps.hpp ++++ b/options/rtdl/include/mlibc/rtdl-sysdeps.hpp +@@ -6,6 +6,7 @@ namespace [[gnu::visibility("hidden")]] mlibc { + int sys_tcb_set(void *pointer); + + [[gnu::weak]] int sys_vm_readahead(void *pointer, size_t size); ++[[gnu::weak]] int sys_tag_memory(void *ptr, size_t size, char *tag); + + } // namespace mlibc + +diff --git a/sysdeps/aero/generic/aero.cpp b/sysdeps/aero/generic/aero.cpp +index e19b159..e3c11a4 100644 +--- a/sysdeps/aero/generic/aero.cpp ++++ b/sysdeps/aero/generic/aero.cpp +@@ -62,6 +62,10 @@ static frg::vector create_slice(char *const arg[]) { + } + + namespace mlibc { ++int sys_tag_memory(void *ptr, size_t size, char *tag) { ++ return syscall(SYS_DEBUG, ptr, size, tag, strlen(tag)); ++} ++ + int sys_uname(struct utsname *buf) { + auto result = syscall(SYS_UNAME, buf); + +@@ -73,6 +77,8 @@ int sys_uname(struct utsname *buf) { + } + + int sys_futex_wait(int *pointer, int expected, const struct timespec *time) { ++ while (*pointer == expected) {} ++ + // auto result = syscall(SYS_FUTEX_WAIT, pointer, expected, time); + // + // if (result < 0) { +@@ -309,7 +315,7 @@ int sys_thread_setname(void *tcb, const char *name) { + } + + void sys_thread_exit() { +- syscall(SYS_EXIT); ++ syscall(SYS_EXIT, 0); + __builtin_trap(); + } + +diff --git a/sysdeps/aero/generic/filesystem.cpp b/sysdeps/aero/generic/filesystem.cpp +index 33a11f4..4f64ba5 100644 +--- a/sysdeps/aero/generic/filesystem.cpp ++++ b/sysdeps/aero/generic/filesystem.cpp +@@ -68,15 +68,22 @@ int sys_seek(int fd, off_t offset, int whence, off_t *new_offset) { + return 0; + } + +-int sys_open(const char *filename, int flags, mode_t mode, int *fd) { +- auto result = syscall(SYS_OPEN, 0, filename, strlen(filename), flags); ++int sys_openat(int dirfd, const char *path, int flags, mode_t mode, int *fd) { ++ (void)mode; + +- if (result < 0) { +- return -result; +- } ++ auto ret = syscall(SYS_OPEN, dirfd, path, strlen(path), flags); ++ if (int e = sc_error(ret); e) ++ return e; ++ *fd = ret; ++ return 0; ++} + +- *fd = result; +- return 0; ++int sys_open(const char *path, int flags, mode_t mode, int *fd) { ++ return sys_openat(AT_FDCWD, path, flags, mode, fd); ++} ++ ++int sys_open_dir(const char *path, int *fd) { ++ return sys_open(path, O_DIRECTORY, 0, fd); + } + + int sys_close(int fd) { +@@ -256,10 +263,6 @@ int sys_read_entries(int handle, void *buffer, size_t max_size, + return 0; + } + +-int sys_open_dir(const char *path, int *handle) { +- return sys_open(path, O_DIRECTORY, 0, handle); +-} +- + int sys_rename(const char *path, const char *new_path) { + auto result = + syscall(SYS_RENAME, path, strlen(path), new_path, strlen(new_path)); +@@ -305,6 +308,13 @@ int sys_dup2(int fd, int flags, int newfd) { + } + + int sys_fcntl(int fd, int request, va_list args, int *result_value) { ++ if(request == F_GETLK) { ++ struct flock *lock = va_arg(args, struct flock *); ++ lock->l_type = F_UNLCK; ++ mlibc::infoLogger() << "\e[31mmlibc: F_GETLK is stubbed!\e[39m" << frg::endlog; ++ return 0; ++ } ++ + auto result = syscall(SYS_FCNTL, fd, request, va_arg(args, uint64_t)); + + if (result < 0) { +diff --git a/sysdeps/aero/generic/sockets.cpp b/sysdeps/aero/generic/sockets.cpp +index 10af36a..bf2602f 100644 +--- a/sysdeps/aero/generic/sockets.cpp ++++ b/sysdeps/aero/generic/sockets.cpp +@@ -174,14 +174,10 @@ int sys_getsockopt(int fd, int layer, int number, void *__restrict buffer, + + int sys_setsockopt(int fd, int layer, int number, const void *buffer, + socklen_t size) { +- (void)fd; +- (void)buffer; +- (void)size; +- + if (layer == SOL_SOCKET && number == SO_PASSCRED) { +- mlibc::infoLogger() << "\e[31mmlibc: setsockopt(SO_PASSCRED) is not " +- "implemented correctly\e[39m" +- << frg::endlog; ++ auto ret = syscall(SYS_SETSOCKOPT, fd, layer, number, buffer, size); ++ if (int e = sc_error(ret); e) ++ return e; + return 0; + } else if (layer == SOL_SOCKET && number == SO_ATTACH_FILTER) { + mlibc::infoLogger() << "\e[31mmlibc: setsockopt(SO_ATTACH_FILTER) is " +diff --git a/sysdeps/aero/include/aero/syscall.h b/sysdeps/aero/include/aero/syscall.h +index 39c5b65..bd2f489 100644 +--- a/sysdeps/aero/include/aero/syscall.h ++++ b/sysdeps/aero/include/aero/syscall.h +@@ -82,6 +82,9 @@ + #define SYS_SOCK_SHUTDOWN 75 + #define SYS_GETPEERNAME 76 + #define SYS_GETSOCKNAME 77 ++#define SYS_DEBUG 78 ++#define SYS_SETSOCKOPT 79 ++#define SYS_GETSOCKOPT 80 + + // Invalid syscall used to trigger a log error in the kernel (as a hint) + // so, that we can implement the syscall in the kernel. +-- +2.42.1 + diff --git a/src/aero_kernel/src/fs/procfs.rs b/src/aero_kernel/src/fs/procfs.rs index 31f9d4521f7..073d08744e0 100644 --- a/src/aero_kernel/src/fs/procfs.rs +++ b/src/aero_kernel/src/fs/procfs.rs @@ -1,5 +1,6 @@ use core::sync::atomic::{AtomicUsize, Ordering}; +use alloc::borrow::ToOwned; use alloc::collections::BTreeMap; use alloc::string::{String, ToString}; use alloc::sync::{Arc, Weak}; @@ -18,6 +19,9 @@ use super::FileSystemError; use super::inode::*; use super::*; +// TODO: put this mf in prelude +use alloc::vec; + fn push_string_if_some(map: &mut serde_json::Value, key: &str, value: Option) { if let Some(value) = value { map[key] = serde_json::Value::String(value); @@ -41,7 +45,6 @@ fn get_cpuinfo_cached() -> &'static str { static CACHED: Once = Once::new(); CACHED.call_once(|| { - use alloc::vec; use serde_json::*; let mut data = json!({ "processors": [] }); @@ -93,6 +96,7 @@ struct ProcINode { enum FileContents { CpuInfo, CmdLine, + SelfMaps, None, } @@ -166,8 +170,25 @@ impl INodeInterface for LockedProcINode { let this = self.0.read(); let data = match &this.contents { - FileContents::CpuInfo => Ok(get_cpuinfo_cached()), - FileContents::CmdLine => Ok(get_cmdline_cached()), + FileContents::CpuInfo => Ok(get_cpuinfo_cached().to_owned()), + FileContents::CmdLine => Ok(get_cmdline_cached().to_owned()), + + FileContents::SelfMaps => { + let current_thread = scheduler::current_thread(); + let mut result = serde_json::json!({ "maps": [] }); + let maps = result.get_mut("maps").unwrap().as_array_mut().unwrap(); + + current_thread.vm().for_each_mapping(|map| { + maps.push(serde_json::json!({ + "start": map.start_addr.as_u64(), + "end": map.end_addr.as_u64(), + "flags": map.flags.bits(), + "protection": map.protection.bits(), + })); + }); + + Ok(result.to_string()) + } _ => Err(FileSystemError::NotSupported), }?; @@ -277,6 +298,11 @@ impl ProcFs { inode.make_inode("cpuinfo", FileType::File, FileContents::CpuInfo)?; inode.make_inode("cmdline", FileType::File, FileContents::CmdLine)?; + let proc_self = inode.make_inode("self", FileType::Directory, FileContents::None)?; + let proc_self = proc_self.downcast_arc::().unwrap(); + + proc_self.make_inode("maps", FileType::File, FileContents::SelfMaps)?; + Ok(ramfs) } diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs index 884f870ad2d..4e8a69e427b 100644 --- a/src/aero_kernel/src/userland/vm.rs +++ b/src/aero_kernel/src/userland/vm.rs @@ -334,14 +334,14 @@ impl MMapFile { } #[derive(Debug, Clone)] -struct Mapping { - protection: MMapProt, - flags: MMapFlags, +pub struct Mapping { + pub protection: MMapProt, + pub flags: MMapFlags, - start_addr: VirtAddr, - end_addr: VirtAddr, + pub start_addr: VirtAddr, + pub end_addr: VirtAddr, - file: Option, + pub file: Option, refresh_flags: bool, } @@ -1237,4 +1237,13 @@ impl Vm { .lock() .handle_page_fault(reason, accessed_address) } + + pub fn for_each_mapping(&self, mut f: F) + where + F: FnMut(&Mapping), + { + for map in &self.inner.lock().mappings { + f(map); + } + } } From 04a856c95ae79b82346b3af8c32c897cbd183682 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 20 Dec 2023 14:29:37 +1100 Subject: [PATCH 022/112] misc(kernel): remove the `trait_upcasting` feature The feature now has been stabalized. Signed-off-by: Anhad Singh --- src/aero_kernel/src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index 58967ac1b36..3a391441363 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -45,7 +45,6 @@ const_trait_impl, // https://github.com/rust-lang/rust/issues/67792 int_roundings, // https://github.com/rust-lang/rust/issues/88581 const_ptr_is_null, // https://github.com/rust-lang/rust/issues/74939 - trait_upcasting, // https://github.com/rust-lang/rust/issues/65991 naked_functions, // https://github.com/rust-lang/rust/issues/32408 cfg_match, // https://github.com/rust-lang/rust/issues/115585 strict_provenance, From 6d92cdc212acc5fb6c778f22a23f3c3681cec2ef Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 5 Jan 2024 23:59:59 +1100 Subject: [PATCH 023/112] misc(everywhere): update copyright year :^) Happy new year :^) Signed-off-by: Anhad Singh --- aero.py | 21 ++++++++++++------- src/aero_kernel/build.rs | 2 +- src/aero_kernel/src/acpi/fadt.rs | 2 +- src/aero_kernel/src/acpi/hpet.rs | 2 +- src/aero_kernel/src/acpi/madt.rs | 2 +- src/aero_kernel/src/acpi/mcfg.rs | 2 +- src/aero_kernel/src/acpi/mod.rs | 2 +- src/aero_kernel/src/acpi/rsdp.rs | 2 +- src/aero_kernel/src/acpi/sdt.rs | 2 +- src/aero_kernel/src/arch/aarch64/mod.rs | 2 +- src/aero_kernel/src/arch/aarch64/task.rs | 2 +- src/aero_kernel/src/arch/aarch64/time.rs | 2 +- src/aero_kernel/src/arch/aarch64/tls.rs | 2 +- src/aero_kernel/src/arch/mod.rs | 2 +- src/aero_kernel/src/arch/x86_64/apic.rs | 2 +- .../src/arch/x86_64/controlregs.rs | 2 +- src/aero_kernel/src/arch/x86_64/cpu_local.rs | 2 +- src/aero_kernel/src/arch/x86_64/gdt.rs | 2 +- .../src/arch/x86_64/interrupts/exceptions.rs | 2 +- .../src/arch/x86_64/interrupts/idt.rs | 2 +- .../src/arch/x86_64/interrupts/mod.rs | 2 +- src/aero_kernel/src/arch/x86_64/io.rs | 2 +- src/aero_kernel/src/arch/x86_64/mem.rs | 2 +- src/aero_kernel/src/arch/x86_64/mod.rs | 2 +- src/aero_kernel/src/arch/x86_64/signals.rs | 2 +- src/aero_kernel/src/arch/x86_64/task.rs | 2 +- src/aero_kernel/src/arch/x86_64/time.rs | 2 +- src/aero_kernel/src/arch/x86_64/tls.rs | 2 +- src/aero_kernel/src/arch/x86_64/user_copy.rs | 2 +- src/aero_kernel/src/cmdline.rs | 17 +++++++++++++++ src/aero_kernel/src/drivers/block/ahci.rs | 2 +- .../src/drivers/block/ide/channel.rs | 2 +- src/aero_kernel/src/drivers/block/ide/mod.rs | 2 +- .../src/drivers/block/ide/registers.rs | 2 +- .../src/drivers/block/nvme/command.rs | 2 +- src/aero_kernel/src/drivers/block/nvme/mod.rs | 2 +- src/aero_kernel/src/drivers/drm/mod.rs | 2 +- src/aero_kernel/src/drivers/drm/rawfb.rs | 2 +- src/aero_kernel/src/drivers/e1000.rs | 2 +- src/aero_kernel/src/drivers/keyboard.rs | 2 +- src/aero_kernel/src/drivers/lai.rs | 2 +- src/aero_kernel/src/drivers/mod.rs | 2 +- src/aero_kernel/src/drivers/mouse.rs | 2 +- src/aero_kernel/src/drivers/pci.rs | 2 +- src/aero_kernel/src/drivers/pty.rs | 2 +- src/aero_kernel/src/drivers/tty/ctty.rs | 2 +- src/aero_kernel/src/drivers/tty/mod.rs | 2 +- src/aero_kernel/src/drivers/tty/vtty.rs | 2 +- src/aero_kernel/src/drivers/uart_16550.rs | 2 +- src/aero_kernel/src/drivers/uart_pl011.rs | 2 +- src/aero_kernel/src/emu.rs | 17 +++++++++++++++ src/aero_kernel/src/fs/block/gpt.rs | 2 +- src/aero_kernel/src/fs/block/mod.rs | 2 +- src/aero_kernel/src/fs/cache.rs | 2 +- src/aero_kernel/src/fs/devfs.rs | 2 +- src/aero_kernel/src/fs/epoll.rs | 2 +- src/aero_kernel/src/fs/eventfd.rs | 2 +- src/aero_kernel/src/fs/ext2/disk.rs | 2 +- src/aero_kernel/src/fs/ext2/group_desc.rs | 2 +- src/aero_kernel/src/fs/ext2/mod.rs | 2 +- src/aero_kernel/src/fs/file_table.rs | 2 +- src/aero_kernel/src/fs/inode.rs | 2 +- src/aero_kernel/src/fs/mod.rs | 2 +- src/aero_kernel/src/fs/pipe.rs | 17 +++++++++++++++ src/aero_kernel/src/fs/procfs.rs | 17 +++++++++++++++ src/aero_kernel/src/fs/ramfs.rs | 2 +- src/aero_kernel/src/logger.rs | 2 +- src/aero_kernel/src/main.rs | 2 +- src/aero_kernel/src/mem/alloc.rs | 2 +- src/aero_kernel/src/mem/mod.rs | 2 +- src/aero_kernel/src/mem/paging/addr.rs | 2 +- src/aero_kernel/src/mem/paging/frame.rs | 2 +- src/aero_kernel/src/mem/paging/mapper.rs | 2 +- src/aero_kernel/src/mem/paging/mod.rs | 2 +- src/aero_kernel/src/mem/paging/page.rs | 2 +- src/aero_kernel/src/mem/paging/page_table.rs | 2 +- src/aero_kernel/src/mem/pti.rs | 2 +- src/aero_kernel/src/mem/slab.rs | 2 +- src/aero_kernel/src/mem/vmalloc.rs | 2 +- src/aero_kernel/src/modules.rs | 2 +- src/aero_kernel/src/net/arp.rs | 2 +- src/aero_kernel/src/net/loopback.rs | 2 +- src/aero_kernel/src/net/mod.rs | 2 +- src/aero_kernel/src/net/tcp.rs | 2 +- src/aero_kernel/src/net/udp.rs | 2 +- src/aero_kernel/src/rendy.rs | 2 +- src/aero_kernel/src/socket/ipv4.rs | 2 +- src/aero_kernel/src/socket/mod.rs | 2 +- src/aero_kernel/src/socket/netlink.rs | 17 +++++++++++++++ src/aero_kernel/src/socket/tcp.rs | 17 +++++++++++++++ src/aero_kernel/src/socket/udp.rs | 2 +- src/aero_kernel/src/socket/unix.rs | 2 +- src/aero_kernel/src/syscall/fs.rs | 2 +- src/aero_kernel/src/syscall/futex.rs | 2 +- src/aero_kernel/src/syscall/ipc.rs | 2 +- src/aero_kernel/src/syscall/mod.rs | 2 +- src/aero_kernel/src/syscall/net.rs | 17 +++++++++++++++ src/aero_kernel/src/syscall/process.rs | 2 +- src/aero_kernel/src/syscall/time.rs | 2 +- src/aero_kernel/src/tests.rs | 2 +- src/aero_kernel/src/unwind.rs | 2 +- src/aero_kernel/src/userland/mod.rs | 2 +- src/aero_kernel/src/userland/scheduler/mod.rs | 2 +- .../src/userland/scheduler/round_robin.rs | 2 +- src/aero_kernel/src/userland/signals.rs | 2 +- src/aero_kernel/src/userland/task/mod.rs | 2 +- src/aero_kernel/src/userland/task/sessions.rs | 2 +- src/aero_kernel/src/userland/terminal.rs | 2 +- src/aero_kernel/src/userland/vm.rs | 2 +- src/aero_kernel/src/utils/bitmap.rs | 17 +++++++++++++++ src/aero_kernel/src/utils/buffer.rs | 2 +- src/aero_kernel/src/utils/dma.rs | 2 +- src/aero_kernel/src/utils/mod.rs | 2 +- src/aero_kernel/src/utils/sync.rs | 17 +++++++++++++++ src/aero_proc/src/cpu_local.rs | 17 +++++++++++++++ src/aero_proc/src/downcastable.rs | 17 +++++++++++++++ src/aero_proc/src/indirect.rs | 17 +++++++++++++++ src/aero_proc/src/ioctl.rs | 17 +++++++++++++++ src/aero_proc/src/lib.rs | 2 +- src/aero_proc/src/syscall.rs | 2 +- src/aero_proc/src/test.rs | 2 +- src/aero_syscall/src/consts.rs | 2 +- src/aero_syscall/src/lib.rs | 2 +- src/aero_syscall/src/signal.rs | 2 +- src/aero_syscall/src/syscall.rs | 2 +- src/aero_syscall/src/time.rs | 2 +- userland/apps/window_test/src/main.rs | 2 +- userland/servers/system_server/src/main.rs | 2 +- userland/servers/window_server/src/main.rs | 2 +- 129 files changed, 349 insertions(+), 123 deletions(-) diff --git a/aero.py b/aero.py index 48a7af35540..a7123bee96f 100755 --- a/aero.py +++ b/aero.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright (C) 2021-2022 The Aero Project Developers. +# Copyright (C) 2021-2024 The Aero Project Developers. # # This file is part of The Aero Project. # @@ -90,6 +90,7 @@ def __init__(self, target_arch: str, args: argparse.Namespace): def get_userland_tool(): return os.path.join(SYSROOT_DIR, "tools") def get_userland_package(): return os.path.join(SYSROOT_DIR, "packages") + def remove_prefix(string: str, prefix: str): if string.startswith(prefix): return string[len(prefix):] @@ -295,7 +296,7 @@ def build_userland_sysroot(minimal): if not os.path.islink(blink): # symlink the bootstrap.yml file in the src root to sysroot/bootstrap.link symlink_rel('bootstrap.yml', blink) - + def run_xbstrap(args): try: return run_command(['xbstrap', *args], cwd=SYSROOT_DIR) @@ -310,7 +311,8 @@ def run_xbstrap(args): code, _, _ = run_xbstrap(command) if code != 0: - log_error(f"`xbstrap {' '.join(command)}` exited with a non-zero status code") + log_error( + f"`xbstrap {' '.join(command)}` exited with a non-zero status code") exit(1) @@ -320,7 +322,8 @@ def build_userland(args): host_cargo = os.path.join(SYSROOT_DIR, "tools/host-rust") if not os.path.exists(host_cargo): - log_error("host-rust not built as a part of the sysroot, skipping compilation of `userland/`") + log_error( + "host-rust not built as a part of the sysroot, skipping compilation of `userland/`") return [] HOST_RUST = "host-rust/bin/rustc" @@ -465,7 +468,7 @@ def run_in_emulator(build_info: BuildInfo, iso_path): '-serial', 'stdio', '-drive', 'file=build/disk.img,if=none,id=NVME1,format=raw', '-device', 'nvme,drive=NVME1,serial=nvme', # Specify the boot order (where `d` is the first CD-ROM drive) - '--boot', 'd', + '--boot', 'd', '-s'] if args.bios == 'uefi': @@ -503,7 +506,8 @@ def run_in_emulator(build_info: BuildInfo, iso_path): if not qemu_binary: qemu_binary = f'qemu-system-{build_info.target_arch}' else: - qemu_binary = os.path.join(qemu_binary, f'qemu-system-{build_info.target_arch}'); + qemu_binary = os.path.join( + qemu_binary, f'qemu-system-{build_info.target_arch}') log_info(f"{qemu_binary} {' '.join(qemu_args)}") run_command([qemu_binary, *qemu_args]) @@ -597,7 +601,8 @@ def main(): if os.path.exists(BUILD_DIR): system_root = os.path.join(SYSROOT_DIR, 'system-root') - sysroot_mod = max(os.path.getmtime(os.path.join(system_root, file)) for file in os.listdir(system_root)) + sysroot_mod = max(os.path.getmtime(os.path.join(system_root, file)) + for file in os.listdir(system_root)) build_mod = os.path.getmtime(BUILD_DIR) if sysroot_mod > build_mod: log_info("sysroot modified, rebuilding") @@ -649,7 +654,7 @@ def main(): if not kernel_bin or args.check: return - + if not user_bins: user_bins = [] diff --git a/src/aero_kernel/build.rs b/src/aero_kernel/build.rs index 7af6bbde842..6e10d97a25e 100644 --- a/src/aero_kernel/build.rs +++ b/src/aero_kernel/build.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/acpi/fadt.rs b/src/aero_kernel/src/acpi/fadt.rs index 96205d77a3e..7f77f57100e 100644 --- a/src/aero_kernel/src/acpi/fadt.rs +++ b/src/aero_kernel/src/acpi/fadt.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/acpi/hpet.rs b/src/aero_kernel/src/acpi/hpet.rs index 89e211f0ae8..af50003ff27 100644 --- a/src/aero_kernel/src/acpi/hpet.rs +++ b/src/aero_kernel/src/acpi/hpet.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/acpi/madt.rs b/src/aero_kernel/src/acpi/madt.rs index dfaada3a4fd..e75dc324850 100644 --- a/src/aero_kernel/src/acpi/madt.rs +++ b/src/aero_kernel/src/acpi/madt.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/acpi/mcfg.rs b/src/aero_kernel/src/acpi/mcfg.rs index 72202a0c50c..d24508260a8 100644 --- a/src/aero_kernel/src/acpi/mcfg.rs +++ b/src/aero_kernel/src/acpi/mcfg.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/acpi/mod.rs b/src/aero_kernel/src/acpi/mod.rs index 9199dd68e1f..5503c41f5ce 100644 --- a/src/aero_kernel/src/acpi/mod.rs +++ b/src/aero_kernel/src/acpi/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/acpi/rsdp.rs b/src/aero_kernel/src/acpi/rsdp.rs index 5baa2eae1df..0ddd290fafc 100644 --- a/src/aero_kernel/src/acpi/rsdp.rs +++ b/src/aero_kernel/src/acpi/rsdp.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/acpi/sdt.rs b/src/aero_kernel/src/acpi/sdt.rs index 3933d698754..8d1c9292314 100644 --- a/src/aero_kernel/src/acpi/sdt.rs +++ b/src/aero_kernel/src/acpi/sdt.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/aarch64/mod.rs b/src/aero_kernel/src/arch/aarch64/mod.rs index 2fa8cc4fa95..0a9d9c9f31c 100644 --- a/src/aero_kernel/src/arch/aarch64/mod.rs +++ b/src/aero_kernel/src/arch/aarch64/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/aarch64/task.rs b/src/aero_kernel/src/arch/aarch64/task.rs index 2189ff28bb9..fc0c5247f53 100644 --- a/src/aero_kernel/src/arch/aarch64/task.rs +++ b/src/aero_kernel/src/arch/aarch64/task.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/aarch64/time.rs b/src/aero_kernel/src/arch/aarch64/time.rs index 989ca06e0f3..950bfc34fd3 100644 --- a/src/aero_kernel/src/arch/aarch64/time.rs +++ b/src/aero_kernel/src/arch/aarch64/time.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/aarch64/tls.rs b/src/aero_kernel/src/arch/aarch64/tls.rs index b6fb352f528..68b8a48b63a 100644 --- a/src/aero_kernel/src/arch/aarch64/tls.rs +++ b/src/aero_kernel/src/arch/aarch64/tls.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/mod.rs b/src/aero_kernel/src/arch/mod.rs index 3c761a2b177..d218c34ae03 100644 --- a/src/aero_kernel/src/arch/mod.rs +++ b/src/aero_kernel/src/arch/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/x86_64/apic.rs b/src/aero_kernel/src/arch/x86_64/apic.rs index 6b08befd45b..464f5116c93 100644 --- a/src/aero_kernel/src/arch/x86_64/apic.rs +++ b/src/aero_kernel/src/arch/x86_64/apic.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/x86_64/controlregs.rs b/src/aero_kernel/src/arch/x86_64/controlregs.rs index 690f09ffa61..93516f60a22 100644 --- a/src/aero_kernel/src/arch/x86_64/controlregs.rs +++ b/src/aero_kernel/src/arch/x86_64/controlregs.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/x86_64/cpu_local.rs b/src/aero_kernel/src/arch/x86_64/cpu_local.rs index f42b6372288..9e0a911ce0e 100644 --- a/src/aero_kernel/src/arch/x86_64/cpu_local.rs +++ b/src/aero_kernel/src/arch/x86_64/cpu_local.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/x86_64/gdt.rs b/src/aero_kernel/src/arch/x86_64/gdt.rs index 8a651b6a2d7..272b732d626 100644 --- a/src/aero_kernel/src/arch/x86_64/gdt.rs +++ b/src/aero_kernel/src/arch/x86_64/gdt.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/x86_64/interrupts/exceptions.rs b/src/aero_kernel/src/arch/x86_64/interrupts/exceptions.rs index 315d0f65105..d5c66833a09 100644 --- a/src/aero_kernel/src/arch/x86_64/interrupts/exceptions.rs +++ b/src/aero_kernel/src/arch/x86_64/interrupts/exceptions.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/x86_64/interrupts/idt.rs b/src/aero_kernel/src/arch/x86_64/interrupts/idt.rs index 319fed51093..3399dac4f5d 100644 --- a/src/aero_kernel/src/arch/x86_64/interrupts/idt.rs +++ b/src/aero_kernel/src/arch/x86_64/interrupts/idt.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/x86_64/interrupts/mod.rs b/src/aero_kernel/src/arch/x86_64/interrupts/mod.rs index ce3e0bfc055..fecaf75bbc3 100644 --- a/src/aero_kernel/src/arch/x86_64/interrupts/mod.rs +++ b/src/aero_kernel/src/arch/x86_64/interrupts/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/x86_64/io.rs b/src/aero_kernel/src/arch/x86_64/io.rs index cd8ea6bcc52..f32d66dabe4 100644 --- a/src/aero_kernel/src/arch/x86_64/io.rs +++ b/src/aero_kernel/src/arch/x86_64/io.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/x86_64/mem.rs b/src/aero_kernel/src/arch/x86_64/mem.rs index 5871c7cf008..c89f15e0648 100644 --- a/src/aero_kernel/src/arch/x86_64/mem.rs +++ b/src/aero_kernel/src/arch/x86_64/mem.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/x86_64/mod.rs b/src/aero_kernel/src/arch/x86_64/mod.rs index d66038d474c..113ba35123b 100644 --- a/src/aero_kernel/src/arch/x86_64/mod.rs +++ b/src/aero_kernel/src/arch/x86_64/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/x86_64/signals.rs b/src/aero_kernel/src/arch/x86_64/signals.rs index a6819abd49b..4582aa1eaf3 100644 --- a/src/aero_kernel/src/arch/x86_64/signals.rs +++ b/src/aero_kernel/src/arch/x86_64/signals.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/x86_64/task.rs b/src/aero_kernel/src/arch/x86_64/task.rs index c2aa7bfa6a5..57851514a03 100644 --- a/src/aero_kernel/src/arch/x86_64/task.rs +++ b/src/aero_kernel/src/arch/x86_64/task.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/x86_64/time.rs b/src/aero_kernel/src/arch/x86_64/time.rs index f9a6c86c8e5..b783ec7c465 100644 --- a/src/aero_kernel/src/arch/x86_64/time.rs +++ b/src/aero_kernel/src/arch/x86_64/time.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/x86_64/tls.rs b/src/aero_kernel/src/arch/x86_64/tls.rs index e2cedfb0388..f202b64aa83 100644 --- a/src/aero_kernel/src/arch/x86_64/tls.rs +++ b/src/aero_kernel/src/arch/x86_64/tls.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/arch/x86_64/user_copy.rs b/src/aero_kernel/src/arch/x86_64/user_copy.rs index 18c0509fd34..630fd2a062a 100644 --- a/src/aero_kernel/src/arch/x86_64/user_copy.rs +++ b/src/aero_kernel/src/arch/x86_64/user_copy.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/cmdline.rs b/src/aero_kernel/src/cmdline.rs index d5299aac0c4..b64e1ad5648 100644 --- a/src/aero_kernel/src/cmdline.rs +++ b/src/aero_kernel/src/cmdline.rs @@ -1,3 +1,20 @@ +// Copyright (C) 2021-2024 The Aero Project Developers. +// +// This file is part of The Aero Project. +// +// Aero is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Aero is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Aero. If not, see . + use core::num::ParseIntError; use limine::NonNullPtr; diff --git a/src/aero_kernel/src/drivers/block/ahci.rs b/src/aero_kernel/src/drivers/block/ahci.rs index bbe5b67c291..dab2c669946 100644 --- a/src/aero_kernel/src/drivers/block/ahci.rs +++ b/src/aero_kernel/src/drivers/block/ahci.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/block/ide/channel.rs b/src/aero_kernel/src/drivers/block/ide/channel.rs index a243b58faf1..a64340807c3 100644 --- a/src/aero_kernel/src/drivers/block/ide/channel.rs +++ b/src/aero_kernel/src/drivers/block/ide/channel.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/block/ide/mod.rs b/src/aero_kernel/src/drivers/block/ide/mod.rs index 688172d8909..f15d05ded6a 100644 --- a/src/aero_kernel/src/drivers/block/ide/mod.rs +++ b/src/aero_kernel/src/drivers/block/ide/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/block/ide/registers.rs b/src/aero_kernel/src/drivers/block/ide/registers.rs index 080ad60c905..3b22a83124d 100644 --- a/src/aero_kernel/src/drivers/block/ide/registers.rs +++ b/src/aero_kernel/src/drivers/block/ide/registers.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/block/nvme/command.rs b/src/aero_kernel/src/drivers/block/nvme/command.rs index 49e8353d090..c967885ebbc 100644 --- a/src/aero_kernel/src/drivers/block/nvme/command.rs +++ b/src/aero_kernel/src/drivers/block/nvme/command.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/block/nvme/mod.rs b/src/aero_kernel/src/drivers/block/nvme/mod.rs index 706776e5149..e60e438b8b1 100644 --- a/src/aero_kernel/src/drivers/block/nvme/mod.rs +++ b/src/aero_kernel/src/drivers/block/nvme/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/drm/mod.rs b/src/aero_kernel/src/drivers/drm/mod.rs index 757b2e3c5c5..2cbfbb7e35e 100644 --- a/src/aero_kernel/src/drivers/drm/mod.rs +++ b/src/aero_kernel/src/drivers/drm/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/drm/rawfb.rs b/src/aero_kernel/src/drivers/drm/rawfb.rs index d1dbe98ec34..0b7f06064ac 100644 --- a/src/aero_kernel/src/drivers/drm/rawfb.rs +++ b/src/aero_kernel/src/drivers/drm/rawfb.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/e1000.rs b/src/aero_kernel/src/drivers/e1000.rs index dfb58016563..7fc30e2cc6d 100644 --- a/src/aero_kernel/src/drivers/e1000.rs +++ b/src/aero_kernel/src/drivers/e1000.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/keyboard.rs b/src/aero_kernel/src/drivers/keyboard.rs index 1968a2e40fb..c5e819665f3 100644 --- a/src/aero_kernel/src/drivers/keyboard.rs +++ b/src/aero_kernel/src/drivers/keyboard.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/lai.rs b/src/aero_kernel/src/drivers/lai.rs index 02542e86b18..08c6a0114b4 100644 --- a/src/aero_kernel/src/drivers/lai.rs +++ b/src/aero_kernel/src/drivers/lai.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/mod.rs b/src/aero_kernel/src/drivers/mod.rs index 7d11c0bb4c0..8cbab02c810 100644 --- a/src/aero_kernel/src/drivers/mod.rs +++ b/src/aero_kernel/src/drivers/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/mouse.rs b/src/aero_kernel/src/drivers/mouse.rs index eadf67f6eca..17c47f4f19d 100644 --- a/src/aero_kernel/src/drivers/mouse.rs +++ b/src/aero_kernel/src/drivers/mouse.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2022 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/pci.rs b/src/aero_kernel/src/drivers/pci.rs index 08c53cae987..1b652d50623 100644 --- a/src/aero_kernel/src/drivers/pci.rs +++ b/src/aero_kernel/src/drivers/pci.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/pty.rs b/src/aero_kernel/src/drivers/pty.rs index ae9b98d3148..931b8db71be 100644 --- a/src/aero_kernel/src/drivers/pty.rs +++ b/src/aero_kernel/src/drivers/pty.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/tty/ctty.rs b/src/aero_kernel/src/drivers/tty/ctty.rs index 19976314f64..5ad2a3880b2 100644 --- a/src/aero_kernel/src/drivers/tty/ctty.rs +++ b/src/aero_kernel/src/drivers/tty/ctty.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/tty/mod.rs b/src/aero_kernel/src/drivers/tty/mod.rs index a98769fc943..ed6b630ad4d 100644 --- a/src/aero_kernel/src/drivers/tty/mod.rs +++ b/src/aero_kernel/src/drivers/tty/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/tty/vtty.rs b/src/aero_kernel/src/drivers/tty/vtty.rs index 7edb0c53add..11b8a16b68a 100644 --- a/src/aero_kernel/src/drivers/tty/vtty.rs +++ b/src/aero_kernel/src/drivers/tty/vtty.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/uart_16550.rs b/src/aero_kernel/src/drivers/uart_16550.rs index 39ea116cc3f..bcbed46d368 100644 --- a/src/aero_kernel/src/drivers/uart_16550.rs +++ b/src/aero_kernel/src/drivers/uart_16550.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/drivers/uart_pl011.rs b/src/aero_kernel/src/drivers/uart_pl011.rs index e5604826bd6..ecce06cfb5f 100644 --- a/src/aero_kernel/src/drivers/uart_pl011.rs +++ b/src/aero_kernel/src/drivers/uart_pl011.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/emu.rs b/src/aero_kernel/src/emu.rs index d4810f54560..bef1869d8d9 100644 --- a/src/aero_kernel/src/emu.rs +++ b/src/aero_kernel/src/emu.rs @@ -1,3 +1,20 @@ +// Copyright (C) 2021-2024 The Aero Project Developers. +// +// This file is part of The Aero Project. +// +// Aero is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Aero is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Aero. If not, see . + use crate::utils::io; #[repr(u32)] diff --git a/src/aero_kernel/src/fs/block/gpt.rs b/src/aero_kernel/src/fs/block/gpt.rs index 3974338c853..b52473b7dd6 100644 --- a/src/aero_kernel/src/fs/block/gpt.rs +++ b/src/aero_kernel/src/fs/block/gpt.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/fs/block/mod.rs b/src/aero_kernel/src/fs/block/mod.rs index c7589fec014..6255ded512f 100644 --- a/src/aero_kernel/src/fs/block/mod.rs +++ b/src/aero_kernel/src/fs/block/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/fs/cache.rs b/src/aero_kernel/src/fs/cache.rs index d20bd0fe4c7..b18cbee1ad9 100644 --- a/src/aero_kernel/src/fs/cache.rs +++ b/src/aero_kernel/src/fs/cache.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/fs/devfs.rs b/src/aero_kernel/src/fs/devfs.rs index 73b383b6fcf..83b59569542 100644 --- a/src/aero_kernel/src/fs/devfs.rs +++ b/src/aero_kernel/src/fs/devfs.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/fs/epoll.rs b/src/aero_kernel/src/fs/epoll.rs index d8ae513590d..ed967f6779f 100644 --- a/src/aero_kernel/src/fs/epoll.rs +++ b/src/aero_kernel/src/fs/epoll.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/fs/eventfd.rs b/src/aero_kernel/src/fs/eventfd.rs index caea7aa24a7..d7b257bcafb 100644 --- a/src/aero_kernel/src/fs/eventfd.rs +++ b/src/aero_kernel/src/fs/eventfd.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/fs/ext2/disk.rs b/src/aero_kernel/src/fs/ext2/disk.rs index f99f046c45c..0dbe5c4f5b1 100644 --- a/src/aero_kernel/src/fs/ext2/disk.rs +++ b/src/aero_kernel/src/fs/ext2/disk.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/fs/ext2/group_desc.rs b/src/aero_kernel/src/fs/ext2/group_desc.rs index d3552158ba2..beaca675e44 100644 --- a/src/aero_kernel/src/fs/ext2/group_desc.rs +++ b/src/aero_kernel/src/fs/ext2/group_desc.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/fs/ext2/mod.rs b/src/aero_kernel/src/fs/ext2/mod.rs index 01326f34f6a..a3bf59bc773 100644 --- a/src/aero_kernel/src/fs/ext2/mod.rs +++ b/src/aero_kernel/src/fs/ext2/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/fs/file_table.rs b/src/aero_kernel/src/fs/file_table.rs index 66ac73890a9..523487493da 100644 --- a/src/aero_kernel/src/fs/file_table.rs +++ b/src/aero_kernel/src/fs/file_table.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/fs/inode.rs b/src/aero_kernel/src/fs/inode.rs index 0ad62ff6530..4cf721ceb8d 100644 --- a/src/aero_kernel/src/fs/inode.rs +++ b/src/aero_kernel/src/fs/inode.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/fs/mod.rs b/src/aero_kernel/src/fs/mod.rs index d6f415aa526..65400e1181d 100644 --- a/src/aero_kernel/src/fs/mod.rs +++ b/src/aero_kernel/src/fs/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/fs/pipe.rs b/src/aero_kernel/src/fs/pipe.rs index 9cf196b95db..be0021f0de7 100644 --- a/src/aero_kernel/src/fs/pipe.rs +++ b/src/aero_kernel/src/fs/pipe.rs @@ -1,3 +1,20 @@ +// Copyright (C) 2021-2024 The Aero Project Developers. +// +// This file is part of The Aero Project. +// +// Aero is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Aero is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Aero. If not, see . + use core::sync::atomic::{AtomicUsize, Ordering}; use aero_syscall::OpenFlags; diff --git a/src/aero_kernel/src/fs/procfs.rs b/src/aero_kernel/src/fs/procfs.rs index 073d08744e0..48f4dc19790 100644 --- a/src/aero_kernel/src/fs/procfs.rs +++ b/src/aero_kernel/src/fs/procfs.rs @@ -1,3 +1,20 @@ +// Copyright (C) 2021-2024 The Aero Project Developers. +// +// This file is part of The Aero Project. +// +// Aero is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Aero is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Aero. If not, see . + use core::sync::atomic::{AtomicUsize, Ordering}; use alloc::borrow::ToOwned; diff --git a/src/aero_kernel/src/fs/ramfs.rs b/src/aero_kernel/src/fs/ramfs.rs index c8835be0b78..060fe214cb7 100644 --- a/src/aero_kernel/src/fs/ramfs.rs +++ b/src/aero_kernel/src/fs/ramfs.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/logger.rs b/src/aero_kernel/src/logger.rs index 0ff59ab1e73..988f0814786 100644 --- a/src/aero_kernel/src/logger.rs +++ b/src/aero_kernel/src/logger.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index 3a391441363..7c08d2fd31f 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/mem/alloc.rs b/src/aero_kernel/src/mem/alloc.rs index e46403e3eb2..e5239d72c82 100644 --- a/src/aero_kernel/src/mem/alloc.rs +++ b/src/aero_kernel/src/mem/alloc.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/mem/mod.rs b/src/aero_kernel/src/mem/mod.rs index cde30ef70d0..a6d5adc3654 100644 --- a/src/aero_kernel/src/mem/mod.rs +++ b/src/aero_kernel/src/mem/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/mem/paging/addr.rs b/src/aero_kernel/src/mem/paging/addr.rs index b42ef95dd0f..75abdca7a08 100644 --- a/src/aero_kernel/src/mem/paging/addr.rs +++ b/src/aero_kernel/src/mem/paging/addr.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/mem/paging/frame.rs b/src/aero_kernel/src/mem/paging/frame.rs index 31a50e8f08b..8333f2a6a7a 100644 --- a/src/aero_kernel/src/mem/paging/frame.rs +++ b/src/aero_kernel/src/mem/paging/frame.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/mem/paging/mapper.rs b/src/aero_kernel/src/mem/paging/mapper.rs index aa36e7eabe5..2efa178dd3d 100644 --- a/src/aero_kernel/src/mem/paging/mapper.rs +++ b/src/aero_kernel/src/mem/paging/mapper.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/mem/paging/mod.rs b/src/aero_kernel/src/mem/paging/mod.rs index 64857cfd5b7..cffac2f2894 100644 --- a/src/aero_kernel/src/mem/paging/mod.rs +++ b/src/aero_kernel/src/mem/paging/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/mem/paging/page.rs b/src/aero_kernel/src/mem/paging/page.rs index 790305cce6f..56e212786d4 100644 --- a/src/aero_kernel/src/mem/paging/page.rs +++ b/src/aero_kernel/src/mem/paging/page.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/mem/paging/page_table.rs b/src/aero_kernel/src/mem/paging/page_table.rs index dd50070d5bd..5698a7c6d7a 100644 --- a/src/aero_kernel/src/mem/paging/page_table.rs +++ b/src/aero_kernel/src/mem/paging/page_table.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/mem/pti.rs b/src/aero_kernel/src/mem/pti.rs index 6292f74d41b..edd5b867e66 100644 --- a/src/aero_kernel/src/mem/pti.rs +++ b/src/aero_kernel/src/mem/pti.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/mem/slab.rs b/src/aero_kernel/src/mem/slab.rs index a291c347441..b92f46d8fdb 100644 --- a/src/aero_kernel/src/mem/slab.rs +++ b/src/aero_kernel/src/mem/slab.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/mem/vmalloc.rs b/src/aero_kernel/src/mem/vmalloc.rs index e1ec8f7a50b..656b7a9bdd7 100644 --- a/src/aero_kernel/src/mem/vmalloc.rs +++ b/src/aero_kernel/src/mem/vmalloc.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/modules.rs b/src/aero_kernel/src/modules.rs index c7ce92203a7..40686669825 100644 --- a/src/aero_kernel/src/modules.rs +++ b/src/aero_kernel/src/modules.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/net/arp.rs b/src/aero_kernel/src/net/arp.rs index ce804f5a789..879dc5c34a6 100644 --- a/src/aero_kernel/src/net/arp.rs +++ b/src/aero_kernel/src/net/arp.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/net/loopback.rs b/src/aero_kernel/src/net/loopback.rs index 6a43b41b0e7..f6bd8a036f2 100644 --- a/src/aero_kernel/src/net/loopback.rs +++ b/src/aero_kernel/src/net/loopback.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/net/mod.rs b/src/aero_kernel/src/net/mod.rs index 1ef19dd290b..bd0bd163405 100644 --- a/src/aero_kernel/src/net/mod.rs +++ b/src/aero_kernel/src/net/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/net/tcp.rs b/src/aero_kernel/src/net/tcp.rs index 9ffb6f520cf..b6337dee38e 100644 --- a/src/aero_kernel/src/net/tcp.rs +++ b/src/aero_kernel/src/net/tcp.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/net/udp.rs b/src/aero_kernel/src/net/udp.rs index f90ea9d284c..1d4599df7d9 100644 --- a/src/aero_kernel/src/net/udp.rs +++ b/src/aero_kernel/src/net/udp.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/rendy.rs b/src/aero_kernel/src/rendy.rs index 30a13e7c29d..2b773f09557 100644 --- a/src/aero_kernel/src/rendy.rs +++ b/src/aero_kernel/src/rendy.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/socket/ipv4.rs b/src/aero_kernel/src/socket/ipv4.rs index d27895816a3..44e0893610d 100644 --- a/src/aero_kernel/src/socket/ipv4.rs +++ b/src/aero_kernel/src/socket/ipv4.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/socket/mod.rs b/src/aero_kernel/src/socket/mod.rs index 1cb73d4c53f..81fbab5b26c 100644 --- a/src/aero_kernel/src/socket/mod.rs +++ b/src/aero_kernel/src/socket/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/socket/netlink.rs b/src/aero_kernel/src/socket/netlink.rs index dc180e638cf..85d22c40494 100644 --- a/src/aero_kernel/src/socket/netlink.rs +++ b/src/aero_kernel/src/socket/netlink.rs @@ -1,3 +1,20 @@ +// Copyright (C) 2021-2024 The Aero Project Developers. +// +// This file is part of The Aero Project. +// +// Aero is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Aero is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Aero. If not, see . + //! Netlink Sockets //! //! Netlink sockets are used for inter-process communication (IPC) between both the kernel and diff --git a/src/aero_kernel/src/socket/tcp.rs b/src/aero_kernel/src/socket/tcp.rs index 05acb9700d7..1cb4c559dff 100644 --- a/src/aero_kernel/src/socket/tcp.rs +++ b/src/aero_kernel/src/socket/tcp.rs @@ -1,3 +1,20 @@ +// Copyright (C) 2021-2024 The Aero Project Developers. +// +// This file is part of The Aero Project. +// +// Aero is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Aero is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Aero. If not, see . + use aero_syscall::socket::{MessageFlags, MessageHeader}; use aero_syscall::{InAddr, OpenFlags, SocketAddrInet, AF_INET}; use alloc::sync::{Arc, Weak}; diff --git a/src/aero_kernel/src/socket/udp.rs b/src/aero_kernel/src/socket/udp.rs index 3d751466688..453279e7398 100644 --- a/src/aero_kernel/src/socket/udp.rs +++ b/src/aero_kernel/src/socket/udp.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/socket/unix.rs b/src/aero_kernel/src/socket/unix.rs index a7a91864aeb..81067917b86 100644 --- a/src/aero_kernel/src/socket/unix.rs +++ b/src/aero_kernel/src/socket/unix.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/syscall/fs.rs b/src/aero_kernel/src/syscall/fs.rs index 3eb0e3ec295..a9d6aeb45c1 100644 --- a/src/aero_kernel/src/syscall/fs.rs +++ b/src/aero_kernel/src/syscall/fs.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/syscall/futex.rs b/src/aero_kernel/src/syscall/futex.rs index ce419cfb73b..e0782114906 100644 --- a/src/aero_kernel/src/syscall/futex.rs +++ b/src/aero_kernel/src/syscall/futex.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/syscall/ipc.rs b/src/aero_kernel/src/syscall/ipc.rs index 662050f9bad..f6471c44bcd 100644 --- a/src/aero_kernel/src/syscall/ipc.rs +++ b/src/aero_kernel/src/syscall/ipc.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/syscall/mod.rs b/src/aero_kernel/src/syscall/mod.rs index e47f24e906c..2d57d128146 100644 --- a/src/aero_kernel/src/syscall/mod.rs +++ b/src/aero_kernel/src/syscall/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/syscall/net.rs b/src/aero_kernel/src/syscall/net.rs index fb6adb6a25f..f54cf2bb3f9 100644 --- a/src/aero_kernel/src/syscall/net.rs +++ b/src/aero_kernel/src/syscall/net.rs @@ -1,3 +1,20 @@ +// Copyright (C) 2021-2024 The Aero Project Developers. +// +// This file is part of The Aero Project. +// +// Aero is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Aero is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Aero. If not, see . + use aero_syscall::netlink::sockaddr_nl; use aero_syscall::socket::{MessageFlags, MessageHeader, SocketOptionLevel}; use aero_syscall::*; diff --git a/src/aero_kernel/src/syscall/process.rs b/src/aero_kernel/src/syscall/process.rs index c943d437c78..df60b8e6c43 100644 --- a/src/aero_kernel/src/syscall/process.rs +++ b/src/aero_kernel/src/syscall/process.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/syscall/time.rs b/src/aero_kernel/src/syscall/time.rs index cde62a4eeaa..0567da5bdb2 100644 --- a/src/aero_kernel/src/syscall/time.rs +++ b/src/aero_kernel/src/syscall/time.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/tests.rs b/src/aero_kernel/src/tests.rs index f0452b4e902..53230b24cc1 100644 --- a/src/aero_kernel/src/tests.rs +++ b/src/aero_kernel/src/tests.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/unwind.rs b/src/aero_kernel/src/unwind.rs index 7ae349e7938..7c2886a5560 100644 --- a/src/aero_kernel/src/unwind.rs +++ b/src/aero_kernel/src/unwind.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/userland/mod.rs b/src/aero_kernel/src/userland/mod.rs index 3568d557cc4..2954470514b 100644 --- a/src/aero_kernel/src/userland/mod.rs +++ b/src/aero_kernel/src/userland/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/userland/scheduler/mod.rs b/src/aero_kernel/src/userland/scheduler/mod.rs index 3691ee879ac..043e97d2dd7 100644 --- a/src/aero_kernel/src/userland/scheduler/mod.rs +++ b/src/aero_kernel/src/userland/scheduler/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/userland/scheduler/round_robin.rs b/src/aero_kernel/src/userland/scheduler/round_robin.rs index a4d6d3d421a..8dcc68fefe4 100644 --- a/src/aero_kernel/src/userland/scheduler/round_robin.rs +++ b/src/aero_kernel/src/userland/scheduler/round_robin.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/userland/signals.rs b/src/aero_kernel/src/userland/signals.rs index cf9d7e849e7..a9a714863d0 100644 --- a/src/aero_kernel/src/userland/signals.rs +++ b/src/aero_kernel/src/userland/signals.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/userland/task/mod.rs b/src/aero_kernel/src/userland/task/mod.rs index 95bc3125dbc..ab4cde12ce4 100644 --- a/src/aero_kernel/src/userland/task/mod.rs +++ b/src/aero_kernel/src/userland/task/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/userland/task/sessions.rs b/src/aero_kernel/src/userland/task/sessions.rs index 9b3ce8f1c5e..c0502680ddd 100644 --- a/src/aero_kernel/src/userland/task/sessions.rs +++ b/src/aero_kernel/src/userland/task/sessions.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/userland/terminal.rs b/src/aero_kernel/src/userland/terminal.rs index 899e69b0061..d7fc67fc888 100644 --- a/src/aero_kernel/src/userland/terminal.rs +++ b/src/aero_kernel/src/userland/terminal.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs index 4e8a69e427b..21f8279bfb9 100644 --- a/src/aero_kernel/src/userland/vm.rs +++ b/src/aero_kernel/src/userland/vm.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/utils/bitmap.rs b/src/aero_kernel/src/utils/bitmap.rs index def9d3aca24..246646af959 100644 --- a/src/aero_kernel/src/utils/bitmap.rs +++ b/src/aero_kernel/src/utils/bitmap.rs @@ -1,3 +1,20 @@ +// Copyright (C) 2021-2024 The Aero Project Developers. +// +// This file is part of The Aero Project. +// +// Aero is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Aero is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Aero. If not, see . + use core::alloc::Allocator; use alloc::vec::Vec; diff --git a/src/aero_kernel/src/utils/buffer.rs b/src/aero_kernel/src/utils/buffer.rs index 4b81e700ea9..2cb0358b419 100644 --- a/src/aero_kernel/src/utils/buffer.rs +++ b/src/aero_kernel/src/utils/buffer.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/utils/dma.rs b/src/aero_kernel/src/utils/dma.rs index e5b95d0642f..861d8f089ab 100644 --- a/src/aero_kernel/src/utils/dma.rs +++ b/src/aero_kernel/src/utils/dma.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/utils/mod.rs b/src/aero_kernel/src/utils/mod.rs index 081c8284836..8fdc0f6389c 100644 --- a/src/aero_kernel/src/utils/mod.rs +++ b/src/aero_kernel/src/utils/mod.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_kernel/src/utils/sync.rs b/src/aero_kernel/src/utils/sync.rs index 8adfd2b0459..7dbe1f53f9c 100644 --- a/src/aero_kernel/src/utils/sync.rs +++ b/src/aero_kernel/src/utils/sync.rs @@ -1,3 +1,20 @@ +// Copyright (C) 2021-2024 The Aero Project Developers. +// +// This file is part of The Aero Project. +// +// Aero is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Aero is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Aero. If not, see . + use alloc::sync::Arc; use alloc::vec::Vec; diff --git a/src/aero_proc/src/cpu_local.rs b/src/aero_proc/src/cpu_local.rs index 244fee62336..e287505f92f 100644 --- a/src/aero_proc/src/cpu_local.rs +++ b/src/aero_proc/src/cpu_local.rs @@ -1,3 +1,20 @@ +// Copyright (C) 2021-2024 The Aero Project Developers. +// +// This file is part of The Aero Project. +// +// Aero is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Aero is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Aero. If not, see . + use proc_macro::TokenStream; use syn::{Lit, Meta, MetaNameValue, NestedMeta}; diff --git a/src/aero_proc/src/downcastable.rs b/src/aero_proc/src/downcastable.rs index 9de451fb531..8ffdf27de3d 100644 --- a/src/aero_proc/src/downcastable.rs +++ b/src/aero_proc/src/downcastable.rs @@ -1,3 +1,20 @@ +// Copyright (C) 2021-2024 The Aero Project Developers. +// +// This file is part of The Aero Project. +// +// Aero is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Aero is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Aero. If not, see . + use proc_macro::TokenStream; use syn::spanned::Spanned; diff --git a/src/aero_proc/src/indirect.rs b/src/aero_proc/src/indirect.rs index 6af4dad3b85..f4b4b1d6478 100644 --- a/src/aero_proc/src/indirect.rs +++ b/src/aero_proc/src/indirect.rs @@ -1,3 +1,20 @@ +// Copyright (C) 2021-2024 The Aero Project Developers. +// +// This file is part of The Aero Project. +// +// Aero is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Aero is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Aero. If not, see . + use proc_macro::TokenStream; use proc_macro2::{Ident, Span}; use syn::spanned::Spanned; diff --git a/src/aero_proc/src/ioctl.rs b/src/aero_proc/src/ioctl.rs index 38abcc1fdcc..4867aec43b3 100644 --- a/src/aero_proc/src/ioctl.rs +++ b/src/aero_proc/src/ioctl.rs @@ -1,3 +1,20 @@ +// Copyright (C) 2021-2024 The Aero Project Developers. +// +// This file is part of The Aero Project. +// +// Aero is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Aero is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Aero. If not, see . + use proc_macro::TokenStream; use syn::{Data, DeriveInput, Path}; diff --git a/src/aero_proc/src/lib.rs b/src/aero_proc/src/lib.rs index 3809b200c32..75cafa90d69 100644 --- a/src/aero_proc/src/lib.rs +++ b/src/aero_proc/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_proc/src/syscall.rs b/src/aero_proc/src/syscall.rs index 935c48b6488..0651e41e642 100644 --- a/src/aero_proc/src/syscall.rs +++ b/src/aero_proc/src/syscall.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_proc/src/test.rs b/src/aero_proc/src/test.rs index 845f35dd17b..a009d741ab3 100644 --- a/src/aero_proc/src/test.rs +++ b/src/aero_proc/src/test.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_syscall/src/consts.rs b/src/aero_syscall/src/consts.rs index 6a2f55d7824..fb800d38f6e 100644 --- a/src/aero_syscall/src/consts.rs +++ b/src/aero_syscall/src/consts.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_syscall/src/lib.rs b/src/aero_syscall/src/lib.rs index fd0257445ff..98ce5533487 100644 --- a/src/aero_syscall/src/lib.rs +++ b/src/aero_syscall/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_syscall/src/signal.rs b/src/aero_syscall/src/signal.rs index 3d6a2c4c4ef..fe814c5a5b8 100644 --- a/src/aero_syscall/src/signal.rs +++ b/src/aero_syscall/src/signal.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_syscall/src/syscall.rs b/src/aero_syscall/src/syscall.rs index 36e20f8389c..1b20e34f5e2 100644 --- a/src/aero_syscall/src/syscall.rs +++ b/src/aero_syscall/src/syscall.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/src/aero_syscall/src/time.rs b/src/aero_syscall/src/time.rs index 818c121ca2d..0d7a41a3985 100644 --- a/src/aero_syscall/src/time.rs +++ b/src/aero_syscall/src/time.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/userland/apps/window_test/src/main.rs b/userland/apps/window_test/src/main.rs index 2adf6124ad9..9a7496f9f34 100644 --- a/userland/apps/window_test/src/main.rs +++ b/userland/apps/window_test/src/main.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/userland/servers/system_server/src/main.rs b/userland/servers/system_server/src/main.rs index 4f300419c33..54ad8378cc4 100644 --- a/userland/servers/system_server/src/main.rs +++ b/userland/servers/system_server/src/main.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // diff --git a/userland/servers/window_server/src/main.rs b/userland/servers/window_server/src/main.rs index 42d0841859e..4f7d385e42e 100644 --- a/userland/servers/window_server/src/main.rs +++ b/userland/servers/window_server/src/main.rs @@ -1,4 +1,4 @@ -// Copyright (C) 2021-2023 The Aero Project Developers. +// Copyright (C) 2021-2024 The Aero Project Developers. // // This file is part of The Aero Project. // From ab409b8162da7c047d06e2aaa170333811d13eeb Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 6 Jan 2024 15:54:25 +1100 Subject: [PATCH 024/112] misc(kernel): cleanup Signed-off-by: Anhad Singh --- patches/mlibc/mlibc.patch | 647 +++++++++++++++++++++++++- src/aero_kernel/src/fs/devfs.rs | 2 +- src/aero_kernel/src/socket/netlink.rs | 2 +- src/aero_kernel/src/utils/mod.rs | 2 +- 4 files changed, 638 insertions(+), 15 deletions(-) diff --git a/patches/mlibc/mlibc.patch b/patches/mlibc/mlibc.patch index 9177a8cd494..4b4fe9f22b4 100644 --- a/patches/mlibc/mlibc.patch +++ b/patches/mlibc/mlibc.patch @@ -1,9 +1,21 @@ -From ea30fe59e091c87eb09d24c20946ee7a90d371c2 Mon Sep 17 00:00:00 2001 +From ff3ad2ec971fffda2a1f098d4e574361f14ab0d2 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Tue, 14 Nov 2023 17:51:25 +1100 Subject: [PATCH] Signed-off-by: Anhad Singh +--- + options/intl/generic/libintl-stubs.cpp | 66 ++- + options/posix/generic/pthread-stubs.cpp | 90 +++- + options/rtdl/generic/linker.cpp | 5 +- + options/rtdl/include/mlibc/rtdl-sysdeps.hpp | 1 + + sysdeps/aero/generic/aero.cpp | 28 +- + sysdeps/aero/generic/filesystem.cpp | 32 +- + sysdeps/aero/generic/sockets.cpp | 10 +- + sysdeps/aero/include/aero/syscall.h | 3 + + sysdeps/aero/include/mlibc/jsmn.h | 474 ++++++++++++++++++++ + 9 files changed, 632 insertions(+), 77 deletions(-) + create mode 100644 sysdeps/aero/include/mlibc/jsmn.h diff --git a/options/intl/generic/libintl-stubs.cpp b/options/intl/generic/libintl-stubs.cpp index 8d4b28f..94ab421 100644 @@ -109,18 +121,125 @@ index 8d4b28f..94ab421 100644 + return (char*)""; } diff --git a/options/posix/generic/pthread-stubs.cpp b/options/posix/generic/pthread-stubs.cpp -index 5618dc6..cd9350d 100644 +index 5618dc6..a5edec6 100644 --- a/options/posix/generic/pthread-stubs.cpp +++ b/options/posix/generic/pthread-stubs.cpp -@@ -299,7 +299,7 @@ int pthread_getattr_np(pthread_t thread, pthread_attr_t *attr) { +@@ -1,4 +1,3 @@ +- + #include + #include + #include +@@ -265,6 +264,87 @@ int pthread_attr_setsigmask_np(pthread_attr_t *__restrict attr, + } + + namespace { ++#include ++#ifdef __aero__ ++ static bool jsoneq(const char *input, jsmntok_t tok, const char *expected) { ++ if (tok.type == JSMN_STRING && ++ (int)strlen(expected) == tok.end - tok.start && ++ strncmp(input + tok.start, expected, tok.end - tok.start) == 0) { ++ return true; ++ } ++ ++ return false; ++ } ++ ++ size_t string_to_usize(const char *string, size_t length) { ++ size_t ret = 0; ++ for (size_t i = 0; i < length; i++) { ++ ret = ret * 10 + (string[i] - '0'); ++ } ++ ++ return ret; ++ } ++ ++ void get_own_stackinfo(void **stack_addr, size_t *stack_size) { ++ auto fp = fopen("/proc/self/maps", "r"); ++ if (!fp) { ++ mlibc::infoLogger() << "mlibc pthreads: /proc/self/maps does not exist! Producing incorrect" ++ " stack results!" << frg::endlog; ++ return; ++ } ++ ++ auto sp = mlibc::get_sp(); ++ ++ char *INPUT = (char *)malloc(4096 * 4); ++ size_t INPUT_SIZE = fread(INPUT, 1, 4096 * 4, fp); ++ ++ jsmn_parser parser; ++ jsmn_init(&parser); ++ ++ int n = jsmn_parse(&parser, INPUT, INPUT_SIZE, nullptr, 0); ++ FRG_ASSERT(n > 0); ++ ++ jsmntok_t *tokens = static_cast(malloc(sizeof(jsmntok_t) * n)); ++ ++ jsmn_init(&parser); ++ int result = jsmn_parse(&parser, INPUT, INPUT_SIZE, tokens, n); ++ FRG_ASSERT(tokens[0].type == JSMN_OBJECT); ++ ++ FRG_ASSERT(jsoneq(INPUT, tokens[1], "maps")); ++ ++ size_t n_fields = tokens[3].size; ++ for (size_t i = 3; i < tokens[2].size * (n_fields * 2 + 1); i+=(n_fields * 2 + 1)) { ++ jsmntok_t *mapping = &tokens[i]; ++ FRG_ASSERT(mapping->type == JSMN_OBJECT); ++ ++ size_t start = SIZE_MAX; ++ size_t end = SIZE_MAX; ++ ++ for (size_t j = 1; j < mapping->size * 2; j += 2) { ++ jsmntok_t *value = &mapping[j + 1]; ++ ++ size_t val = string_to_usize(INPUT + value->start, value->end - value->start); ++ ++ if (jsoneq(INPUT, mapping[j], "start")) { ++ start = val; ++ } else if (jsoneq(INPUT, mapping[j], "end")) { ++ end = val; ++ } ++ } ++ ++ if (sp < end && sp > start) { ++ *stack_addr = reinterpret_cast(start); ++ *stack_size = end - start; ++ ++ fclose(fp); ++ free(INPUT); ++ return; ++ } ++ } ++ ++ FRG_ASSERT(!"reached unreachable code"); ++ } ++#else + void get_own_stackinfo(void **stack_addr, size_t *stack_size) { + auto fp = fopen("/proc/self/maps", "r"); + if (!fp) { +@@ -290,7 +370,8 @@ namespace { + + fclose(fp); + } +-} ++#endif ++} // namespace annonymous + + int pthread_getattr_np(pthread_t thread, pthread_attr_t *attr) { + auto tcb = reinterpret_cast(thread); +@@ -299,9 +380,10 @@ int pthread_getattr_np(pthread_t thread, pthread_attr_t *attr) { if (!tcb->stackAddr || !tcb->stackSize) { // allocate stack - attr->__mlibc_stackaddr = 0x00; + attr->__mlibc_stackaddr = (void*)0x7ffffff9a000; attr->__mlibc_stacksize = 0x20000; - // get_own_stackinfo(&attr->__mlibc_stackaddr, &attr->__mlibc_stacksize); +- // get_own_stackinfo(&attr->__mlibc_stackaddr, &attr->__mlibc_stacksize); ++ ++ get_own_stackinfo(&attr->__mlibc_stackaddr, &attr->__mlibc_stacksize); } else { + attr->__mlibc_stacksize = tcb->stackSize; + attr->__mlibc_stackaddr = tcb->stackAddr; diff --git a/options/rtdl/generic/linker.cpp b/options/rtdl/generic/linker.cpp index 50cca94..a095ab0 100644 --- a/options/rtdl/generic/linker.cpp @@ -159,7 +278,7 @@ index c35271c..8a941b2 100644 } // namespace mlibc diff --git a/sysdeps/aero/generic/aero.cpp b/sysdeps/aero/generic/aero.cpp -index e19b159..e3c11a4 100644 +index e19b159..a54b6d3 100644 --- a/sysdeps/aero/generic/aero.cpp +++ b/sysdeps/aero/generic/aero.cpp @@ -62,6 +62,10 @@ static frg::vector create_slice(char *const arg[]) { @@ -173,16 +292,40 @@ index e19b159..e3c11a4 100644 int sys_uname(struct utsname *buf) { auto result = syscall(SYS_UNAME, buf); -@@ -73,6 +77,8 @@ int sys_uname(struct utsname *buf) { +@@ -73,22 +77,20 @@ int sys_uname(struct utsname *buf) { } int sys_futex_wait(int *pointer, int expected, const struct timespec *time) { -+ while (*pointer == expected) {} +- // auto result = syscall(SYS_FUTEX_WAIT, pointer, expected, time); +- // +- // if (result < 0) { +- // return -result; +- // } +- // ++ auto ret = syscall(SYS_FUTEX_WAIT, pointer, expected, time); + - // auto result = syscall(SYS_FUTEX_WAIT, pointer, expected, time); - // - // if (result < 0) { -@@ -309,7 +315,7 @@ int sys_thread_setname(void *tcb, const char *name) { ++ if (int e = sc_error(ret); e) ++ return e; ++ + return 0; + } + + int sys_futex_wake(int *pointer) { +- // auto result = syscall(SYS_FUTEX_WAKE, pointer); +- // +- // if (result < 0) { +- // return -result; +- // } +- // ++ auto ret = syscall(SYS_FUTEX_WAKE, pointer); ++ ++ if (int e = sc_error(ret); e) ++ return e; ++ + return 0; + } + +@@ -309,7 +311,7 @@ int sys_thread_setname(void *tcb, const char *name) { } void sys_thread_exit() { @@ -286,6 +429,486 @@ index 39c5b65..bd2f489 100644 // Invalid syscall used to trigger a log error in the kernel (as a hint) // so, that we can implement the syscall in the kernel. +diff --git a/sysdeps/aero/include/mlibc/jsmn.h b/sysdeps/aero/include/mlibc/jsmn.h +new file mode 100644 +index 0000000..2d8f591 +--- /dev/null ++++ b/sysdeps/aero/include/mlibc/jsmn.h +@@ -0,0 +1,474 @@ ++/* ++ * MIT License ++ * ++ * Copyright (c) 2010 Serge Zaitsev ++ * ++ * Permission is hereby granted, free of charge, to any person obtaining a copy ++ * of this software and associated documentation files (the "Software"), to deal ++ * in the Software without restriction, including without limitation the rights ++ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ++ * copies of the Software, and to permit persons to whom the Software is ++ * furnished to do so, subject to the following conditions: ++ * ++ * The above copyright notice and this permission notice shall be included in ++ * all copies or substantial portions of the Software. ++ * ++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ++ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ++ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ++ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ++ * SOFTWARE. ++ */ ++#ifndef JSMN_H ++#define JSMN_H ++ ++#include ++ ++#define JSMN_PARENT_LINKS ++#define JSMN_STRICT ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#ifdef JSMN_STATIC ++#define JSMN_API static ++#else ++#define JSMN_API extern ++#endif ++ ++/** ++ * JSON type identifier. Basic types are: ++ * o Object ++ * o Array ++ * o String ++ * o Other primitive: number, boolean (true/false) or null ++ */ ++typedef enum { ++ JSMN_UNDEFINED = 0, ++ JSMN_OBJECT = 1 << 0, ++ JSMN_ARRAY = 1 << 1, ++ JSMN_STRING = 1 << 2, ++ JSMN_PRIMITIVE = 1 << 3 ++} jsmntype_t; ++ ++enum jsmnerr { ++ /* Not enough tokens were provided */ ++ JSMN_ERROR_NOMEM = -1, ++ /* Invalid character inside JSON string */ ++ JSMN_ERROR_INVAL = -2, ++ /* The string is not a full JSON packet, more bytes expected */ ++ JSMN_ERROR_PART = -3 ++}; ++ ++/** ++ * JSON token description. ++ * type type (object, array, string etc.) ++ * start start position in JSON data string ++ * end end position in JSON data string ++ */ ++typedef struct jsmntok { ++ jsmntype_t type; ++ int start; ++ int end; ++ int size; ++#ifdef JSMN_PARENT_LINKS ++ int parent; ++#endif ++} jsmntok_t; ++ ++/** ++ * JSON parser. Contains an array of token blocks available. Also stores ++ * the string being parsed now and current position in that string. ++ */ ++typedef struct jsmn_parser { ++ unsigned int pos; /* offset in the JSON string */ ++ unsigned int toknext; /* next token to allocate */ ++ int toksuper; /* superior token node, e.g. parent object or array */ ++} jsmn_parser; ++ ++/** ++ * Create JSON parser over an array of tokens ++ */ ++JSMN_API void jsmn_init(jsmn_parser *parser); ++ ++/** ++ * Run JSON parser. It parses a JSON data string into and array of tokens, each ++ * describing ++ * a single JSON object. ++ */ ++JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len, ++ jsmntok_t *tokens, const unsigned int num_tokens); ++ ++#ifndef JSMN_HEADER ++/** ++ * Allocates a fresh unused token from the token pool. ++ */ ++static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, jsmntok_t *tokens, ++ const size_t num_tokens) { ++ jsmntok_t *tok; ++ if (parser->toknext >= num_tokens) { ++ return NULL; ++ } ++ tok = &tokens[parser->toknext++]; ++ tok->start = tok->end = -1; ++ tok->size = 0; ++#ifdef JSMN_PARENT_LINKS ++ tok->parent = -1; ++#endif ++ return tok; ++} ++ ++/** ++ * Fills token type and boundaries. ++ */ ++static void jsmn_fill_token(jsmntok_t *token, const jsmntype_t type, ++ const int start, const int end) { ++ token->type = type; ++ token->start = start; ++ token->end = end; ++ token->size = 0; ++} ++ ++/** ++ * Fills next available token with JSON primitive. ++ */ ++static int jsmn_parse_primitive(jsmn_parser *parser, const char *js, ++ const size_t len, jsmntok_t *tokens, ++ const size_t num_tokens) { ++ jsmntok_t *token; ++ int start; ++ ++ start = parser->pos; ++ ++ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { ++ switch (js[parser->pos]) { ++#ifndef JSMN_STRICT ++ /* In strict mode primitive must be followed by "," or "}" or "]" */ ++ case ':': ++#endif ++ case '\t': ++ case '\r': ++ case '\n': ++ case ' ': ++ case ',': ++ case ']': ++ case '}': ++ goto found; ++ default: ++ /* to quiet a warning from gcc*/ ++ break; ++ } ++ if (js[parser->pos] < 32 || js[parser->pos] >= 127) { ++ parser->pos = start; ++ return JSMN_ERROR_INVAL; ++ } ++ } ++#ifdef JSMN_STRICT ++ /* In strict mode primitive must be followed by a comma/object/array */ ++ parser->pos = start; ++ return JSMN_ERROR_PART; ++#endif ++ ++found: ++ if (tokens == NULL) { ++ parser->pos--; ++ return 0; ++ } ++ token = jsmn_alloc_token(parser, tokens, num_tokens); ++ if (token == NULL) { ++ parser->pos = start; ++ return JSMN_ERROR_NOMEM; ++ } ++ jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos); ++#ifdef JSMN_PARENT_LINKS ++ token->parent = parser->toksuper; ++#endif ++ parser->pos--; ++ return 0; ++} ++ ++/** ++ * Fills next token with JSON string. ++ */ ++static int jsmn_parse_string(jsmn_parser *parser, const char *js, ++ const size_t len, jsmntok_t *tokens, ++ const size_t num_tokens) { ++ jsmntok_t *token; ++ ++ int start = parser->pos; ++ ++ /* Skip starting quote */ ++ parser->pos++; ++ ++ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { ++ char c = js[parser->pos]; ++ ++ /* Quote: end of string */ ++ if (c == '\"') { ++ if (tokens == NULL) { ++ return 0; ++ } ++ token = jsmn_alloc_token(parser, tokens, num_tokens); ++ if (token == NULL) { ++ parser->pos = start; ++ return JSMN_ERROR_NOMEM; ++ } ++ jsmn_fill_token(token, JSMN_STRING, start + 1, parser->pos); ++#ifdef JSMN_PARENT_LINKS ++ token->parent = parser->toksuper; ++#endif ++ return 0; ++ } ++ ++ /* Backslash: Quoted symbol expected */ ++ if (c == '\\' && parser->pos + 1 < len) { ++ int i; ++ parser->pos++; ++ switch (js[parser->pos]) { ++ /* Allowed escaped symbols */ ++ case '\"': ++ case '/': ++ case '\\': ++ case 'b': ++ case 'f': ++ case 'r': ++ case 'n': ++ case 't': ++ break; ++ /* Allows escaped symbol \uXXXX */ ++ case 'u': ++ parser->pos++; ++ for (i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; ++ i++) { ++ /* If it isn't a hex character we have an error */ ++ if (!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */ ++ (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */ ++ (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */ ++ parser->pos = start; ++ return JSMN_ERROR_INVAL; ++ } ++ parser->pos++; ++ } ++ parser->pos--; ++ break; ++ /* Unexpected symbol */ ++ default: ++ parser->pos = start; ++ return JSMN_ERROR_INVAL; ++ } ++ } ++ } ++ parser->pos = start; ++ return JSMN_ERROR_PART; ++} ++ ++/** ++ * Parse JSON string and fill tokens. ++ */ ++JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len, ++ jsmntok_t *tokens, const unsigned int num_tokens) { ++ int r; ++ int i; ++ jsmntok_t *token; ++ int count = parser->toknext; ++ ++ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { ++ char c; ++ jsmntype_t type; ++ ++ c = js[parser->pos]; ++ switch (c) { ++ case '{': ++ case '[': ++ count++; ++ if (tokens == NULL) { ++ break; ++ } ++ token = jsmn_alloc_token(parser, tokens, num_tokens); ++ if (token == NULL) { ++ return JSMN_ERROR_NOMEM; ++ } ++ if (parser->toksuper != -1) { ++ jsmntok_t *t = &tokens[parser->toksuper]; ++#ifdef JSMN_STRICT ++ /* In strict mode an object or array can't become a key */ ++ if (t->type == JSMN_OBJECT) { ++ return JSMN_ERROR_INVAL; ++ } ++#endif ++ t->size++; ++#ifdef JSMN_PARENT_LINKS ++ token->parent = parser->toksuper; ++#endif ++ } ++ token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY); ++ token->start = parser->pos; ++ parser->toksuper = parser->toknext - 1; ++ break; ++ case '}': ++ case ']': ++ if (tokens == NULL) { ++ break; ++ } ++ type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY); ++#ifdef JSMN_PARENT_LINKS ++ if (parser->toknext < 1) { ++ return JSMN_ERROR_INVAL; ++ } ++ token = &tokens[parser->toknext - 1]; ++ for (;;) { ++ if (token->start != -1 && token->end == -1) { ++ if (token->type != type) { ++ return JSMN_ERROR_INVAL; ++ } ++ token->end = parser->pos + 1; ++ parser->toksuper = token->parent; ++ break; ++ } ++ if (token->parent == -1) { ++ if (token->type != type || parser->toksuper == -1) { ++ return JSMN_ERROR_INVAL; ++ } ++ break; ++ } ++ token = &tokens[token->parent]; ++ } ++#else ++ for (i = parser->toknext - 1; i >= 0; i--) { ++ token = &tokens[i]; ++ if (token->start != -1 && token->end == -1) { ++ if (token->type != type) { ++ return JSMN_ERROR_INVAL; ++ } ++ parser->toksuper = -1; ++ token->end = parser->pos + 1; ++ break; ++ } ++ } ++ /* Error if unmatched closing bracket */ ++ if (i == -1) { ++ return JSMN_ERROR_INVAL; ++ } ++ for (; i >= 0; i--) { ++ token = &tokens[i]; ++ if (token->start != -1 && token->end == -1) { ++ parser->toksuper = i; ++ break; ++ } ++ } ++#endif ++ break; ++ case '\"': ++ r = jsmn_parse_string(parser, js, len, tokens, num_tokens); ++ if (r < 0) { ++ return r; ++ } ++ count++; ++ if (parser->toksuper != -1 && tokens != NULL) { ++ tokens[parser->toksuper].size++; ++ } ++ break; ++ case '\t': ++ case '\r': ++ case '\n': ++ case ' ': ++ break; ++ case ':': ++ parser->toksuper = parser->toknext - 1; ++ break; ++ case ',': ++ if (tokens != NULL && parser->toksuper != -1 && ++ tokens[parser->toksuper].type != JSMN_ARRAY && ++ tokens[parser->toksuper].type != JSMN_OBJECT) { ++#ifdef JSMN_PARENT_LINKS ++ parser->toksuper = tokens[parser->toksuper].parent; ++#else ++ for (i = parser->toknext - 1; i >= 0; i--) { ++ if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) { ++ if (tokens[i].start != -1 && tokens[i].end == -1) { ++ parser->toksuper = i; ++ break; ++ } ++ } ++ } ++#endif ++ } ++ break; ++#ifdef JSMN_STRICT ++ /* In strict mode primitives are: numbers and booleans */ ++ case '-': ++ case '0': ++ case '1': ++ case '2': ++ case '3': ++ case '4': ++ case '5': ++ case '6': ++ case '7': ++ case '8': ++ case '9': ++ case 't': ++ case 'f': ++ case 'n': ++ /* And they must not be keys of the object */ ++ if (tokens != NULL && parser->toksuper != -1) { ++ const jsmntok_t *t = &tokens[parser->toksuper]; ++ if (t->type == JSMN_OBJECT || ++ (t->type == JSMN_STRING && t->size != 0)) { ++ return JSMN_ERROR_INVAL; ++ } ++ } ++#else ++ /* In non-strict mode every unquoted value is a primitive */ ++ default: ++#endif ++ r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens); ++ if (r < 0) { ++ return r; ++ } ++ count++; ++ if (parser->toksuper != -1 && tokens != NULL) { ++ tokens[parser->toksuper].size++; ++ } ++ break; ++ ++#ifdef JSMN_STRICT ++ /* Unexpected char in strict mode */ ++ default: ++ return JSMN_ERROR_INVAL; ++#endif ++ } ++ } ++ ++ if (tokens != NULL) { ++ for (i = parser->toknext - 1; i >= 0; i--) { ++ /* Unmatched opened object or array */ ++ if (tokens[i].start != -1 && tokens[i].end == -1) { ++ return JSMN_ERROR_PART; ++ } ++ } ++ } ++ ++ return count; ++} ++ ++/** ++ * Creates a new parser based over a given buffer with an array of tokens ++ * available. ++ */ ++JSMN_API void jsmn_init(jsmn_parser *parser) { ++ parser->pos = 0; ++ parser->toknext = 0; ++ parser->toksuper = -1; ++} ++ ++#endif /* JSMN_HEADER */ ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* JSMN_H */ -- -2.42.1 +2.43.0 diff --git a/src/aero_kernel/src/fs/devfs.rs b/src/aero_kernel/src/fs/devfs.rs index 83b59569542..819c17d212d 100644 --- a/src/aero_kernel/src/fs/devfs.rs +++ b/src/aero_kernel/src/fs/devfs.rs @@ -336,7 +336,7 @@ impl INodeInterface for DevFb { // This is a shared file mapping. let fb = lock.get_framebuffer(); - let fb_ptr = fb.as_ptr() as *const u8; + let fb_ptr = fb.as_ptr().cast::(); let fb_ptr = fb_ptr.add(offset); let fb_phys_ptr = fb_ptr.sub(crate::PHYSICAL_MEMORY_OFFSET.as_u64() as usize); diff --git a/src/aero_kernel/src/socket/netlink.rs b/src/aero_kernel/src/socket/netlink.rs index 85d22c40494..bc3588a3169 100644 --- a/src/aero_kernel/src/socket/netlink.rs +++ b/src/aero_kernel/src/socket/netlink.rs @@ -292,7 +292,7 @@ impl INodeInterface for NetLinkSocket { let mut offset = 0; while offset + hdr_size <= data.len() { - let header = unsafe { &*(data.as_ptr().add(offset) as *const netlink::nlmsghdr) }; + let header = unsafe { &*(data.as_ptr().cast::().byte_add(offset)) }; let payload = &data[offset + hdr_size..]; match header.nlmsg_type { diff --git a/src/aero_kernel/src/utils/mod.rs b/src/aero_kernel/src/utils/mod.rs index 8fdc0f6389c..d2cabaa058b 100644 --- a/src/aero_kernel/src/utils/mod.rs +++ b/src/aero_kernel/src/utils/mod.rs @@ -162,7 +162,7 @@ impl PerCpu { } pub fn slice_into_bytes(slice: &[T]) -> &[u8] { - let data = slice.as_ptr() as *const u8; + let data = slice.as_ptr().cast::(); let size = core::mem::size_of_val(slice); unsafe { core::slice::from_raw_parts(data, size) } From 53099256da593e6d6da928b5af4ac535f3e18204 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 6 Jan 2024 20:19:10 +1100 Subject: [PATCH 025/112] misc(config): unstable flags to improve compilation times Signed-off-by: Anhad Singh --- src/.cargo/config.toml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/.cargo/config.toml b/src/.cargo/config.toml index c6633f4e6a3..c583ec52b03 100644 --- a/src/.cargo/config.toml +++ b/src/.cargo/config.toml @@ -4,4 +4,14 @@ build-std-features = ["compiler-builtins-mem"] [build] target = "./.cargo/x86_64-aero_os.json" -rustflags = ["-Cforce-frame-pointers=yes"] +rustflags = [ + # Miscellaneous: + "-Cforce-frame-pointers=yes", + + # Unstable faster compilation time flags: + # + # https://blog.rust-lang.org/2023/11/09/parallel-rustc.html + "-Zthreads=8", + # https://blog.rust-lang.org/inside-rust/2023/12/22/trait-system-refactor-initiative.html + "-Znext-solver=coherence", +] From dd72c3dbd9514430e46b632c2a832798cbef29b8 Mon Sep 17 00:00:00 2001 From: Anhad Singh <62820092+Andy-Python-Programmer@users.noreply.github.com> Date: Tue, 9 Jan 2024 13:24:49 +1100 Subject: [PATCH 026/112] Create FUNDING.yml --- .github/FUNDING.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000000..0e38fe5a9c3 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,13 @@ +# These are supported funding model platforms + +github: [Andy-Python-Programmer] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] From 4b5f1082f3a3e3f15df143b62925d7aa235ae993 Mon Sep 17 00:00:00 2001 From: Anhad Singh <62820092+Andy-Python-Programmer@users.noreply.github.com> Date: Sun, 11 Feb 2024 13:31:09 +1100 Subject: [PATCH 027/112] switch to Jinx (#117) Signed-off-by: Anhad Singh --- .gitattributes | 6 +- .github/workflows/build.yml | 4 +- .gitignore | 9 + Makefile | 47 + base-files/bin | 1 + base-files/etc/X11/xinit/xinitrc | 2 + .../xorg => base-files/etc/X11}/xorg.conf | 0 base-files/lib | 1 + base-files/lib64 | 1 + base-files/sbin | 1 + build-support/cross-llvm-config | 95 ++ build-support/jwm/system.jwmrc | 228 +++++ build-support/limine.cfg | 12 + build-support/mkimage.sh | 33 + build-support/mkiso.sh | 24 + build-support/rust/config.toml | 22 + extra-files/rust/config.toml | 22 - host-recipes/autoconf | 16 + host-recipes/autoconf-2.69 | 16 + host-recipes/automake | 21 + host-recipes/binutils | 24 + host-recipes/cmake | 18 + host-recipes/gcc | 38 + host-recipes/gnulib | 3 + host-recipes/libgcc-binaries | 8 + host-recipes/libtool | 23 + host-recipes/limine | 24 + host-recipes/llvm | 27 + host-recipes/pkg-config | 28 + host-recipes/rust | 25 + improving-build-times.txt | 2 + jinx-config | 72 ++ patches/alacritty/alacritty.patch | 71 -- patches/alsa-lib/alsa-lib.patch | 124 --- patches/autoconf/jinx-working-patch.patch | 47 + patches/automake-v1.16/automake-v1.16.patch | 26 - patches/bash/bash.patch | 282 ------ patches/bash/jinx-working-patch.patch | 368 +++++++ patches/binutils/binutils.patch | 87 -- patches/binutils/jinx-working-patch.patch | 154 +++ patches/cairo/jinx-working-patch.patch | 33 + patches/coreutils/coreutils.patch | 13 - patches/dbus/jinx-working-patch.patch | 13 + patches/dmenu/dmenu.patch | 27 - patches/dwm/0001-uselessgaps.patch | 81 -- patches/dwm/dwm.patch | 71 -- ...001-fontconfig-aero-specific-changes.patch | 26 - patches/fontconfig/jinx-working-patch.patch | 13 + patches/gcc-host/jinx-working-patch.patch | 153 +++ patches/gcc/gcc.patch | 214 ---- patches/glib/0001-glib.patch | 51 - ...ch-out-assert-in-g_io_unix_get_flags.patch | 30 - patches/glib/jinx-working-patch.patch | 53 + .../gobject-introspection.patch | 29 - patches/gtk+-3/gtk+-3.patch | 77 -- patches/gtk+-3/jinx-working-patch.patch | 37 + patches/jq/jq.patch | 40 - patches/libdrm/libdrm.patch | 147 --- patches/libgcrypt/jinx-working-patch.patch | 23 + .../0001-libiconv-aero-specific-changes.patch | 50 - patches/libtasn/libtasn.patch | 25 - patches/libtool/jinx-working-patch.patch | 138 +++ patches/libtool/libtool.patch | 60 -- ...0001-libxfont2-aero-specific-changes.patch | 37 - ...dd-aero.patch => jinx-working-patch.patch} | 321 ++---- patches/mesa/jinx-working-patch.patch | 157 +++ patches/mesa/mesa.patch | 219 ----- patches/mlibc/jinx-working-patch.patch | 180 ++++ patches/mlibc/mlibc.patch | 914 ------------------ patches/ncurses/jinx-working-patch.patch | 15 + patches/ncurses/ncurses.patch | 41 - patches/neofetch/neofetch.patch | 34 - patches/nss/0001-Add-a-missing-include.patch | 24 - patches/nss/0002-NSS-Standalone-patch.patch | 258 ----- patches/nyancat/nyancat.patch | 42 - ...changes.patch => jinx-working-patch.patch} | 94 +- patches/python/python.patch | 81 -- patches/quickjs/quickjs.patch | 86 -- patches/readline/jinx-working-patch.patch | 22 + patches/readline/readline.patch | 48 - patches/rust-getrandom/rust-getrandom.patch | 53 - patches/rust-glutin/rust-glutin.patch | 331 ------- patches/rust-host/jinx-working-patch.patch | 531 ++++++++++ patches/rust-libloading/rust-libloading.patch | 50 - patches/rust-mio-0.6/rust-mio-0.6.patch | 94 -- patches/rust-mio-0.8/rust-mio-0.8.patch | 73 -- patches/rust-nix/rust-nix.patch | 708 -------------- patches/rust-num-cpus/rust-num-cpus.patch | 35 - .../rust-shared-library.patch | 45 - patches/rust-users/rust-users.patch | 40 - patches/rust-winit/rust-winit.patch | 122 --- ...p-build-target-in-x.py-and-bootstrap.patch | 77 -- patches/tcc/tcc.patch | 166 ---- patches/wayland/wayland.patch | 71 -- .../webkitgtk/0001-Initial-Aero-support.patch | 243 ----- patches/webkitgtk/0002-xxx.patch | 181 ---- ...eyboard.patch => jinx-working-patch.patch} | 68 +- ...t-mouse.patch => jinx-working-patch.patch} | 53 +- ...changes.patch => jinx-working-patch.patch} | 64 +- ...001-xorg-proto-aero-specific-changes.patch | 52 - patches/xorg-proto/jinx-working-patch.patch | 27 + ...-server.patch => jinx-working-patch.patch} | 212 ++-- patches/xorg-xinit/jinx-working-patch.patch | 13 + patches/xorg-xinit/xorg-xinit.patch | 25 - .../0001-zlib-aero-specific-changes.patch | 26 - recipes/at-spi2-core | 22 + recipes/autoconf-archive | 12 + recipes/base-files | 8 + recipes/bash | 30 + recipes/binutils | 40 + recipes/bzip2 | 66 ++ recipes/cairo | 24 + recipes/core-libs | 3 + recipes/coreutils | 40 + recipes/cxxshim | 21 + recipes/dbus | 39 + recipes/fontconfig | 29 + recipes/freeglut | 28 + recipes/freetype2 | 21 + recipes/fribidi | 25 + recipes/frigg | 22 + recipes/gcc | 48 + recipes/gdk-pixbuf | 22 + recipes/gettext | 41 + recipes/glib | 21 + recipes/glib-networking | 22 + recipes/glu | 21 + recipes/gmp | 26 + recipes/graphite2 | 25 + recipes/grep | 28 + recipes/gsettings-desktop-schemas | 28 + recipes/gtk+-3 | 29 + recipes/harfbuzz | 35 + recipes/icu | 36 + recipes/jwm | 29 + recipes/less | 24 + recipes/libepoxy | 22 + recipes/libexpat | 24 + recipes/libffi | 24 + recipes/libfontenc | 25 + recipes/libgcc | 35 + recipes/libgcrypt | 31 + recipes/libgpg-error | 30 + recipes/libice | 25 + recipes/libiconv | 32 + recipes/libintl | 39 + recipes/libjpeg-turbo | 29 + recipes/libnghttp2 | 27 + recipes/libpng | 24 + recipes/libpsl | 28 + recipes/libsm | 25 + recipes/libsoup | 27 + recipes/libstdc++ | 33 + recipes/libtasn | 29 + recipes/libtiff | 31 + recipes/libunistring | 24 + recipes/libwebp | 29 + recipes/libx11 | 28 + recipes/libxau | 25 + recipes/libxaw | 25 + recipes/libxcb | 27 + recipes/libxcomposite | 29 + recipes/libxcrypt | 27 + recipes/libxcursor | 25 + recipes/libxcvt | 20 + recipes/libxdamage | 25 + recipes/libxdmcp | 25 + recipes/libxext | 25 + recipes/libxfixes | 25 + recipes/libxfont2 | 28 + recipes/libxft | 25 + recipes/libxi | 25 + recipes/libxinerama | 25 + recipes/libxkbcommon | 25 + recipes/libxkbfile | 25 + recipes/libxml | 29 + recipes/libxmu | 25 + recipes/libxpm | 25 + recipes/libxrandr | 25 + recipes/libxrender | 25 + recipes/libxshmfence | 26 + recipes/libxslt | 36 + recipes/libxt | 27 + recipes/libxv | 25 + recipes/libxxf86vm | 25 + recipes/linux-headers | 21 + recipes/llvm | 33 + recipes/mesa | 25 + recipes/mesa-demos | 30 + recipes/mlibc | 28 + recipes/mlibc-headers | 25 + recipes/mpc | 26 + recipes/mpfr | 33 + recipes/ncurses | 51 + recipes/neofetch | 9 + recipes/nettle | 25 + recipes/openssl | 32 + recipes/pango | 21 + recipes/pcre2 | 31 + recipes/pixman | 24 + recipes/readline | 32 + recipes/sdl2 | 59 ++ recipes/sqlite | 27 + recipes/ttf-dejavu | 15 + recipes/tzdata | 57 ++ recipes/userland | 19 + recipes/xcb-proto | 25 + recipes/xf86-input-keyboard | 25 + recipes/xf86-input-mouse | 25 + recipes/xf86-video-fbdev | 27 + recipes/xkeyboard-config | 27 + recipes/xorg-font-util | 25 + recipes/xorg-proto | 25 + recipes/xorg-server | 52 + recipes/xorg-util-macros | 24 + recipes/xorg-xclock | 27 + recipes/xorg-xeyes | 26 + recipes/xorg-xfontsel | 26 + recipes/xorg-xinit | 25 + recipes/xorg-xkbcomp | 25 + recipes/xorg-xlsfonts | 24 + recipes/xtrans | 25 + recipes/xz | 24 + recipes/zlib | 27 + recipes/zstd | 29 + scripts/mkimage | 48 + source-recipes/autoconf | 4 + source-recipes/autoconf-2.69 | 4 + source-recipes/automake | 8 + source-recipes/cmake | 4 + source-recipes/gcc-host | 16 + source-recipes/gnulib | 4 + source-recipes/libgcc-binaries | 4 + source-recipes/libtool | 11 + source-recipes/limine | 12 + source-recipes/llvm-host | 11 + source-recipes/pkg-config | 9 + source-recipes/rust-host | 33 + source-recipes/rust-libc | 4 + src/Cargo.lock | 147 +-- src/aero_kernel/Cargo.toml | 12 +- .../src/arch/x86_64/interrupts/exceptions.rs | 1 + src/aero_kernel/src/fs/ext2/mod.rs | 2 + src/aero_kernel/src/fs/file_table.rs | 27 +- src/aero_kernel/src/fs/mod.rs | 10 +- src/aero_kernel/src/main.rs | 4 +- src/aero_kernel/src/rendy.rs | 10 + src/aero_kernel/src/syscall/fs.rs | 42 +- src/aero_kernel/src/syscall/mod.rs | 2 +- src/aero_kernel/src/userland/task/mod.rs | 13 +- src/aero_kernel/src/userland/vm.rs | 2 +- src/aero_proc/Cargo.toml | 4 +- src/aero_syscall/src/lib.rs | 13 +- src/aero_syscall/src/syscall.rs | 40 +- userland/CMakeToolchain-x86_64.cmake | 4 +- userland/Cargo.lock | 355 ------- userland/Cargo.toml | 6 - userland/Makefile | 37 + userland/aero.cmake | 1 - userland/apps/systrace/Cargo.toml | 2 +- userland/cross-file.ini | 2 +- userland/cross-llvm-config | 153 --- userland/init/init.c | 30 + userland/tests/getchar.cc | 18 - userland/tests/{test.cc => utest.cc} | 62 +- web/index.html | 2 +- 266 files changed, 6910 insertions(+), 6933 deletions(-) create mode 100644 Makefile create mode 120000 base-files/bin create mode 100644 base-files/etc/X11/xinit/xinitrc rename {extra-files/xorg => base-files/etc/X11}/xorg.conf (100%) create mode 120000 base-files/lib create mode 120000 base-files/lib64 create mode 120000 base-files/sbin create mode 100755 build-support/cross-llvm-config create mode 100644 build-support/jwm/system.jwmrc create mode 100644 build-support/limine.cfg create mode 100755 build-support/mkimage.sh create mode 100755 build-support/mkiso.sh create mode 100644 build-support/rust/config.toml delete mode 100644 extra-files/rust/config.toml create mode 100644 host-recipes/autoconf create mode 100644 host-recipes/autoconf-2.69 create mode 100644 host-recipes/automake create mode 100644 host-recipes/binutils create mode 100644 host-recipes/cmake create mode 100644 host-recipes/gcc create mode 100644 host-recipes/gnulib create mode 100644 host-recipes/libgcc-binaries create mode 100644 host-recipes/libtool create mode 100644 host-recipes/limine create mode 100644 host-recipes/llvm create mode 100644 host-recipes/pkg-config create mode 100644 host-recipes/rust create mode 100644 improving-build-times.txt create mode 100644 jinx-config delete mode 100644 patches/alacritty/alacritty.patch delete mode 100644 patches/alsa-lib/alsa-lib.patch create mode 100644 patches/autoconf/jinx-working-patch.patch delete mode 100644 patches/automake-v1.16/automake-v1.16.patch delete mode 100644 patches/bash/bash.patch create mode 100644 patches/bash/jinx-working-patch.patch delete mode 100644 patches/binutils/binutils.patch create mode 100644 patches/binutils/jinx-working-patch.patch create mode 100644 patches/cairo/jinx-working-patch.patch delete mode 100644 patches/coreutils/coreutils.patch create mode 100644 patches/dbus/jinx-working-patch.patch delete mode 100644 patches/dmenu/dmenu.patch delete mode 100644 patches/dwm/0001-uselessgaps.patch delete mode 100644 patches/dwm/dwm.patch delete mode 100644 patches/fontconfig/0001-fontconfig-aero-specific-changes.patch create mode 100644 patches/fontconfig/jinx-working-patch.patch create mode 100644 patches/gcc-host/jinx-working-patch.patch delete mode 100644 patches/gcc/gcc.patch delete mode 100644 patches/glib/0001-glib.patch delete mode 100644 patches/glib/0002-Patch-out-assert-in-g_io_unix_get_flags.patch create mode 100644 patches/glib/jinx-working-patch.patch delete mode 100644 patches/gobject-introspection/gobject-introspection.patch delete mode 100644 patches/gtk+-3/gtk+-3.patch create mode 100644 patches/gtk+-3/jinx-working-patch.patch delete mode 100644 patches/jq/jq.patch delete mode 100644 patches/libdrm/libdrm.patch create mode 100644 patches/libgcrypt/jinx-working-patch.patch delete mode 100644 patches/libiconv/0001-libiconv-aero-specific-changes.patch delete mode 100644 patches/libtasn/libtasn.patch create mode 100644 patches/libtool/jinx-working-patch.patch delete mode 100644 patches/libtool/libtool.patch delete mode 100644 patches/libxfont2/0001-libxfont2-aero-specific-changes.patch rename patches/llvm/{0001-feat-targets-add-aero.patch => jinx-working-patch.patch} (71%) create mode 100644 patches/mesa/jinx-working-patch.patch delete mode 100644 patches/mesa/mesa.patch create mode 100644 patches/mlibc/jinx-working-patch.patch delete mode 100644 patches/mlibc/mlibc.patch create mode 100644 patches/ncurses/jinx-working-patch.patch delete mode 100644 patches/ncurses/ncurses.patch delete mode 100644 patches/neofetch/neofetch.patch delete mode 100644 patches/nss/0001-Add-a-missing-include.patch delete mode 100644 patches/nss/0002-NSS-Standalone-patch.patch delete mode 100644 patches/nyancat/nyancat.patch rename patches/openssl/{0001-openssl-aero-specific-changes.patch => jinx-working-patch.patch} (58%) delete mode 100644 patches/python/python.patch delete mode 100644 patches/quickjs/quickjs.patch create mode 100644 patches/readline/jinx-working-patch.patch delete mode 100644 patches/readline/readline.patch delete mode 100644 patches/rust-getrandom/rust-getrandom.patch delete mode 100644 patches/rust-glutin/rust-glutin.patch create mode 100644 patches/rust-host/jinx-working-patch.patch delete mode 100644 patches/rust-libloading/rust-libloading.patch delete mode 100644 patches/rust-mio-0.6/rust-mio-0.6.patch delete mode 100644 patches/rust-mio-0.8/rust-mio-0.8.patch delete mode 100644 patches/rust-nix/rust-nix.patch delete mode 100644 patches/rust-num-cpus/rust-num-cpus.patch delete mode 100644 patches/rust-shared-library/rust-shared-library.patch delete mode 100644 patches/rust-users/rust-users.patch delete mode 100644 patches/rust-winit/rust-winit.patch delete mode 100644 patches/rust/0001-fix-bootstrap-build-target-in-x.py-and-bootstrap.patch delete mode 100644 patches/tcc/tcc.patch delete mode 100644 patches/wayland/wayland.patch delete mode 100644 patches/webkitgtk/0001-Initial-Aero-support.patch delete mode 100644 patches/webkitgtk/0002-xxx.patch rename patches/xf86-input-keyboard/{xf86-input-keyboard.patch => jinx-working-patch.patch} (70%) rename patches/xf86-input-mouse/{xf86-input-mouse.patch => jinx-working-patch.patch} (69%) rename patches/xf86-video-fbdev/{0001-fbdev-aero-specific-changes.patch => jinx-working-patch.patch} (54%) delete mode 100644 patches/xorg-proto/0001-xorg-proto-aero-specific-changes.patch create mode 100644 patches/xorg-proto/jinx-working-patch.patch rename patches/xorg-server/{xorg-server.patch => jinx-working-patch.patch} (53%) create mode 100644 patches/xorg-xinit/jinx-working-patch.patch delete mode 100644 patches/xorg-xinit/xorg-xinit.patch delete mode 100644 patches/zlib/0001-zlib-aero-specific-changes.patch create mode 100644 recipes/at-spi2-core create mode 100644 recipes/autoconf-archive create mode 100644 recipes/base-files create mode 100644 recipes/bash create mode 100644 recipes/binutils create mode 100644 recipes/bzip2 create mode 100644 recipes/cairo create mode 100644 recipes/core-libs create mode 100644 recipes/coreutils create mode 100644 recipes/cxxshim create mode 100644 recipes/dbus create mode 100644 recipes/fontconfig create mode 100644 recipes/freeglut create mode 100644 recipes/freetype2 create mode 100644 recipes/fribidi create mode 100644 recipes/frigg create mode 100644 recipes/gcc create mode 100644 recipes/gdk-pixbuf create mode 100644 recipes/gettext create mode 100644 recipes/glib create mode 100644 recipes/glib-networking create mode 100644 recipes/glu create mode 100644 recipes/gmp create mode 100644 recipes/graphite2 create mode 100644 recipes/grep create mode 100644 recipes/gsettings-desktop-schemas create mode 100644 recipes/gtk+-3 create mode 100644 recipes/harfbuzz create mode 100644 recipes/icu create mode 100644 recipes/jwm create mode 100644 recipes/less create mode 100644 recipes/libepoxy create mode 100644 recipes/libexpat create mode 100644 recipes/libffi create mode 100644 recipes/libfontenc create mode 100644 recipes/libgcc create mode 100644 recipes/libgcrypt create mode 100644 recipes/libgpg-error create mode 100644 recipes/libice create mode 100644 recipes/libiconv create mode 100644 recipes/libintl create mode 100644 recipes/libjpeg-turbo create mode 100644 recipes/libnghttp2 create mode 100644 recipes/libpng create mode 100644 recipes/libpsl create mode 100644 recipes/libsm create mode 100644 recipes/libsoup create mode 100644 recipes/libstdc++ create mode 100644 recipes/libtasn create mode 100644 recipes/libtiff create mode 100644 recipes/libunistring create mode 100644 recipes/libwebp create mode 100644 recipes/libx11 create mode 100644 recipes/libxau create mode 100644 recipes/libxaw create mode 100644 recipes/libxcb create mode 100644 recipes/libxcomposite create mode 100644 recipes/libxcrypt create mode 100644 recipes/libxcursor create mode 100644 recipes/libxcvt create mode 100644 recipes/libxdamage create mode 100644 recipes/libxdmcp create mode 100644 recipes/libxext create mode 100644 recipes/libxfixes create mode 100644 recipes/libxfont2 create mode 100644 recipes/libxft create mode 100644 recipes/libxi create mode 100644 recipes/libxinerama create mode 100644 recipes/libxkbcommon create mode 100644 recipes/libxkbfile create mode 100644 recipes/libxml create mode 100644 recipes/libxmu create mode 100644 recipes/libxpm create mode 100644 recipes/libxrandr create mode 100644 recipes/libxrender create mode 100644 recipes/libxshmfence create mode 100644 recipes/libxslt create mode 100644 recipes/libxt create mode 100644 recipes/libxv create mode 100644 recipes/libxxf86vm create mode 100644 recipes/linux-headers create mode 100644 recipes/llvm create mode 100644 recipes/mesa create mode 100644 recipes/mesa-demos create mode 100644 recipes/mlibc create mode 100644 recipes/mlibc-headers create mode 100644 recipes/mpc create mode 100644 recipes/mpfr create mode 100644 recipes/ncurses create mode 100644 recipes/neofetch create mode 100644 recipes/nettle create mode 100644 recipes/openssl create mode 100644 recipes/pango create mode 100644 recipes/pcre2 create mode 100644 recipes/pixman create mode 100644 recipes/readline create mode 100644 recipes/sdl2 create mode 100644 recipes/sqlite create mode 100644 recipes/ttf-dejavu create mode 100644 recipes/tzdata create mode 100644 recipes/userland create mode 100644 recipes/xcb-proto create mode 100644 recipes/xf86-input-keyboard create mode 100644 recipes/xf86-input-mouse create mode 100644 recipes/xf86-video-fbdev create mode 100644 recipes/xkeyboard-config create mode 100644 recipes/xorg-font-util create mode 100644 recipes/xorg-proto create mode 100644 recipes/xorg-server create mode 100644 recipes/xorg-util-macros create mode 100644 recipes/xorg-xclock create mode 100644 recipes/xorg-xeyes create mode 100644 recipes/xorg-xfontsel create mode 100644 recipes/xorg-xinit create mode 100644 recipes/xorg-xkbcomp create mode 100644 recipes/xorg-xlsfonts create mode 100644 recipes/xtrans create mode 100644 recipes/xz create mode 100644 recipes/zlib create mode 100644 recipes/zstd create mode 100755 scripts/mkimage create mode 100644 source-recipes/autoconf create mode 100644 source-recipes/autoconf-2.69 create mode 100644 source-recipes/automake create mode 100644 source-recipes/cmake create mode 100644 source-recipes/gcc-host create mode 100644 source-recipes/gnulib create mode 100644 source-recipes/libgcc-binaries create mode 100644 source-recipes/libtool create mode 100644 source-recipes/limine create mode 100644 source-recipes/llvm-host create mode 100644 source-recipes/pkg-config create mode 100644 source-recipes/rust-host create mode 100644 source-recipes/rust-libc delete mode 100644 userland/Cargo.lock delete mode 100644 userland/Cargo.toml create mode 100644 userland/Makefile delete mode 100644 userland/aero.cmake delete mode 100755 userland/cross-llvm-config create mode 100644 userland/init/init.c delete mode 100644 userland/tests/getchar.cc rename userland/tests/{test.cc => utest.cc} (95%) diff --git a/.gitattributes b/.gitattributes index 0b518af4199..5e472ae4bcc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,6 @@ * text=auto eol=lf -*.real linguist-language=Assembly \ No newline at end of file + +jinx-config linguist-language=Shell +host-recipes/* linguist-language=Shell +recipes/* linguist-language=Shell +source-recipes/* linguist-language=Shell diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b707ee4045b..af2d62b065b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -24,10 +24,10 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y nasm + sudo apt-get install -y nasm make python3 -m pip install requests xbstrap - name: Build Documentation - run: ./aero.py --document + run: make doc - name: Formatting Check run: | ./aero.py --fmt diff --git a/.gitignore b/.gitignore index 20b37a745f4..dd4aec68aa7 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,12 @@ base-files/server # todo: remove these debug + +# XXXXXXXXXXXXXXXX +3rdparty/ +.jinx-cache +sources/ +host-pkgs/ +host-builds/ +pkgs/ +builds/ diff --git a/Makefile b/Makefile new file mode 100644 index 00000000000..f5b44ca4165 --- /dev/null +++ b/Makefile @@ -0,0 +1,47 @@ +jinx: + if [ ! -d "target/jinx" ]; then \ + git clone https://github.com/mintsuki/jinx target/jinx; \ + fi + + # FIXME: autosync + mkdir -p target/cargo-home + cp build-support/rust/config.toml target/cargo-home/config.toml + +.PHONY: distro +distro: jinx + ./target/jinx/jinx build-all + +SOURCE_DIR := src +USERLAND_DIR := userland +USERLAND_TARGET := builds/userland/target/init +KERNEL_TARGET := src/target/x86_64-aero_os/release/aero_kernel + +.PHONY: clean +clean: + rm -rf src/target + +$(KERNEL_TARGET): $(shell find $(SOURCE_DIR) -type f -not -path '$(SOURCE_DIR)/target/*') + cd src && cargo build --package aero_kernel --target .cargo/x86_64-aero_os.json --release + @$(MAKE) iso + +$(USERLAND_TARGET): $(shell find $(USERLAND_DIR) -type f -not -path '$(USERLAND_DIR)/target/*') + ./target/jinx/jinx rebuild userland + @$(MAKE) distro-image + +.PHONY: iso +iso: $(KERNEL_TARGET) + ./build-support/mkiso.sh + +.PHONY: distro-image +distro-image: distro + ./build-support/mkimage.sh + +.PHONY: qemu +qemu: $(KERNEL_TARGET) $(USERLAND_TARGET) + ${QEMU_PATH}/qemu-system-x86_64 -cdrom target/aero.iso -m 8G -serial stdio --boot d -s -enable-kvm -cpu host -drive file=target/disk.img,if=none,id=NVME1,format=raw -device nvme,drive=NVME1,serial=nvme + +.PHONY: doc +doc: + rm -rf target/doc + cd src && cargo doc --package aero_kernel --target .cargo/x86_64-aero_os.json --release --target-dir=../target/doc/ + cp web/index.html target/doc/index.html diff --git a/base-files/bin b/base-files/bin new file mode 120000 index 00000000000..0b11bef6890 --- /dev/null +++ b/base-files/bin @@ -0,0 +1 @@ +/usr/bin \ No newline at end of file diff --git a/base-files/etc/X11/xinit/xinitrc b/base-files/etc/X11/xinit/xinitrc new file mode 100644 index 00000000000..0b6b361fd42 --- /dev/null +++ b/base-files/etc/X11/xinit/xinitrc @@ -0,0 +1,2 @@ +#!/usr/bin/sh +jwm & diff --git a/extra-files/xorg/xorg.conf b/base-files/etc/X11/xorg.conf similarity index 100% rename from extra-files/xorg/xorg.conf rename to base-files/etc/X11/xorg.conf diff --git a/base-files/lib b/base-files/lib new file mode 120000 index 00000000000..6c1836ebc71 --- /dev/null +++ b/base-files/lib @@ -0,0 +1 @@ +/usr/lib \ No newline at end of file diff --git a/base-files/lib64 b/base-files/lib64 new file mode 120000 index 00000000000..6c1836ebc71 --- /dev/null +++ b/base-files/lib64 @@ -0,0 +1 @@ +/usr/lib \ No newline at end of file diff --git a/base-files/sbin b/base-files/sbin new file mode 120000 index 00000000000..0b11bef6890 --- /dev/null +++ b/base-files/sbin @@ -0,0 +1 @@ +/usr/bin \ No newline at end of file diff --git a/build-support/cross-llvm-config b/build-support/cross-llvm-config new file mode 100755 index 00000000000..0a8bf851e4f --- /dev/null +++ b/build-support/cross-llvm-config @@ -0,0 +1,95 @@ +#!/usr/bin/env python3 + +# This file was taken from Managarm and I have no clue what it does. + +import argparse +import sys +import os + +our_version = 17 + + +def do_version(): + return '{}.0.6'.format(our_version) + + +def do_components(): + return 'all all-targets analysis asmparser asmprinter binaryformat bitreader bitwriter codegen core coroutines coverage debuginfocodeview debuginfodwarf debuginfomsf debuginfopdb demangle dlltooldriver engine executionengine fuzzmutate globalisel gtest gtest_main instcombine instrumentation interpreter ipo irreader libdriver lineeditor linker lto mc mcdisassembler mcjit mcparser mirparser native nativecodegen objcarcopts object objectyaml option orcjit passes profiledata runtimedyld scalaropts selectiondag support symbolize tablegen target testingsupport transformutils vectorize windowsmanifest x86 x86asmparser x86asmprinter x86codegen x86desc x86disassembler x86info x86utils' + + +def do_targets_built(): + return 'X86' + + +def get_includedir(): + return '/sysroot/usr/include' + + +def get_libdir(): + return '/sysroot/usr/lib' + + +def do_has_rtti(): + return 'YES' + + +def do_shared_mode(): + return 'shared' + + +def do_libs(): + return f'-lLLVM-{our_version}' + + +def do_system_libs(): + return f'-lLLVM-{our_version}' + + +def do_cppflags(): + return '' + + +def do_cxxflags(): + return '' + + +def do_ldflags(): + return '-L' + get_libdir() + + +parser = argparse.ArgumentParser() +parser.add_argument('--version', action='append_const', + dest='command', const=do_version) +parser.add_argument('--targets-built', action='append_const', + dest='command', const=do_targets_built) +parser.add_argument('--components', action='append_const', + dest='command', const=do_components) +parser.add_argument('--includedir', action='append_const', + dest='command', const=get_includedir) +parser.add_argument('--libdir', action='append_const', + dest='command', const=get_libdir) +parser.add_argument('--has-rtti', action='append_const', + dest='command', const=do_has_rtti) +parser.add_argument('--shared-mode', action='append_const', + dest='command', const=do_shared_mode) +parser.add_argument('--link-shared', action='store_const', + dest='link', const='shared') +parser.add_argument('--cppflags', action='append_const', + dest='command', const=do_cppflags) +parser.add_argument('--cxxflags', action='append_const', + dest='command', const=do_cxxflags) +parser.add_argument('--ldflags', action='append_const', + dest='command', const=do_ldflags) +parser.add_argument('--libs', action='append_const', + dest='command', const=do_libs) +parser.add_argument('--system-libs', action='append_const', + dest='command', const=do_system_libs) +parser.add_argument('components', type=str, nargs='*') + +print("cross-llvm-config:", sys.argv, file=sys.stderr) + +args = parser.parse_args() +for command in args.command: + result = command() + print("cross-llvm-config yields:", result, file=sys.stderr) + print(result) diff --git a/build-support/jwm/system.jwmrc b/build-support/jwm/system.jwmrc new file mode 100644 index 00000000000..88cd55fdfe0 --- /dev/null +++ b/build-support/jwm/system.jwmrc @@ -0,0 +1,228 @@ + + + + + + + xterm + + audacious + xcalc + firefox + gimp + claws-mail + rox ~ + glxgears + gtk3-demo + + + xfontsel + + xprop | xmessage -file - + + + xwininfo | xmessage -file - + + + + + xscreensaver-command -lock + + + + + + + + + + + + xterm + + + + xclock + + + + + + + + root:1 + + showdesktop + + + + + + + + + + + + + + Sans-12:bold + 4 + 0 + #FFFFFF + #555555 + 0.5 + + #FFFFFF + #0077CC + 1.0 + + + + Sans-12 + #333333 + #FFFFFF + 0.75 + + + Sans-12 + + #FFFFFF + #555555 + + #FFFFFF + #333333 + + + #555555 + #333333 + #FFFFFF + + #0077CC + #004488 + + + + Sans-12 + #FFFFFF + #333333 + + #FFFFFF + #0077CC + + 0.85 + + + Sans-12 + #000000 + #999999 + + + + + /usr/local/share/icons/Tango/scalable/actions + + + /usr/local/share/icons/Tango/scalable/apps + + + /usr/local/share/icons/Tango/scalable/places + + + /usr/local/share/icons/Tango/scalable/status + + + /usr/local/share/icons/Tango/scalable/mimetypes + + + /usr/local/share/jwm + + + + + + + #111111 + + + + 400 + + + 2 + + + sloppy + + + border + + + opaque + + + opaque + + + up + down + right + left + left + down + up + right + select + escape + + nextstacked + close + desktop# + root:1 + window + maximize + rdesktop + ldesktop + udesktop + ddesktop + + + ldesktop + rdesktop + + move + move + window + shade + shade + maximize + + window + move + window + shade + shade + + resize + move + window + + close + move + close + + maximize + maxv + maxh + + minimize + move + shade + + diff --git a/build-support/limine.cfg b/build-support/limine.cfg new file mode 100644 index 00000000000..2ad5984fee2 --- /dev/null +++ b/build-support/limine.cfg @@ -0,0 +1,12 @@ +TIMEOUT=0 +VERBOSE=yes + +:aero +PROTOCOL=limine +KASLR=no +KERNEL_PATH=boot:///aero +CMDLINE=term-background=background theme-background=0x50000000 +#RESOLUTION=1920x1080 + +MODULE_PATH=boot:///term_background.bmp +MODULE_CMDLINE=background diff --git a/build-support/mkimage.sh b/build-support/mkimage.sh new file mode 100755 index 00000000000..ce7a8cbb9ce --- /dev/null +++ b/build-support/mkimage.sh @@ -0,0 +1,33 @@ +IMAGE_PATH=target/disk.img + +./target/jinx/jinx sysroot + +rm -rf $IMAGE_PATH + +dd if=/dev/zero of=$IMAGE_PATH bs=1G count=0 seek=512 +parted -s $IMAGE_PATH mklabel gpt +parted -s $IMAGE_PATH mkpart primary 2048s 100% + +# ensure loop kernel module is enabled +if ! lsmod | grep -q 'loop'; then + echo 'mkimage.sh: `loop` kernel module not found, attempting to load' + sudo modprobe loop +fi + +sudo losetup -Pf --show $IMAGE_PATH > loopback_dev +sudo mkfs.ext2 `cat loopback_dev`p1 -I128 + +rm -rf target/disk_image/ +mkdir target/disk_image +sudo mount `cat loopback_dev`p1 target/disk_image +sudo cp -r -v sysroot/. target/disk_image/ +pushd target/disk_image +sudo mkdir dev proc tmp +popd +sync +sudo umount target/disk_image/ +sudo losetup -d `cat loopback_dev` +sync + +rm -rf loopback_dev +rm -rf target/disk_image diff --git a/build-support/mkiso.sh b/build-support/mkiso.sh new file mode 100755 index 00000000000..46435fd04bf --- /dev/null +++ b/build-support/mkiso.sh @@ -0,0 +1,24 @@ +set -ex + +./target/jinx/jinx host-build limine + +rm -rf target/iso_root +mkdir -pv target/iso_root/boot + +cp src/target/x86_64-aero_os/release/aero_kernel target/iso_root/aero +cp build-support/limine.cfg src/.cargo/term_background.bmp target/iso_root/ + +# Install the limine binaries +cp host-pkgs/limine/usr/local/share/limine/limine-bios.sys target/iso_root/boot/ +cp host-pkgs/limine/usr/local/share/limine/limine-bios-cd.bin target/iso_root/boot/ +cp host-pkgs/limine/usr/local/share/limine/limine-uefi-cd.bin target/iso_root/boot/ +mkdir -pv target/iso_root/EFI/BOOT +cp host-pkgs/limine/usr/local/share/limine/BOOT*.EFI target/iso_root/EFI/BOOT/ + +# Create the disk image. +xorriso -as mkisofs -b boot/limine-bios-cd.bin -no-emul-boot -boot-load-size 4 \ + -boot-info-table --efi-boot boot/limine-uefi-cd.bin -efi-boot-part \ + --efi-boot-image --protective-msdos-label target/iso_root -o target/aero.iso + +# Install limine. +host-pkgs/limine/usr/local/bin/limine bios-install target/aero.iso diff --git a/build-support/rust/config.toml b/build-support/rust/config.toml new file mode 100644 index 00000000000..32c4c163307 --- /dev/null +++ b/build-support/rust/config.toml @@ -0,0 +1,22 @@ +# [unstable] +# patch-in-config = true + +[build] +rustc = "/base_dir/host-pkgs/rust/bin/rustc" +target = "x86_64-unknown-aero" +rustflags = ["-C", "link-args=-no-pie", "-C", "link-args=-lgcc_s"] + +[target.x86_64-unknown-aero] +linker = "/base_dir/host-pkgs/gcc/usr/local/bin/x86_64-aero-gcc" + +[patch.crates-io] +libc = { path = "/base_dir/sources/rust-libc" } +# num_cpus = { path = "@SOURCE_ROOT@/bundled/rust-num-cpus" } +# users = { path = "@SOURCE_ROOT@/bundled/rust-users" } +# winit = { path = "@SOURCE_ROOT@/bundled/rust-winit" } +# nix = { path = "@SOURCE_ROOT@/bundled/rust-nix" } +# mio-06 = { path = "@SOURCE_ROOT@/bundled/rust-mio-0.6", package = "mio" } +# mio-08 = { path = "@SOURCE_ROOT@/bundled/rust-mio-0.8", package = "mio" } +# glutin = { path = "@SOURCE_ROOT@/bundled/rust-glutin/glutin" } +# shared_library = { path = "@SOURCE_ROOT@/bundled/rust-shared-library" } +# libloading = { path = "@SOURCE_ROOT@/bundled/rust-libloading" } diff --git a/extra-files/rust/config.toml b/extra-files/rust/config.toml deleted file mode 100644 index 54f3a75dc53..00000000000 --- a/extra-files/rust/config.toml +++ /dev/null @@ -1,22 +0,0 @@ -[unstable] -patch-in-config = true - -[build] -rustc = "@BUILD_ROOT@/tools/host-rust/bin/rustc" -target = "x86_64-unknown-aero" -rustflags = ["-C", "link-args=-no-pie"] - -[target.x86_64-unknown-aero] -linker = "@BUILD_ROOT@/tools/host-gcc/bin/x86_64-aero-gcc" - -[patch.crates-io] -libc = { path = "@SOURCE_ROOT@/bundled/rust-libc" } -num_cpus = { path = "@SOURCE_ROOT@/bundled/rust-num-cpus" } -users = { path = "@SOURCE_ROOT@/bundled/rust-users" } -winit = { path = "@SOURCE_ROOT@/bundled/rust-winit" } -nix = { path = "@SOURCE_ROOT@/bundled/rust-nix" } -mio-06 = { path = "@SOURCE_ROOT@/bundled/rust-mio-0.6", package = "mio" } -mio-08 = { path = "@SOURCE_ROOT@/bundled/rust-mio-0.8", package = "mio" } -glutin = { path = "@SOURCE_ROOT@/bundled/rust-glutin/glutin" } -shared_library = { path = "@SOURCE_ROOT@/bundled/rust-shared-library" } -libloading = { path = "@SOURCE_ROOT@/bundled/rust-libloading" } diff --git a/host-recipes/autoconf b/host-recipes/autoconf new file mode 100644 index 00000000000..08a52ad8039 --- /dev/null +++ b/host-recipes/autoconf @@ -0,0 +1,16 @@ +name=autoconf +from_source=autoconf +revision=1 + +build() { + "${source_dir}"/configure --prefix="${prefix}" + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + strip_command=strip \ + post_package_strip +} diff --git a/host-recipes/autoconf-2.69 b/host-recipes/autoconf-2.69 new file mode 100644 index 00000000000..9593c60ac1d --- /dev/null +++ b/host-recipes/autoconf-2.69 @@ -0,0 +1,16 @@ +name=autoconf-2.69 +from_source=autoconf-2.69 +revision=1 + +build() { + "${source_dir}"/configure --prefix="${prefix}" + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + strip_command=strip \ + post_package_strip +} diff --git a/host-recipes/automake b/host-recipes/automake new file mode 100644 index 00000000000..ba10abce956 --- /dev/null +++ b/host-recipes/automake @@ -0,0 +1,21 @@ +name=automake +from_source=automake +revision=1 +hostdeps="autoconf" +imagedeps="gcc" + +build() { + "${source_dir}"/configure --prefix="${prefix}" + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + cp -pv /usr/local/share/autoconf/build-aux/config.sub "${dest_dir}${prefix}"/share/automake-1.16/ + cp -pv /usr/local/share/autoconf/build-aux/config.guess "${dest_dir}${prefix}"/share/automake-1.16/ + + strip_command=strip \ + post_package_strip +} diff --git a/host-recipes/binutils b/host-recipes/binutils new file mode 100644 index 00000000000..1fa8fb86e0d --- /dev/null +++ b/host-recipes/binutils @@ -0,0 +1,24 @@ +name=binutils +from_source=binutils +revision=1 +imagedeps="gcc" +hostdeps="autoconf-2.69 automake libtool pkg-config" + +build() { + "${source_dir}"/configure \ + --prefix="${prefix}" \ + --target=${OS_TRIPLET} \ + --with-sysroot="${sysroot_dir}" \ + --disable-nls \ + --disable-werror \ + --disable-dependency-tracking + + make -j${parallelism} all +} + +package() { + DESTDIR="${dest_dir}" make install + + strip_command=strip \ + post_package_strip +} diff --git a/host-recipes/cmake b/host-recipes/cmake new file mode 100644 index 00000000000..31536bc001b --- /dev/null +++ b/host-recipes/cmake @@ -0,0 +1,18 @@ +name=cmake +from_source=cmake +revision=1 +imagedeps="gcc" + +build() { + "${source_dir}"/configure --prefix="${prefix}" --parallel="${parallelism}" + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + echo 'include(Platform/UnixPaths)' > "${dest_dir}${prefix}/share/cmake-3.27/Modules/Platform/Aero.cmake" + + strip_command=strip \ + post_package_strip +} diff --git a/host-recipes/gcc b/host-recipes/gcc new file mode 100644 index 00000000000..a102d4ab4e4 --- /dev/null +++ b/host-recipes/gcc @@ -0,0 +1,38 @@ +name=gcc +from_source=gcc-host +revision=1 +imagedeps="gcc" +hostdeps="autoconf-2.69 automake libtool pkg-config" +hostrundeps="binutils" +deps="mlibc-headers" + +build() { + cp -rp "${source_dir}"/. ./ + + mkdir build && cd build + + CXXFLAGS_FOR_TARGET="$CFLAGS" \ + CFLAGS_FOR_TARGET="$CFLAGS" \ + ../configure \ + --prefix="${prefix}" \ + --target=${OS_TRIPLET} \ + --with-sysroot="${sysroot_dir}" \ + --disable-nls \ + --enable-languages=c,c++,lto \ + --disable-multilib \ + --enable-initfini-array \ + --enable-shared \ + --enable-host-shared + + make -j${parallelism} all-gcc +} + +package() { + cd build + DESTDIR="${dest_dir}" make install-gcc + + ln -s ${OS_TRIPLET}-gcc "${dest_dir}${prefix}/bin/${OS_TRIPLET}-cc" + + strip_command=strip \ + post_package_strip +} diff --git a/host-recipes/gnulib b/host-recipes/gnulib new file mode 100644 index 00000000000..a0711c37a7b --- /dev/null +++ b/host-recipes/gnulib @@ -0,0 +1,3 @@ +name=gnulib +from_source=gnulib +revision=1 diff --git a/host-recipes/libgcc-binaries b/host-recipes/libgcc-binaries new file mode 100644 index 00000000000..6328e669e67 --- /dev/null +++ b/host-recipes/libgcc-binaries @@ -0,0 +1,8 @@ +name=libgcc-binaries +from_source=libgcc-binaries +revision=1 + +package() { + mkdir -p ${dest_dir}${prefix}/libgcc-binaries + cp -rv ${source_dir}/. ${dest_dir}${prefix}/libgcc-binaries/ +} diff --git a/host-recipes/libtool b/host-recipes/libtool new file mode 100644 index 00000000000..3141fc5d9e3 --- /dev/null +++ b/host-recipes/libtool @@ -0,0 +1,23 @@ +name=libtool +from_source=libtool +revision=1 +hostdeps="autoconf automake" +imagedeps="help2man gcc" + +build() { + cp -rp "${source_dir}"/. ./ + ./configure \ + --prefix="${prefix}" + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + cp -pv /usr/local/share/autoconf/build-aux/config.sub "${dest_dir}${prefix}"/share/libtool/build-aux/ + cp -pv /usr/local/share/autoconf/build-aux/config.guess "${dest_dir}${prefix}"/share/libtool/build-aux/ + + strip_command=strip \ + post_package_strip +} diff --git a/host-recipes/limine b/host-recipes/limine new file mode 100644 index 00000000000..d93f3e397db --- /dev/null +++ b/host-recipes/limine @@ -0,0 +1,24 @@ +name=limine +from_source=limine +revision=1 +hostdeps="gcc pkg-config" +imagedeps="nasm gcc mtools" + +build() { + "${source_dir}"/configure \ + --enable-uefi-ia32 \ + --enable-uefi-x86-64 \ + --enable-uefi-cd \ + --enable-bios \ + --enable-bios-cd \ + --enable-bios-pxe + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + strip_command=strip \ + post_package_strip +} diff --git a/host-recipes/llvm b/host-recipes/llvm new file mode 100644 index 00000000000..6bfe5294b3b --- /dev/null +++ b/host-recipes/llvm @@ -0,0 +1,27 @@ +name=llvm +version=17.0.6 +revision=1 +from_source=llvm-host +imagedeps="gcc cmake ninja git" +source_deps="binutils" + +build() { + cmake \ + -GNinja \ + -DCMAKE_INSTALL_PREFIX="${prefix}" \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_TARGETS_TO_BUILD=X86 \ + -DLLVM_ENABLE_PROJECTS="llvm;clang;clang-tools-extra" \ + -DDEFAULT_SYSROOT="${sysroot_dir}" \ + -DLLVM_BINUTILS_INCDIR="${source_dir}/../binutils/include" \ + "${source_dir}/llvm" + + ninja -j ${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + strip_command=strip \ + post_package_strip +} diff --git a/host-recipes/pkg-config b/host-recipes/pkg-config new file mode 100644 index 00000000000..ee2b4f6a190 --- /dev/null +++ b/host-recipes/pkg-config @@ -0,0 +1,28 @@ +name=pkg-config +from_source=pkg-config +revision=1 +imagedeps="gcc" +hostdeps="automake autoconf libtool" + +build() { + "${source_dir}"/configure \ + --prefix="${prefix}" + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + mkdir -p "${dest_dir}${prefix}/share/pkgconfig/personality.d" + cat <"${dest_dir}${prefix}/share/pkgconfig/personality.d/${OS_TRIPLET}.personality" +Triplet: ${OS_TRIPLET} +SysrootDir: ${sysroot_dir} +DefaultSearchPaths: ${sysroot_dir}/usr/lib/pkgconfig:${sysroot_dir}/usr/share/pkgconfig +SystemIncludePaths: ${sysroot_dir}/usr/include +SystemLibraryPaths: ${sysroot_dir}/usr/lib +EOF + ln -s pkgconf "${dest_dir}${prefix}/bin/${OS_TRIPLET}-pkg-config" + + strip_command=strip \ + post_package_strip +} diff --git a/host-recipes/rust b/host-recipes/rust new file mode 100644 index 00000000000..9a7a03c1350 --- /dev/null +++ b/host-recipes/rust @@ -0,0 +1,25 @@ +name=rust +revision=1 +from_source=rust-host +hostdeps="llvm gcc" +source_deps="rust-libc" +imagedeps="python git wget gcc" +allow_network="yes" + +#unset CARGO_HOME + +build() { + # Rust memes. + # cp -rp "${source_dir}/." ./ + + ./x.py build --stage 2 -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ./x.py install -j${parallelism} + + find ${dest_dir} -name "*.old" -delete + + strip_command=strip + post_package_strip +} diff --git a/improving-build-times.txt b/improving-build-times.txt new file mode 100644 index 00000000000..6c4026a4d07 --- /dev/null +++ b/improving-build-times.txt @@ -0,0 +1,2 @@ +28.36s + diff --git a/jinx-config b/jinx-config new file mode 100644 index 00000000000..fe0d9974467 --- /dev/null +++ b/jinx-config @@ -0,0 +1,72 @@ +JINX_MAJOR_VER=0.2 + +export CFLAGS='-O2 -pipe' +export CXXFLAGS="${CFLAGS}" + +OS_TRIPLET=x86_64-aero +export CARGO_HOME="${base_dir}/target/cargo-home" + +# Required by scripts/mkimage +imagedeps="parted" + +autotools_recursive_regen() { + ACLOCAL_INCLUDE="" + if [ -d ${sysroot_dir}/usr/share/aclocal ]; then + ACLOCAL_INCLUDE="-I${sysroot_dir}/usr/share/aclocal" + fi + + for f in $(find . -name configure.ac -type f); do + echo "* autotools regen in '$(dirname $f)'..." + ( cd "$(dirname "$f")" && autoreconf -fvi "$@" $ACLOCAL_INCLUDE ) + done +} + +post_package_strip() { + if [ -z "$strip_command" ]; then + strip_command="${OS_TRIPLET}-strip" + fi + + for f in $(find "${dest_dir}"); do + if file "$f" | grep 'not stripped' >/dev/null; then + echo "* stripping '$f'..." + stripped_file="$(mktemp)" + ${strip_command} "$f" -o "$stripped_file" + chmod --reference="$f" "$stripped_file" + mv -f "$stripped_file" "$f" + fi + done +} + +autotools_configure() { + if [ -z "${configure_script_path}" ]; then + configure_script_path="${source_dir}/configure" + fi + + ${configure_script_path} \ + --host=${OS_TRIPLET} \ + --with-sysroot=${sysroot_dir} \ + --prefix=${prefix} \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --libdir=${prefix}/lib \ + --disable-static \ + --enable-shared \ + --disable-malloc0returnsnull \ + "$@" +} + +meson_configure() { + if [ -z "${meson_source_dir}" ]; then + meson_source_dir="${source_dir}" + fi + + # TODO(andypython): Move cross-file.ini to build-support/ + meson setup "${meson_source_dir}" \ + --cross-file "${base_dir}/userland/cross-file.ini" \ + --prefix=${prefix} \ + --sysconfdir=/etc \ + --libdir=lib \ + --buildtype=release \ + -Ddefault_library=shared \ + "$@" +} diff --git a/patches/alacritty/alacritty.patch b/patches/alacritty/alacritty.patch deleted file mode 100644 index 3921b7fa3eb..00000000000 --- a/patches/alacritty/alacritty.patch +++ /dev/null @@ -1,71 +0,0 @@ -From b194e3d72903f677f2aacf9293706ff2027a413b Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Sun, 11 Dec 2022 18:43:18 +1100 -Subject: [PATCH] - ---- - alacritty/src/display/window.rs | 8 ++++---- - alacritty_terminal/src/tty/unix.rs | 17 +++++++++-------- - 2 files changed, 13 insertions(+), 12 deletions(-) - -diff --git a/alacritty/src/display/window.rs b/alacritty/src/display/window.rs -index ee2e74f..d75996b 100644 ---- a/alacritty/src/display/window.rs -+++ b/alacritty/src/display/window.rs -@@ -128,9 +128,9 @@ fn create_gl_window( - } - - let windowed_context = ContextBuilder::new() -- .with_srgb(srgb) -- .with_vsync(vsync) -- .with_hardware_acceleration(None) -+ // .with_srgb(srgb) -+ // .with_vsync(vsync) -+ // .with_hardware_acceleration(None) - .build_windowed(window, event_loop)?; - - // Make the context current so OpenGL operations can run. -@@ -292,7 +292,7 @@ impl Window { - let builder = WindowBuilder::new() - .with_title(&identity.title) - .with_visible(false) -- .with_transparent(true) -+ .with_transparent(false) - .with_decorations(window_config.decorations != Decorations::None) - .with_maximized(window_config.maximized()) - .with_fullscreen(window_config.fullscreen()); -diff --git a/alacritty_terminal/src/tty/unix.rs b/alacritty_terminal/src/tty/unix.rs -index 206dbe8..cb172ab 100644 ---- a/alacritty_terminal/src/tty/unix.rs -+++ b/alacritty_terminal/src/tty/unix.rs -@@ -90,18 +90,19 @@ fn get_pw_entry(buf: &mut [i8; 1024]) -> Passwd<'_> { - die!("getpwuid_r failed"); - } - -- if res.is_null() { -- die!("pw not found"); -- } -+ // if res.is_null() { -+ // die!("pw not found"); -+ // } - -- // Sanity check. -- assert_eq!(entry.pw_uid, uid); -+ // // Sanity check. -+ // assert_eq!(entry.pw_uid, uid); - - // Build a borrowed Passwd struct. -+ // FIXME(mlibc): Assertion '!"slab_pool corruption. Possible write to unallocated object"' failed! - Passwd { -- name: unsafe { CStr::from_ptr(entry.pw_name).to_str().unwrap() }, -- dir: unsafe { CStr::from_ptr(entry.pw_dir).to_str().unwrap() }, -- shell: unsafe { CStr::from_ptr(entry.pw_shell).to_str().unwrap() }, -+ name: "root", -+ dir: "/", -+ shell: "/usr/bin/bash", - } - } - --- -2.38.1 - diff --git a/patches/alsa-lib/alsa-lib.patch b/patches/alsa-lib/alsa-lib.patch deleted file mode 100644 index 1ebb5b22abc..00000000000 --- a/patches/alsa-lib/alsa-lib.patch +++ /dev/null @@ -1,124 +0,0 @@ -From 3b4d643d6648ead86648e0033868f903af6aeb70 Mon Sep 17 00:00:00 2001 -From: Dennis Bonke -Date: Wed, 2 Aug 2023 13:50:05 +0200 -Subject: [PATCH] Add Managarm support - -Signed-off-by: Dennis Bonke ---- - src/conf.c | 10 ++++++++++ - src/pcm/pcm_ladspa.c | 5 +++++ - src/ucm/main.c | 5 +++++ - src/ucm/parser.c | 8 ++++++++ - src/ucm/ucm_exec.c | 7 +++++++ - src/ucm/ucm_subs.c | 5 +++++ - 6 files changed, 40 insertions(+) - -diff --git a/src/conf.c b/src/conf.c -index da51182..743e4cd 100644 ---- a/src/conf.c -+++ b/src/conf.c -@@ -435,6 +435,16 @@ beginning:

- #include - #endif - -+#ifdef __aero__ -+#define stat64 stat -+#define dirent64 dirent -+#define lstat64 lstat -+#define readdir64 readdir -+#define scandir64 scandir -+#define versionsort64 versionsort -+typedef ino_t ino64_t; -+#endif -+ - #ifndef DOC_HIDDEN - - #ifdef HAVE_LIBPTHREAD -diff --git a/src/pcm/pcm_ladspa.c b/src/pcm/pcm_ladspa.c -index 9b2b32d..dde5d2a 100644 ---- a/src/pcm/pcm_ladspa.c -+++ b/src/pcm/pcm_ladspa.c -@@ -41,6 +41,11 @@ - - #include "ladspa.h" - -+#ifdef __aero__ -+#define readdir64 readdir -+#define dirent64 dirent -+#endif -+ - #ifndef PIC - /* entry for static linking */ - const char *_snd_module_pcm_ladspa = ""; -diff --git a/src/ucm/main.c b/src/ucm/main.c -index 66ffd00..7448963 100644 ---- a/src/ucm/main.c -+++ b/src/ucm/main.c -@@ -40,6 +40,11 @@ - #include - #include - -+#ifdef __aero__ -+#define stat64 stat -+#define fstat64 fstat -+#endif -+ - /* - * misc - */ -diff --git a/src/ucm/parser.c b/src/ucm/parser.c -index c111661..2115ac7 100644 ---- a/src/ucm/parser.c -+++ b/src/ucm/parser.c -@@ -36,6 +36,14 @@ - #include - #include - -+#ifdef __aero__ -+#define stat64 stat -+#define lstat64 lstat -+#define scandir64 scandir -+#define versionsort64 versionsort -+#define dirent64 dirent -+#endif -+ - static int filename_filter(const struct dirent64 *dirent); - - static int parse_sequence(snd_use_case_mgr_t *uc_mgr, -diff --git a/src/ucm/ucm_exec.c b/src/ucm/ucm_exec.c -index 276cf59..a6890dd 100644 ---- a/src/ucm/ucm_exec.c -+++ b/src/ucm/ucm_exec.c -@@ -42,6 +42,13 @@ extern char **environ; - #endif - #endif - -+#ifdef __aero__ -+#define stat64 stat -+#define dirent64 dirent -+#define lstat64 lstat -+#define readdir64 readdir -+#endif -+ - static pthread_mutex_t fork_lock = PTHREAD_MUTEX_INITIALIZER; - - /* -diff --git a/src/ucm/ucm_subs.c b/src/ucm/ucm_subs.c -index e62290e..b4dbff2 100644 ---- a/src/ucm/ucm_subs.c -+++ b/src/ucm/ucm_subs.c -@@ -30,6 +30,11 @@ - #include - #include - -+#ifdef __aero__ -+#define stat64 stat -+#define lstat64 lstat -+#endif -+ - static char *rval_open_name(snd_use_case_mgr_t *uc_mgr) - { - const char *name; --- -2.40.1 - diff --git a/patches/autoconf/jinx-working-patch.patch b/patches/autoconf/jinx-working-patch.patch new file mode 100644 index 00000000000..b4e4be02eec --- /dev/null +++ b/patches/autoconf/jinx-working-patch.patch @@ -0,0 +1,47 @@ +diff --git autoconf-clean/build-aux/config.guess autoconf-workdir/build-aux/config.guess +index cdfc439..0e1b56a 100755 +--- autoconf-clean/build-aux/config.guess ++++ autoconf-workdir/build-aux/config.guess +@@ -4,7 +4,8 @@ + + # shellcheck disable=SC2006,SC2268 # see below for rationale + +-timestamp='2023-08-22' ++# timestamp it to always be newer ++timestamp='9999-99-99' + + # This file is free software; you can redistribute it and/or modify it + # under the terms of the GNU General Public License as published by +@@ -933,6 +934,9 @@ EOF + i*:PW*:*) + GUESS=$UNAME_MACHINE-pc-pw32 + ;; ++ *:Aero:*:*) ++ GUESS=$UNAME_MACHINE-pc-aero ++ ;; + *:SerenityOS:*:*) + GUESS=$UNAME_MACHINE-pc-serenity + ;; +diff --git autoconf-clean/build-aux/config.sub autoconf-workdir/build-aux/config.sub +index defe52c..8600125 100755 +--- autoconf-clean/build-aux/config.sub ++++ autoconf-workdir/build-aux/config.sub +@@ -4,7 +4,8 @@ + + # shellcheck disable=SC2006,SC2268 # see below for rationale + +-timestamp='2023-09-19' ++# timestamp it to always be newer ++timestamp='9999-99-99' + + # This file is free software; you can redistribute it and/or modify it + # under the terms of the GNU General Public License as published by +@@ -1749,7 +1750,7 @@ case $os in + | mirbsd* | netbsd* | dicos* | openedition* | ose* \ + | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \ + | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \ +- | bosx* | nextstep* | cxux* | oabi* \ ++ | bosx* | nextstep* | cxux* | oabi* | aero* \ + | ptx* | ecoff* | winnt* | domain* | vsta* \ + | udi* | lites* | ieee* | go32* | aux* | hcos* \ + | chorusrdb* | cegcc* | glidix* | serenity* \ diff --git a/patches/automake-v1.16/automake-v1.16.patch b/patches/automake-v1.16/automake-v1.16.patch deleted file mode 100644 index d0760f5c71a..00000000000 --- a/patches/automake-v1.16/automake-v1.16.patch +++ /dev/null @@ -1,26 +0,0 @@ -From bd762227b35e7afac102348e88f1aee3cfcab9c9 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Thu, 30 Dec 2021 13:16:15 +1100 -Subject: [PATCH] config.sub: add aero target - -Signed-off-by: Andy-Python-Programmer ---- - lib/config.sub | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/lib/config.sub b/lib/config.sub -index d74fb6d..194fc2c 100755 ---- a/lib/config.sub -+++ b/lib/config.sub -@@ -1723,7 +1723,7 @@ case $os in - | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ - | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ - | hiux* | abug | nacl* | netware* | windows* \ -- | os9* | macos* | osx* | ios* \ -+ | os9* | macos* | osx* | ios* | aero* \ - | mpw* | magic* | mmixware* | mon960* | lnews* \ - | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ - | aos* | aros* | cloudabi* | sortix* | twizzler* \ --- -2.25.1 - diff --git a/patches/bash/bash.patch b/patches/bash/bash.patch deleted file mode 100644 index ea6a0e0b730..00000000000 --- a/patches/bash/bash.patch +++ /dev/null @@ -1,282 +0,0 @@ -From 50a9f0c440ae12cb24316ae5397976ab83ea7e6a Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Tue, 18 Jan 2022 13:35:43 +1100 -Subject: [PATCH] bash: add aero port - -Signed-off-by: Andy-Python-Programmer ---- - .vscode/settings.json | 3 +++ - builtins/psize.c | 19 +++------------- - lib/readline/terminal.c | 2 +- - lib/termcap/termcap.c | 2 +- - mksyntax.c | 48 ++--------------------------------------- - shell.c | 4 ++-- - support/bashversion.c | 7 ++---- - support/config.sub | 2 +- - support/man2html.c | 5 +++-- - support/mksignames.c | 2 -- - support/signames.c | 2 -- - 11 files changed, 18 insertions(+), 78 deletions(-) - create mode 100644 .vscode/settings.json - -diff --git a/.vscode/settings.json b/.vscode/settings.json -new file mode 100644 -index 0000000..9792498 ---- /dev/null -+++ b/.vscode/settings.json -@@ -0,0 +1,3 @@ -+{ -+ "editor.formatOnSave": false -+} -\ No newline at end of file -diff --git a/builtins/psize.c b/builtins/psize.c -index 30881fb..be9c84b 100644 ---- a/builtins/psize.c -+++ b/builtins/psize.c -@@ -21,25 +21,12 @@ - /* Write output in 128-byte chunks until we get a sigpipe or write gets an - EPIPE. Then report how many bytes we wrote. We assume that this is the - pipe size. */ --#include -- --#if defined (HAVE_UNISTD_H) --# ifdef _MINIX --# include --# endif --# include --#endif - - #include --#ifndef _MINIX --#include "../bashtypes.h" --#endif -+#include - #include - #include -- --#include "../command.h" --#include "../general.h" --#include "../sig.h" -+#include - - #ifndef errno - extern int errno; -@@ -47,7 +34,7 @@ extern int errno; - - int nw; - --sighandler -+void - sigpipe (sig) - int sig; - { -diff --git a/lib/readline/terminal.c b/lib/readline/terminal.c -index 05415dc..a6b5307 100644 ---- a/lib/readline/terminal.c -+++ b/lib/readline/terminal.c -@@ -103,7 +103,7 @@ static char *term_string_buffer = (char *)NULL; - static int tcap_initialized; - - #if !defined (__linux__) && !defined (NCURSES_VERSION) --# if defined (__EMX__) || defined (NEED_EXTERN_PC) -+# if defined (__EMX__) || defined (__aero__) || defined (NEED_EXTERN_PC) - extern - # endif /* __EMX__ || NEED_EXTERN_PC */ - char PC, *BC, *UP; -diff --git a/lib/termcap/termcap.c b/lib/termcap/termcap.c -index ba3dab2..2882f0c 100644 ---- a/lib/termcap/termcap.c -+++ b/lib/termcap/termcap.c -@@ -627,7 +627,7 @@ scan_file (str, fd, bufp) - bufp->ateof = 0; - *bufp->ptr = '\0'; - -- lseek (fd, 0L, 0); -+ lseek (fd, 0L, SEEK_SET); - - while (!bufp->ateof) - { -diff --git a/mksyntax.c b/mksyntax.c -index 0385686..1a73eca 100644 ---- a/mksyntax.c -+++ b/mksyntax.c -@@ -20,16 +20,12 @@ - along with Bash. If not, see . - */ - --#include "config.h" -- - #include -+#include - #include "bashansi.h" - #include "chartypes.h" - #include -- --#ifdef HAVE_UNISTD_H --# include --#endif -+#include - - #include "syntax.h" - -@@ -40,9 +36,7 @@ extern char *optarg; - extern int errno; - #endif - --#ifndef HAVE_STRERROR - extern char *strerror(); --#endif - - struct wordflag { - int flag; -@@ -375,41 +369,3 @@ main(argc, argv) - fclose (fp); - exit (0); - } -- -- --#if !defined (HAVE_STRERROR) -- --#include --#if defined (HAVE_SYS_PARAM_H) --# include --#endif -- --#if defined (HAVE_UNISTD_H) --# include --#endif -- --/* Return a string corresponding to the error number E. From -- the ANSI C spec. */ --#if defined (strerror) --# undef strerror --#endif -- --char * --strerror (e) -- int e; --{ -- static char emsg[40]; --#if defined (HAVE_SYS_ERRLIST) -- extern int sys_nerr; -- extern char *sys_errlist[]; -- -- if (e > 0 && e < sys_nerr) -- return (sys_errlist[e]); -- else --#endif /* HAVE_SYS_ERRLIST */ -- { -- sprintf (emsg, "Unknown system error %d", e); -- return (&emsg[0]); -- } --} --#endif /* HAVE_STRERROR */ -diff --git a/shell.c b/shell.c -index ce8087f..b7475dd 100644 ---- a/shell.c -+++ b/shell.c -@@ -1614,7 +1614,7 @@ open_shell_script (script_name) - #endif - - /* Only do this with non-tty file descriptors we can seek on. */ -- if (fd_is_tty == 0 && (lseek (fd, 0L, 1) != -1)) -+ if (fd_is_tty == 0 && (lseek (fd, 0L, SEEK_CUR) != -1)) - { - /* Check to see if the `file' in `bash file' is a binary file - according to the same tests done by execute_simple_command (), -@@ -1651,7 +1651,7 @@ open_shell_script (script_name) - exit (EX_BINARY_FILE); - } - /* Now rewind the file back to the beginning. */ -- lseek (fd, 0L, 0); -+ lseek (fd, 0L, SEEK_SET); - } - - /* Open the script. But try to move the file descriptor to a randomly -diff --git a/support/bashversion.c b/support/bashversion.c -index 4f86b13..64779de 100644 ---- a/support/bashversion.c -+++ b/support/bashversion.c -@@ -18,15 +18,12 @@ - along with Bash. If not, see . - */ - --#include "config.h" -- - #include "stdc.h" - - #include -+#include - --#if defined (HAVE_UNISTD_H) --# include --#endif -+#include - - #include "bashansi.h" - -diff --git a/support/config.sub b/support/config.sub -index c874b7a..4ce3963 100755 ---- a/support/config.sub -+++ b/support/config.sub -@@ -1707,7 +1707,7 @@ case $os in - | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ - | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ - | udi* | lites* | ieee* | go32* | aux* | hcos* \ -- | chorusrdb* | cegcc* | glidix* \ -+ | chorusrdb* | cegcc* | glidix* | aero* \ - | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ - | midipix* | mingw32* | mingw64* | mint* \ - | uxpv* | beos* | mpeix* | udk* | moxiebox* \ -diff --git a/support/man2html.c b/support/man2html.c -index e6f441b..f02453d 100644 ---- a/support/man2html.c -+++ b/support/man2html.c -@@ -63,7 +63,7 @@ - * time to look through all the available manpages.) - */ - #ifdef HAVE_CONFIG_H --#include -+//#include - #endif - - #define NROFF 0 -@@ -123,7 +123,8 @@ char *manpage; - #define BD_LITERAL 1 - #define BD_INDENT 2 - --#ifndef HAVE_STRERROR -+//#ifndef HAVE_STRERROR -+#if (0) - static char * - strerror(int e) - { -diff --git a/support/mksignames.c b/support/mksignames.c -index ba87ae8..4b39787 100644 ---- a/support/mksignames.c -+++ b/support/mksignames.c -@@ -19,8 +19,6 @@ - along with Bash. If not, see . - */ - --#include -- - #include - #include - -diff --git a/support/signames.c b/support/signames.c -index aba4842..b4bbdc6 100644 ---- a/support/signames.c -+++ b/support/signames.c -@@ -18,8 +18,6 @@ - along with Bash. If not, see . - */ - --#include -- - #include - - #include --- -2.25.1 - diff --git a/patches/bash/jinx-working-patch.patch b/patches/bash/jinx-working-patch.patch new file mode 100644 index 00000000000..ff0943d4732 --- /dev/null +++ b/patches/bash/jinx-working-patch.patch @@ -0,0 +1,368 @@ +diff --git bash-clean/builtins/psize.c bash-workdir/builtins/psize.c +index 30881fb..6c99972 100644 +--- bash-clean/builtins/psize.c ++++ bash-workdir/builtins/psize.c +@@ -21,33 +21,36 @@ + /* Write output in 128-byte chunks until we get a sigpipe or write gets an + EPIPE. Then report how many bytes we wrote. We assume that this is the + pipe size. */ +-#include +- +-#if defined (HAVE_UNISTD_H) +-# ifdef _MINIX +-# include +-# endif +-# include +-#endif +- +-#include +-#ifndef _MINIX +-#include "../bashtypes.h" +-#endif ++// #include ++ ++// #if defined (HAVE_UNISTD_H) ++// # ifdef _MINIX ++// # include ++// # endif ++// # include ++// #endif ++ ++// #include ++// #ifndef _MINIX ++// #include "../bashtypes.h" ++// #endif + #include +-#include ++// #include + +-#include "../command.h" +-#include "../general.h" +-#include "../sig.h" ++// #include "../command.h" ++// #include "../general.h" ++// #include "../sig.h" + +-#ifndef errno +-extern int errno; +-#endif ++// #ifndef errno ++// extern int errno; ++// #endif ++#include ++#include ++#include + + int nw; + +-sighandler ++void + sigpipe (sig) + int sig; + { +diff --git bash-clean/lib/termcap/termcap.c bash-workdir/lib/termcap/termcap.c +index 87fae05..ed9d105 100644 +--- bash-clean/lib/termcap/termcap.c ++++ bash-workdir/lib/termcap/termcap.c +@@ -630,7 +630,7 @@ scan_file (str, fd, bufp) + bufp->ateof = 0; + *bufp->ptr = '\0'; + +- lseek (fd, 0L, 0); ++ lseek (fd, 0L, SEEK_SET); + + while (!bufp->ateof) + { +diff --git bash-clean/mksyntax.c bash-workdir/mksyntax.c +index 0385686..53011a2 100644 +--- bash-clean/mksyntax.c ++++ bash-workdir/mksyntax.c +@@ -20,29 +20,31 @@ + along with Bash. If not, see . + */ + +-#include "config.h" ++// #include "config.h" + ++#include + #include + #include "bashansi.h" + #include "chartypes.h" + #include + +-#ifdef HAVE_UNISTD_H +-# include +-#endif ++// #ifdef HAVE_UNISTD_H ++// # include ++// #endif ++#include + + #include "syntax.h" + + extern int optind; + extern char *optarg; + +-#ifndef errno +-extern int errno; +-#endif ++// #ifndef errno ++// extern int errno; ++// #endif + +-#ifndef HAVE_STRERROR +-extern char *strerror(); +-#endif ++// #ifndef HAVE_STRERROR ++// extern char *strerror(); ++// #endif + + struct wordflag { + int flag; +@@ -377,39 +379,39 @@ main(argc, argv) + } + + +-#if !defined (HAVE_STRERROR) +- +-#include +-#if defined (HAVE_SYS_PARAM_H) +-# include +-#endif +- +-#if defined (HAVE_UNISTD_H) +-# include +-#endif +- +-/* Return a string corresponding to the error number E. From +- the ANSI C spec. */ +-#if defined (strerror) +-# undef strerror +-#endif +- +-char * +-strerror (e) +- int e; +-{ +- static char emsg[40]; +-#if defined (HAVE_SYS_ERRLIST) +- extern int sys_nerr; +- extern char *sys_errlist[]; +- +- if (e > 0 && e < sys_nerr) +- return (sys_errlist[e]); +- else +-#endif /* HAVE_SYS_ERRLIST */ +- { +- sprintf (emsg, "Unknown system error %d", e); +- return (&emsg[0]); +- } +-} +-#endif /* HAVE_STRERROR */ ++// #if !defined (HAVE_STRERROR) ++ ++// #include ++// #if defined (HAVE_SYS_PARAM_H) ++// # include ++// #endif ++ ++// #if defined (HAVE_UNISTD_H) ++// # include ++// #endif ++ ++// /* Return a string corresponding to the error number E. From ++// the ANSI C spec. */ ++// #if defined (strerror) ++// # undef strerror ++// #endif ++ ++// char * ++// strerror (e) ++// int e; ++// { ++// static char emsg[40]; ++// #if defined (HAVE_SYS_ERRLIST) ++// extern int sys_nerr; ++// extern char *sys_errlist[]; ++ ++// if (e > 0 && e < sys_nerr) ++// return (sys_errlist[e]); ++// else ++// #endif /* HAVE_SYS_ERRLIST */ ++// { ++// sprintf (emsg, "Unknown system error %d", e); ++// return (&emsg[0]); ++// } ++// } ++// #endif /* HAVE_STRERROR */ +diff --git bash-clean/shell.c bash-workdir/shell.c +index ebd8965..05d6a85 100644 +--- bash-clean/shell.c ++++ bash-workdir/shell.c +@@ -1647,7 +1647,7 @@ open_shell_script (script_name) + #endif + + /* Only do this with non-tty file descriptors we can seek on. */ +- if (fd_is_tty == 0 && (lseek (fd, 0L, 1) != -1)) ++ if (fd_is_tty == 0 && (lseek (fd, 0L, SEEK_CUR) != -1)) + { + /* Check to see if the `file' in `bash file' is a binary file + according to the same tests done by execute_simple_command (), +@@ -1684,7 +1684,7 @@ open_shell_script (script_name) + exit (EX_BINARY_FILE); + } + /* Now rewind the file back to the beginning. */ +- lseek (fd, 0L, 0); ++ lseek (fd, 0L, SEEK_SET); + } + + /* Open the script. But try to move the file descriptor to a randomly +diff --git bash-clean/support/bashversion.c bash-workdir/support/bashversion.c +index ad02d46..1b8a4ae 100644 +--- bash-clean/support/bashversion.c ++++ bash-workdir/support/bashversion.c +@@ -18,15 +18,17 @@ + along with Bash. If not, see . + */ + +-#include "config.h" ++// #include "config.h" + + #include "stdc.h" + + #include ++#include + +-#if defined (HAVE_UNISTD_H) +-# include +-#endif ++// #if defined (HAVE_UNISTD_H) ++// # include ++// #endif ++#include + + #include "bashansi.h" + +diff --git bash-clean/support/man2html.c bash-workdir/support/man2html.c +index e6f441b..906e9f8 100644 +--- bash-clean/support/man2html.c ++++ bash-workdir/support/man2html.c +@@ -62,9 +62,9 @@ + * that all these features work on all manpages. (I didn't have the + * time to look through all the available manpages.) + */ +-#ifdef HAVE_CONFIG_H +-#include +-#endif ++// #ifdef HAVE_CONFIG_H ++// #include ++// #endif + + #define NROFF 0 + +@@ -123,26 +123,26 @@ char *manpage; + #define BD_LITERAL 1 + #define BD_INDENT 2 + +-#ifndef HAVE_STRERROR +-static char * +-strerror(int e) +-{ +- static char emsg[40]; +- +-#if defined (HAVE_SYS_ERRLIST) +- extern int sys_nerr; +- extern char *sys_errlist[]; +- +- if (e > 0 && e < sys_nerr) +- return (sys_errlist[e]); +- else +-#endif /* HAVE_SYS_ERRLIST */ +- { +- sprintf(emsg, "Unknown system error %d", e); +- return (&emsg[0]); +- } +-} +-#endif /* !HAVE_STRERROR */ ++// #ifndef HAVE_STRERROR ++// static char * ++// strerror(int e) ++// { ++// static char emsg[40]; ++ ++// #if defined (HAVE_SYS_ERRLIST) ++// extern int sys_nerr; ++// extern char *sys_errlist[]; ++ ++// if (e > 0 && e < sys_nerr) ++// return (sys_errlist[e]); ++// else ++// #endif /* HAVE_SYS_ERRLIST */ ++// { ++// sprintf(emsg, "Unknown system error %d", e); ++// return (&emsg[0]); ++// } ++// } ++// #endif /* !HAVE_STRERROR */ + + static char * + strgrow(char *old, int len) +diff --git bash-clean/support/mksignames.c bash-workdir/support/mksignames.c +index ba87ae8..bd13bab 100644 +--- bash-clean/support/mksignames.c ++++ bash-workdir/support/mksignames.c +@@ -19,17 +19,18 @@ + along with Bash. If not, see . + */ + +-#include ++// #include + + #include + #include + + #include +-#if defined (HAVE_STDLIB_H) +-# include +-#else +-# include "ansi_stdlib.h" +-#endif /* HAVE_STDLIB_H */ ++// #if defined (HAVE_STDLIB_H) ++// # include ++// #else ++// # include "ansi_stdlib.h" ++// #endif /* HAVE_STDLIB_H */ ++#include + + /* Duplicated from signames.c */ + #if !defined (NSIG) +diff --git bash-clean/support/signames.c bash-workdir/support/signames.c +index 84864fd..6b4e29f 100644 +--- bash-clean/support/signames.c ++++ bash-workdir/support/signames.c +@@ -18,18 +18,19 @@ + along with Bash. If not, see . + */ + +-#include ++// #include + + #include + + #include + #include + +-#if defined (HAVE_STDLIB_H) +-# include +-#else +-# include "ansi_stdlib.h" +-#endif /* HAVE_STDLIB_H */ ++// #if defined (HAVE_STDLIB_H) ++// # include ++// #else ++// # include "ansi_stdlib.h" ++// #endif /* HAVE_STDLIB_H */ ++#include + + #if !defined (NSIG) + # define NSIG 64 diff --git a/patches/binutils/binutils.patch b/patches/binutils/binutils.patch deleted file mode 100644 index 3e2580aa27f..00000000000 --- a/patches/binutils/binutils.patch +++ /dev/null @@ -1,87 +0,0 @@ -From 23c517e8985baa0b4a788186d53e6299f72d48d0 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Tue, 31 Aug 2021 11:15:02 +1000 -Subject: [PATCH] targets: add aero target port - -Signed-off-by: Andy-Python-Programmer ---- - .vscode/settings.json | 6 ++++++ - bfd/config.bfd | 5 +++++ - config.sub | 2 +- - gas/configure.tgt | 1 + - ld/configure.tgt | 4 ++++ - 5 files changed, 17 insertions(+), 1 deletion(-) - create mode 100644 .vscode/settings.json - -diff --git a/.vscode/settings.json b/.vscode/settings.json -new file mode 100644 -index 00000000..7a72e53f ---- /dev/null -+++ b/.vscode/settings.json -@@ -0,0 +1,6 @@ -+{ -+ "editor.formatOnSave": false, -+ "files.associations": { -+ "inttypes.h": "c" -+ } -+} -\ No newline at end of file -diff --git a/bfd/config.bfd b/bfd/config.bfd -index 30087e3b..5f204466 100644 ---- a/bfd/config.bfd -+++ b/bfd/config.bfd -@@ -719,6 +719,11 @@ case "${targ}" in - targ_defvec=i386_elf32_vec - targ_selvecs="iamcu_elf32_vec i386_pe_vec i386_pei_vec" - ;; -+ x86_64-*-aero*) -+ targ_defvec=x86_64_elf64_vec -+ targ_selvecs=i386_elf32_vec -+ want64=true -+ ;; - i[3-7]86-*-interix*) - targ_defvec=i386_pei_vec - targ_selvecs="i386_pe_vec" -diff --git a/config.sub b/config.sub -index 7384e919..e1e5c644 100755 ---- a/config.sub -+++ b/config.sub -@@ -1704,7 +1704,7 @@ case $os in - | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ - | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ - | hiux* | abug | nacl* | netware* | windows* \ -- | os9* | macos* | osx* | ios* \ -+ | os9* | macos* | osx* | ios* | aero* \ - | mpw* | magic* | mmixware* | mon960* | lnews* \ - | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ - | aos* | aros* | cloudabi* | sortix* | twizzler* \ -diff --git a/gas/configure.tgt b/gas/configure.tgt -index 338892ad..d1a9ac68 100644 ---- a/gas/configure.tgt -+++ b/gas/configure.tgt -@@ -221,6 +221,7 @@ case ${generic_target} in - i386-*-beos*) fmt=elf ;; - i386-*-elfiamcu) fmt=elf arch=iamcu ;; - i386-*-elf*) fmt=elf ;; -+ i386-*-aero*) fmt=elf ;; - i386-*-fuchsia*) fmt=elf ;; - i386-*-genode*) fmt=elf ;; - i386-*-bsd*) fmt=aout em=386bsd ;; -diff --git a/ld/configure.tgt b/ld/configure.tgt -index 6205d7c9..5cd3f070 100644 ---- a/ld/configure.tgt -+++ b/ld/configure.tgt -@@ -323,6 +323,10 @@ i[3-7]86-*-linux-*) targ_emul=elf_i386 - targ64_extra_emuls="elf_x86_64 elf32_x86_64 elf_l1om elf_k1om" - targ64_extra_libpath="elf_x86_64 elf32_x86_64" - ;; -+x86_64-*-aero*) -+ targ_emul=elf_x86_64 -+ targ_extra_emuls=elf_i386 -+ ;; - i[3-7]86-*-redox*) targ_emul=elf_i386 - targ_extra_emuls=elf_x86_64 - ;; --- -2.25.1 - diff --git a/patches/binutils/jinx-working-patch.patch b/patches/binutils/jinx-working-patch.patch new file mode 100644 index 00000000000..2e63a00fa3d --- /dev/null +++ b/patches/binutils/jinx-working-patch.patch @@ -0,0 +1,154 @@ +diff --git binutils-clean/bfd/Makefile.am binutils-workdir/bfd/Makefile.am +index 5c5fdef..3c91651 100644 +--- binutils-clean/bfd/Makefile.am ++++ binutils-workdir/bfd/Makefile.am +@@ -778,7 +778,7 @@ ofiles: stamp-ofiles ; @true + libbfd_la_SOURCES = $(BFD32_LIBS_CFILES) + EXTRA_libbfd_la_SOURCES = $(CFILES) + libbfd_la_DEPENDENCIES = $(OFILES) ofiles ../libsframe/libsframe.la +-libbfd_la_LIBADD = `cat ofiles` @SHARED_LIBADD@ $(LIBDL) $(ZLIB) $(ZSTD_LIBS) ../libsframe/libsframe.la ++libbfd_la_LIBADD = `cat ofiles` @SHARED_LIBADD@ $(LIBDL) $(ZLIB) $(ZSTD_LIBS) $(SFRAME_LIB_PATH) ../libsframe/libsframe.la + libbfd_la_LDFLAGS += -release `cat libtool-soversion` @SHARED_LDFLAGS@ + + # This file holds an array associating configuration triplets and +diff --git binutils-clean/bfd/config.bfd binutils-workdir/bfd/config.bfd +index bdee539..48b2360 100644 +--- binutils-clean/bfd/config.bfd ++++ binutils-workdir/bfd/config.bfd +@@ -664,6 +664,11 @@ case "${targ}" in + targ_selvecs= + targ64_selvecs=x86_64_elf64_vec + ;; ++ i[3-7]86-*-aero*) ++ targ_defvec=i386_elf32_vec ++ targ_selvecs= ++ targ64_selvecs=x86_64_elf64_vec ++ ;; + #ifdef BFD64 + x86_64-*-cloudabi*) + targ_defvec=x86_64_elf64_cloudabi_vec +@@ -734,6 +739,11 @@ case "${targ}" in + targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec" + want64=true + ;; ++ x86_64-*-aero*) ++ targ_defvec=x86_64_elf64_vec ++ targ_selvecs=i386_elf32_vec ++ want64=true ++ ;; + #endif + i[3-7]86-*-lynxos*) + targ_defvec=i386_elf32_vec +diff --git binutils-clean/gas/configure.tgt binutils-workdir/gas/configure.tgt +index 3429f85..8fe03c1 100644 +--- binutils-clean/gas/configure.tgt ++++ binutils-workdir/gas/configure.tgt +@@ -227,6 +227,7 @@ case ${generic_target} in + i386-*-beos*) fmt=elf ;; + i386-*-elfiamcu) fmt=elf arch=iamcu ;; + i386-*-elf*) fmt=elf ;; ++ i386-*-aero*) fmt=elf em=gnu ;; + i386-*-fuchsia*) fmt=elf ;; + i386-*-haiku*) fmt=elf em=haiku ;; + i386-*-genode*) fmt=elf ;; +diff --git binutils-clean/gprofng/libcollector/configure.ac binutils-workdir/gprofng/libcollector/configure.ac +index 7af9581..c55e424 100644 +--- binutils-clean/gprofng/libcollector/configure.ac ++++ binutils-workdir/gprofng/libcollector/configure.ac +@@ -18,7 +18,7 @@ dnl . + + m4_include([../../bfd/version.m4]) + AC_INIT([gprofng], BFD_VERSION) +-AC_CONFIG_MACRO_DIRS([../../config ../..]) ++#AC_CONFIG_MACRO_DIRS([../../config ../..]) + AC_CONFIG_AUX_DIR(../..) + AC_CANONICAL_TARGET + AM_INIT_AUTOMAKE +diff --git binutils-clean/ld/configure.tgt binutils-workdir/ld/configure.tgt +index c62b958..3873c96 100644 +--- binutils-clean/ld/configure.tgt ++++ binutils-workdir/ld/configure.tgt +@@ -378,6 +378,9 @@ i[3-7]86-*-linux-*) targ_emul=elf_i386 + i[3-7]86-*-redox*) targ_emul=elf_i386 + targ_extra_emuls=elf_x86_64 + ;; ++i[3-7]86-*-aero*) targ_emul=elf_i386 ++ targ_extra_emuls=elf_x86_64 ++ ;; + i[3-7]86-*-solaris2*) targ_emul=elf_i386_sol2 + targ_extra_emuls="elf_i386_ldso elf_i386 elf_iamcu elf_x86_64_sol2 elf_x86_64" + targ_extra_libpath=$targ_extra_emuls +@@ -1011,6 +1014,9 @@ x86_64-*-linux-*) targ_emul=elf_x86_64 + x86_64-*-redox*) targ_emul=elf_x86_64 + targ_extra_emuls=elf_i386 + ;; ++x86_64-*-aero*) targ_emul=elf_x86_64 ++ targ_extra_emuls=elf_i386 ++ ;; + x86_64-*-solaris2*) targ_emul=elf_x86_64_sol2 + targ_extra_emuls="elf_x86_64 elf_i386_sol2 elf_i386_ldso elf_i386 elf_iamcu" + targ_extra_libpath=$targ_extra_emuls +diff --git binutils-clean/libiberty/configure.ac binutils-workdir/libiberty/configure.ac +index 0748c59..954e014 100644 +--- binutils-clean/libiberty/configure.ac ++++ binutils-workdir/libiberty/configure.ac +@@ -37,7 +37,7 @@ else + libiberty_topdir="${srcdir}/.." + fi + AC_SUBST(libiberty_topdir) +-AC_CONFIG_AUX_DIR($libiberty_topdir) ++AC_CONFIG_AUX_DIR([.]) + + dnl Very limited version of automake's enable-maintainer-mode + +diff --git binutils-workdir/multilib.am binutils-workdir/multilib.am +new file mode 100644 +index 0000000..5c98b69 +--- /dev/null ++++ binutils-workdir/multilib.am +@@ -0,0 +1,45 @@ ++## automake - create Makefile.in from Makefile.am ++ ++## Copyright (C) 1994-2017 Free Software Foundation, Inc. ++## This Makefile.in is free software; the Free Software Foundation ++## gives unlimited permission to copy and/or distribute it, ++## with or without modifications, as long as this notice is preserved. ++ ++## This program is distributed in the hope that it will be useful, ++## but WITHOUT ANY WARRANTY; without even the implied warranty of ++## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++## GNU General Public License for more details. ++ ++MULTISRCTOP = ++MULTIBUILDTOP = ++MULTIDIRS = ++MULTISUBDIR = ++MULTIDO = true ++MULTICLEAN = true ++ ++# GNU Make needs to see an explicit $(MAKE) variable in the command it ++# runs to enable its job server during parallel builds. Hence the ++# comments below. ++all-multi: ++ $(MULTIDO) $(AM_MAKEFLAGS) DO=all multi-do # $(MAKE) ++install-multi: ++ $(MULTIDO) $(AM_MAKEFLAGS) DO=install multi-do # $(MAKE) ++mostlyclean-multi: ++ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=mostlyclean multi-clean # $(MAKE) ++clean-multi: ++ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=clean multi-clean # $(MAKE) ++distclean-multi: ++ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=distclean multi-clean # $(MAKE) ++maintainer-clean-multi: ++ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=maintainer-clean multi-clean # $(MAKE) ++ ++.MAKE .PHONY: all-multi clean-multi distclean-multi install-am \ ++ install-multi maintainer-clean-multi mostlyclean-multi ++ ++install-exec-local: install-multi ++ ++all-local: all-multi ++mostlyclean-local: mostlyclean-multi ++clean-local: clean-multi ++distclean-local: distclean-multi ++maintainer-clean-local: maintainer-clean-multi diff --git a/patches/cairo/jinx-working-patch.patch b/patches/cairo/jinx-working-patch.patch new file mode 100644 index 00000000000..accf74eb94a --- /dev/null +++ b/patches/cairo/jinx-working-patch.patch @@ -0,0 +1,33 @@ +diff --git cairo-clean/meson.build cairo-workdir/meson.build +index 9100152..1b7e91d 100644 +--- cairo-clean/meson.build ++++ cairo-workdir/meson.build +@@ -374,18 +374,18 @@ if x11_dep.found() and xext_dep.found() + # between a set value (bool) or the fallback value (string), so convert to + # a string and check the string value. + prop_str = '@0@'.format(prop) +- if prop_str in ['true', 'false'] ++ #if prop_str in ['true', 'false'] + ipc_rmid_deferred_release = (prop_str == 'true') + message('IPC_RMID_DEFERRED_RELEASE:', ipc_rmid_deferred_release) +- elif prop_str == 'auto' +- res = cc.run(files('meson-cc-tests/ipc_rmid_deferred_release.c'), +- dependencies: [x11_dep, xext_dep], +- name: 'shmctl IPC_RMID allowes subsequent attaches') +- +- ipc_rmid_deferred_release = (res.returncode() == 0) +- else +- error('Unexpected value for external property ipc_rmid_deferred_release: @0@'.format(prop_str)) +- endif ++ #elif prop_str == 'auto' ++ # res = cc.run(files('meson-cc-tests/ipc_rmid_deferred_release.c'), ++ # dependencies: [x11_dep, xext_dep], ++ # name: 'shmctl IPC_RMID allowes subsequent attaches') ++ ++ # ipc_rmid_deferred_release = (res.returncode() == 0) ++ #else ++ # error('Unexpected value for external property ipc_rmid_deferred_release: @0@'.format(prop_str)) ++ #endif + + conf.set10('IPC_RMID_DEFERRED_RELEASE', ipc_rmid_deferred_release) + endif diff --git a/patches/coreutils/coreutils.patch b/patches/coreutils/coreutils.patch deleted file mode 100644 index da878672fc8..00000000000 --- a/patches/coreutils/coreutils.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/bundled/coreutils-orig/build-aux/config.sub b/bundled/coreutils-workdir/build-aux/config.sub -index f02d43a..06e0dab 100755 ---- a/bundled/coreutils-orig/build-aux/config.sub -+++ b/bundled/coreutils-workdir/build-aux/config.sub -@@ -1346,7 +1346,7 @@ case $os in - | aos* | aros* | cloudabi* | sortix* | twizzler* \ - | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ - | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ -- | knetbsd* | mirbsd* | netbsd* \ -+ | knetbsd* | mirbsd* | netbsd* | aero* \ - | bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \ - | ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \ - | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ \ No newline at end of file diff --git a/patches/dbus/jinx-working-patch.patch b/patches/dbus/jinx-working-patch.patch new file mode 100644 index 00000000000..2daea44cafa --- /dev/null +++ b/patches/dbus/jinx-working-patch.patch @@ -0,0 +1,13 @@ +diff --git dbus-clean/dbus/dbus-sysdeps-unix.c dbus-workdir/dbus/dbus-sysdeps-unix.c +index dbc459c..6a3e851 100644 +--- dbus-clean/dbus/dbus-sysdeps-unix.c ++++ dbus-workdir/dbus/dbus-sysdeps-unix.c +@@ -4896,7 +4896,7 @@ _dbus_check_setuid (void) + + if (_DBUS_UNLIKELY (!check_setuid_initialised)) + { +-#ifdef HAVE_GETRESUID ++#if defined HAVE_GETRESUID && !defined(__aero__) + if (getresuid (&ruid, &euid, &suid) != 0 || + getresgid (&rgid, &egid, &sgid) != 0) + #endif /* HAVE_GETRESUID */ diff --git a/patches/dmenu/dmenu.patch b/patches/dmenu/dmenu.patch deleted file mode 100644 index 39f67ba2b98..00000000000 --- a/patches/dmenu/dmenu.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 919950798aa0175e18a12e3ab970d133ea0947c5 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Sat, 12 Nov 2022 19:41:25 +1100 -Subject: [PATCH] - ---- - config.mk | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/config.mk b/config.mk -index 566348b..ae68b54 100644 ---- a/config.mk -+++ b/config.mk -@@ -9,8 +9,8 @@ X11INC = /usr/X11R6/include - X11LIB = /usr/X11R6/lib - - # Xinerama, comment if you don't want it --XINERAMALIBS = -lXinerama --XINERAMAFLAGS = -DXINERAMA -+# XINERAMALIBS = -lXinerama -+# XINERAMAFLAGS = -DXINERAMA - - # freetype - FREETYPELIBS = -lfontconfig -lXft --- -2.38.1 - diff --git a/patches/dwm/0001-uselessgaps.patch b/patches/dwm/0001-uselessgaps.patch deleted file mode 100644 index d9cacbecb6d..00000000000 --- a/patches/dwm/0001-uselessgaps.patch +++ /dev/null @@ -1,81 +0,0 @@ -From 58a5ece9406ca6c90dc362617c065e4aac19417f Mon Sep 17 00:00:00 2001 -From: Cyril Cressent -Date: Wed, 3 Jul 2019 21:33:45 -0700 -Subject: [PATCH] Port the uselessgap patch to 6.2 - ---- - config.def.h | 1 + - dwm.c | 36 ++++++++++++++++++++++++++++++------ - 2 files changed, 31 insertions(+), 6 deletions(-) - -diff --git a/config.def.h b/config.def.h -index 1c0b587..b11471d 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -2,6 +2,7 @@ - - /* appearance */ - static const unsigned int borderpx = 1; /* border pixel of windows */ -+static const unsigned int gappx = 6; /* gaps between windows */ - static const unsigned int snap = 32; /* snap pixel */ - static const int showbar = 1; /* 0 means no bar */ - static const int topbar = 1; /* 0 means bottom bar */ -diff --git a/dwm.c b/dwm.c -index 4465af1..4545e05 100644 ---- a/dwm.c -+++ b/dwm.c -@@ -52,8 +52,8 @@ - #define ISVISIBLE(C) ((C->tags & C->mon->tagset[C->mon->seltags])) - #define LENGTH(X) (sizeof X / sizeof X[0]) - #define MOUSEMASK (BUTTONMASK|PointerMotionMask) --#define WIDTH(X) ((X)->w + 2 * (X)->bw) --#define HEIGHT(X) ((X)->h + 2 * (X)->bw) -+#define WIDTH(X) ((X)->w + 2 * (X)->bw + gappx) -+#define HEIGHT(X) ((X)->h + 2 * (X)->bw + gappx) - #define TAGMASK ((1 << LENGTH(tags)) - 1) - #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) - -@@ -1276,12 +1276,36 @@ void - resizeclient(Client *c, int x, int y, int w, int h) - { - XWindowChanges wc; -+ unsigned int n; -+ unsigned int gapoffset; -+ unsigned int gapincr; -+ Client *nbc; - -- c->oldx = c->x; c->x = wc.x = x; -- c->oldy = c->y; c->y = wc.y = y; -- c->oldw = c->w; c->w = wc.width = w; -- c->oldh = c->h; c->h = wc.height = h; - wc.border_width = c->bw; -+ -+ /* Get number of clients for the selected monitor */ -+ for (n = 0, nbc = nexttiled(selmon->clients); nbc; nbc = nexttiled(nbc->next), n++); -+ -+ /* Do nothing if layout is floating */ -+ if (c->isfloating || selmon->lt[selmon->sellt]->arrange == NULL) { -+ gapincr = gapoffset = 0; -+ } else { -+ /* Remove border and gap if layout is monocle or only one client */ -+ if (selmon->lt[selmon->sellt]->arrange == monocle || n == 1) { -+ gapoffset = 0; -+ gapincr = -2 * borderpx; -+ wc.border_width = 0; -+ } else { -+ gapoffset = gappx; -+ gapincr = 2 * gappx; -+ } -+ } -+ -+ c->oldx = c->x; c->x = wc.x = x + gapoffset; -+ c->oldy = c->y; c->y = wc.y = y + gapoffset; -+ c->oldw = c->w; c->w = wc.width = w - gapincr; -+ c->oldh = c->h; c->h = wc.height = h - gapincr; -+ - XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); - configure(c); - XSync(dpy, False); --- -2.22.0 - diff --git a/patches/dwm/dwm.patch b/patches/dwm/dwm.patch deleted file mode 100644 index 64e1887b23d..00000000000 --- a/patches/dwm/dwm.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 21113e6d56c83249371b8f57a9cd3128df2f2436 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Wed, 29 Mar 2023 12:17:14 +1100 -Subject: [PATCH] - ---- - config.def.h | 22 +++++++++++----------- - config.mk | 4 ++-- - 2 files changed, 13 insertions(+), 13 deletions(-) - -diff --git a/config.def.h b/config.def.h -index 9efa774..1be6069 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -4,18 +4,18 @@ - static const unsigned int borderpx = 1; /* border pixel of windows */ - static const unsigned int snap = 32; /* snap pixel */ - static const int showbar = 1; /* 0 means no bar */ --static const int topbar = 1; /* 0 means bottom bar */ -+static const int topbar = 0; /* 0 means bottom bar */ - static const char *fonts[] = { "monospace:size=10" }; - static const char dmenufont[] = "monospace:size=10"; --static const char col_gray1[] = "#222222"; --static const char col_gray2[] = "#444444"; --static const char col_gray3[] = "#bbbbbb"; --static const char col_gray4[] = "#eeeeee"; --static const char col_cyan[] = "#005577"; -+static const char col_gray1[] = "#2e3440"; -+static const char col_gray2[] = "#434c5e"; -+static const char col_gray3[] = "#e5e9f0"; -+static const char col_gray4[] = "#d8dee9"; -+static const char col_cyan[] = "#88c0d0"; - static const char *colors[][3] = { -- /* fg bg border */ -- [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, -- [SchemeSel] = { col_gray4, col_cyan, col_cyan }, -+ /* fg bg border */ -+ [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, -+ [SchemeSel] = { col_gray1, col_cyan, col_cyan }, - }; - - /* tagging */ -@@ -57,8 +57,8 @@ static const Layout layouts[] = { - - /* commands */ - static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ --static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; --static const char *termcmd[] = { "st", NULL }; -+static const char *dmenucmd[] = { "dmenu_run", NULL }; -+static const char *termcmd[] = { "alacritty", NULL }; - - static const Key keys[] = { - /* modifier key function argument */ -diff --git a/config.mk b/config.mk -index ba64d3d..d360492 100644 ---- a/config.mk -+++ b/config.mk -@@ -11,8 +11,8 @@ X11INC = /usr/X11R6/include - X11LIB = /usr/X11R6/lib - - # Xinerama, comment if you don't want it --XINERAMALIBS = -lXinerama --XINERAMAFLAGS = -DXINERAMA -+# XINERAMALIBS = -lXinerama -+# XINERAMAFLAGS = -DXINERAMA - - # freetype - FREETYPELIBS = -lfontconfig -lXft --- -2.39.2 - diff --git a/patches/fontconfig/0001-fontconfig-aero-specific-changes.patch b/patches/fontconfig/0001-fontconfig-aero-specific-changes.patch deleted file mode 100644 index 31da2315c26..00000000000 --- a/patches/fontconfig/0001-fontconfig-aero-specific-changes.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 923dd34de98831460447a85a2786e7c7d6ff3a95 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Wed, 5 Oct 2022 19:43:23 +1100 -Subject: [PATCH] fontconfig: aero specific changes - -Signed-off-by: Andy-Python-Programmer ---- - src/fcstat.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/fcstat.c b/src/fcstat.c -index 4f69eae..8a621dd 100644 ---- a/src/fcstat.c -+++ b/src/fcstat.c -@@ -386,7 +386,7 @@ FcFStatFs (int fd, FcStatFS *statb) - # endif - # if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) - p = buf.f_fstypename; --# elif defined(__linux__) || defined (__EMSCRIPTEN__) -+# elif defined(__linux__) || defined(__aero__) || defined (__EMSCRIPTEN__) - switch (buf.f_type) - { - case 0x6969: /* nfs */ --- -2.25.1 - diff --git a/patches/fontconfig/jinx-working-patch.patch b/patches/fontconfig/jinx-working-patch.patch new file mode 100644 index 00000000000..b1816e93eeb --- /dev/null +++ b/patches/fontconfig/jinx-working-patch.patch @@ -0,0 +1,13 @@ +diff --git fontconfig-clean/src/fcstat.c fontconfig-workdir/src/fcstat.c +index 4f69eae..519cf1d 100644 +--- fontconfig-clean/src/fcstat.c ++++ fontconfig-workdir/src/fcstat.c +@@ -386,7 +386,7 @@ FcFStatFs (int fd, FcStatFS *statb) + # endif + # if defined(HAVE_STRUCT_STATFS_F_FSTYPENAME) + p = buf.f_fstypename; +-# elif defined(__linux__) || defined (__EMSCRIPTEN__) ++# elif defined(__linux__) || defined (__aero__) || defined (__EMSCRIPTEN__) + switch (buf.f_type) + { + case 0x6969: /* nfs */ diff --git a/patches/gcc-host/jinx-working-patch.patch b/patches/gcc-host/jinx-working-patch.patch new file mode 100644 index 00000000000..d280068ea5f --- /dev/null +++ b/patches/gcc-host/jinx-working-patch.patch @@ -0,0 +1,153 @@ +diff --git gcc-host-clean/fixincludes/mkfixinc.sh gcc-host-workdir/fixincludes/mkfixinc.sh +index df90720..da6408a 100755 +--- gcc-host-clean/fixincludes/mkfixinc.sh ++++ gcc-host-workdir/fixincludes/mkfixinc.sh +@@ -12,6 +12,7 @@ target=fixinc.sh + # Check for special fix rules for particular targets + case $machine in + i?86-*-cygwin* | \ ++ x86_64-*-aero* | \ + i?86-*-mingw32* | \ + x86_64-*-mingw32* | \ + powerpc-*-eabisim* | \ +diff --git gcc-host-workdir/gcc/config/aero.h gcc-host-workdir/gcc/config/aero.h +new file mode 100644 +index 0000000..be79aae +--- /dev/null ++++ gcc-host-workdir/gcc/config/aero.h +@@ -0,0 +1,29 @@ ++#undef TARGET_AERO ++#define TARGET_AERO 1 ++ ++#undef LIB_SPEC ++#define LIB_SPEC "-lc" ++ ++#undef STARTFILE_SPEC ++#define STARTFILE_SPEC "%{!shared:crt0.o%s} crti.o%s %{shared:crtbeginS.o%s;:crtbegin.o%s}" ++ ++#undef ENDFILE_SPEC ++#define ENDFILE_SPEC "%{shared:crtendS.o%s;:crtend.o%s} crtn.o%s" ++ ++#define GNU_USER_LINK_EMULATION32 "elf_i386" ++#define GNU_USER_LINK_EMULATION64 "elf_x86_64" ++#define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64" ++ ++#define GNU_USER_DYNAMIC_LINKER32 "/usr/lib/ld_i386.so" ++#define GNU_USER_DYNAMIC_LINKER64 "/usr/lib/ld.so" ++#define GNU_USER_DYNAMIC_LINKERX32 "/usr/lib/ld32.so" ++ ++#undef TARGET_OS_CPP_BUILTINS ++#define TARGET_OS_CPP_BUILTINS() \ ++ do { \ ++ builtin_define ("__aero__"); \ ++ builtin_define ("__unix__"); \ ++ builtin_assert ("system=aero"); \ ++ builtin_assert ("system=unix"); \ ++ builtin_assert ("system=posix"); \ ++ } while (0); +diff --git gcc-host-clean/gcc/config.gcc gcc-host-workdir/gcc/config.gcc +index 648b3dc..f2b0217 100644 +--- gcc-host-clean/gcc/config.gcc ++++ gcc-host-workdir/gcc/config.gcc +@@ -840,6 +840,15 @@ case ${target} in + tmake_file="${tmake_file} t-freebsd" + target_has_targetdm=yes + ;; ++*-*-aero*) ++ extra_options="$extra_options gnu-user.opt" ++ gas=yes ++ gnu_ld=yes ++ default_use_cxa_atexit=yes ++ use_gcc_stdint=wrap ++ tmake_file="${tmake_file} t-slibgcc" ++ thread_file='posix' ++ ;; + *-*-fuchsia*) + native_system_header_dir=/include + ;; +@@ -2214,6 +2223,9 @@ i[34567]86-*-mingw* | x86_64-*-mingw*) + ;; + esac + ;; ++x86_64-*-aero*) ++ tm_file="${tm_file} i386/unix.h i386/att.h elfos.h gnu-user.h glibc-stdint.h i386/x86-64.h i386/gnu-user-common.h i386/gnu-user64.h aero.h" ++ ;; + x86_64-*-fuchsia*) + tmake_file="${tmake_file} i386/t-x86_64-elf" + tm_file="${tm_file} i386/unix.h i386/att.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h fuchsia.h" +diff --git gcc-host-clean/libgcc/config.host gcc-host-workdir/libgcc/config.host +index 9d72120..b4e90ab 100644 +--- gcc-host-clean/libgcc/config.host ++++ gcc-host-workdir/libgcc/config.host +@@ -281,6 +281,11 @@ case ${host} in + tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-fuchsia" + extra_parts="crtbegin.o crtend.o" + ;; ++*-*-aero*) ++ extra_parts="$extra_parts crti.o crtbegin.o crtbeginS.o crtend.o crtendS.o crtn.o" ++ tmake_file="$tmake_file t-crtstuff-pic" ++ tmake_file="$tmake_file t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver t-libgcc-pic" ++ ;; + *-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-gnu* | *-*-kopensolaris*-gnu | *-*-uclinuxfdpiceabi) + tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver t-linux" + extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o" +@@ -715,6 +720,10 @@ x86_64-*-elf* | x86_64-*-rtems*) + x86_64-*-fuchsia*) + tmake_file="$tmake_file t-libgcc-pic" + ;; ++x86_64-*-aero*) ++ extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o" ++ tmake_file="$tmake_file i386/t-crtpc t-crtfm i386/t-crtstuff t-dfprules" ++ ;; + i[34567]86-*-dragonfly*) + tmake_file="${tmake_file} i386/t-dragonfly i386/t-crtstuff" + md_unwind_header=i386/dragonfly-unwind.h +diff --git gcc-host-clean/libgcc/configure.ac gcc-host-workdir/libgcc/configure.ac +index 2fc9d5d..83d246e 100644 +--- gcc-host-clean/libgcc/configure.ac ++++ gcc-host-workdir/libgcc/configure.ac +@@ -46,7 +46,7 @@ else + libgcc_topdir="${srcdir}/.." + fi + AC_SUBST(libgcc_topdir) +-AC_CONFIG_AUX_DIR($libgcc_topdir) ++AC_CONFIG_AUX_DIR([.]) + AC_CONFIG_HEADER(auto-target.h:config.in) + + AC_ARG_ENABLE(shared, +diff --git gcc-host-clean/libiberty/configure.ac gcc-host-workdir/libiberty/configure.ac +index 28d996f..61ff752 100644 +--- gcc-host-clean/libiberty/configure.ac ++++ gcc-host-workdir/libiberty/configure.ac +@@ -37,7 +37,7 @@ else + libiberty_topdir="${srcdir}/.." + fi + AC_SUBST(libiberty_topdir) +-AC_CONFIG_AUX_DIR($libiberty_topdir) ++AC_CONFIG_AUX_DIR([.]) + + dnl Very limited version of automake's enable-maintainer-mode + +diff --git gcc-host-clean/libstdc++-v3/crossconfig.m4 gcc-host-workdir/libstdc++-v3/crossconfig.m4 +index b3269cb..a1d4a28 100644 +--- gcc-host-clean/libstdc++-v3/crossconfig.m4 ++++ gcc-host-workdir/libstdc++-v3/crossconfig.m4 +@@ -136,6 +136,18 @@ case "${host}" in + AC_CHECK_FUNCS(uselocale) + ;; + ++ *-aero*) ++ GLIBCXX_CHECK_COMPILER_FEATURES ++ GLIBCXX_CHECK_LINKER_FEATURES ++ GLIBCXX_CHECK_MATH_SUPPORT ++ GLIBCXX_CHECK_STDLIB_SUPPORT ++ AC_DEFINE(_GLIBCXX_USE_DEV_RANDOM) ++ AC_DEFINE(_GLIBCXX_USE_RANDOM_TR1) ++ GCC_CHECK_TLS ++ AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc) ++ AC_CHECK_FUNCS(timespec_get) ++ ;; ++ + *-fuchsia*) + SECTION_FLAGS='-ffunction-sections -fdata-sections' + AC_SUBST(SECTION_FLAGS) diff --git a/patches/gcc/gcc.patch b/patches/gcc/gcc.patch deleted file mode 100644 index 9465555f5b7..00000000000 --- a/patches/gcc/gcc.patch +++ /dev/null @@ -1,214 +0,0 @@ -From 4c867374622a04f29a5501dfc74f1057041cc0fc Mon Sep 17 00:00:00 2001 -From: Anhad Singh -Date: Thu, 3 Aug 2023 12:51:21 +1000 -Subject: [PATCH] gcc: add aero target - -Signed-off-by: Anhad Singh ---- - config.sub | 4 ++-- - fixincludes/mkfixinc.sh | 1 + - gcc/config.gcc | 12 ++++++++++++ - gcc/config/aero.h | 30 ++++++++++++++++++++++++++++++ - libgcc/config.host | 8 ++++++++ - libgcc/libgcov.h | 1 + - libstdc++-v3/crossconfig.m4 | 12 ++++++++++++ - libtool.m4 | 14 ++++++++++++++ - 8 files changed, 80 insertions(+), 2 deletions(-) - create mode 100644 gcc/config/aero.h - -diff --git a/config.sub b/config.sub -index 38f3d037a..956f31f08 100755 ---- a/config.sub -+++ b/config.sub -@@ -145,7 +145,7 @@ case $1 in - nto-qnx* | linux-* | uclinux-uclibc* \ - | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ - | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ -- | storm-chaos* | os2-emx* | rtmk-nova*) -+ | storm-chaos* | os2-emx* | rtmk-nova* | aero*) - basic_machine=$field1 - basic_os=$maybe_os - ;; -@@ -1749,7 +1749,7 @@ case $os in - | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ - | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ - | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ -- | fiwix* ) -+ | fiwix* | aero*) - ;; - # This one is extra strict with allowed versions - sco3.2v2 | sco3.2v[4-9]* | sco5v6*) -diff --git a/fixincludes/mkfixinc.sh b/fixincludes/mkfixinc.sh -index df90720b7..e8c2b21c1 100755 ---- a/fixincludes/mkfixinc.sh -+++ b/fixincludes/mkfixinc.sh -@@ -11,6 +11,7 @@ target=fixinc.sh - - # Check for special fix rules for particular targets - case $machine in -+ x86_64-*-aero* | \ - i?86-*-cygwin* | \ - i?86-*-mingw32* | \ - x86_64-*-mingw32* | \ -diff --git a/gcc/config.gcc b/gcc/config.gcc -index 648b3dc21..4a13aceda 100644 ---- a/gcc/config.gcc -+++ b/gcc/config.gcc -@@ -840,6 +840,15 @@ case ${target} in - tmake_file="${tmake_file} t-freebsd" - target_has_targetdm=yes - ;; -+*-*-aero*) -+ extra_options="$extra_options gnu-user.opt" -+ gas=yes -+ gnu_ld=yes -+ default_use_cxa_atexit=yes -+ use_gcc_stdint=wrap -+ tmake_file="${tmake_file} t-slibgcc" -+ thread_file='posix' -+ ;; - *-*-fuchsia*) - native_system_header_dir=/include - ;; -@@ -2214,6 +2223,9 @@ i[34567]86-*-mingw* | x86_64-*-mingw*) - ;; - esac - ;; -+x86_64-*-aero*) -+ tm_file="${tm_file} i386/unix.h i386/att.h elfos.h gnu-user.h glibc-stdint.h i386/x86-64.h i386/gnu-user-common.h i386/gnu-user64.h aero.h" -+ ;; - x86_64-*-fuchsia*) - tmake_file="${tmake_file} i386/t-x86_64-elf" - tm_file="${tm_file} i386/unix.h i386/att.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h fuchsia.h" -diff --git a/gcc/config/aero.h b/gcc/config/aero.h -new file mode 100644 -index 000000000..e8c149e40 ---- /dev/null -+++ b/gcc/config/aero.h -@@ -0,0 +1,30 @@ -+#undef TARGET_AERO -+#define TARGET_AERO 1 -+ -+#undef LIB_SPEC -+#define LIB_SPEC "-lc -lm" -+ -+#undef STARTFILE_SPEC -+#define STARTFILE_SPEC "%{!shared:crt0.o%s} crti.o%s %{shared:crtbeginS.o%s;:crtbegin.o%s}" -+ -+#undef ENDFILE_SPEC -+#define ENDFILE_SPEC "%{shared:crtendS.o%s;:crtend.o%s} crtn.o%s" -+ -+#define GNU_USER_LINK_EMULATION32 "elf_i386" -+#define GNU_USER_LINK_EMULATION64 "elf_x86_64" -+#define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64" -+ -+#define GNU_USER_DYNAMIC_LINKER32 "/usr/lib/ld_i386.so" -+#define GNU_USER_DYNAMIC_LINKER64 "/usr/lib/ld.so" -+#define GNU_USER_DYNAMIC_LINKERX32 "/usr/lib/ld32.so" -+ -+#undef TARGET_OS_CPP_BUILTINS -+#define TARGET_OS_CPP_BUILTINS() \ -+ do \ -+ { \ -+ builtin_define("__aero__"); \ -+ builtin_define("__unix__"); \ -+ builtin_assert("system=aero"); \ -+ builtin_assert("system=unix"); \ -+ builtin_assert("system=posix"); \ -+ } while (0); -diff --git a/libgcc/config.host b/libgcc/config.host -index 9d7212028..3724a1ac5 100644 ---- a/libgcc/config.host -+++ b/libgcc/config.host -@@ -281,6 +281,11 @@ case ${host} in - tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-fuchsia" - extra_parts="crtbegin.o crtend.o" - ;; -+*-*-aero*) -+ extra_parts="$extra_parts crti.o crtbegin.o crtbeginS.o crtend.o crtendS.o crtn.o" -+ tmake_file="$tmake_file t-crtstuff-pic" -+ tmake_file="$tmake_file t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver t-libgcc-pic" -+ ;; - *-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-gnu* | *-*-kopensolaris*-gnu | *-*-uclinuxfdpiceabi) - tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver t-linux" - extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o" -@@ -715,6 +720,9 @@ x86_64-*-elf* | x86_64-*-rtems*) - x86_64-*-fuchsia*) - tmake_file="$tmake_file t-libgcc-pic" - ;; -+x86_64-*-aero*) -+ tmake_file="$tmake_file i386/t-crtstuff" -+ ;; - i[34567]86-*-dragonfly*) - tmake_file="${tmake_file} i386/t-dragonfly i386/t-crtstuff" - md_unwind_header=i386/dragonfly-unwind.h -diff --git a/libgcc/libgcov.h b/libgcc/libgcov.h -index 92df440d4..320f3b500 100644 ---- a/libgcc/libgcov.h -+++ b/libgcc/libgcov.h -@@ -44,6 +44,7 @@ - #include "tm.h" - #include "libgcc_tm.h" - #include "gcov.h" -+#include - - #if HAVE_SYS_MMAN_H - #include -diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4 -index b3269cb88..4187dba89 100644 ---- a/libstdc++-v3/crossconfig.m4 -+++ b/libstdc++-v3/crossconfig.m4 -@@ -136,6 +136,18 @@ case "${host}" in - AC_CHECK_FUNCS(uselocale) - ;; - -+ *-aero*) -+ GLIBCXX_CHECK_COMPILER_FEATURES -+ GLIBCXX_CHECK_LINKER_FEATURES -+ GLIBCXX_CHECK_MATH_SUPPORT -+ GLIBCXX_CHECK_STDLIB_SUPPORT -+ AC_DEFINE(_GLIBCXX_USE_DEV_RANDOM) -+ AC_DEFINE(_GLIBCXX_USE_RANDOM_TR1) -+ GCC_CHECK_TLS -+ AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc) -+ AC_CHECK_FUNCS(timespec_get) -+ ;; -+ - *-fuchsia*) - SECTION_FLAGS='-ffunction-sections -fdata-sections' - AC_SUBST(SECTION_FLAGS) -diff --git a/libtool.m4 b/libtool.m4 -index b92e284d9..491d24c54 100644 ---- a/libtool.m4 -+++ b/libtool.m4 -@@ -2491,6 +2491,16 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu* | uclinuxfdpiceabi) - dynamic_linker='GNU/Linux ld.so' - ;; - -+aero*) -+ version_type=linux -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' -+ soname_spec='${libname}${release}${shared_ext}$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ hardcode_into_libs=yes -+ ;; -+ - netbsd*) - version_type=sunos - need_lib_prefix=no -@@ -3109,6 +3119,10 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | uclinuxfdpiceabi) - lt_cv_deplibs_check_method=pass_all - ;; - -+aero*) -+ lt_cv_deplibs_check_method=pass_all -+ ;; -+ - netbsd*) - if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then - lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' --- -2.41.0 - diff --git a/patches/glib/0001-glib.patch b/patches/glib/0001-glib.patch deleted file mode 100644 index 04bd02ecce8..00000000000 --- a/patches/glib/0001-glib.patch +++ /dev/null @@ -1,51 +0,0 @@ -From b8ace0ebfb751e7ae165aa3d52093c89801f37e5 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Sun, 16 Apr 2023 16:50:17 +1000 -Subject: [PATCH] - ---- - gio/gcredentialsprivate.h | 2 +- - glib/glib-init.c | 1 + - glib/gstrfuncs.c | 1 + - 3 files changed, 3 insertions(+), 1 deletion(-) - -diff --git a/gio/gcredentialsprivate.h b/gio/gcredentialsprivate.h -index c09f9ec..3942c48 100644 ---- a/gio/gcredentialsprivate.h -+++ b/gio/gcredentialsprivate.h -@@ -102,7 +102,7 @@ - */ - #undef G_CREDENTIALS_HAS_PID - --#ifdef __linux__ -+#if defined(__linux__) || defined(__aero__) - #define G_CREDENTIALS_SUPPORTED 1 - #define G_CREDENTIALS_USE_LINUX_UCRED 1 - #define G_CREDENTIALS_NATIVE_TYPE G_CREDENTIALS_TYPE_LINUX_UCRED -diff --git a/glib/glib-init.c b/glib/glib-init.c -index e7b4984..2e38538 100644 ---- a/glib/glib-init.c -+++ b/glib/glib-init.c -@@ -27,6 +27,7 @@ - #include "gmem.h" /* for g_mem_gc_friendly */ - - #include -+#include - #include - #include - #include -diff --git a/glib/gstrfuncs.c b/glib/gstrfuncs.c -index 9273533..2e3b9b2 100644 ---- a/glib/gstrfuncs.c -+++ b/glib/gstrfuncs.c -@@ -33,6 +33,7 @@ - #include - #include - #include -+#include - #include - #include - #include --- -2.40.0 - diff --git a/patches/glib/0002-Patch-out-assert-in-g_io_unix_get_flags.patch b/patches/glib/0002-Patch-out-assert-in-g_io_unix_get_flags.patch deleted file mode 100644 index fa109fc2557..00000000000 --- a/patches/glib/0002-Patch-out-assert-in-g_io_unix_get_flags.patch +++ /dev/null @@ -1,30 +0,0 @@ -From fe2c4357d753d3a5baed7e2354f3542a1e87b46d Mon Sep 17 00:00:00 2001 -From: Dennis Bonke -Date: Wed, 12 Oct 2022 02:54:15 +0200 -Subject: [PATCH 2/2] Patch out assert in g_io_unix_get_flags - -We don't implement the neccesary bits to fully support this, so in case of doubt, return readable and writeable. - -Signed-off-by: Dennis Bonke ---- - glib/giounix.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/glib/giounix.c b/glib/giounix.c -index ad3aba2..e0237fc 100644 ---- a/glib/giounix.c -+++ b/glib/giounix.c -@@ -436,7 +436,10 @@ g_io_unix_get_flags (GIOChannel *channel) - channel->is_writeable = TRUE; - break; - default: -- g_assert_not_reached (); -+ channel->is_readable = TRUE; -+ channel->is_writeable = TRUE; -+ break; -+ //g_assert_not_reached (); - } - - return flags; --- -2.37.2 diff --git a/patches/glib/jinx-working-patch.patch b/patches/glib/jinx-working-patch.patch new file mode 100644 index 00000000000..5469c6c890a --- /dev/null +++ b/patches/glib/jinx-working-patch.patch @@ -0,0 +1,53 @@ +diff --git glib-clean/gio/gcredentialsprivate.h glib-workdir/gio/gcredentialsprivate.h +index 0310a75..f967f90 100644 +--- glib-clean/gio/gcredentialsprivate.h ++++ glib-workdir/gio/gcredentialsprivate.h +@@ -104,7 +104,7 @@ + */ + #undef G_CREDENTIALS_HAS_PID + +-#ifdef __linux__ ++#if defined(__linux__) || defined(__aero__) + #define G_CREDENTIALS_SUPPORTED 1 + #define G_CREDENTIALS_USE_LINUX_UCRED 1 + #define G_CREDENTIALS_NATIVE_TYPE G_CREDENTIALS_TYPE_LINUX_UCRED +diff --git glib-clean/glib/giounix.c glib-workdir/glib/giounix.c +index 84e8135..5b68f25 100644 +--- glib-clean/glib/giounix.c ++++ glib-workdir/glib/giounix.c +@@ -440,7 +440,10 @@ g_io_unix_get_flags (GIOChannel *channel) + channel->is_writeable = TRUE; + break; + default: +- g_assert_not_reached (); ++ channel->is_readable = TRUE; ++ channel->is_writeable = TRUE; ++ break; ++ // g_assert_not_reached (); + } + + return flags; +diff --git glib-clean/glib/glib-init.c glib-workdir/glib/glib-init.c +index 933f891..393e51d 100644 +--- glib-clean/glib/glib-init.c ++++ glib-workdir/glib/glib-init.c +@@ -29,6 +29,7 @@ + #include "gmem.h" /* for g_mem_gc_friendly */ + + #include ++#include + #include + #include + #include +diff --git glib-clean/glib/gstrfuncs.c glib-workdir/glib/gstrfuncs.c +index 22a608d..29e123c 100644 +--- glib-clean/glib/gstrfuncs.c ++++ glib-workdir/glib/gstrfuncs.c +@@ -35,6 +35,7 @@ + #include + #include + #include ++#include + #include + #include + #include diff --git a/patches/gobject-introspection/gobject-introspection.patch b/patches/gobject-introspection/gobject-introspection.patch deleted file mode 100644 index 77521b645e8..00000000000 --- a/patches/gobject-introspection/gobject-introspection.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 4e30153d4e58f67d3cb040a75afa37cdc57cba33 Mon Sep 17 00:00:00 2001 -From: Dennis Bonke -Date: Fri, 4 Feb 2022 02:24:50 +0100 -Subject: [PATCH] Disable tests as they are broken - -Signed-off-by: Dennis Bonke ---- - meson.build | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/meson.build b/meson.build -index bb4873e0..83931a4a 100644 ---- a/meson.build -+++ b/meson.build -@@ -234,9 +234,9 @@ subdir('docs') - - # The tests will also run, which is not possible if they - # were built for a different architecture. --if not meson.is_cross_build() -- subdir('tests') --endif -+#if not meson.is_cross_build() -+# subdir('tests') -+#endif - - install_data('Makefile.introspection', install_dir: join_paths(get_option('datadir'), 'gobject-introspection-1.0')) - install_data('m4/introspection.m4', install_dir: join_paths(get_option('datadir'), 'aclocal')) --- -2.34.1 diff --git a/patches/gtk+-3/gtk+-3.patch b/patches/gtk+-3/gtk+-3.patch deleted file mode 100644 index 0745b344f97..00000000000 --- a/patches/gtk+-3/gtk+-3.patch +++ /dev/null @@ -1,77 +0,0 @@ -From ce246ae059f136289ac1e1d65a406f724e5114a6 Mon Sep 17 00:00:00 2001 -From: Dennis Bonke -Date: Sun, 3 Apr 2022 22:48:43 +0200 -Subject: [PATCH] Initial Aero support - -Signed-off-by: Dennis Bonke ---- - gdk/wayland/gdkdisplay-wayland.c | 1 - - gtk/a11y/gtkaccessibility.c | 5 +++++ - gtk/gtkmain.c | 5 +++++ - meson.build | 2 +- - 4 files changed, 11 insertions(+), 2 deletions(-) - -diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c -index d4503c2..0e2efc6 100644 ---- a/gdk/wayland/gdkdisplay-wayland.c -+++ b/gdk/wayland/gdkdisplay-wayland.c -@@ -28,7 +28,6 @@ - #endif - - #include --#include - - #include - #include "gdkwayland.h" -diff --git a/gtk/a11y/gtkaccessibility.c b/gtk/a11y/gtkaccessibility.c -index 7f0e520..543a78e 100644 ---- a/gtk/a11y/gtkaccessibility.c -+++ b/gtk/a11y/gtkaccessibility.c -@@ -974,6 +974,10 @@ do_window_event_initialization (void) - void - _gtk_accessibility_init (void) - { -+// We don't care about a11y at this point in time and dbus isn't working, so let's just not start that. -+#ifdef __aero__ -+ return; -+#else - if (initialized) - return; - -@@ -993,4 +997,5 @@ _gtk_accessibility_init (void) - #endif - - atk_misc_instance = g_object_new (GTK_TYPE_MISC_IMPL, NULL); -+#endif - } -diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c -index f7cbb34..8e035d4 100644 ---- a/gtk/gtkmain.c -+++ b/gtk/gtkmain.c -@@ -357,6 +357,11 @@ static gboolean - check_setugid (void) - { - /* this isn't at all relevant on MS Windows and doesn't compile ... --hb */ -+#ifdef __aero__ -+ /* Aero runs everything as root for the time being, this check is thus useless. */ -+ g_warning("Aero ignores the setugid check!\n"); -+ return TRUE; -+#endif - #ifndef G_OS_WIN32 - uid_t ruid, euid, suid; /* Real, effective and saved user ID's */ - gid_t rgid, egid, sgid; /* Real, effective and saved group ID's */ -diff --git a/meson.build b/meson.build -index a8f1383..32118df 100644 ---- a/meson.build -+++ b/meson.build -@@ -307,7 +307,7 @@ elif cc.get_id() == 'gcc' or cc.get_id() == 'clang' - '-Werror=sequence-point', - '-Werror=return-type', - '-Werror=trigraphs', -- '-Werror=array-bounds', -+ #'-Werror=array-bounds', - '-Werror=write-strings', - '-Werror=address', - '-Werror=int-to-pointer-cast', --- -2.39.0 diff --git a/patches/gtk+-3/jinx-working-patch.patch b/patches/gtk+-3/jinx-working-patch.patch new file mode 100644 index 00000000000..3dfbaf5c570 --- /dev/null +++ b/patches/gtk+-3/jinx-working-patch.patch @@ -0,0 +1,37 @@ +diff --git gtk+-3-clean/gtk/a11y/gtkaccessibility.c gtk+-3-workdir/gtk/a11y/gtkaccessibility.c +index 7f0e520..3bf670c 100644 +--- gtk+-3-clean/gtk/a11y/gtkaccessibility.c ++++ gtk+-3-workdir/gtk/a11y/gtkaccessibility.c +@@ -974,6 +974,10 @@ do_window_event_initialization (void) + void + _gtk_accessibility_init (void) + { ++// We don't care about a11y at this point in time and dbus isn't working, so let's just not start that. ++#ifdef __aero__ ++ return; ++#else + if (initialized) + return; + +@@ -993,4 +997,5 @@ _gtk_accessibility_init (void) + #endif + + atk_misc_instance = g_object_new (GTK_TYPE_MISC_IMPL, NULL); ++#endif + } +diff --git gtk+-3-clean/gtk/gtkmain.c gtk+-3-workdir/gtk/gtkmain.c +index ae64e18..2d43754 100644 +--- gtk+-3-clean/gtk/gtkmain.c ++++ gtk+-3-workdir/gtk/gtkmain.c +@@ -355,6 +355,11 @@ static gboolean + check_setugid (void) + { + /* this isn't at all relevant on MS Windows and doesn't compile ... --hb */ ++#ifdef __aero__ ++ /* Lyre runs everything as root for the time being, this check is thus useless. */ ++ g_warning("Lyre ignores the setugid check!\n"); ++ return TRUE; ++#endif + #ifndef G_OS_WIN32 + uid_t ruid, euid, suid; /* Real, effective and saved user ID's */ + gid_t rgid, egid, sgid; /* Real, effective and saved group ID's */ diff --git a/patches/jq/jq.patch b/patches/jq/jq.patch deleted file mode 100644 index 48435b6e0b3..00000000000 --- a/patches/jq/jq.patch +++ /dev/null @@ -1,40 +0,0 @@ -diff -crB jq-1.7-orig/config/config.sub jq-1.7/config/config.sub -*** jq-1.7-orig/config/config.sub 2023-11-04 14:43:08.915178973 +1100 ---- jq-1.7/config/config.sub 2023-11-04 14:43:43.691560304 +1100 -*************** -*** 1754,1760 **** - | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ - | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ - | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ -! | fiwix* ) - ;; - # This one is extra strict with allowed versions - sco3.2v2 | sco3.2v[4-9]* | sco5v6*) ---- 1754,1760 ---- - | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ - | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ - | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ -! | fiwix* | aero* ) - ;; - # This one is extra strict with allowed versions - sco3.2v2 | sco3.2v[4-9]* | sco5v6*) -diff -crB jq-1.7-orig/modules/oniguruma/config.sub jq-1.7/modules/oniguruma/config.sub -*** jq-1.7-orig/modules/oniguruma/config.sub 2023-11-04 14:43:08.921845585 +1100 ---- jq-1.7/modules/oniguruma/config.sub 2023-11-04 14:44:17.544620423 +1100 -*************** -*** 1722,1728 **** - | skyos* | haiku* | rdos* | toppers* | drops* | es* \ - | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ - | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ -! | nsk* | powerunix* | genode* | zvmoe* ) - ;; - # This one is extra strict with allowed versions - sco3.2v2 | sco3.2v[4-9]* | sco5v6*) ---- 1722,1728 ---- - | skyos* | haiku* | rdos* | toppers* | drops* | es* \ - | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ - | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ -! | nsk* | powerunix* | genode* | zvmoe* | aero* ) - ;; - # This one is extra strict with allowed versions - sco3.2v2 | sco3.2v[4-9]* | sco5v6*) diff --git a/patches/libdrm/libdrm.patch b/patches/libdrm/libdrm.patch deleted file mode 100644 index ff811a0bccd..00000000000 --- a/patches/libdrm/libdrm.patch +++ /dev/null @@ -1,147 +0,0 @@ -From c1dbfc87b74825c0f21b9031fc932d27908fcc71 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Sat, 14 May 2022 14:42:38 +1000 -Subject: [PATCH] drm: aero specific changes - -Signed-off-by: Andy-Python-Programmer ---- - .gitignore | 1 + - include/drm/drm.h | 4 ++-- - xf86drm.c | 20 ++++++++++---------- - xf86drm.h | 2 +- - 4 files changed, 14 insertions(+), 13 deletions(-) - -diff --git a/.gitignore b/.gitignore -index 0ec9e7f..e0c197e 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -1 +1,2 @@ - /build* -+.vscode -diff --git a/include/drm/drm.h b/include/drm/drm.h -index 398c396..3e35299 100644 ---- a/include/drm/drm.h -+++ b/include/drm/drm.h -@@ -35,10 +35,10 @@ - #ifndef _DRM_H_ - #define _DRM_H_ - --#if defined(__linux__) -+#if defined(__linux__) || defined(__aero__) - -+#include - #include --#include - typedef unsigned int drm_handle_t; - - #else /* One of the BSDs */ -diff --git a/xf86drm.c b/xf86drm.c -index 5933e4b..2b79641 100644 ---- a/xf86drm.c -+++ b/xf86drm.c -@@ -3346,7 +3346,7 @@ drm_public int drmCloseBufferHandle(int fd, uint32_t handle) - - static char *drmGetMinorNameForFD(int fd, int type) - { --#ifdef __linux__ -+#if defined(__linux__) || defined(__aero__) - DIR *sysdir; - struct dirent *ent; - struct stat sbuf; -@@ -3468,7 +3468,7 @@ drm_public char *drmGetRenderDeviceNameFromFd(int fd) - return drmGetMinorNameForFD(fd, DRM_NODE_RENDER); - } - --#ifdef __linux__ -+#if defined(__linux__) || defined(__aero__) - static char * DRM_PRINTFLIKE(2, 3) - sysfs_uevent_get(const char *path, const char *fmt, ...) - { -@@ -3515,7 +3515,7 @@ sysfs_uevent_get(const char *path, const char *fmt, ...) - /* Little white lie to avoid major rework of the existing code */ - #define DRM_BUS_VIRTIO 0x10 - --#ifdef __linux__ -+#if defined(__linux__) || defined(__aero__) - static int get_subsystem_type(const char *device_path) - { - char path[PATH_MAX + 1] = ""; -@@ -3581,7 +3581,7 @@ static int drmParseSubsystemType(int maj, int min) - #endif - } - --#ifdef __linux__ -+#if defined(__linux__) || defined(__aero__) - static void - get_pci_path(int maj, int min, char *pci_path) - { -@@ -3661,7 +3661,7 @@ static int get_sysctl_pci_bus_info(int maj, int min, drmPciBusInfoPtr info) - - static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info) - { --#ifdef __linux__ -+#if defined(__linux__) || defined(__aero__) - unsigned int domain, bus, dev, func; - char pci_path[PATH_MAX + 1], *value; - int num; -@@ -3770,7 +3770,7 @@ static int drmGetMaxNodeName(void) - 3 /* length of the node number */; - } - --#ifdef __linux__ -+#if defined(__linux__) || defined(__aero__) - static int parse_separate_sysfs_files(int maj, int min, - drmPciDeviceInfoPtr device, - bool ignore_revision) -@@ -3848,7 +3848,7 @@ static int drmParsePciDeviceInfo(int maj, int min, - drmPciDeviceInfoPtr device, - uint32_t flags) - { --#ifdef __linux__ -+#if defined(__linux__) || defined(__aero__) - if (!(flags & DRM_DEVICE_GET_PCI_REVISION)) - return parse_separate_sysfs_files(maj, min, device, true); - -@@ -4072,7 +4072,7 @@ free_device: - return ret; - } - --#ifdef __linux__ -+#if defined(__linux__) || defined(__aero__) - static int drm_usb_dev_path(int maj, int min, char *path, size_t len) - { - char *value, *tmp_path, *slash; -@@ -4160,7 +4160,7 @@ static int drmParseUsbBusInfo(int maj, int min, drmUsbBusInfoPtr info) - - static int drmParseUsbDeviceInfo(int maj, int min, drmUsbDeviceInfoPtr info) - { --#ifdef __linux__ -+#if defined(__linux__) || defined(__aero__) - char path[PATH_MAX + 1], *value; - unsigned int vendor, product; - int ret; -@@ -4760,7 +4760,7 @@ drm_public int drmGetDevices(drmDevicePtr devices[], int max_devices) - - drm_public char *drmGetDeviceNameFromFd2(int fd) - { --#ifdef __linux__ -+#if defined(__linux__) || defined(__aero__) - struct stat sbuf; - char path[PATH_MAX + 1], *value; - unsigned int maj, min; -diff --git a/xf86drm.h b/xf86drm.h -index 1631396..a2118f1 100644 ---- a/xf86drm.h -+++ b/xf86drm.h -@@ -47,7 +47,7 @@ extern "C" { - #define DRM_MAX_MINOR 16 - #endif - --#if defined(__linux__) -+#if defined(__linux__) || defined(__aero__) - - #define DRM_IOCTL_NR(n) _IOC_NR(n) - #define DRM_IOC_VOID _IOC_NONE --- -2.25.1 - diff --git a/patches/libgcrypt/jinx-working-patch.patch b/patches/libgcrypt/jinx-working-patch.patch new file mode 100644 index 00000000000..a86085ff566 --- /dev/null +++ b/patches/libgcrypt/jinx-working-patch.patch @@ -0,0 +1,23 @@ +diff --git a/random/rndunix.c b/random/rndunix.c +index fcb45b7..1e32242 100644 +--- a/random/rndunix.c ++++ b/random/rndunix.c +@@ -105,7 +105,7 @@ + #include + #include + #include +-#ifndef __QNX__ ++#if !defined __QNX__ && !defined (__aero__) + #include + #include + #endif /* __QNX__ */ +@@ -119,7 +119,9 @@ + #ifndef __QNX__ + #include + #include ++#ifndef __aero__ + #include ++#endif + #endif /* __QNX__ */ + #include + #include /* Verschiedene komische Typen */ diff --git a/patches/libiconv/0001-libiconv-aero-specific-changes.patch b/patches/libiconv/0001-libiconv-aero-specific-changes.patch deleted file mode 100644 index 6a7e24eaaf2..00000000000 --- a/patches/libiconv/0001-libiconv-aero-specific-changes.patch +++ /dev/null @@ -1,50 +0,0 @@ -From d29c791b1dfcd9459e7f9ee1101a035ee31daa75 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Wed, 29 Jun 2022 18:57:29 +1000 -Subject: [PATCH] libiconv: aero specific changes - -Signed-off-by: Andy-Python-Programmer ---- - Makefile.devel | 8 ++++---- - libcharset/Makefile.devel | 6 +++--- - 2 files changed, 7 insertions(+), 7 deletions(-) - -diff --git a/Makefile.devel b/Makefile.devel -index 2a5e101..a179aaf 100644 ---- a/Makefile.devel -+++ b/Makefile.devel -@@ -4,10 +4,10 @@ - - SHELL = /bin/sh - MAKE = make --AUTOCONF = autoconf-2.69 --AUTOHEADER = autoheader-2.69 --AUTOMAKE = automake-1.16 --ACLOCAL = aclocal-1.16 -+AUTOCONF = autoconf -+AUTOHEADER = autoheader -+AUTOMAKE = automake -+ACLOCAL = aclocal - GPERF = gperf - CC = gcc -Wall - CFLAGS = -O -diff --git a/libcharset/Makefile.devel b/libcharset/Makefile.devel -index 04f4c7a..3e0e2ca 100644 ---- a/libcharset/Makefile.devel -+++ b/libcharset/Makefile.devel -@@ -3,9 +3,9 @@ - - SHELL = /bin/sh - MAKE = make --AUTOCONF = autoconf-2.69 --AUTOHEADER = autoheader-2.69 --ACLOCAL = aclocal-1.16 -+AUTOCONF = autoconf -+AUTOHEADER = autoheader -+ACLOCAL = aclocal - CP = cp - RM = rm -f - --- -2.25.1 - diff --git a/patches/libtasn/libtasn.patch b/patches/libtasn/libtasn.patch deleted file mode 100644 index 6650d9859cd..00000000000 --- a/patches/libtasn/libtasn.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 006807c2ec4429094c7bc0b1f54a7db462916df1 Mon Sep 17 00:00:00 2001 -From: Dennis Bonke -Date: Wed, 14 Jul 2021 02:35:21 +0200 -Subject: [PATCH] Remove test directory as that can't be cross-compiled - -Signed-off-by: Dennis Bonke ---- - Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/Makefile.am b/Makefile.am -index 86cca65..76b49b1 100644 ---- a/Makefile.am -+++ b/Makefile.am -@@ -27,7 +27,7 @@ EXTRA_DIST = windows/asn1-parser/asn1-parser.vcproj \ - windows/test-tree/test-tree.vcproj windows/libtasn14win.mk - EXTRA_DIST += cfg.mk maint.mk CONTRIBUTING.md README.md - --SUBDIRS = lib src fuzz tests -+SUBDIRS = lib src fuzz - - if ENABLE_DOC - SUBDIRS += doc examples --- -2.32.0 diff --git a/patches/libtool/jinx-working-patch.patch b/patches/libtool/jinx-working-patch.patch new file mode 100644 index 00000000000..d2f5a84233a --- /dev/null +++ b/patches/libtool/jinx-working-patch.patch @@ -0,0 +1,138 @@ +diff --git libtool-clean/build-aux/ltmain.in libtool-workdir/build-aux/ltmain.in +index a5f21a1..c06d55c 100644 +--- libtool-clean/build-aux/ltmain.in ++++ libtool-workdir/build-aux/ltmain.in +@@ -6497,7 +6497,7 @@ func_mode_link () + fi + else + # We cannot seem to hardcode it, guess we'll fake it. +- add_dir=-L$libdir ++ add_dir=-L$lt_sysroot$libdir + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case $libdir in +diff --git libtool-clean/libtoolize.in libtool-workdir/libtoolize.in +index 0c40fed..763619b 100644 +--- libtool-clean/libtoolize.in ++++ libtool-workdir/libtoolize.in +@@ -1891,7 +1891,7 @@ func_require_seen_libtool () + # Do not remove config.guess, config.sub or install-sh, we don't + # install them without --install, and the project may not be using + # Automake. Similarly, do not remove Gnulib files. +- all_pkgaux_files="compile depcomp missing ltmain.sh" ++ all_pkgaux_files="" + all_pkgmacro_files="libtool.m4 ltargz.m4 ltdl.m4 ltoptions.m4 ltsugar.m4 ltversion.in ltversion.m4 lt~obsolete.m4" + all_pkgltdl_files="COPYING.LIB Makefile Makefile.in Makefile.inc Makefile.am README acinclude.m4 aclocal.m4 argz_.h argz.c config.h.in config-h.in configure configure.ac configure.in libltdl/lt__alloc.h libltdl/lt__argz.h libltdl/lt__dirent.h libltdl/lt__glibc.h libltdl/lt__private.h libltdl/lt__strl.h libltdl/lt_dlloader.h libltdl/lt_error.h libltdl/lt_system.h libltdl/slist.h loaders/dld_link.c loaders/dlopen.c loaders/dyld.c loaders/load_add_on.c loaders/loadlibrary.c loaders/preopen.c loaders/shl_load.c lt__alloc.c lt__argz.c lt__dirent.c lt__strl.c lt_dlloader.c lt_error.c ltdl.c ltdl.h ltdl.mk slist.c" + +diff --git libtool-clean/m4/libtool.m4 libtool-workdir/m4/libtool.m4 +index 79a2451..b6e8ca4 100644 +--- libtool-clean/m4/libtool.m4 ++++ libtool-workdir/m4/libtool.m4 +@@ -1696,7 +1696,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + +- gnu*) ++ gnu* | aero*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever +@@ -2925,6 +2925,18 @@ netbsd*) + hardcode_into_libs=yes + ;; + ++aero*) ++ version_type=linux # correct to gnu/linux during the next big refactor ++ need_lib_prefix=no ++ need_version=no ++ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ++ soname_spec='$libname$release$shared_ext$major' ++ dynamic_linker='mlibc ld.so' ++ shlibpath_var=LD_LIBRARY_PATH ++ shlibpath_overrides_runpath=no ++ hardcode_into_libs=yes ++ ;; ++ + newsos6) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' +@@ -3566,6 +3578,10 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + ++aero*) ++ lt_cv_deplibs_check_method=pass_all ++ ;; ++ + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' +@@ -4446,6 +4462,8 @@ m4_if([$1], [CXX], [ + ;; + netbsd*) + ;; ++ aero*) ++ ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. +@@ -4794,6 +4812,12 @@ m4_if([$1], [CXX], [ + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + ++ aero*) ++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ++ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ++ ;; ++ + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. +@@ -5273,6 +5297,11 @@ _LT_EOF + fi + ;; + ++ aero*) ++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' ++ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ++ ;; ++ + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' +@@ -5815,6 +5844,9 @@ _LT_EOF + esac + ;; + ++ aero*) ++ ;; ++ + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out +@@ -7115,6 +7147,10 @@ if test yes != "$_lt_caught_CXX_error"; then + esac + ;; + ++ aero*) ++ _LT_TAGVAR(ld_shlibs, $1)=yes ++ ;; ++ + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' +diff --git libtool-clean/m4/ltdl.m4 libtool-workdir/m4/ltdl.m4 +index 772c150..642966e 100644 +--- libtool-clean/m4/ltdl.m4 ++++ libtool-workdir/m4/ltdl.m4 +@@ -497,6 +497,9 @@ AC_CACHE_CHECK([whether deplibs are loaded by dlopen], + # at 6.2 and later dlopen does load deplibs. + lt_cv_sys_dlopen_deplibs=yes + ;; ++ aero*) ++ lt_cv_sys_dlopen_deplibs=yes ++ ;; + netbsd*) + lt_cv_sys_dlopen_deplibs=yes + ;; diff --git a/patches/libtool/libtool.patch b/patches/libtool/libtool.patch deleted file mode 100644 index ae10581cfd1..00000000000 --- a/patches/libtool/libtool.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 634f15ee7db8317cb39e1f13dbd1e4cd16f922e6 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Wed, 25 May 2022 16:43:44 +1000 -Subject: [PATCH] libtool: aero specific changes - -Signed-off-by: Andy-Python-Programmer ---- - build-aux/ltmain.in | 2 +- - m4/libtool.m4 | 15 +++++++++++++++ - 2 files changed, 16 insertions(+), 1 deletion(-) - -diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in -index d5cf07a..ce97a5f 100644 ---- a/build-aux/ltmain.in -+++ b/build-aux/ltmain.in -@@ -6449,7 +6449,7 @@ func_mode_link () - fi - else - # We cannot seem to hardcode it, guess we'll fake it. -- add_dir=-L$libdir -+ add_dir=-L$lt_sysroot$libdir - # Try looking first in the location we're being installed to. - if test -n "$inst_prefix_dir"; then - case $libdir in -diff --git a/m4/libtool.m4 b/m4/libtool.m4 -index a3bc337..9136171 100644 ---- a/m4/libtool.m4 -+++ b/m4/libtool.m4 -@@ -2905,6 +2905,17 @@ netbsd*) - hardcode_into_libs=yes - ;; - -+aero*) -+ version_type=linux # correct to gnu/linux during the next big refactor -+ need_lib_prefix=no -+ need_version=no -+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' -+ soname_spec='$libname$release$shared_ext$major' -+ shlibpath_var=LD_LIBRARY_PATH -+ shlibpath_overrides_runpath=no -+ hardcode_into_libs=yes -+ ;; -+ - newsos6) - version_type=linux # correct to gnu/linux during the next big refactor - library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' -@@ -3554,6 +3565,10 @@ netbsd*) - fi - ;; - -+aero*) -+ lt_cv_deplibs_check_method=pass_all -+ ;; -+ - newos6*) - lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' - lt_cv_file_magic_cmd=/usr/bin/file --- -2.25.1 - diff --git a/patches/libxfont2/0001-libxfont2-aero-specific-changes.patch b/patches/libxfont2/0001-libxfont2-aero-specific-changes.patch deleted file mode 100644 index e4453bba46f..00000000000 --- a/patches/libxfont2/0001-libxfont2-aero-specific-changes.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 0da59aec1e86152858f47e12da033883e4b16852 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Thu, 30 Jun 2022 10:46:56 +1000 -Subject: [PATCH] libxfont2: aero specific changes - -Signed-off-by: Andy-Python-Programmer ---- - .gitignore | 2 ++ - src/fc/fslibos.h | 2 +- - 2 files changed, 3 insertions(+), 1 deletion(-) - -diff --git a/.gitignore b/.gitignore -index 2efa153..4370b7e 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -79,3 +79,5 @@ core - *.sig - *.announce - TAGS -+# editor configs: -+.vscode -diff --git a/src/fc/fslibos.h b/src/fc/fslibos.h -index 1ef362d..a9935d1 100644 ---- a/src/fc/fslibos.h -+++ b/src/fc/fslibos.h -@@ -60,7 +60,7 @@ from The Open Group. - # endif - # endif - # ifndef OPEN_MAX --# if defined(SVR4) -+# if defined(SVR4) || defined(__aero__) - # define OPEN_MAX 256 - # else - # include --- -2.25.1 - diff --git a/patches/llvm/0001-feat-targets-add-aero.patch b/patches/llvm/jinx-working-patch.patch similarity index 71% rename from patches/llvm/0001-feat-targets-add-aero.patch rename to patches/llvm/jinx-working-patch.patch index d765ad6c9e7..24d4135b66b 100644 --- a/patches/llvm/0001-feat-targets-add-aero.patch +++ b/patches/llvm/jinx-working-patch.patch @@ -1,69 +1,9 @@ -From bc36fc2f014463a6baa37512c708bca46dbd55c5 Mon Sep 17 00:00:00 2001 -From: Anhad Singh -Date: Thu, 19 Oct 2023 21:54:42 +1100 -Subject: [PATCH] feat(targets): add aero - -Signed-off-by: Anhad Singh ---- - clang/lib/Basic/Targets.cpp | 10 + - clang/lib/Basic/Targets/OSTargets.h | 31 ++ - clang/lib/Driver/CMakeLists.txt | 1 + - clang/lib/Driver/Driver.cpp | 4 + - clang/lib/Driver/ToolChains/Aero.cpp | 432 ++++++++++++++++++++++ - clang/lib/Driver/ToolChains/Aero.h | 49 +++ - clang/lib/Driver/ToolChains/Gnu.cpp | 13 +- - llvm/cmake/modules/CrossCompile.cmake | 4 +- - llvm/include/llvm/Support/SwapByteOrder.h | 2 +- - llvm/include/llvm/TargetParser/Triple.h | 5 +- - llvm/lib/Support/Unix/Path.inc | 6 +- - llvm/lib/Support/Unix/Program.inc | 1 + - llvm/lib/TargetParser/Triple.cpp | 6 + - llvm/tools/llvm-shlib/CMakeLists.txt | 1 + - 14 files changed, 555 insertions(+), 10 deletions(-) - create mode 100644 clang/lib/Driver/ToolChains/Aero.cpp - create mode 100644 clang/lib/Driver/ToolChains/Aero.h - -diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp -index 636b59fd1..9e1e08ec5 100644 ---- a/clang/lib/Basic/Targets.cpp -+++ b/clang/lib/Basic/Targets.cpp -@@ -151,6 +151,10 @@ std::unique_ptr AllocateTarget(const llvm::Triple &Triple, - case llvm::Triple::Fuchsia: - return std::make_unique>(Triple, - Opts); -+ case llvm::Triple::Aero: -+ return std::make_unique>(Triple, -+ Opts); -+ - case llvm::Triple::Linux: - switch (Triple.getEnvironment()) { - default: -@@ -455,6 +459,9 @@ std::unique_ptr AllocateTarget(const llvm::Triple &Triple, - case llvm::Triple::Fuchsia: - return std::make_unique>(Triple, - Opts); -+ case llvm::Triple::Aero: -+ return std::make_unique>(Triple, -+ Opts); - case llvm::Triple::Linux: - switch (Triple.getEnvironment()) { - default: -@@ -636,6 +643,9 @@ std::unique_ptr AllocateTarget(const llvm::Triple &Triple, - case llvm::Triple::Fuchsia: - return std::make_unique>(Triple, - Opts); -+ case llvm::Triple::Aero: -+ return std::make_unique>(Triple, -+ Opts); - case llvm::Triple::KFreeBSD: - return std::make_unique>(Triple, - Opts); -diff --git a/clang/lib/Basic/Targets/OSTargets.h b/clang/lib/Basic/Targets/OSTargets.h -index 8f4331b02..bacb1e071 100644 ---- a/clang/lib/Basic/Targets/OSTargets.h -+++ b/clang/lib/Basic/Targets/OSTargets.h -@@ -278,6 +278,37 @@ public: - using OSTargetInfo::OSTargetInfo; +diff --git llvm-clean/clang/lib/Basic/Targets/OSTargets.h llvm-workdir/clang/lib/Basic/Targets/OSTargets.h +index cf8cc8e..19984dc 100644 +--- llvm-clean/clang/lib/Basic/Targets/OSTargets.h ++++ llvm-workdir/clang/lib/Basic/Targets/OSTargets.h +@@ -922,6 +922,34 @@ public: + } }; +// Aero Target @@ -78,8 +18,6 @@ index 8f4331b02..bacb1e071 100644 + Builder.defineMacro("_REENTRANT"); + if (Opts.CPlusPlus) + Builder.defineMacro("_GNU_SOURCE"); -+ // if (this->HasFloat128) -+ // Builder.defineMacro("__FLOAT128__"); + } + +public: @@ -96,34 +34,46 @@ index 8f4331b02..bacb1e071 100644 + } +}; + -+ - // Haiku Target + // WebAssembly target template - class LLVM_LIBRARY_VISIBILITY HaikuTargetInfo : public OSTargetInfo { -diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt -index a6bd2d41e..132da8bbe 100644 ---- a/clang/lib/Driver/CMakeLists.txt -+++ b/clang/lib/Driver/CMakeLists.txt -@@ -59,6 +59,7 @@ add_clang_library(clangDriver - ToolChains/Flang.cpp - ToolChains/FreeBSD.cpp - ToolChains/Fuchsia.cpp + class LLVM_LIBRARY_VISIBILITY WebAssemblyOSTargetInfo +diff --git llvm-clean/clang/lib/Basic/Targets.cpp llvm-workdir/clang/lib/Basic/Targets.cpp +index 636b59f..98ef355 100644 +--- llvm-clean/clang/lib/Basic/Targets.cpp ++++ llvm-workdir/clang/lib/Basic/Targets.cpp +@@ -590,6 +590,8 @@ std::unique_ptr AllocateTarget(const llvm::Triple &Triple, + } + case llvm::Triple::Haiku: + return std::make_unique(Triple, Opts); ++ case llvm::Triple::Aero: ++ return std::make_unique>(Triple, Opts); + case llvm::Triple::RTEMS: + return std::make_unique(Triple, Opts); + case llvm::Triple::NaCl: +diff --git llvm-clean/clang/lib/Driver/CMakeLists.txt llvm-workdir/clang/lib/Driver/CMakeLists.txt +index a6bd2d4..81893cf 100644 +--- llvm-clean/clang/lib/Driver/CMakeLists.txt ++++ llvm-workdir/clang/lib/Driver/CMakeLists.txt +@@ -76,6 +76,7 @@ add_clang_library(clangDriver + ToolChains/Myriad.cpp + ToolChains/NaCl.cpp + ToolChains/NetBSD.cpp + ToolChains/Aero.cpp - ToolChains/Gnu.cpp - ToolChains/Haiku.cpp - ToolChains/HIPUtility.cpp -diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp -index bdbdad936..bc194b1f5 100644 ---- a/clang/lib/Driver/Driver.cpp -+++ b/clang/lib/Driver/Driver.cpp -@@ -24,6 +24,7 @@ + ToolChains/OHOS.cpp + ToolChains/OpenBSD.cpp + ToolChains/PS4CPU.cpp +diff --git llvm-clean/clang/lib/Driver/Driver.cpp llvm-workdir/clang/lib/Driver/Driver.cpp +index bdbdad9..1dd717e 100644 +--- llvm-clean/clang/lib/Driver/Driver.cpp ++++ llvm-workdir/clang/lib/Driver/Driver.cpp +@@ -20,6 +20,7 @@ + #include "ToolChains/Contiki.h" + #include "ToolChains/CrossWindows.h" + #include "ToolChains/Cuda.h" ++#include "ToolChains/Aero.h" + #include "ToolChains/Darwin.h" #include "ToolChains/DragonFly.h" #include "ToolChains/FreeBSD.h" - #include "ToolChains/Fuchsia.h" -+#include "ToolChains/Aero.h" - #include "ToolChains/Gnu.h" - #include "ToolChains/HIPAMD.h" - #include "ToolChains/HIPSPV.h" @@ -6225,6 +6226,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, case llvm::Triple::Fuchsia: TC = std::make_unique(*this, Target, Args); @@ -134,11 +84,11 @@ index bdbdad936..bc194b1f5 100644 case llvm::Triple::Solaris: TC = std::make_unique(*this, Target, Args); break; -diff --git a/clang/lib/Driver/ToolChains/Aero.cpp b/clang/lib/Driver/ToolChains/Aero.cpp +diff --git llvm-workdir/clang/lib/Driver/ToolChains/Aero.cpp llvm-workdir/clang/lib/Driver/ToolChains/Aero.cpp new file mode 100644 -index 000000000..580d85cde +index 0000000..580d85c --- /dev/null -+++ b/clang/lib/Driver/ToolChains/Aero.cpp ++++ llvm-workdir/clang/lib/Driver/ToolChains/Aero.cpp @@ -0,0 +1,432 @@ +//===--- Aero.h - Aero ToolChain Implementations --------*- C++ -*-===// +// @@ -572,11 +522,11 @@ index 000000000..580d85cde + Res |= SanitizerKind::MemTag; + return Res; +} -diff --git a/clang/lib/Driver/ToolChains/Aero.h b/clang/lib/Driver/ToolChains/Aero.h +diff --git llvm-workdir/clang/lib/Driver/ToolChains/Aero.h llvm-workdir/clang/lib/Driver/ToolChains/Aero.h new file mode 100644 -index 000000000..a7b0b4da2 +index 0000000..a7b0b4d --- /dev/null -+++ b/clang/lib/Driver/ToolChains/Aero.h ++++ llvm-workdir/clang/lib/Driver/ToolChains/Aero.h @@ -0,0 +1,49 @@ +//===--- Aero.h - Aero ToolChain Implementations --------*- C++ -*-===// +// @@ -627,55 +577,23 @@ index 000000000..a7b0b4da2 +} // end namespace clang + +#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AERO_H -diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp -index 40038dce4..f9e92ba87 100644 ---- a/clang/lib/Driver/ToolChains/Gnu.cpp -+++ b/clang/lib/Driver/ToolChains/Gnu.cpp -@@ -227,6 +227,8 @@ static const char *getLDMOption(const llvm::Triple &T, const ArgList &Args) { - return "elf_iamcu"; - return "elf_i386"; - case llvm::Triple::aarch64: -+ if (T.getOS() == llvm::Triple::Aero) -+ return "aarch64aero"; - return "aarch64linux"; - case llvm::Triple::aarch64_be: - return "aarch64linuxb"; -@@ -2298,7 +2300,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( - static const char *const AArch64LibDirs[] = {"/lib64", "/lib"}; - static const char *const AArch64Triples[] = { - "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux", -- "aarch64-suse-linux"}; -+ "aarch64-suse-linux", "aarch64-aero", "aarch64-aero-system", -+ "aarch64-aero-kernel"}; - static const char *const AArch64beLibDirs[] = {"/lib"}; - static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu", - "aarch64_be-linux-gnu"}; -@@ -2328,7 +2331,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( +diff --git llvm-clean/clang/lib/Driver/ToolChains/Gnu.cpp llvm-workdir/clang/lib/Driver/ToolChains/Gnu.cpp +index 40038dc..86a5c53 100644 +--- llvm-clean/clang/lib/Driver/ToolChains/Gnu.cpp ++++ llvm-workdir/clang/lib/Driver/ToolChains/Gnu.cpp +@@ -2328,7 +2328,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( "x86_64-redhat-linux", "x86_64-suse-linux", "x86_64-manbo-linux-gnu", "x86_64-linux-gnu", "x86_64-slackware-linux", "x86_64-unknown-linux", - "x86_64-amazon-linux"}; -+ "x86_64-amazon-linux", "x86_64-aero", -+ "x86_64-aero-system", "x86_64-aero-kernel"}; ++ "x86_64-amazon-linux", "x86_64-aero"}; static const char *const X32Triples[] = {"x86_64-linux-gnux32", "x86_64-pc-linux-gnux32"}; static const char *const X32LibDirs[] = {"/libx32", "/lib"}; -@@ -2404,7 +2408,10 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( - static const char *const RISCV64LibDirs[] = {"/lib64", "/lib"}; - static const char *const RISCV64Triples[] = {"riscv64-unknown-linux-gnu", - "riscv64-linux-gnu", -- "riscv64-unknown-elf"}; -+ "riscv64-unknown-elf", -+ "riscv64-aero", -+ "riscv64-aero-kernel", -+ "riscv64-aero-system"}; - - static const char *const SPARCv8LibDirs[] = {"/lib32", "/lib"}; - static const char *const SPARCv8Triples[] = {"sparc-linux-gnu", -diff --git a/llvm/cmake/modules/CrossCompile.cmake b/llvm/cmake/modules/CrossCompile.cmake -index 6af47b51d..78983fa16 100644 ---- a/llvm/cmake/modules/CrossCompile.cmake -+++ b/llvm/cmake/modules/CrossCompile.cmake +diff --git llvm-clean/llvm/cmake/modules/CrossCompile.cmake llvm-workdir/llvm/cmake/modules/CrossCompile.cmake +index 6af47b5..78983fa 100644 +--- llvm-clean/llvm/cmake/modules/CrossCompile.cmake ++++ llvm-workdir/llvm/cmake/modules/CrossCompile.cmake @@ -17,8 +17,8 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype) -DCMAKE_TOOLCHAIN_FILE=\"${LLVM_MAIN_SRC_DIR}/cmake/platforms/${toolchain}.cmake\") elseif (NOT CMAKE_CROSSCOMPILING) @@ -687,10 +605,10 @@ index 6af47b51d..78983fa16 100644 ) endif() set(CROSS_TOOLCHAIN_FLAGS_${target_name} ${CROSS_TOOLCHAIN_FLAGS_INIT} -diff --git a/llvm/include/llvm/Support/SwapByteOrder.h b/llvm/include/llvm/Support/SwapByteOrder.h -index 1bbc2e2f9..4b41da767 100644 ---- a/llvm/include/llvm/Support/SwapByteOrder.h -+++ b/llvm/include/llvm/Support/SwapByteOrder.h +diff --git llvm-clean/llvm/include/llvm/Support/SwapByteOrder.h llvm-workdir/llvm/include/llvm/Support/SwapByteOrder.h +index 1bbc2e2..4b41da7 100644 +--- llvm-clean/llvm/include/llvm/Support/SwapByteOrder.h ++++ llvm-workdir/llvm/include/llvm/Support/SwapByteOrder.h @@ -20,7 +20,7 @@ #include @@ -700,43 +618,33 @@ index 1bbc2e2f9..4b41da767 100644 #include #elif defined(_AIX) #include -diff --git a/llvm/include/llvm/TargetParser/Triple.h b/llvm/include/llvm/TargetParser/Triple.h -index 79ccd644a..82520d0e0 100644 ---- a/llvm/include/llvm/TargetParser/Triple.h -+++ b/llvm/include/llvm/TargetParser/Triple.h -@@ -194,6 +194,7 @@ public: - IOS, - KFreeBSD, - Linux, -+ Aero, +diff --git llvm-clean/llvm/include/llvm/TargetParser/Triple.h llvm-workdir/llvm/include/llvm/TargetParser/Triple.h +index 79ccd64..ae3bfb0 100644 +--- llvm-clean/llvm/include/llvm/TargetParser/Triple.h ++++ llvm-workdir/llvm/include/llvm/TargetParser/Triple.h +@@ -197,6 +197,7 @@ public: Lv2, // PS3 MacOSX, NetBSD, -@@ -276,7 +277,9 @@ public: - Mesh, - Amplification, - OpenHOS, -- LastEnvironmentType = OpenHOS -+ Kernel, -+ System, -+ LastEnvironmentType = System - }; - enum ObjectFormatType { - UnknownObjectFormat, -diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc -index e2aece49c..cc19a25a4 100644 ---- a/llvm/lib/Support/Unix/Path.inc -+++ b/llvm/lib/Support/Unix/Path.inc -@@ -74,7 +74,7 @@ extern char **environ; ++ Aero, + OpenBSD, + Solaris, + UEFI, +diff --git llvm-clean/llvm/lib/Support/Unix/Path.inc llvm-workdir/llvm/lib/Support/Unix/Path.inc +index e2aece4..72a6259 100644 +--- llvm-clean/llvm/lib/Support/Unix/Path.inc ++++ llvm-workdir/llvm/lib/Support/Unix/Path.inc +@@ -74,7 +74,8 @@ extern char **environ; #include #if !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && \ - !defined(__linux__) && !defined(__FreeBSD_kernel__) && !defined(_AIX) -+ !defined(__linux__) && !defined(__FreeBSD_kernel__) && !defined(_AIX) && !defined(__aero__) ++ !defined(__linux__) && !defined(__FreeBSD_kernel__) && !defined(_AIX) && \ ++ !defined(__aero__) #include #define STATVFS statvfs #define FSTATVFS fstatvfs -@@ -83,7 +83,7 @@ extern char **environ; +@@ -83,7 +84,7 @@ extern char **environ; #if defined(__OpenBSD__) || defined(__FreeBSD__) #include #include @@ -745,7 +653,7 @@ index e2aece49c..cc19a25a4 100644 #if defined(HAVE_LINUX_MAGIC_H) #include #else -@@ -472,7 +472,7 @@ std::error_code remove(const Twine &path, bool IgnoreNonExisting) { +@@ -472,7 +473,7 @@ std::error_code remove(const Twine &path, bool IgnoreNonExisting) { } static bool is_local_impl(struct STATVFS &Vfs) { @@ -754,10 +662,10 @@ index e2aece49c..cc19a25a4 100644 #ifndef NFS_SUPER_MAGIC #define NFS_SUPER_MAGIC 0x6969 #endif -diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc -index 897e22711..02f74d7eb 100644 ---- a/llvm/lib/Support/Unix/Program.inc -+++ b/llvm/lib/Support/Unix/Program.inc +diff --git llvm-clean/llvm/lib/Support/Unix/Program.inc llvm-workdir/llvm/lib/Support/Unix/Program.inc +index 897e227..02f74d7 100644 +--- llvm-clean/llvm/lib/Support/Unix/Program.inc ++++ llvm-workdir/llvm/lib/Support/Unix/Program.inc @@ -41,6 +41,7 @@ #if HAVE_UNISTD_H #include @@ -766,28 +674,19 @@ index 897e22711..02f74d7eb 100644 #ifdef HAVE_POSIX_SPAWN #include -diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp -index a3d6a06af..3825a2a06 100644 ---- a/llvm/lib/TargetParser/Triple.cpp -+++ b/llvm/lib/TargetParser/Triple.cpp -@@ -205,6 +205,7 @@ StringRef Triple::getOSTypeName(OSType Kind) { - switch (Kind) { - case UnknownOS: return "unknown"; - +diff --git llvm-clean/llvm/lib/TargetParser/Triple.cpp llvm-workdir/llvm/lib/TargetParser/Triple.cpp +index a3d6a06..f431d74 100644 +--- llvm-clean/llvm/lib/TargetParser/Triple.cpp ++++ llvm-workdir/llvm/lib/TargetParser/Triple.cpp +@@ -219,6 +219,7 @@ StringRef Triple::getOSTypeName(OSType Kind) { + case Emscripten: return "emscripten"; + case FreeBSD: return "freebsd"; + case Fuchsia: return "fuchsia"; + case Aero: return "aero"; - case AIX: return "aix"; - case AMDHSA: return "amdhsa"; - case AMDPAL: return "amdpal"; -@@ -270,6 +271,8 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) { - case GNUX32: return "gnux32"; - case GNUILP32: return "gnu_ilp32"; - case Itanium: return "itanium"; -+ case Kernel: return "kernel"; -+ case System: return "system"; - case MSVC: return "msvc"; - case MacABI: return "macabi"; - case Musl: return "musl"; -@@ -575,6 +578,7 @@ static Triple::VendorType parseVendor(StringRef VendorName) { + case Haiku: return "haiku"; + case HermitCore: return "hermit"; + case Hurd: return "hurd"; +@@ -575,6 +576,7 @@ static Triple::VendorType parseVendor(StringRef VendorName) { static Triple::OSType parseOS(StringRef OSName) { return StringSwitch(OSName) @@ -795,27 +694,15 @@ index a3d6a06af..3825a2a06 100644 .StartsWith("ananas", Triple::Ananas) .StartsWith("cloudabi", Triple::CloudABI) .StartsWith("darwin", Triple::Darwin) -@@ -641,6 +645,8 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) { - .StartsWith("musl", Triple::Musl) - .StartsWith("msvc", Triple::MSVC) - .StartsWith("itanium", Triple::Itanium) -+ .StartsWith("kernel", Triple::Kernel) -+ .StartsWith("system", Triple::System) - .StartsWith("cygnus", Triple::Cygnus) - .StartsWith("coreclr", Triple::CoreCLR) - .StartsWith("simulator", Triple::Simulator) -diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt -index 4f6a2cbfb..559a35ab9 100644 ---- a/llvm/tools/llvm-shlib/CMakeLists.txt -+++ b/llvm/tools/llvm-shlib/CMakeLists.txt -@@ -38,6 +38,7 @@ if(LLVM_BUILD_LLVM_DYLIB) - OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "GNU") +diff --git llvm-clean/llvm/tools/llvm-shlib/CMakeLists.txt llvm-workdir/llvm/tools/llvm-shlib/CMakeLists.txt +index 8ace190..b79c68d 100644 +--- llvm-clean/llvm/tools/llvm-shlib/CMakeLists.txt ++++ llvm-workdir/llvm/tools/llvm-shlib/CMakeLists.txt +@@ -41,6 +41,7 @@ if(LLVM_BUILD_LLVM_DYLIB) OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD") - OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia") -+ OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "aero") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "DragonFly") + OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia") ++ OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "Aero") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "Android") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")) # FIXME: It should be "GNU ld for elf" --- -2.42.0 - + configure_file( diff --git a/patches/mesa/jinx-working-patch.patch b/patches/mesa/jinx-working-patch.patch new file mode 100644 index 00000000000..3fdc866bcfa --- /dev/null +++ b/patches/mesa/jinx-working-patch.patch @@ -0,0 +1,157 @@ +diff --git mesa-clean/include/drm-uapi/drm.h mesa-workdir/include/drm-uapi/drm.h +index 0254024..c2ffd35 100644 +--- mesa-clean/include/drm-uapi/drm.h ++++ mesa-workdir/include/drm-uapi/drm.h +@@ -44,7 +44,7 @@ typedef unsigned int drm_handle_t; + #else /* One of the BSDs */ + + #include +-#include ++// #include + #include + typedef int8_t __s8; + typedef uint8_t __u8; +diff --git mesa-clean/src/compiler/spirv/spirv_to_nir.c mesa-workdir/src/compiler/spirv/spirv_to_nir.c +index 5f36118..a501802 100644 +--- mesa-clean/src/compiler/spirv/spirv_to_nir.c ++++ mesa-workdir/src/compiler/spirv/spirv_to_nir.c +@@ -39,6 +39,7 @@ + #include "util/u_debug.h" + + #include ++#include + + #ifndef NDEBUG + uint32_t mesa_spirv_debug = 0; +diff --git mesa-clean/src/egl/main/egllog.c mesa-workdir/src/egl/main/egllog.c +index 678bb75..016a70d 100644 +--- mesa-clean/src/egl/main/egllog.c ++++ mesa-workdir/src/egl/main/egllog.c +@@ -37,6 +37,7 @@ + #include + #include + #include ++#include + #include "c11/threads.h" + #include "util/macros.h" + #include "util/simple_mtx.h" +diff --git mesa-clean/src/gallium/drivers/llvmpipe/lp_texture.c mesa-workdir/src/gallium/drivers/llvmpipe/lp_texture.c +index 5c5a6cd..ae6c23d 100644 +--- mesa-clean/src/gallium/drivers/llvmpipe/lp_texture.c ++++ mesa-workdir/src/gallium/drivers/llvmpipe/lp_texture.c +@@ -1152,7 +1152,7 @@ llvmpipe_resource_get_param(struct pipe_screen *screen, + default: + break; + } +- assert(0); ++ // assert(0); + *value = 0; + return false; + } +diff --git mesa-clean/src/util/detect_os.h mesa-workdir/src/util/detect_os.h +index 6506948..93ce551 100644 +--- mesa-clean/src/util/detect_os.h ++++ mesa-workdir/src/util/detect_os.h +@@ -28,6 +28,11 @@ + #define DETECT_OS_ANDROID 1 + #endif + ++#if defined(__aero__) ++#define DETECT_OS_AERO 1 ++#define DETECT_OS_UNIX 1 ++#endif ++ + #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + #define DETECT_OS_FREEBSD 1 + #define DETECT_OS_BSD 1 +@@ -128,4 +133,8 @@ + #define DETECT_OS_WINDOWS 0 + #endif + ++#ifndef DETECT_OS_AERO ++#define DETECT_OS_AERO 0 ++#endif ++ + #endif /* DETECT_OS_H */ +diff --git mesa-clean/src/util/futex.h mesa-workdir/src/util/futex.h +index c397507..995c1e2 100644 +--- mesa-clean/src/util/futex.h ++++ mesa-workdir/src/util/futex.h +@@ -24,7 +24,7 @@ + #ifndef UTIL_FUTEX_H + #define UTIL_FUTEX_H + +-#if defined(HAVE_LINUX_FUTEX_H) ++#if defined(HAVE_LINUX_FUTEX_H) && defined(__linux__) + #define UTIL_FUTEX_SUPPORTED 1 + #elif defined(__FreeBSD__) + #define UTIL_FUTEX_SUPPORTED 1 +diff --git mesa-clean/src/util/os_misc.c mesa-workdir/src/util/os_misc.c +index c378a9e..64f6cff 100644 +--- mesa-clean/src/util/os_misc.c ++++ mesa-workdir/src/util/os_misc.c +@@ -57,7 +57,7 @@ + # include + # include + # include +-#elif DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD ++#elif DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD || DETECT_OS_AERO + # include + #elif DETECT_OS_OPENBSD || DETECT_OS_FREEBSD + # include +@@ -248,7 +248,7 @@ exit_mutex: + bool + os_get_total_physical_memory(uint64_t *size) + { +-#if DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD ++#if DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD || DETECT_OS_AERO + const long phys_pages = sysconf(_SC_PHYS_PAGES); + const long page_size = sysconf(_SC_PAGE_SIZE); + +diff --git mesa-clean/src/util/os_time.c mesa-workdir/src/util/os_time.c +index 7fb3134..38b6ade 100644 +--- mesa-clean/src/util/os_time.c ++++ mesa-workdir/src/util/os_time.c +@@ -65,7 +65,7 @@ os_time_get_nano(void) + void + os_time_sleep(int64_t usecs) + { +-#if DETECT_OS_LINUX ++#if DETECT_OS_LINUX || DETECT_OS_AERO + struct timespec time; + time.tv_sec = usecs / 1000000; + time.tv_nsec = (usecs % 1000000) * 1000; +diff --git mesa-clean/src/util/u_debug.c mesa-workdir/src/util/u_debug.c +index 61f628e..e390606 100644 +--- mesa-clean/src/util/u_debug.c ++++ mesa-workdir/src/util/u_debug.c +@@ -32,6 +32,7 @@ + #include "util/u_math.h" + #include + ++#include + #include + #include /* CHAR_BIT */ + #include /* isalnum */ +diff --git mesa-clean/src/util/u_thread.c mesa-workdir/src/util/u_thread.c +index 55b6b68..277ffbd 100644 +--- mesa-clean/src/util/u_thread.c ++++ mesa-workdir/src/util/u_thread.c +@@ -75,7 +75,7 @@ int u_thread_create(thrd_t *thrd, int (*routine)(void *), void *param) + void u_thread_setname( const char *name ) + { + #if defined(HAVE_PTHREAD) +-#if DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || defined(__GLIBC__) ++#if DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || defined(__GLIBC__) || DETECT_OS_AERO + int ret = pthread_setname_np(pthread_self(), name); + if (ret == ERANGE) { + char buf[16]; +@@ -154,7 +154,7 @@ util_set_thread_affinity(thrd_t thread, + int64_t + util_thread_get_time_nano(thrd_t thread) + { +-#if defined(HAVE_PTHREAD) && !defined(__APPLE__) && !defined(__HAIKU__) ++#if defined(HAVE_PTHREAD) && !defined(__APPLE__) && !defined(__HAIKU__) && !defined(__aero__) + struct timespec ts; + clockid_t cid; + diff --git a/patches/mesa/mesa.patch b/patches/mesa/mesa.patch deleted file mode 100644 index 05dab1ee953..00000000000 --- a/patches/mesa/mesa.patch +++ /dev/null @@ -1,219 +0,0 @@ -From 17fb4ad377b2cd0d43a62af25b8c8375909da019 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Sat, 18 Feb 2023 14:31:17 +1100 -Subject: [PATCH] - ---- - include/drm-uapi/drm.h | 5 +++-- - meson.build | 2 +- - src/compiler/spirv/spirv_to_nir.c | 1 + - src/egl/main/egllog.c | 1 + - src/gallium/drivers/llvmpipe/lp_texture.c | 1 - - src/util/debug.c | 1 + - src/util/detect_os.h | 8 ++++++++ - src/util/futex.h | 2 +- - src/util/os_misc.c | 4 ++-- - src/util/os_time.c | 4 ++-- - src/util/u_printf.h | 2 ++ - src/util/u_thread.h | 4 ++-- - 12 files changed, 24 insertions(+), 11 deletions(-) - -diff --git a/include/drm-uapi/drm.h b/include/drm-uapi/drm.h -index 5e54c3a..be0e26d 100644 ---- a/include/drm-uapi/drm.h -+++ b/include/drm-uapi/drm.h -@@ -35,10 +35,11 @@ - #ifndef _DRM_H_ - #define _DRM_H_ - --#if defined(__linux__) -+#if defined(__linux__) || defined(__aero__) - -+#include - #include --#include -+//#include - typedef unsigned int drm_handle_t; - - #else /* One of the BSDs */ -diff --git a/meson.build b/meson.build -index 0aea312..6624be3 100644 ---- a/meson.build -+++ b/meson.build -@@ -164,7 +164,7 @@ with_any_opengl = with_opengl or with_gles1 or with_gles2 - # Only build shared_glapi if at least one OpenGL API is enabled - with_shared_glapi = with_shared_glapi and with_any_opengl - --system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'gnu/kfreebsd', 'dragonfly', 'linux', 'sunos'].contains(host_machine.system()) -+system_has_kms_drm = ['openbsd', 'netbsd', 'freebsd', 'gnu/kfreebsd', 'dragonfly', 'linux', 'aero', 'sunos'].contains(host_machine.system()) - - dri_drivers = get_option('dri-drivers') - if dri_drivers.contains('auto') -diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c -index 71cdc83..3d26705 100644 ---- a/src/compiler/spirv/spirv_to_nir.c -+++ b/src/compiler/spirv/spirv_to_nir.c -@@ -37,6 +37,7 @@ - #include "util/u_string.h" - - #include -+#include - - #ifndef NDEBUG - static enum nir_spirv_debug_level -diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c -index 984dd5b..6a91952 100644 ---- a/src/egl/main/egllog.c -+++ b/src/egl/main/egllog.c -@@ -39,6 +39,7 @@ - #include - #include - #include -+#include - #include "c11/threads.h" - #include "util/macros.h" - #include "util/u_string.h" -diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c -index 5bfc8db..d2b31e1 100644 ---- a/src/gallium/drivers/llvmpipe/lp_texture.c -+++ b/src/gallium/drivers/llvmpipe/lp_texture.c -@@ -1102,7 +1102,6 @@ llvmpipe_resource_get_param(struct pipe_screen *screen, - default: - break; - } -- assert(0); - *value = 0; - return false; - } -diff --git a/src/util/debug.c b/src/util/debug.c -index 89ae613..fbf45f4 100644 ---- a/src/util/debug.c -+++ b/src/util/debug.c -@@ -23,6 +23,7 @@ - - #include - #include -+#include - #include "debug.h" - #include "u_string.h" - -diff --git a/src/util/detect_os.h b/src/util/detect_os.h -index 6506948..f5d49de 100644 ---- a/src/util/detect_os.h -+++ b/src/util/detect_os.h -@@ -81,6 +81,11 @@ - #define DETECT_OS_UNIX 1 - #endif - -+#if defined(__aero__) -+#define DETECT_OS_aero 1 -+#define DETECT_OS_UNIX 1 -+#endif -+ - - /* - * Make sure DETECT_OS_* are always defined, so that they can be used with #if -@@ -127,5 +132,8 @@ - #ifndef DETECT_OS_WINDOWS - #define DETECT_OS_WINDOWS 0 - #endif -+#ifndef DETECT_OS_aero -+#define DETECT_OS_aero 0 -+#endif - - #endif /* DETECT_OS_H */ -diff --git a/src/util/futex.h b/src/util/futex.h -index 43097f4..98af1db 100644 ---- a/src/util/futex.h -+++ b/src/util/futex.h -@@ -24,7 +24,7 @@ - #ifndef UTIL_FUTEX_H - #define UTIL_FUTEX_H - --#if defined(HAVE_LINUX_FUTEX_H) -+#if defined(HAVE_LINUX_FUTEX_H) && defined(__linux__) - #define UTIL_FUTEX_SUPPORTED 1 - - #include -diff --git a/src/util/os_misc.c b/src/util/os_misc.c -index 31f1c55..cd3e2c7 100644 ---- a/src/util/os_misc.c -+++ b/src/util/os_misc.c -@@ -57,7 +57,7 @@ - # include - # include - # include --#elif DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD -+#elif DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD || DETECT_OS_aero - # include - #elif DETECT_OS_OPENBSD || DETECT_OS_FREEBSD - # include -@@ -223,7 +223,7 @@ os_get_option(const char *name) - bool - os_get_total_physical_memory(uint64_t *size) - { --#if DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD -+#if DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_HURD || DETECT_OS_aero - const long phys_pages = sysconf(_SC_PHYS_PAGES); - const long page_size = sysconf(_SC_PAGE_SIZE); - -diff --git a/src/util/os_time.c b/src/util/os_time.c -index d2edd88..47de02d 100644 ---- a/src/util/os_time.c -+++ b/src/util/os_time.c -@@ -53,7 +53,7 @@ - int64_t - os_time_get_nano(void) - { --#if DETECT_OS_LINUX || DETECT_OS_BSD -+#if DETECT_OS_LINUX || DETECT_OS_BSD || DETECT_OS_aero - - struct timespec tv; - clock_gettime(CLOCK_MONOTONIC, &tv); -@@ -92,7 +92,7 @@ os_time_get_nano(void) - void - os_time_sleep(int64_t usecs) - { --#if DETECT_OS_LINUX -+#if DETECT_OS_LINUX || DETECT_OS_aero - struct timespec time; - time.tv_sec = usecs / 1000000; - time.tv_nsec = (usecs % 1000000) * 1000; -diff --git a/src/util/u_printf.h b/src/util/u_printf.h -index 44dcce5..e9e23ba 100644 ---- a/src/util/u_printf.h -+++ b/src/util/u_printf.h -@@ -22,6 +22,8 @@ - #ifndef U_PRINTF_H - #define U_PRINTF_H - -+#include -+ - #ifdef __cplusplus - - #include -diff --git a/src/util/u_thread.h b/src/util/u_thread.h -index 013e8be..a30eada 100644 ---- a/src/util/u_thread.h -+++ b/src/util/u_thread.h -@@ -129,7 +129,7 @@ static inline thrd_t u_thread_create(int (*routine)(void *), void *param) - static inline void u_thread_setname( const char *name ) - { - #if defined(HAVE_PTHREAD) --#if DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS -+#if DETECT_OS_LINUX || DETECT_OS_CYGWIN || DETECT_OS_SOLARIS || DETECT_OS_aero - int ret = pthread_setname_np(pthread_self(), name); - if (ret == ERANGE) { - char buf[16]; -@@ -242,7 +242,7 @@ util_set_current_thread_affinity(const uint32_t *mask, - static inline int64_t - util_thread_get_time_nano(thrd_t thread) - { --#if defined(HAVE_PTHREAD) && !defined(__APPLE__) && !defined(__HAIKU__) -+#if defined(HAVE_PTHREAD) && !defined(__APPLE__) && !defined(__HAIKU__) && !defined(__aero__) - struct timespec ts; - clockid_t cid; - --- -2.39.1 - diff --git a/patches/mlibc/jinx-working-patch.patch b/patches/mlibc/jinx-working-patch.patch new file mode 100644 index 00000000000..dbb0969d0bb --- /dev/null +++ b/patches/mlibc/jinx-working-patch.patch @@ -0,0 +1,180 @@ +diff --git mlibc-clean/options/ansi/generic/time-stubs.cpp mlibc-workdir/options/ansi/generic/time-stubs.cpp +index 887a7d3..7fd46bc 100644 +--- mlibc-clean/options/ansi/generic/time-stubs.cpp ++++ mlibc-workdir/options/ansi/generic/time-stubs.cpp +@@ -242,6 +242,7 @@ size_t strftime(char *__restrict dest, size_t max_size, + c++; + break; + } ++ case 'l': + case 'I': { + int hour = tm->tm_hour; + if(!hour) +diff --git mlibc-clean/options/posix/generic/posix_stdlib.cpp mlibc-workdir/options/posix/generic/posix_stdlib.cpp +index 7128e16..14e1dd7 100644 +--- mlibc-clean/options/posix/generic/posix_stdlib.cpp ++++ mlibc-workdir/options/posix/generic/posix_stdlib.cpp +@@ -139,23 +139,34 @@ char *setstate(char *state) { + // ---------------------------------------------------------------------------- + + int mkostemp(char *pattern, int flags) { ++ return mkostemps(pattern, 0, flags); ++} ++ ++int mkstemp(char *path) { ++ return mkostemp(path, 0); ++} ++ ++int mkostemps(char *pattern, int suffixlen, int flags) { + flags &= ~O_WRONLY; + auto n = strlen(pattern); + __ensure(n >= 6); +- if(n < 6) { ++ ++ if(n < 6 || suffixlen > (n - 6)) { + errno = EINVAL; + return -1; + } +- for(size_t i = 0; i < 6; i++) { +- if(pattern[n - 6 + i] == 'X') +- continue; ++ ++ if (memcmp(pattern + (n - suffixlen - 6), "XXXXXX", 6)) { + errno = EINVAL; + return -1; + } + + // TODO: Do an exponential search. + for(size_t i = 0; i < 999999; i++) { +- __ensure(sprintf(pattern + (n - 6), "%06zu", i) == 6); ++ int x = i; ++ for (int j = 0; j < 6; j++, x >>= 5) { ++ pattern[(n - suffixlen - 6) + j] = 'A' + (x & 15) + (x & 16) * 2; ++ } + // mlibc::infoLogger() << "mlibc: mkstemp candidate is " + // << (const char *)pattern << frg::endlog; + +@@ -172,16 +183,6 @@ int mkostemp(char *pattern, int flags) { + return -1; + } + +-int mkstemp(char *path) { +- return mkostemp(path, 0); +-} +- +-int mkostemps(char *pattern, int suffixlen, int flags) { +- (void)suffixlen; +- mlibc::infoLogger() << "mlibc: mkostemps ignores suffixlen!" << frg::endlog; +- return mkostemp(pattern, flags); +-} +- + int mkstemps(char *pattern, int suffixlen) { + return mkostemps(pattern, suffixlen, 0); + } +diff --git mlibc-workdir/sysdeps/aero/crt-x86_64/crti.S mlibc-workdir/sysdeps/aero/crt-x86_64/crti.S +new file mode 100644 +index 0000000..f04679c +--- /dev/null ++++ mlibc-workdir/sysdeps/aero/crt-x86_64/crti.S +@@ -0,0 +1,10 @@ ++.section .init ++.global _init ++_init: ++ push %rax ++ ++.section .fini ++.global _fini ++_fini: ++ push %rax ++.section .note.GNU-stack,"",%progbits +diff --git mlibc-workdir/sysdeps/aero/crt-x86_64/crtn.S mlibc-workdir/sysdeps/aero/crt-x86_64/crtn.S +new file mode 100644 +index 0000000..1b61d5a +--- /dev/null ++++ mlibc-workdir/sysdeps/aero/crt-x86_64/crtn.S +@@ -0,0 +1,8 @@ ++.section .init ++ pop %rax ++ ret ++ ++.section .fini ++ pop %rax ++ ret ++.section .note.GNU-stack,"",%progbits +diff --git mlibc-clean/sysdeps/aero/generic/filesystem.cpp mlibc-workdir/sysdeps/aero/generic/filesystem.cpp +index 33a11f4..8795382 100644 +--- mlibc-clean/sysdeps/aero/generic/filesystem.cpp ++++ mlibc-workdir/sysdeps/aero/generic/filesystem.cpp +@@ -102,31 +102,24 @@ int sys_access(const char *filename, int mode) { + + int sys_stat(fsfd_target fsfdt, int fd, const char *path, int flags, + struct stat *statbuf) { +- auto result = 0; +- + switch (fsfdt) { +- case fsfd_target::path: { +- result = syscall(SYS_STAT, path, strlen(path), statbuf); ++ case fsfd_target::path: ++ fd = AT_FDCWD; + break; +- } +- +- case fsfd_target::fd: { +- result = syscall(SYS_FSTAT, fd, statbuf); ++ case fsfd_target::fd: ++ flags |= AT_EMPTY_PATH; ++ ++ case fsfd_target::fd_path: + break; +- } +- +- default: { +- mlibc::infoLogger() +- << "mlibc warning: sys_stat: unsupported fsfd target" +- << frg::endlog; +- return EINVAL; +- } +- } + +- if (result < 0) { +- return -result; ++ default: ++ __ensure(!"Invalid fsfd_target"); ++ __builtin_unreachable(); + } + ++ auto ret = syscall(SYS_FSTAT, fd, path, strlen(path), flags, statbuf); ++ if(int e = sc_error(ret); e) ++ return e; + return 0; + } + +diff --git mlibc-clean/sysdeps/aero/meson.build mlibc-workdir/sysdeps/aero/meson.build +index 9d10701..3d2a883 100644 +--- mlibc-clean/sysdeps/aero/meson.build ++++ mlibc-workdir/sysdeps/aero/meson.build +@@ -75,6 +75,24 @@ if not headers_only + install: true, + install_dir: get_option('libdir') + ) ++ ++ custom_target('crti', ++ build_by_default: true, ++ command: c_compiler.cmd_array() + ['-c', '-o', '@OUTPUT@', '@INPUT@'], ++ input: 'crt-x86_64/crti.S', ++ output: 'crti.o', ++ install: true, ++ install_dir: get_option('libdir') ++ ) ++ ++ custom_target('crtn', ++ build_by_default: true, ++ command: c_compiler.cmd_array() + ['-c', '-o', '@OUTPUT@', '@INPUT@'], ++ input: 'crt-x86_64/crtn.S', ++ output: 'crtn.o', ++ install: true, ++ install_dir: get_option('libdir') ++ ) + endif + + if host_machine.cpu_family() == 'x86_64' diff --git a/patches/mlibc/mlibc.patch b/patches/mlibc/mlibc.patch deleted file mode 100644 index 4b4fe9f22b4..00000000000 --- a/patches/mlibc/mlibc.patch +++ /dev/null @@ -1,914 +0,0 @@ -From ff3ad2ec971fffda2a1f098d4e574361f14ab0d2 Mon Sep 17 00:00:00 2001 -From: Anhad Singh -Date: Tue, 14 Nov 2023 17:51:25 +1100 -Subject: [PATCH] - -Signed-off-by: Anhad Singh ---- - options/intl/generic/libintl-stubs.cpp | 66 ++- - options/posix/generic/pthread-stubs.cpp | 90 +++- - options/rtdl/generic/linker.cpp | 5 +- - options/rtdl/include/mlibc/rtdl-sysdeps.hpp | 1 + - sysdeps/aero/generic/aero.cpp | 28 +- - sysdeps/aero/generic/filesystem.cpp | 32 +- - sysdeps/aero/generic/sockets.cpp | 10 +- - sysdeps/aero/include/aero/syscall.h | 3 + - sysdeps/aero/include/mlibc/jsmn.h | 474 ++++++++++++++++++++ - 9 files changed, 632 insertions(+), 77 deletions(-) - create mode 100644 sysdeps/aero/include/mlibc/jsmn.h - -diff --git a/options/intl/generic/libintl-stubs.cpp b/options/intl/generic/libintl-stubs.cpp -index 8d4b28f..94ab421 100644 ---- a/options/intl/generic/libintl-stubs.cpp -+++ b/options/intl/generic/libintl-stubs.cpp -@@ -1,73 +1,57 @@ - #include -+#include -+#include -+#include - #include - -+static char *current_domain; -+ - char *gettext(const char *msgid) { -- (void)msgid; -- __ensure(!"Not implemented"); -- __builtin_unreachable(); -+ // (void)msgid; -+ // __ensure(!"Not implemented"); -+ // __builtin_unreachable(); -+ return (char*)""; - } - - char *dgettext(const char *domainname, const char *msgid) { -- (void)domainname; -- (void)msgid; -- __ensure(!"Not implemented"); -- __builtin_unreachable(); -+ return (char*)""; - } - - char *dcgettext(const char *domainname, const char *msgid, - int category) { -- (void)domainname; -- (void)msgid; -- (void)category; -- __ensure(!"Not implemented"); -- __builtin_unreachable(); -+ return (char*)""; -+ - } - - char *ngettext(const char *msgid, const char *msgid_plural, unsigned long int n) { -- (void)msgid; -- (void)msgid_plural; -- (void)n; -- __ensure(!"Not implemented"); -- __builtin_unreachable(); -+ return (char*)""; -+ - } - - char *dngettext(const char *domainname, const char *msgid, - const char *msgid_plural, unsigned long int n) { -- (void)domainname; -- (void)msgid; -- (void)msgid_plural; -- (void)n; -- __ensure(!"Not implemented"); -- __builtin_unreachable(); -+ return (char*)""; -+ - } - - char *dcngettext(const char *domainname, const char *msgid, - const char *msgid_plural, unsigned long int n, int category) { -- (void)domainname; -- (void)msgid; -- (void)msgid_plural; -- (void)n; -- (void)category; -- __ensure(!"Not implemented"); -- __builtin_unreachable(); -+ return (char*)""; -+ - } - - char *textdomain(const char *domainname) { -- (void)domainname; -- __ensure(!"Not implemented"); -- __builtin_unreachable(); -+ if(!domainname) -+ return current_domain ? current_domain : (char *)"messages"; -+ -+ return (char*)"messages"; - } - - char *bindtextdomain(const char *domainname, const char *dirname) { -- (void)domainname; -- (void)dirname; -- __ensure(!"Not implemented"); -- __builtin_unreachable(); -+ return (char*)""; -+ - } - - char *bind_textdomain_codeset(const char *domainname, const char *codeset) { -- (void)domainname; -- (void)codeset; -- __ensure(!"Not implemented"); -- __builtin_unreachable(); -+ return (char*)""; - } -diff --git a/options/posix/generic/pthread-stubs.cpp b/options/posix/generic/pthread-stubs.cpp -index 5618dc6..a5edec6 100644 ---- a/options/posix/generic/pthread-stubs.cpp -+++ b/options/posix/generic/pthread-stubs.cpp -@@ -1,4 +1,3 @@ -- - #include - #include - #include -@@ -265,6 +264,87 @@ int pthread_attr_setsigmask_np(pthread_attr_t *__restrict attr, - } - - namespace { -+#include -+#ifdef __aero__ -+ static bool jsoneq(const char *input, jsmntok_t tok, const char *expected) { -+ if (tok.type == JSMN_STRING && -+ (int)strlen(expected) == tok.end - tok.start && -+ strncmp(input + tok.start, expected, tok.end - tok.start) == 0) { -+ return true; -+ } -+ -+ return false; -+ } -+ -+ size_t string_to_usize(const char *string, size_t length) { -+ size_t ret = 0; -+ for (size_t i = 0; i < length; i++) { -+ ret = ret * 10 + (string[i] - '0'); -+ } -+ -+ return ret; -+ } -+ -+ void get_own_stackinfo(void **stack_addr, size_t *stack_size) { -+ auto fp = fopen("/proc/self/maps", "r"); -+ if (!fp) { -+ mlibc::infoLogger() << "mlibc pthreads: /proc/self/maps does not exist! Producing incorrect" -+ " stack results!" << frg::endlog; -+ return; -+ } -+ -+ auto sp = mlibc::get_sp(); -+ -+ char *INPUT = (char *)malloc(4096 * 4); -+ size_t INPUT_SIZE = fread(INPUT, 1, 4096 * 4, fp); -+ -+ jsmn_parser parser; -+ jsmn_init(&parser); -+ -+ int n = jsmn_parse(&parser, INPUT, INPUT_SIZE, nullptr, 0); -+ FRG_ASSERT(n > 0); -+ -+ jsmntok_t *tokens = static_cast(malloc(sizeof(jsmntok_t) * n)); -+ -+ jsmn_init(&parser); -+ int result = jsmn_parse(&parser, INPUT, INPUT_SIZE, tokens, n); -+ FRG_ASSERT(tokens[0].type == JSMN_OBJECT); -+ -+ FRG_ASSERT(jsoneq(INPUT, tokens[1], "maps")); -+ -+ size_t n_fields = tokens[3].size; -+ for (size_t i = 3; i < tokens[2].size * (n_fields * 2 + 1); i+=(n_fields * 2 + 1)) { -+ jsmntok_t *mapping = &tokens[i]; -+ FRG_ASSERT(mapping->type == JSMN_OBJECT); -+ -+ size_t start = SIZE_MAX; -+ size_t end = SIZE_MAX; -+ -+ for (size_t j = 1; j < mapping->size * 2; j += 2) { -+ jsmntok_t *value = &mapping[j + 1]; -+ -+ size_t val = string_to_usize(INPUT + value->start, value->end - value->start); -+ -+ if (jsoneq(INPUT, mapping[j], "start")) { -+ start = val; -+ } else if (jsoneq(INPUT, mapping[j], "end")) { -+ end = val; -+ } -+ } -+ -+ if (sp < end && sp > start) { -+ *stack_addr = reinterpret_cast(start); -+ *stack_size = end - start; -+ -+ fclose(fp); -+ free(INPUT); -+ return; -+ } -+ } -+ -+ FRG_ASSERT(!"reached unreachable code"); -+ } -+#else - void get_own_stackinfo(void **stack_addr, size_t *stack_size) { - auto fp = fopen("/proc/self/maps", "r"); - if (!fp) { -@@ -290,7 +370,8 @@ namespace { - - fclose(fp); - } --} -+#endif -+} // namespace annonymous - - int pthread_getattr_np(pthread_t thread, pthread_attr_t *attr) { - auto tcb = reinterpret_cast(thread); -@@ -299,9 +380,10 @@ int pthread_getattr_np(pthread_t thread, pthread_attr_t *attr) { - if (!tcb->stackAddr || !tcb->stackSize) { - // allocate stack - -- attr->__mlibc_stackaddr = 0x00; -+ attr->__mlibc_stackaddr = (void*)0x7ffffff9a000; - attr->__mlibc_stacksize = 0x20000; -- // get_own_stackinfo(&attr->__mlibc_stackaddr, &attr->__mlibc_stacksize); -+ -+ get_own_stackinfo(&attr->__mlibc_stackaddr, &attr->__mlibc_stacksize); - } else { - attr->__mlibc_stacksize = tcb->stackSize; - attr->__mlibc_stackaddr = tcb->stackAddr; -diff --git a/options/rtdl/generic/linker.cpp b/options/rtdl/generic/linker.cpp -index 50cca94..a095ab0 100644 ---- a/options/rtdl/generic/linker.cpp -+++ b/options/rtdl/generic/linker.cpp -@@ -438,6 +438,7 @@ void ObjectRepository::_fetchFromFile(SharedObject *object, int fd) { - - __ensure(!(object->baseAddress & (hugeSize - 1))); - -+ size_t tagSize = highest_address - object->baseAddress; - #if MLIBC_MMAP_ALLOCATE_DSO - void *mappedAddr = nullptr; - -@@ -457,9 +458,11 @@ void ObjectRepository::_fetchFromFile(SharedObject *object, int fd) { - libraryBase += (highest_address + (hugeSize - 1)) & ~(hugeSize - 1); - #endif - -- if(verbose || logBaseAddresses) -+ if(verbose || logBaseAddresses) { -+ mlibc::sys_tag_memory((void *)object->baseAddress, tagSize, object->name.data()); - mlibc::infoLogger() << "rtdl: Loading " << object->name - << " at " << (void *)object->baseAddress << frg::endlog; -+ } - - // Load all segments. - constexpr size_t pageSize = 0x1000; -diff --git a/options/rtdl/include/mlibc/rtdl-sysdeps.hpp b/options/rtdl/include/mlibc/rtdl-sysdeps.hpp -index c35271c..8a941b2 100644 ---- a/options/rtdl/include/mlibc/rtdl-sysdeps.hpp -+++ b/options/rtdl/include/mlibc/rtdl-sysdeps.hpp -@@ -6,6 +6,7 @@ namespace [[gnu::visibility("hidden")]] mlibc { - int sys_tcb_set(void *pointer); - - [[gnu::weak]] int sys_vm_readahead(void *pointer, size_t size); -+[[gnu::weak]] int sys_tag_memory(void *ptr, size_t size, char *tag); - - } // namespace mlibc - -diff --git a/sysdeps/aero/generic/aero.cpp b/sysdeps/aero/generic/aero.cpp -index e19b159..a54b6d3 100644 ---- a/sysdeps/aero/generic/aero.cpp -+++ b/sysdeps/aero/generic/aero.cpp -@@ -62,6 +62,10 @@ static frg::vector create_slice(char *const arg[]) { - } - - namespace mlibc { -+int sys_tag_memory(void *ptr, size_t size, char *tag) { -+ return syscall(SYS_DEBUG, ptr, size, tag, strlen(tag)); -+} -+ - int sys_uname(struct utsname *buf) { - auto result = syscall(SYS_UNAME, buf); - -@@ -73,22 +77,20 @@ int sys_uname(struct utsname *buf) { - } - - int sys_futex_wait(int *pointer, int expected, const struct timespec *time) { -- // auto result = syscall(SYS_FUTEX_WAIT, pointer, expected, time); -- // -- // if (result < 0) { -- // return -result; -- // } -- // -+ auto ret = syscall(SYS_FUTEX_WAIT, pointer, expected, time); -+ -+ if (int e = sc_error(ret); e) -+ return e; -+ - return 0; - } - - int sys_futex_wake(int *pointer) { -- // auto result = syscall(SYS_FUTEX_WAKE, pointer); -- // -- // if (result < 0) { -- // return -result; -- // } -- // -+ auto ret = syscall(SYS_FUTEX_WAKE, pointer); -+ -+ if (int e = sc_error(ret); e) -+ return e; -+ - return 0; - } - -@@ -309,7 +311,7 @@ int sys_thread_setname(void *tcb, const char *name) { - } - - void sys_thread_exit() { -- syscall(SYS_EXIT); -+ syscall(SYS_EXIT, 0); - __builtin_trap(); - } - -diff --git a/sysdeps/aero/generic/filesystem.cpp b/sysdeps/aero/generic/filesystem.cpp -index 33a11f4..4f64ba5 100644 ---- a/sysdeps/aero/generic/filesystem.cpp -+++ b/sysdeps/aero/generic/filesystem.cpp -@@ -68,15 +68,22 @@ int sys_seek(int fd, off_t offset, int whence, off_t *new_offset) { - return 0; - } - --int sys_open(const char *filename, int flags, mode_t mode, int *fd) { -- auto result = syscall(SYS_OPEN, 0, filename, strlen(filename), flags); -+int sys_openat(int dirfd, const char *path, int flags, mode_t mode, int *fd) { -+ (void)mode; - -- if (result < 0) { -- return -result; -- } -+ auto ret = syscall(SYS_OPEN, dirfd, path, strlen(path), flags); -+ if (int e = sc_error(ret); e) -+ return e; -+ *fd = ret; -+ return 0; -+} - -- *fd = result; -- return 0; -+int sys_open(const char *path, int flags, mode_t mode, int *fd) { -+ return sys_openat(AT_FDCWD, path, flags, mode, fd); -+} -+ -+int sys_open_dir(const char *path, int *fd) { -+ return sys_open(path, O_DIRECTORY, 0, fd); - } - - int sys_close(int fd) { -@@ -256,10 +263,6 @@ int sys_read_entries(int handle, void *buffer, size_t max_size, - return 0; - } - --int sys_open_dir(const char *path, int *handle) { -- return sys_open(path, O_DIRECTORY, 0, handle); --} -- - int sys_rename(const char *path, const char *new_path) { - auto result = - syscall(SYS_RENAME, path, strlen(path), new_path, strlen(new_path)); -@@ -305,6 +308,13 @@ int sys_dup2(int fd, int flags, int newfd) { - } - - int sys_fcntl(int fd, int request, va_list args, int *result_value) { -+ if(request == F_GETLK) { -+ struct flock *lock = va_arg(args, struct flock *); -+ lock->l_type = F_UNLCK; -+ mlibc::infoLogger() << "\e[31mmlibc: F_GETLK is stubbed!\e[39m" << frg::endlog; -+ return 0; -+ } -+ - auto result = syscall(SYS_FCNTL, fd, request, va_arg(args, uint64_t)); - - if (result < 0) { -diff --git a/sysdeps/aero/generic/sockets.cpp b/sysdeps/aero/generic/sockets.cpp -index 10af36a..bf2602f 100644 ---- a/sysdeps/aero/generic/sockets.cpp -+++ b/sysdeps/aero/generic/sockets.cpp -@@ -174,14 +174,10 @@ int sys_getsockopt(int fd, int layer, int number, void *__restrict buffer, - - int sys_setsockopt(int fd, int layer, int number, const void *buffer, - socklen_t size) { -- (void)fd; -- (void)buffer; -- (void)size; -- - if (layer == SOL_SOCKET && number == SO_PASSCRED) { -- mlibc::infoLogger() << "\e[31mmlibc: setsockopt(SO_PASSCRED) is not " -- "implemented correctly\e[39m" -- << frg::endlog; -+ auto ret = syscall(SYS_SETSOCKOPT, fd, layer, number, buffer, size); -+ if (int e = sc_error(ret); e) -+ return e; - return 0; - } else if (layer == SOL_SOCKET && number == SO_ATTACH_FILTER) { - mlibc::infoLogger() << "\e[31mmlibc: setsockopt(SO_ATTACH_FILTER) is " -diff --git a/sysdeps/aero/include/aero/syscall.h b/sysdeps/aero/include/aero/syscall.h -index 39c5b65..bd2f489 100644 ---- a/sysdeps/aero/include/aero/syscall.h -+++ b/sysdeps/aero/include/aero/syscall.h -@@ -82,6 +82,9 @@ - #define SYS_SOCK_SHUTDOWN 75 - #define SYS_GETPEERNAME 76 - #define SYS_GETSOCKNAME 77 -+#define SYS_DEBUG 78 -+#define SYS_SETSOCKOPT 79 -+#define SYS_GETSOCKOPT 80 - - // Invalid syscall used to trigger a log error in the kernel (as a hint) - // so, that we can implement the syscall in the kernel. -diff --git a/sysdeps/aero/include/mlibc/jsmn.h b/sysdeps/aero/include/mlibc/jsmn.h -new file mode 100644 -index 0000000..2d8f591 ---- /dev/null -+++ b/sysdeps/aero/include/mlibc/jsmn.h -@@ -0,0 +1,474 @@ -+/* -+ * MIT License -+ * -+ * Copyright (c) 2010 Serge Zaitsev -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a copy -+ * of this software and associated documentation files (the "Software"), to deal -+ * in the Software without restriction, including without limitation the rights -+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -+ * copies of the Software, and to permit persons to whom the Software is -+ * furnished to do so, subject to the following conditions: -+ * -+ * The above copyright notice and this permission notice shall be included in -+ * all copies or substantial portions of the Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -+ * SOFTWARE. -+ */ -+#ifndef JSMN_H -+#define JSMN_H -+ -+#include -+ -+#define JSMN_PARENT_LINKS -+#define JSMN_STRICT -+ -+#ifdef __cplusplus -+extern "C" { -+#endif -+ -+#ifdef JSMN_STATIC -+#define JSMN_API static -+#else -+#define JSMN_API extern -+#endif -+ -+/** -+ * JSON type identifier. Basic types are: -+ * o Object -+ * o Array -+ * o String -+ * o Other primitive: number, boolean (true/false) or null -+ */ -+typedef enum { -+ JSMN_UNDEFINED = 0, -+ JSMN_OBJECT = 1 << 0, -+ JSMN_ARRAY = 1 << 1, -+ JSMN_STRING = 1 << 2, -+ JSMN_PRIMITIVE = 1 << 3 -+} jsmntype_t; -+ -+enum jsmnerr { -+ /* Not enough tokens were provided */ -+ JSMN_ERROR_NOMEM = -1, -+ /* Invalid character inside JSON string */ -+ JSMN_ERROR_INVAL = -2, -+ /* The string is not a full JSON packet, more bytes expected */ -+ JSMN_ERROR_PART = -3 -+}; -+ -+/** -+ * JSON token description. -+ * type type (object, array, string etc.) -+ * start start position in JSON data string -+ * end end position in JSON data string -+ */ -+typedef struct jsmntok { -+ jsmntype_t type; -+ int start; -+ int end; -+ int size; -+#ifdef JSMN_PARENT_LINKS -+ int parent; -+#endif -+} jsmntok_t; -+ -+/** -+ * JSON parser. Contains an array of token blocks available. Also stores -+ * the string being parsed now and current position in that string. -+ */ -+typedef struct jsmn_parser { -+ unsigned int pos; /* offset in the JSON string */ -+ unsigned int toknext; /* next token to allocate */ -+ int toksuper; /* superior token node, e.g. parent object or array */ -+} jsmn_parser; -+ -+/** -+ * Create JSON parser over an array of tokens -+ */ -+JSMN_API void jsmn_init(jsmn_parser *parser); -+ -+/** -+ * Run JSON parser. It parses a JSON data string into and array of tokens, each -+ * describing -+ * a single JSON object. -+ */ -+JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len, -+ jsmntok_t *tokens, const unsigned int num_tokens); -+ -+#ifndef JSMN_HEADER -+/** -+ * Allocates a fresh unused token from the token pool. -+ */ -+static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, jsmntok_t *tokens, -+ const size_t num_tokens) { -+ jsmntok_t *tok; -+ if (parser->toknext >= num_tokens) { -+ return NULL; -+ } -+ tok = &tokens[parser->toknext++]; -+ tok->start = tok->end = -1; -+ tok->size = 0; -+#ifdef JSMN_PARENT_LINKS -+ tok->parent = -1; -+#endif -+ return tok; -+} -+ -+/** -+ * Fills token type and boundaries. -+ */ -+static void jsmn_fill_token(jsmntok_t *token, const jsmntype_t type, -+ const int start, const int end) { -+ token->type = type; -+ token->start = start; -+ token->end = end; -+ token->size = 0; -+} -+ -+/** -+ * Fills next available token with JSON primitive. -+ */ -+static int jsmn_parse_primitive(jsmn_parser *parser, const char *js, -+ const size_t len, jsmntok_t *tokens, -+ const size_t num_tokens) { -+ jsmntok_t *token; -+ int start; -+ -+ start = parser->pos; -+ -+ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { -+ switch (js[parser->pos]) { -+#ifndef JSMN_STRICT -+ /* In strict mode primitive must be followed by "," or "}" or "]" */ -+ case ':': -+#endif -+ case '\t': -+ case '\r': -+ case '\n': -+ case ' ': -+ case ',': -+ case ']': -+ case '}': -+ goto found; -+ default: -+ /* to quiet a warning from gcc*/ -+ break; -+ } -+ if (js[parser->pos] < 32 || js[parser->pos] >= 127) { -+ parser->pos = start; -+ return JSMN_ERROR_INVAL; -+ } -+ } -+#ifdef JSMN_STRICT -+ /* In strict mode primitive must be followed by a comma/object/array */ -+ parser->pos = start; -+ return JSMN_ERROR_PART; -+#endif -+ -+found: -+ if (tokens == NULL) { -+ parser->pos--; -+ return 0; -+ } -+ token = jsmn_alloc_token(parser, tokens, num_tokens); -+ if (token == NULL) { -+ parser->pos = start; -+ return JSMN_ERROR_NOMEM; -+ } -+ jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos); -+#ifdef JSMN_PARENT_LINKS -+ token->parent = parser->toksuper; -+#endif -+ parser->pos--; -+ return 0; -+} -+ -+/** -+ * Fills next token with JSON string. -+ */ -+static int jsmn_parse_string(jsmn_parser *parser, const char *js, -+ const size_t len, jsmntok_t *tokens, -+ const size_t num_tokens) { -+ jsmntok_t *token; -+ -+ int start = parser->pos; -+ -+ /* Skip starting quote */ -+ parser->pos++; -+ -+ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { -+ char c = js[parser->pos]; -+ -+ /* Quote: end of string */ -+ if (c == '\"') { -+ if (tokens == NULL) { -+ return 0; -+ } -+ token = jsmn_alloc_token(parser, tokens, num_tokens); -+ if (token == NULL) { -+ parser->pos = start; -+ return JSMN_ERROR_NOMEM; -+ } -+ jsmn_fill_token(token, JSMN_STRING, start + 1, parser->pos); -+#ifdef JSMN_PARENT_LINKS -+ token->parent = parser->toksuper; -+#endif -+ return 0; -+ } -+ -+ /* Backslash: Quoted symbol expected */ -+ if (c == '\\' && parser->pos + 1 < len) { -+ int i; -+ parser->pos++; -+ switch (js[parser->pos]) { -+ /* Allowed escaped symbols */ -+ case '\"': -+ case '/': -+ case '\\': -+ case 'b': -+ case 'f': -+ case 'r': -+ case 'n': -+ case 't': -+ break; -+ /* Allows escaped symbol \uXXXX */ -+ case 'u': -+ parser->pos++; -+ for (i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; -+ i++) { -+ /* If it isn't a hex character we have an error */ -+ if (!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */ -+ (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */ -+ (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */ -+ parser->pos = start; -+ return JSMN_ERROR_INVAL; -+ } -+ parser->pos++; -+ } -+ parser->pos--; -+ break; -+ /* Unexpected symbol */ -+ default: -+ parser->pos = start; -+ return JSMN_ERROR_INVAL; -+ } -+ } -+ } -+ parser->pos = start; -+ return JSMN_ERROR_PART; -+} -+ -+/** -+ * Parse JSON string and fill tokens. -+ */ -+JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len, -+ jsmntok_t *tokens, const unsigned int num_tokens) { -+ int r; -+ int i; -+ jsmntok_t *token; -+ int count = parser->toknext; -+ -+ for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { -+ char c; -+ jsmntype_t type; -+ -+ c = js[parser->pos]; -+ switch (c) { -+ case '{': -+ case '[': -+ count++; -+ if (tokens == NULL) { -+ break; -+ } -+ token = jsmn_alloc_token(parser, tokens, num_tokens); -+ if (token == NULL) { -+ return JSMN_ERROR_NOMEM; -+ } -+ if (parser->toksuper != -1) { -+ jsmntok_t *t = &tokens[parser->toksuper]; -+#ifdef JSMN_STRICT -+ /* In strict mode an object or array can't become a key */ -+ if (t->type == JSMN_OBJECT) { -+ return JSMN_ERROR_INVAL; -+ } -+#endif -+ t->size++; -+#ifdef JSMN_PARENT_LINKS -+ token->parent = parser->toksuper; -+#endif -+ } -+ token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY); -+ token->start = parser->pos; -+ parser->toksuper = parser->toknext - 1; -+ break; -+ case '}': -+ case ']': -+ if (tokens == NULL) { -+ break; -+ } -+ type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY); -+#ifdef JSMN_PARENT_LINKS -+ if (parser->toknext < 1) { -+ return JSMN_ERROR_INVAL; -+ } -+ token = &tokens[parser->toknext - 1]; -+ for (;;) { -+ if (token->start != -1 && token->end == -1) { -+ if (token->type != type) { -+ return JSMN_ERROR_INVAL; -+ } -+ token->end = parser->pos + 1; -+ parser->toksuper = token->parent; -+ break; -+ } -+ if (token->parent == -1) { -+ if (token->type != type || parser->toksuper == -1) { -+ return JSMN_ERROR_INVAL; -+ } -+ break; -+ } -+ token = &tokens[token->parent]; -+ } -+#else -+ for (i = parser->toknext - 1; i >= 0; i--) { -+ token = &tokens[i]; -+ if (token->start != -1 && token->end == -1) { -+ if (token->type != type) { -+ return JSMN_ERROR_INVAL; -+ } -+ parser->toksuper = -1; -+ token->end = parser->pos + 1; -+ break; -+ } -+ } -+ /* Error if unmatched closing bracket */ -+ if (i == -1) { -+ return JSMN_ERROR_INVAL; -+ } -+ for (; i >= 0; i--) { -+ token = &tokens[i]; -+ if (token->start != -1 && token->end == -1) { -+ parser->toksuper = i; -+ break; -+ } -+ } -+#endif -+ break; -+ case '\"': -+ r = jsmn_parse_string(parser, js, len, tokens, num_tokens); -+ if (r < 0) { -+ return r; -+ } -+ count++; -+ if (parser->toksuper != -1 && tokens != NULL) { -+ tokens[parser->toksuper].size++; -+ } -+ break; -+ case '\t': -+ case '\r': -+ case '\n': -+ case ' ': -+ break; -+ case ':': -+ parser->toksuper = parser->toknext - 1; -+ break; -+ case ',': -+ if (tokens != NULL && parser->toksuper != -1 && -+ tokens[parser->toksuper].type != JSMN_ARRAY && -+ tokens[parser->toksuper].type != JSMN_OBJECT) { -+#ifdef JSMN_PARENT_LINKS -+ parser->toksuper = tokens[parser->toksuper].parent; -+#else -+ for (i = parser->toknext - 1; i >= 0; i--) { -+ if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) { -+ if (tokens[i].start != -1 && tokens[i].end == -1) { -+ parser->toksuper = i; -+ break; -+ } -+ } -+ } -+#endif -+ } -+ break; -+#ifdef JSMN_STRICT -+ /* In strict mode primitives are: numbers and booleans */ -+ case '-': -+ case '0': -+ case '1': -+ case '2': -+ case '3': -+ case '4': -+ case '5': -+ case '6': -+ case '7': -+ case '8': -+ case '9': -+ case 't': -+ case 'f': -+ case 'n': -+ /* And they must not be keys of the object */ -+ if (tokens != NULL && parser->toksuper != -1) { -+ const jsmntok_t *t = &tokens[parser->toksuper]; -+ if (t->type == JSMN_OBJECT || -+ (t->type == JSMN_STRING && t->size != 0)) { -+ return JSMN_ERROR_INVAL; -+ } -+ } -+#else -+ /* In non-strict mode every unquoted value is a primitive */ -+ default: -+#endif -+ r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens); -+ if (r < 0) { -+ return r; -+ } -+ count++; -+ if (parser->toksuper != -1 && tokens != NULL) { -+ tokens[parser->toksuper].size++; -+ } -+ break; -+ -+#ifdef JSMN_STRICT -+ /* Unexpected char in strict mode */ -+ default: -+ return JSMN_ERROR_INVAL; -+#endif -+ } -+ } -+ -+ if (tokens != NULL) { -+ for (i = parser->toknext - 1; i >= 0; i--) { -+ /* Unmatched opened object or array */ -+ if (tokens[i].start != -1 && tokens[i].end == -1) { -+ return JSMN_ERROR_PART; -+ } -+ } -+ } -+ -+ return count; -+} -+ -+/** -+ * Creates a new parser based over a given buffer with an array of tokens -+ * available. -+ */ -+JSMN_API void jsmn_init(jsmn_parser *parser) { -+ parser->pos = 0; -+ parser->toknext = 0; -+ parser->toksuper = -1; -+} -+ -+#endif /* JSMN_HEADER */ -+ -+#ifdef __cplusplus -+} -+#endif -+ -+#endif /* JSMN_H */ --- -2.43.0 - diff --git a/patches/ncurses/jinx-working-patch.patch b/patches/ncurses/jinx-working-patch.patch new file mode 100644 index 00000000000..7ebebf230b9 --- /dev/null +++ b/patches/ncurses/jinx-working-patch.patch @@ -0,0 +1,15 @@ +diff --git ncurses-clean/configure ncurses-workdir/configure +index d652dc0..1572ae3 100755 +--- ncurses-clean/configure ++++ ncurses-workdir/configure +@@ -6923,6 +6923,10 @@ CF_EOF + LINK_PROGS="$SHELL ${rel_builddir}/mk_prog.sh" + LINK_TESTS="$SHELL ${rel_builddir}/mk_prog.sh" + ;; ++ (aero*) ++ CC_SHARED_OPTS='-fPIC' ++ MK_SHARED_LIB='${CC} -shared -o $@' ++ ;; + (mingw*) + cf_cv_shlib_version=mingw + cf_cv_shlib_version_infix=mingw diff --git a/patches/ncurses/ncurses.patch b/patches/ncurses/ncurses.patch deleted file mode 100644 index daf6ac0a94a..00000000000 --- a/patches/ncurses/ncurses.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 4d53b6fbd2a90d69c153933c413ecf5a0598518a Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Fri, 2 Dec 2022 19:15:20 +1100 -Subject: [PATCH] - ---- - config.sub | 2 +- - configure | 4 ++++ - 2 files changed, 5 insertions(+), 1 deletion(-) - -diff --git a/config.sub b/config.sub -index 0f2234c..0cf7603 100755 ---- a/config.sub -+++ b/config.sub -@@ -1366,7 +1366,7 @@ case $os in - | skyos* | haiku* | rdos* | toppers* | drops* | es* \ - | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ - | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ -- | nsk* | powerunix) -+ | nsk* | powerunix | aero*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - qnx*) -diff --git a/configure b/configure -index 06f344f..a008d88 100755 ---- a/configure -+++ b/configure -@@ -5961,6 +5961,10 @@ echo "${ECHO_T}$cf_cv_ldflags_search_paths_first" >&6 - - MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $@' - ;; -+ (aero*) -+ CC_SHARED_OPTS='-fPIC' -+ MK_SHARED_LIB='${CC} -shared -o $@' -+ ;; - (mingw*) - cf_cv_shlib_version=mingw - cf_cv_shlib_version_infix=mingw --- -2.38.1 - diff --git a/patches/neofetch/neofetch.patch b/patches/neofetch/neofetch.patch deleted file mode 100644 index 6b2a9572e7d..00000000000 --- a/patches/neofetch/neofetch.patch +++ /dev/null @@ -1,34 +0,0 @@ -From f1fae2e54122bb1342dec30f218a4bdcdaf3c428 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Wed, 21 Dec 2022 17:37:50 +1100 -Subject: [PATCH] - ---- - neofetch | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/neofetch b/neofetch -index 9f2ba30..2d5c4de 100755 ---- a/neofetch -+++ b/neofetch -@@ -945,7 +945,7 @@ get_os() { - AIX) os=AIX ;; - IRIX*) os=IRIX ;; - FreeMiNT) os=FreeMiNT ;; -- aero) os=Aero;; -+ Aero) os=Aero;; - - Linux|GNU*) - os=Linux -@@ -8528,7 +8528,7 @@ EOF - # TODO: Add proper art - set_colors 2 1 3 5 - read -rd '' ascii_data <<'EOF' -- ,---, -+${c1} ,---, - ' .' \ - / ; '. - : : \ --- -2.38.1 - diff --git a/patches/nss/0001-Add-a-missing-include.patch b/patches/nss/0001-Add-a-missing-include.patch deleted file mode 100644 index eb71fcab2a5..00000000000 --- a/patches/nss/0001-Add-a-missing-include.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 8c7f96493b8706d43b30f49d56e0e84ee27fe65e Mon Sep 17 00:00:00 2001 -From: Dennis Bonke -Date: Wed, 27 Apr 2022 20:27:21 +0200 -Subject: [PATCH 1/2] Add a missing include - -Signed-off-by: Dennis Bonke ---- - lib/dbm/src/h_page.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/lib/dbm/src/h_page.c b/lib/dbm/src/h_page.c -index d4e4ff6..7b3271e 100644 ---- a/lib/dbm/src/h_page.c -+++ b/lib/dbm/src/h_page.c -@@ -81,6 +81,7 @@ static char sccsid[] = "@(#)hash_page.c 8.7 (Berkeley) 8/16/94"; - #endif - - #include -+#include - - #include "mcom_db.h" - #include "hash.h" --- -2.36.0 diff --git a/patches/nss/0002-NSS-Standalone-patch.patch b/patches/nss/0002-NSS-Standalone-patch.patch deleted file mode 100644 index cd78732af8a..00000000000 --- a/patches/nss/0002-NSS-Standalone-patch.patch +++ /dev/null @@ -1,258 +0,0 @@ -From ee4b3e43e0143f94289c418c0db5f803119e8be6 Mon Sep 17 00:00:00 2001 -From: Dennis Bonke -Date: Wed, 27 Apr 2022 20:35:40 +0200 -Subject: [PATCH 2/2] NSS Standalone patch - -Taken from Beyond Linux From Scratch (https://www.linuxfromscratch.org/patches/blfs/svn/nss-3.77-standalone-1.patch) - -Adds auto-generated nss.pc and nss-config script, and allows building without nspr in the source tree. -Minimum NSPR version is now read out from package, instead of hardcoded value in the patch. - -Signed-off-by: Dennis Bonke ---- - config/Makefile | 41 ++++++++++++ - config/nss-config.in | 152 +++++++++++++++++++++++++++++++++++++++++++ - config/nss.pc.in | 11 ++++ - manifest.mn | 2 +- - 4 files changed, 205 insertions(+), 1 deletion(-) - create mode 100644 config/Makefile - create mode 100644 config/nss-config.in - create mode 100644 config/nss.pc.in - -diff --git a/config/Makefile b/config/Makefile -new file mode 100644 -index 0000000..662020a ---- /dev/null -+++ b/config/Makefile -@@ -0,0 +1,41 @@ -+CORE_DEPTH = .. -+DEPTH = .. -+ -+include $(CORE_DEPTH)/coreconf/config.mk -+ -+NSS_MAJOR_VERSION = `grep "NSS_VMAJOR" ../lib/nss/nss.h | awk '{print $$3}'` -+NSS_MINOR_VERSION = `grep "NSS_VMINOR" ../lib/nss/nss.h | awk '{print $$3}'` -+NSS_PATCH_VERSION = `grep "NSS_VPATCH" ../lib/nss/nss.h | awk '{print $$3}'` -+NSS_NSPR_MINIMUM = `head -n1 ../automation/release/nspr-version.txt` -+PREFIX = /usr -+ -+all: export libs -+ -+export: -+ # Create the nss.pc file -+ mkdir -p $(DIST)/lib/pkgconfig -+ sed -e "s,@prefix@,$(PREFIX)," \ -+ -e "s,@exec_prefix@,\$${prefix}," \ -+ -e "s,@libdir@,\$${prefix}/lib," \ -+ -e "s,@includedir@,\$${prefix}/include/nss," \ -+ -e "s,@NSS_MAJOR_VERSION@,$(NSS_MAJOR_VERSION),g" \ -+ -e "s,@NSS_MINOR_VERSION@,$(NSS_MINOR_VERSION)," \ -+ -e "s,@NSS_PATCH_VERSION@,$(NSS_PATCH_VERSION)," \ -+ -e "s,@NSS_NSPR_MINIMUM@,$(NSS_NSPR_MINIMUM)," \ -+ nss.pc.in > nss.pc -+ chmod 0644 nss.pc -+ cp -v nss.pc $(DIST)/lib/pkgconfig -+ -+ # Create the nss-config script -+ mkdir -p $(DIST)/bin -+ sed -e "s,@prefix@,$(PREFIX)," \ -+ -e "s,@NSS_MAJOR_VERSION@,$(NSS_MAJOR_VERSION)," \ -+ -e "s,@NSS_MINOR_VERSION@,$(NSS_MINOR_VERSION)," \ -+ -e "s,@NSS_PATCH_VERSION@,$(NSS_PATCH_VERSION)," \ -+ nss-config.in > nss-config -+ chmod 0755 nss-config -+ cp -v nss-config $(DIST)/bin -+ -+libs: -+ -+dummy: all export libs -diff --git a/config/nss-config.in b/config/nss-config.in -new file mode 100644 -index 0000000..7e3750d ---- /dev/null -+++ b/config/nss-config.in -@@ -0,0 +1,152 @@ -+#!/bin/sh -+ -+prefix=@prefix@ -+ -+major_version=@NSS_MAJOR_VERSION@ -+minor_version=@NSS_MINOR_VERSION@ -+patch_version=@NSS_PATCH_VERSION@ -+ -+usage() -+{ -+ cat <&2 -+fi -+ -+lib_nss=yes -+lib_nssutil=yes -+lib_smime=yes -+lib_ssl=yes -+lib_softokn=yes -+ -+while test $# -gt 0; do -+ case "$1" in -+ -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; -+ *) optarg= ;; -+ esac -+ -+ case $1 in -+ --prefix=*) -+ prefix=$optarg -+ ;; -+ --prefix) -+ echo_prefix=yes -+ ;; -+ --exec-prefix=*) -+ exec_prefix=$optarg -+ ;; -+ --exec-prefix) -+ echo_exec_prefix=yes -+ ;; -+ --includedir=*) -+ includedir=$optarg -+ ;; -+ --includedir) -+ echo_includedir=yes -+ ;; -+ --libdir=*) -+ libdir=$optarg -+ ;; -+ --libdir) -+ echo_libdir=yes -+ ;; -+ --version) -+ echo ${major_version}.${minor_version}.${patch_version} -+ ;; -+ --cflags) -+ echo_cflags=yes -+ ;; -+ --libs) -+ echo_libs=yes -+ ;; -+ nss) -+ lib_nss=yes -+ ;; -+ nssutil) -+ lib_nssutil=yes -+ ;; -+ smime) -+ lib_smime=yes -+ ;; -+ ssl) -+ lib_ssl=yes -+ ;; -+ softokn) -+ lib_softokn=yes -+ ;; -+ *) -+ usage 1 1>&2 -+ ;; -+ esac -+ shift -+done -+ -+# Set variables that may be dependent upon other variables -+if test -z "$exec_prefix"; then -+ exec_prefix=`pkg-config --variable=exec_prefix nss` -+fi -+if test -z "$includedir"; then -+ includedir=`pkg-config --variable=includedir nss` -+fi -+if test -z "$libdir"; then -+ libdir=`pkg-config --variable=libdir nss` -+fi -+ -+if test "$echo_prefix" = "yes"; then -+ echo $prefix -+fi -+ -+if test "$echo_exec_prefix" = "yes"; then -+ echo $exec_prefix -+fi -+ -+if test "$echo_includedir" = "yes"; then -+ echo $includedir -+fi -+ -+if test "$echo_libdir" = "yes"; then -+ echo $libdir -+fi -+ -+if test "$echo_cflags" = "yes"; then -+ echo -I$includedir -+fi -+ -+if test "$echo_libs" = "yes"; then -+ libdirs="-L$libdir" -+ if test -n "$lib_nss"; then -+ libdirs="$libdirs -lnss${major_version}" -+ fi -+ if test -n "$lib_nssutil"; then -+ libdirs="$libdirs -lnssutil${major_version}" -+ fi -+ if test -n "$lib_smime"; then -+ libdirs="$libdirs -lsmime${major_version}" -+ fi -+ if test -n "$lib_ssl"; then -+ libdirs="$libdirs -lssl${major_version}" -+ fi -+ if test -n "$lib_softokn"; then -+ libdirs="$libdirs -lsoftokn${major_version}" -+ fi -+ echo $libdirs -+fi -diff --git a/config/nss.pc.in b/config/nss.pc.in -new file mode 100644 -index 0000000..c8c263d ---- /dev/null -+++ b/config/nss.pc.in -@@ -0,0 +1,11 @@ -+prefix=@prefix@ -+exec_prefix=@exec_prefix@ -+libdir=@libdir@ -+includedir=@includedir@ -+ -+Name: NSS -+Description: Network Security Services -+Version: @NSS_MAJOR_VERSION@.@NSS_MINOR_VERSION@.@NSS_PATCH_VERSION@ -+Requires: nspr >= @NSS_NSPR_MINIMUM@ -+Libs: -L@libdir@ -lnss@NSS_MAJOR_VERSION@ -lnssutil@NSS_MAJOR_VERSION@ -lsmime@NSS_MAJOR_VERSION@ -lssl@NSS_MAJOR_VERSION@ -lsoftokn@NSS_MAJOR_VERSION@ -+Cflags: -I${includedir} -diff --git a/manifest.mn b/manifest.mn -index fbc420a..b983d88 100644 ---- a/manifest.mn -+++ b/manifest.mn -@@ -10,7 +10,7 @@ IMPORTS = nspr20/v4.8 \ - - RELEASE = nss - --DIRS = coreconf lib cmd cpputil gtests -+DIRS = coreconf lib cmd cpputil gtests config - - HAVE_ALL_TARGET := 1 - --- -2.36.0 diff --git a/patches/nyancat/nyancat.patch b/patches/nyancat/nyancat.patch deleted file mode 100644 index abe6dc4956d..00000000000 --- a/patches/nyancat/nyancat.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 040f0506e6ba7093bd12a7c89fb90f99a67ad33d Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Thu, 23 Dec 2021 12:17:11 +1100 -Subject: [PATCH] targets: add aero target port - -Signed-off-by: Andy-Python-Programmer ---- - .vscode/settings.json | 6 ++++++ - src/nyancat.c | 2 -- - 2 files changed, 6 insertions(+), 2 deletions(-) - create mode 100644 .vscode/settings.json - -diff --git a/.vscode/settings.json b/.vscode/settings.json -new file mode 100644 -index 0000000..b5431d3 ---- /dev/null -+++ b/.vscode/settings.json -@@ -0,0 +1,6 @@ -+{ -+ "editor.formatOnSave": false, -+ "files.associations": { -+ "termios.h": "c" -+ }, -+} -\ No newline at end of file -diff --git a/src/nyancat.c b/src/nyancat.c -index 537225c..af77e5b 100644 ---- a/src/nyancat.c -+++ b/src/nyancat.c -@@ -67,9 +67,7 @@ - - #include - --#ifndef TIOCGWINSZ - #include --#endif - - #ifdef ECHO - #undef ECHO --- -2.25.1 - diff --git a/patches/openssl/0001-openssl-aero-specific-changes.patch b/patches/openssl/jinx-working-patch.patch similarity index 58% rename from patches/openssl/0001-openssl-aero-specific-changes.patch rename to patches/openssl/jinx-working-patch.patch index 46029c9a7f0..8f76a3937b7 100644 --- a/patches/openssl/0001-openssl-aero-specific-changes.patch +++ b/patches/openssl/jinx-working-patch.patch @@ -1,45 +1,20 @@ -From 1ddd02965f0a65b5c59e8b152229b2b88517ae2b Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Tue, 28 Jun 2022 17:33:52 +1000 -Subject: [PATCH] openssl: aero specific changes - -Signed-off-by: Andy-Python-Programmer ---- - .gitignore | 3 +++ - Configurations/10-main.conf | 33 +++++++++++++++++++++++++++++++++ - Configure | 15 +-------------- - apps/speed.c | 2 ++ - test/rsa_complex.c | 4 +++- - 5 files changed, 42 insertions(+), 15 deletions(-) - -diff --git a/.gitignore b/.gitignore -index b7bee656..673368bd 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -184,3 +184,6 @@ pod2htmd.tmp - # Windows manifest files - *.manifest - doc-nits -+ -+# editor configs: -+.vscode -diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf -index 8ca8235e..414fe92b 100644 ---- a/Configurations/10-main.conf -+++ b/Configurations/10-main.conf -@@ -918,6 +918,39 @@ my %targets = ( +diff --git openssl-clean/Configurations/10-main.conf openssl-workdir/Configurations/10-main.conf +index f815a09..d403653 100644 +--- openssl-clean/Configurations/10-main.conf ++++ openssl-workdir/Configurations/10-main.conf +@@ -925,6 +925,40 @@ my %targets = ( ranlib => "true", }, -+#### Aero ++#### Aero + "aero-generic64" => { + inherit_from => [ "BASE_unix" ], + CFLAGS => picker(default => "-Wall", -+ debug => "-O0 -g", -+ release => "-O3"), ++ debug => "-O0 -g", ++ release => "-O3"), + CXXFLAGS => picker(default => "-Wall", -+ debug => "-O0 -g", -+ release => "-O3"), ++ debug => "-O0 -g", ++ release => "-O3"), + cxxflags => add("-std=c++11"), + lib_cppflags => combine("-DOPENSSL_USE_NODELETE", "-DL_ENDIAN"), + bn_ops => "SIXTY_FOUR_BIT_LONG RC4_CHAR", @@ -52,25 +27,26 @@ index 8ca8235e..414fe92b 100644 + }, + + # This breaks the usual configuration naming convention but it's more -+ # convenient for us, since it matches the target triples. ++ # convenient for us, since it matches the target triples + + "x86_64-aero" => { + inherit_from => [ "aero-generic64", asm("x86_64_asm") ], + perlasm_scheme => "elf", + + # Configure doesn't want to play nice and passes "--cross-compile-suffix" -+ # on to the GCC invocation. ++ # on to the GCC invocation + CC => "x86_64-aero-gcc", + CXX => "x86_64-aero-g++", ++ + }, + #### *BSD "BSD-generic32" => { # As for thread cflag. Idea is to maintain "collective" set of -diff --git a/Configure b/Configure -index 4bea49d7..964793fe 100755 ---- a/Configure -+++ b/Configure +diff --git openssl-clean/Configure openssl-workdir/Configure +index 78cc15d..2d3fb3e 100755 +--- openssl-clean/Configure ++++ openssl-workdir/Configure @@ -1549,20 +1549,7 @@ unless ($disabled{"crypto-mdebug-backtrace"}) unless ($disabled{afalgeng}) { $config{afalgeng}=""; @@ -93,10 +69,10 @@ index 4bea49d7..964793fe 100755 } else { disable('not-linux', 'afalgeng'); } -diff --git a/apps/speed.c b/apps/speed.c -index 89bf1848..74322241 100644 ---- a/apps/speed.c -+++ b/apps/speed.c +diff --git openssl-clean/apps/speed.c openssl-workdir/apps/speed.c +index 89bf184..7432224 100644 +--- openssl-clean/apps/speed.c ++++ openssl-workdir/apps/speed.c @@ -113,6 +113,8 @@ # define NO_FORK #endif @@ -106,21 +82,33 @@ index 89bf1848..74322241 100644 #define MAX_MISALIGNMENT 63 #define MAX_ECDH_SIZE 256 #define MISALIGN 64 -diff --git a/test/rsa_complex.c b/test/rsa_complex.c -index fac58125..4c7aeeef 100644 ---- a/test/rsa_complex.c -+++ b/test/rsa_complex.c +diff --git openssl-clean/crypto/mem_sec.c openssl-workdir/crypto/mem_sec.c +index 222c786..edb5192 100644 +--- openssl-clean/crypto/mem_sec.c ++++ openssl-workdir/crypto/mem_sec.c +@@ -492,8 +492,10 @@ static int sh_init(size_t size, int minsize) + ret = 2; + #endif + #ifdef MADV_DONTDUMP ++/* + if (madvise(sh.arena, sh.arena_size, MADV_DONTDUMP) < 0) + ret = 2; ++*/ + #endif + + return ret; +diff --git openssl-clean/test/rsa_complex.c openssl-workdir/test/rsa_complex.c +index fac5812..a23670d 100644 +--- openssl-clean/test/rsa_complex.c ++++ openssl-workdir/test/rsa_complex.c @@ -14,7 +14,9 @@ */ #if defined(__STDC_VERSION__) # if __STDC_VERSION__ >= 199901L -# include -+# if !defined(__aero) ++# if !defined(__aero__) +# include +# endif # endif #endif #include --- -2.25.1 - diff --git a/patches/python/python.patch b/patches/python/python.patch deleted file mode 100644 index b30d30cddac..00000000000 --- a/patches/python/python.patch +++ /dev/null @@ -1,81 +0,0 @@ -From d413109d47cba4c05c48ff959850bef39bd1630e Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Sun, 2 Jan 2022 13:01:40 +1100 -Subject: [PATCH] config: add aero target - -Signed-off-by: Andy-Python-Programmer ---- - config.sub | 2 +- - configure.ac | 15 ++++++++++++++- - 2 files changed, 15 insertions(+), 2 deletions(-) - -diff --git a/config.sub b/config.sub -index ba37cf9..cea962e 100755 ---- a/config.sub -+++ b/config.sub -@@ -1394,7 +1394,7 @@ case $os in - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ - | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox* | -bme* \ -- | -midnightbsd*) -+ | -midnightbsd* | -aero*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - -qnx*) -diff --git a/configure.ac b/configure.ac -index e57ef7c..d686b36 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -379,6 +379,9 @@ then - *-*-cygwin*) - ac_sys_system=Cygwin - ;; -+ *-*-aero*) -+ ac_sys_system=Aero -+ ;; - *-*-vxworks*) - ac_sys_system=VxWorks - ;; -@@ -431,6 +434,9 @@ if test "$cross_compiling" = yes; then - *-*-vxworks*) - _host_cpu=$host_cpu - ;; -+ *-*-aero*) -+ _host_cpu=$host_cpu -+ ;; - *) - # for now, limit cross builds to known configurations - MACHDEP="unknown" -@@ -2641,6 +2647,9 @@ then - CYGWIN*) - LDSHARED="gcc -shared -Wl,--enable-auto-image-base" - LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";; -+ Aero*) -+ LDSHARED='$(CC) -shared' -+ LDCXXSHARED='$(CXX) -shared';; - *) LDSHARED="ld";; - esac - fi -@@ -2677,7 +2686,9 @@ then - else CCSHARED="-Kpic -belf" - fi;; - VxWorks*) -- CCSHARED="-fpic -D__SO_PICABILINUX__ -ftls-model=global-dynamic" -+ CCSHARED="-fpic -D__SO_PICABILINUX__ -ftls-model=global-dynamic";; -+ Aero*) -+ CCSHARED="-fPIC";; - esac - fi - AC_MSG_RESULT($CCSHARED) -@@ -2738,6 +2749,8 @@ then - LINKFORSHARED='-Wl,-E -N 2048K';; - VxWorks*) - LINKFORSHARED='--export-dynamic';; -+ Aero*) -+ LINKFORSHARED='-export-dynamic';; - esac - fi - AC_MSG_RESULT($LINKFORSHARED) --- -2.25.1 - diff --git a/patches/quickjs/quickjs.patch b/patches/quickjs/quickjs.patch deleted file mode 100644 index c348b716ebb..00000000000 --- a/patches/quickjs/quickjs.patch +++ /dev/null @@ -1,86 +0,0 @@ -From e6336a3d82e80205e1dd91dc08cf92e7d40393a5 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Thu, 13 Jan 2022 14:53:32 +1100 -Subject: [PATCH] aero specific changes - -Signed-off-by: Andy-Python-Programmer ---- - .vscode/settings.json | 3 +++ - qjs.c | 4 ++++ - quickjs-libc.c | 4 ++++ - quickjs.c | 4 ++++ - 4 files changed, 15 insertions(+) - create mode 100644 .vscode/settings.json - -diff --git a/.vscode/settings.json b/.vscode/settings.json -new file mode 100644 -index 0000000..560faaa ---- /dev/null -+++ b/.vscode/settings.json -@@ -0,0 +1,3 @@ -+{ -+ "editor.formatOnSave": false, -+} -\ No newline at end of file -diff --git a/qjs.c b/qjs.c -index d56b843..de8308a 100644 ---- a/qjs.c -+++ b/qjs.c -@@ -148,6 +148,8 @@ static inline size_t js_trace_malloc_usable_size(void *ptr) - return _msize(ptr); - #elif defined(EMSCRIPTEN) - return 0; -+#elif defined(__aero__) -+ return 0; // TODO: (Aero): This is totally wrong. - #elif defined(__linux__) - return malloc_usable_size(ptr); - #else -@@ -270,6 +272,8 @@ static const JSMallocFunctions trace_mf = { - (size_t (*)(const void *))_msize, - #elif defined(EMSCRIPTEN) - NULL, -+#elif defined(__aero__) -+ NULL, // TODO: (Aero): This is totally wrong. - #elif defined(__linux__) - (size_t (*)(const void *))malloc_usable_size, - #else -diff --git a/quickjs-libc.c b/quickjs-libc.c -index e180dd0..45313fd 100644 ---- a/quickjs-libc.c -+++ b/quickjs-libc.c -@@ -57,6 +57,10 @@ typedef sig_t sighandler_t; - - #endif - -+#if defined(__aero__) -+typedef void (*sighandler_t)(int); -+#endif -+ - #if !defined(_WIN32) - /* enable the os.Worker API. IT relies on POSIX threads */ - #define USE_WORKER -diff --git a/quickjs.c b/quickjs.c -index 48aeffc..8922b67 100644 ---- a/quickjs.c -+++ b/quickjs.c -@@ -1682,6 +1682,8 @@ static inline size_t js_def_malloc_usable_size(void *ptr) - return _msize(ptr); - #elif defined(EMSCRIPTEN) - return 0; -+#elif defined(__aero__) -+ return 0; // TODO: (Aero) this is totally wrong :^) - #elif defined(__linux__) - return malloc_usable_size(ptr); - #else -@@ -1756,6 +1758,8 @@ static const JSMallocFunctions def_malloc_funcs = { - (size_t (*)(const void *))_msize, - #elif defined(EMSCRIPTEN) - NULL, -+#elif defined(__aero__) -+ NULL, // TODO: (Aero) this is totally wrong :^) - #elif defined(__linux__) - (size_t (*)(const void *))malloc_usable_size, - #else --- -2.25.1 - diff --git a/patches/readline/jinx-working-patch.patch b/patches/readline/jinx-working-patch.patch new file mode 100644 index 00000000000..7de35244a74 --- /dev/null +++ b/patches/readline/jinx-working-patch.patch @@ -0,0 +1,22 @@ +diff --git readline-clean/support/shlib-install readline-workdir/support/shlib-install +index 661355d..cd7d659 100755 +--- readline-clean/support/shlib-install ++++ readline-workdir/support/shlib-install +@@ -71,7 +71,7 @@ fi + # Cygwin installs both a dll (which must go in $BINDIR) and an implicit + # link library (in $libdir) + case "$host_os" in +-hpux*|darwin*|macosx*|linux*|solaris2*) ++hpux*|darwin*|macosx*|linux*|solaris2*|aero*) + if [ -z "$uninstall" ]; then + chmod 755 ${INSTALLDIR}/${LIBNAME} + fi ;; +@@ -146,7 +146,7 @@ bsdi4*|*gnu*|darwin*|macosx*|netbsd*|mirbsd*) + fi + ;; + +-solaris2*|aix4.[2-9]*|aix[5-9]*|osf*|irix[56]*|sysv[45]*|dgux*|interix*) ++solaris2*|aix4.[2-9]*|aix[5-9]*|osf*|irix[56]*|sysv[45]*|dgux*|interix*|aero*) + # libname.so -> libname.so.M + ${echo} ${RM} ${INSTALLDIR}/$LINK1 + if [ -z "$uninstall" ]; then diff --git a/patches/readline/readline.patch b/patches/readline/readline.patch deleted file mode 100644 index 0c24ca877c0..00000000000 --- a/patches/readline/readline.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 983b779d546a3e7657a46e46ec3946083420c14a Mon Sep 17 00:00:00 2001 -From: Dennis Bonke -Date: Tue, 9 Feb 2021 22:36:49 +0100 -Subject: [PATCH] Add Aero support - -Signed-off-by: Dennis Bonke ---- - support/config.sub | 2 +- - support/shlib-install | 4 ++-- - 2 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/support/config.sub b/support/config.sub -index c874b7a..58e7639 100755 ---- a/support/config.sub -+++ b/support/config.sub -@@ -1720,7 +1720,7 @@ case $os in - | skyos* | haiku* | rdos* | toppers* | drops* | es* \ - | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ - | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ -- | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx*) -+ | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | aero*) - ;; - # This one is extra strict with allowed versions - sco3.2v2 | sco3.2v[4-9]* | sco5v6*) -diff --git a/support/shlib-install b/support/shlib-install -index 661355d..2d554f3 100755 ---- a/support/shlib-install -+++ b/support/shlib-install -@@ -71,7 +71,7 @@ fi - # Cygwin installs both a dll (which must go in $BINDIR) and an implicit - # link library (in $libdir) - case "$host_os" in --hpux*|darwin*|macosx*|linux*|solaris2*) -+hpux*|darwin*|macosx*|linux*|solaris2*|*aero*) - if [ -z "$uninstall" ]; then - chmod 755 ${INSTALLDIR}/${LIBNAME} - fi ;; -@@ -146,7 +146,7 @@ bsdi4*|*gnu*|darwin*|macosx*|netbsd*|mirbsd*) - fi - ;; - --solaris2*|aix4.[2-9]*|aix[5-9]*|osf*|irix[56]*|sysv[45]*|dgux*|interix*) -+solaris2*|aix4.[2-9]*|aix[5-9]*|osf*|irix[56]*|sysv[45]*|dgux*|interix*|*aero*) - # libname.so -> libname.so.M - ${echo} ${RM} ${INSTALLDIR}/$LINK1 - if [ -z "$uninstall" ]; then --- -2.30.0 diff --git a/patches/rust-getrandom/rust-getrandom.patch b/patches/rust-getrandom/rust-getrandom.patch deleted file mode 100644 index 9b244bc8249..00000000000 --- a/patches/rust-getrandom/rust-getrandom.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 7ffdb350f8bf10017165131c8433e8371df89754 Mon Sep 17 00:00:00 2001 -From: Dennis Bonke -Date: Mon, 7 Aug 2023 16:07:20 +0200 -Subject: [PATCH] Add aero support - -Signed-off-by: Dennis Bonke ---- - src/lib.rs | 2 +- - src/use_file.rs | 1 + - src/util_libc.rs | 2 +- - 3 files changed, 3 insertions(+), 2 deletions(-) - -diff --git a/src/lib.rs b/src/lib.rs -index 931856f..e700572 100644 ---- a/src/lib.rs -+++ b/src/lib.rs -@@ -215,7 +215,7 @@ pub use crate::error::Error; - // The function MUST NOT ever write uninitialized bytes into `dest`, - // regardless of what value it returns. - cfg_if! { -- if #[cfg(any(target_os = "haiku", target_os = "redox", target_os = "nto", target_os = "aix"))] { -+ if #[cfg(any(target_os = "haiku", target_os = "redox", target_os = "nto", target_os = "aix", target_os = "aero"))] { - mod util_libc; - #[path = "use_file.rs"] mod imp; - } else if #[cfg(any(target_os = "android", target_os = "linux"))] { -diff --git a/src/use_file.rs b/src/use_file.rs -index a6ef0d2..ef9bf54 100644 ---- a/src/use_file.rs -+++ b/src/use_file.rs -@@ -33,6 +33,7 @@ const FILE_PATH: &str = "/dev/random\0"; - target_os = "haiku", - target_os = "macos", - target_os = "nto", -+ target_os = "aero", - ))] - const FILE_PATH: &str = "/dev/urandom\0"; - -diff --git a/src/util_libc.rs b/src/util_libc.rs -index de1455c..65bc1a6 100644 ---- a/src/util_libc.rs -+++ b/src/util_libc.rs -@@ -19,7 +19,7 @@ use libc::c_void; - cfg_if! { - if #[cfg(any(target_os = "netbsd", target_os = "openbsd", target_os = "android"))] { - use libc::__errno as errno_location; -- } else if #[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "redox"))] { -+ } else if #[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "redox", target_os = "aero"))] { - use libc::__errno_location as errno_location; - } else if #[cfg(any(target_os = "solaris", target_os = "illumos"))] { - use libc::___errno as errno_location; --- -2.42.0 - diff --git a/patches/rust-glutin/rust-glutin.patch b/patches/rust-glutin/rust-glutin.patch deleted file mode 100644 index b472d33e744..00000000000 --- a/patches/rust-glutin/rust-glutin.patch +++ /dev/null @@ -1,331 +0,0 @@ -From b9cdd46f1acb5a6dd84b08f782f1c01ea40eb23c Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Sun, 11 Dec 2022 16:27:48 +1100 -Subject: [PATCH] - ---- - glutin/Cargo.toml | 2 +- - glutin/src/api/dlloader.rs | 1 + - glutin/src/api/egl/mod.rs | 6 ++++++ - glutin/src/api/glx/mod.rs | 7 ++++++- - glutin/src/api/osmesa/mod.rs | 1 + - glutin/src/lib.rs | 16 ++++++++++------ - glutin/src/platform/mod.rs | 1 + - glutin/src/platform/unix.rs | 1 + - glutin/src/platform_impl/mod.rs | 1 + - glutin/src/platform_impl/unix/mod.rs | 1 + - glutin/src/windowed.rs | 2 ++ - glutin_egl_sys/build.rs | 1 + - glutin_egl_sys/src/lib.rs | 2 ++ - glutin_glx_sys/Cargo.toml | 2 +- - glutin_glx_sys/build.rs | 1 + - glutin_glx_sys/src/lib.rs | 1 + - 16 files changed, 37 insertions(+), 9 deletions(-) - -diff --git a/glutin/Cargo.toml b/glutin/Cargo.toml -index ddd23ee..d3c2eac 100644 ---- a/glutin/Cargo.toml -+++ b/glutin/Cargo.toml -@@ -56,7 +56,7 @@ glutin_wgl_sys = { version = "0.1.5", path = "../glutin_wgl_sys" } - glutin_egl_sys = { version = "0.1.5", path = "../glutin_egl_sys" } - parking_lot = "0.11" - --[target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd"))'.dependencies] -+[target.'cfg(any(target_os = "linux", target_os = "aero", target_os = "freebsd", target_os = "dragonfly", target_os = "netbsd", target_os = "openbsd"))'.dependencies] - osmesa-sys = "0.1" - wayland-client = { version = "0.29", features = ["dlopen"], optional = true } - wayland-egl = { version = "0.29", optional = true } -diff --git a/glutin/src/api/dlloader.rs b/glutin/src/api/dlloader.rs -index 9cfba93..8b3d93e 100644 ---- a/glutin/src/api/dlloader.rs -+++ b/glutin/src/api/dlloader.rs -@@ -1,6 +1,7 @@ - #![cfg(any( - target_os = "windows", - target_os = "linux", -+ target_os = "aero", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", -diff --git a/glutin/src/api/egl/mod.rs b/glutin/src/api/egl/mod.rs -index d567678..de59a09 100644 ---- a/glutin/src/api/egl/mod.rs -+++ b/glutin/src/api/egl/mod.rs -@@ -1,6 +1,7 @@ - #![cfg(any( - target_os = "windows", - target_os = "linux", -+ target_os = "aero", - target_os = "android", - target_os = "dragonfly", - target_os = "freebsd", -@@ -121,6 +122,7 @@ use parking_lot::Mutex; - target_os = "android", - target_os = "windows", - target_os = "linux", -+ target_os = "aero", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", -@@ -773,6 +775,7 @@ pub struct ContextPrototype<'a> { - #[cfg(any( - target_os = "linux", - target_os = "dragonfly", -+ target_os = "aero", - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd", -@@ -804,6 +807,7 @@ impl<'a> ContextPrototype<'a> { - #[cfg(any( - target_os = "linux", - target_os = "dragonfly", -+ target_os = "aero", - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd", -@@ -829,6 +833,7 @@ impl<'a> ContextPrototype<'a> { - - #[cfg(any( - target_os = "linux", -+ target_os = "aero", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", -@@ -847,6 +852,7 @@ impl<'a> ContextPrototype<'a> { - #[cfg(any( - target_os = "android", - target_os = "windows", -+ target_os = "aero", - target_os = "linux", - target_os = "dragonfly", - target_os = "freebsd", -diff --git a/glutin/src/api/glx/mod.rs b/glutin/src/api/glx/mod.rs -index 61968e6..e5876a3 100644 ---- a/glutin/src/api/glx/mod.rs -+++ b/glutin/src/api/glx/mod.rs -@@ -1,5 +1,6 @@ - #![cfg(any( - target_os = "linux", -+ target_os = "aero", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", -@@ -409,7 +410,11 @@ impl<'a> ContextPrototype<'a> { - unsafe { - extra_functions.SwapIntervalSGI(swap_mode); - } -- } else { -+ } else if self.opengl.vsync { -+ // If vsync was not requested and it is not supported on the system, -+ // then this feature can safely be ignored. -+ // -+ // cc - return Err(CreationError::OsError( - "Couldn't find any available vsync extension".to_string(), - )); -diff --git a/glutin/src/api/osmesa/mod.rs b/glutin/src/api/osmesa/mod.rs -index 89c0765..80cc2cd 100644 ---- a/glutin/src/api/osmesa/mod.rs -+++ b/glutin/src/api/osmesa/mod.rs -@@ -1,5 +1,6 @@ - #![cfg(any( - target_os = "linux", -+ target_os = "aero", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", -diff --git a/glutin/src/lib.rs b/glutin/src/lib.rs -index 7ee1522..ff9d6f0 100644 ---- a/glutin/src/lib.rs -+++ b/glutin/src/lib.rs -@@ -43,6 +43,7 @@ - #![cfg_attr( - not(any( - target_os = "linux", -+ target_os = "aero", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", -@@ -56,6 +57,7 @@ - #![cfg_attr( - any( - target_os = "linux", -+ target_os = "aero", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", -@@ -73,6 +75,7 @@ - #[cfg(any( - target_os = "windows", - target_os = "linux", -+ target_os = "aero", - target_os = "android", - target_os = "dragonfly", - target_os = "freebsd", -@@ -298,6 +301,7 @@ pub enum CreationError { - impl CreationError { - #[cfg(any( - target_os = "linux", -+ target_os = "aero", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", -@@ -598,16 +602,16 @@ impl Default for PixelFormatRequirements { - #[inline] - fn default() -> PixelFormatRequirements { - PixelFormatRequirements { -- hardware_accelerated: Some(true), -- color_bits: Some(24), -+ hardware_accelerated: None, -+ color_bits: None, - float_color_buffer: false, -- alpha_bits: Some(8), -- depth_bits: Some(24), -- stencil_bits: Some(8), -+ alpha_bits: None, -+ depth_bits: None, -+ stencil_bits: None, - double_buffer: None, - multisampling: None, - stereoscopy: false, -- srgb: true, -+ srgb: false, - release_behavior: ReleaseBehavior::Flush, - x11_visual_xid: None, - } -diff --git a/glutin/src/platform/mod.rs b/glutin/src/platform/mod.rs -index e508519..c83423b 100644 ---- a/glutin/src/platform/mod.rs -+++ b/glutin/src/platform/mod.rs -@@ -25,6 +25,7 @@ pub mod run_return { - target_os = "windows", - target_os = "macos", - target_os = "linux", -+ target_os = "aero", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", -diff --git a/glutin/src/platform/unix.rs b/glutin/src/platform/unix.rs -index 66aed2c..9128e23 100644 ---- a/glutin/src/platform/unix.rs -+++ b/glutin/src/platform/unix.rs -@@ -1,5 +1,6 @@ - #![cfg(any( - target_os = "linux", -+ target_os = "aero", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", -diff --git a/glutin/src/platform_impl/mod.rs b/glutin/src/platform_impl/mod.rs -index 82affa7..7559367 100644 ---- a/glutin/src/platform_impl/mod.rs -+++ b/glutin/src/platform_impl/mod.rs -@@ -5,6 +5,7 @@ pub use self::platform_impl::*; - mod platform_impl; - #[cfg(any( - target_os = "linux", -+ target_os = "aero", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", -diff --git a/glutin/src/platform_impl/unix/mod.rs b/glutin/src/platform_impl/unix/mod.rs -index 510ec9c..423fc85 100644 ---- a/glutin/src/platform_impl/unix/mod.rs -+++ b/glutin/src/platform_impl/unix/mod.rs -@@ -1,5 +1,6 @@ - #![cfg(any( - target_os = "linux", -+ target_os = "aero", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", -diff --git a/glutin/src/windowed.rs b/glutin/src/windowed.rs -index b603918..00a1029 100644 ---- a/glutin/src/windowed.rs -+++ b/glutin/src/windowed.rs -@@ -57,6 +57,7 @@ pub type WindowedContext = ContextWrapper; - #[cfg_attr( - not(any( - target_os = "linux", -+ target_os = "aero", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", -@@ -70,6 +71,7 @@ pub type WindowedContext = ContextWrapper; - any( - target_os = "linux", - target_os = "dragonfly", -+ target_os = "aero", - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd", -diff --git a/glutin_egl_sys/build.rs b/glutin_egl_sys/build.rs -index 2920f3b..6017f1d 100644 ---- a/glutin_egl_sys/build.rs -+++ b/glutin_egl_sys/build.rs -@@ -11,6 +11,7 @@ fn main() { - - if target.contains("linux") - || target.contains("dragonfly") -+ || target.contains("aero") - || target.contains("freebsd") - || target.contains("netbsd") - || target.contains("openbsd") -diff --git a/glutin_egl_sys/src/lib.rs b/glutin_egl_sys/src/lib.rs -index fac07d2..115899d 100644 ---- a/glutin_egl_sys/src/lib.rs -+++ b/glutin_egl_sys/src/lib.rs -@@ -3,6 +3,7 @@ - target_os = "linux", - target_os = "android", - target_os = "dragonfly", -+ target_os = "aero", - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd" -@@ -44,6 +45,7 @@ pub type EGLNativeWindowType = *const raw::c_void; - pub type EGLNativeWindowType = *const raw::c_void; - #[cfg(any( - target_os = "dragonfly", -+ target_os = "aero", - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd" -diff --git a/glutin_glx_sys/Cargo.toml b/glutin_glx_sys/Cargo.toml -index a919dec..03f2d9f 100644 ---- a/glutin_glx_sys/Cargo.toml -+++ b/glutin_glx_sys/Cargo.toml -@@ -12,5 +12,5 @@ edition = "2018" - [build-dependencies] - gl_generator = "0.14" - --[target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os="dragonfly", target_os="netbsd", target_os="openbsd"))'.dependencies] -+[target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os = "aero", target_os="dragonfly", target_os="netbsd", target_os="openbsd"))'.dependencies] - x11-dl = "2.18.3" -diff --git a/glutin_glx_sys/build.rs b/glutin_glx_sys/build.rs -index 21e1cb3..dff1bfc 100644 ---- a/glutin_glx_sys/build.rs -+++ b/glutin_glx_sys/build.rs -@@ -11,6 +11,7 @@ fn main() { - - if target.contains("linux") - || target.contains("dragonfly") -+ || target.contains("aero") - || target.contains("freebsd") - || target.contains("netbsd") - || target.contains("openbsd") -diff --git a/glutin_glx_sys/src/lib.rs b/glutin_glx_sys/src/lib.rs -index fadb62a..6aa9cc2 100644 ---- a/glutin_glx_sys/src/lib.rs -+++ b/glutin_glx_sys/src/lib.rs -@@ -1,6 +1,7 @@ - #![cfg(any( - target_os = "linux", - target_os = "dragonfly", -+ target_os = "aero", - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd" --- -2.38.1 - diff --git a/patches/rust-host/jinx-working-patch.patch b/patches/rust-host/jinx-working-patch.patch new file mode 100644 index 00000000000..84643abf5f3 --- /dev/null +++ b/patches/rust-host/jinx-working-patch.patch @@ -0,0 +1,531 @@ +diff --git rust-host-clean/Cargo.toml rust-host-workdir/Cargo.toml +index 9b11ae8..2d310ce 100644 +--- rust-host-clean/Cargo.toml ++++ rust-host-workdir/Cargo.toml +@@ -110,6 +110,7 @@ object.debug = 0 + rustc-std-workspace-core = { path = 'library/rustc-std-workspace-core' } + rustc-std-workspace-alloc = { path = 'library/rustc-std-workspace-alloc' } + rustc-std-workspace-std = { path = 'library/rustc-std-workspace-std' } ++libc = { path = "/base_dir/sources/rust-libc" } + + [patch."https://github.com/rust-lang/rust-clippy"] + clippy_lints = { path = "src/tools/clippy/clippy_lints" } +diff --git rust-host-workdir/compiler/rustc_target/src/spec/base/aero.rs rust-host-workdir/compiler/rustc_target/src/spec/base/aero.rs +new file mode 100644 +index 0000000..1237a43 +--- /dev/null ++++ rust-host-workdir/compiler/rustc_target/src/spec/base/aero.rs +@@ -0,0 +1,34 @@ ++use crate::spec::{cvs, LinkArgs, LinkerFlavor, RelroLevel, TargetOptions, Cc, Lld}; ++ ++pub fn opts() -> TargetOptions { ++ let mut args = LinkArgs::new(); ++ args.insert( ++ LinkerFlavor::Gnu(Cc::Yes, Lld::No), ++ vec![ ++ // We want to be able to strip as much executable code as possible ++ // from the linker command line, and this flag indicates to the ++ // linker that it can avoid linking in dynamic libraries that don't ++ // actually satisfy any symbols up to that point (as with many other ++ // resolutions the linker does). This option only applies to all ++ // following libraries so we're sure to pass it as one of the first ++ // arguments. ++ "-Wl,--as-needed".into(), ++ // Always enable NX protection when it is available ++ "-Wl,-z,noexecstack".into(), ++ ], ++ ); ++ ++ TargetOptions { ++ os: "aero".into(), ++ dynamic_linking: true, ++ executables: true, ++ families: cvs!["unix"], ++ has_rpath: true, ++ pre_link_args: args, ++ position_independent_executables: true, ++ relro_level: RelroLevel::Full, ++ has_thread_local: true, ++ crt_static_respected: true, ++ ..Default::default() ++ } ++} +diff --git rust-host-clean/compiler/rustc_target/src/spec/base/mod.rs rust-host-workdir/compiler/rustc_target/src/spec/base/mod.rs +index d137aaa..6f52f4a 100644 +--- rust-host-clean/compiler/rustc_target/src/spec/base/mod.rs ++++ rust-host-workdir/compiler/rustc_target/src/spec/base/mod.rs +@@ -1,3 +1,4 @@ ++pub(crate) mod aero; + pub(crate) mod aix; + pub(crate) mod android; + pub(crate) mod apple; +diff --git rust-host-clean/compiler/rustc_target/src/spec/mod.rs rust-host-workdir/compiler/rustc_target/src/spec/mod.rs +index f047994..83be01f 100644 +--- rust-host-clean/compiler/rustc_target/src/spec/mod.rs ++++ rust-host-workdir/compiler/rustc_target/src/spec/mod.rs +@@ -1556,6 +1556,8 @@ supported_targets! { + ("x86_64-fuchsia", x86_64_fuchsia), + ("x86_64-unknown-fuchsia", x86_64_unknown_fuchsia), + ++ ("x86_64-unknown-aero", x86_64_unknown_aero), ++ + ("avr-unknown-gnu-atmega328", avr_unknown_gnu_atmega328), + + ("x86_64-unknown-l4re-uclibc", x86_64_unknown_l4re_uclibc), +diff --git rust-host-workdir/compiler/rustc_target/src/spec/targets/x86_64_unknown_aero.rs rust-host-workdir/compiler/rustc_target/src/spec/targets/x86_64_unknown_aero.rs +new file mode 100644 +index 0000000..b88491e +--- /dev/null ++++ rust-host-workdir/compiler/rustc_target/src/spec/targets/x86_64_unknown_aero.rs +@@ -0,0 +1,20 @@ ++use crate::spec::{base, LinkerFlavor, StackProbeType, Target, Cc, Lld}; ++ ++pub fn target() -> Target { ++ let mut base = base::aero::opts(); ++ base.cpu = "x86-64".into(); ++ base.max_atomic_width = Some(64); ++ base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); ++ // don't use probe-stack=inline-asm until rust-lang/rust#83139 is resolved. ++ base.stack_probes = StackProbeType::Call; ++ ++ Target { ++ // Should we use "aero" or "aero-mlibc" here? ++ llvm_target: "x86_64-aero".into(), ++ pointer_width: 64, ++ data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" ++ .into(), ++ arch: "x86_64".into(), ++ options: base, ++ } ++} +diff --git rust-host-clean/library/std/build.rs rust-host-workdir/library/std/build.rs +index ad0a82e..14488d7 100644 +--- rust-host-clean/library/std/build.rs ++++ rust-host-workdir/library/std/build.rs +@@ -4,6 +4,7 @@ fn main() { + println!("cargo:rerun-if-changed=build.rs"); + let target = env::var("TARGET").expect("TARGET was not set"); + if target.contains("linux") ++ || target.contains("aero") + || target.contains("netbsd") + || target.contains("dragonfly") + || target.contains("openbsd") +diff --git rust-host-workdir/library/std/src/os/aero/fs.rs rust-host-workdir/library/std/src/os/aero/fs.rs +new file mode 100644 +index 0000000..a3c953c +--- /dev/null ++++ rust-host-workdir/library/std/src/os/aero/fs.rs +@@ -0,0 +1,144 @@ ++#![stable(feature = "raw_ext", since = "1.1.0")] ++ ++use crate::fs::Metadata; ++use crate::sys_common::AsInner; ++ ++#[allow(deprecated)] ++use crate::os::aero::raw; ++ ++/// OS-specific extensions to [`fs::Metadata`]. ++/// ++/// [`fs::Metadata`]: crate::fs::Metadata ++#[stable(feature = "metadata_ext", since = "1.1.0")] ++pub trait MetadataExt { ++ /// Gain a reference to the underlying `stat` structure which contains ++ /// the raw information returned by the OS. ++ /// ++ /// The contents of the returned `stat` are **not** consistent across ++ /// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the ++ /// cross-Unix abstractions contained within the raw stat. ++ #[stable(feature = "metadata_ext", since = "1.1.0")] ++ #[deprecated(since = "1.8.0", note = "other methods of this trait are now preferred")] ++ #[allow(deprecated)] ++ fn as_raw_stat(&self) -> &raw::stat; ++ ++ #[stable(feature = "metadata_ext2", since = "1.8.0")] ++ fn st_dev(&self) -> u64; ++ ++ #[stable(feature = "metadata_ext2", since = "1.8.0")] ++ fn st_ino(&self) -> u64; ++ ++ #[stable(feature = "metadata_ext2", since = "1.8.0")] ++ fn st_mode(&self) -> u32; ++ ++ #[stable(feature = "metadata_ext2", since = "1.8.0")] ++ fn st_nlink(&self) -> u64; ++ ++ #[stable(feature = "metadata_ext2", since = "1.8.0")] ++ fn st_uid(&self) -> u32; ++ ++ #[stable(feature = "metadata_ext2", since = "1.8.0")] ++ fn st_gid(&self) -> u32; ++ ++ #[stable(feature = "metadata_ext2", since = "1.8.0")] ++ fn st_rdev(&self) -> u64; ++ ++ #[stable(feature = "metadata_ext2", since = "1.8.0")] ++ fn st_size(&self) -> u64; ++ ++ #[stable(feature = "metadata_ext2", since = "1.8.0")] ++ fn st_atime(&self) -> i64; ++ ++ #[stable(feature = "metadata_ext2", since = "1.8.0")] ++ fn st_atime_nsec(&self) -> i64; ++ ++ #[stable(feature = "metadata_ext2", since = "1.8.0")] ++ fn st_mtime(&self) -> i64; ++ ++ #[stable(feature = "metadata_ext2", since = "1.8.0")] ++ fn st_mtime_nsec(&self) -> i64; ++ ++ #[stable(feature = "metadata_ext2", since = "1.8.0")] ++ fn st_ctime(&self) -> i64; ++ ++ #[stable(feature = "metadata_ext2", since = "1.8.0")] ++ fn st_ctime_nsec(&self) -> i64; ++ ++ #[stable(feature = "metadata_ext2", since = "1.8.0")] ++ fn st_blksize(&self) -> u64; ++ ++ #[stable(feature = "metadata_ext2", since = "1.8.0")] ++ fn st_blocks(&self) -> u64; ++} ++ ++#[stable(feature = "metadata_ext", since = "1.1.0")] ++impl MetadataExt for Metadata { ++ #[allow(deprecated)] ++ fn as_raw_stat(&self) -> &raw::stat { ++ unsafe { &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat) } ++ } ++ ++ fn st_dev(&self) -> u64 { ++ self.as_inner().as_inner().st_dev as u64 ++ } ++ ++ fn st_ino(&self) -> u64 { ++ self.as_inner().as_inner().st_ino as u64 ++ } ++ ++ fn st_mode(&self) -> u32 { ++ self.as_inner().as_inner().st_mode as u32 ++ } ++ ++ fn st_nlink(&self) -> u64 { ++ self.as_inner().as_inner().st_nlink as u64 ++ } ++ ++ fn st_uid(&self) -> u32 { ++ self.as_inner().as_inner().st_uid as u32 ++ } ++ ++ fn st_gid(&self) -> u32 { ++ self.as_inner().as_inner().st_gid as u32 ++ } ++ ++ fn st_rdev(&self) -> u64 { ++ self.as_inner().as_inner().st_rdev as u64 ++ } ++ ++ fn st_size(&self) -> u64 { ++ self.as_inner().as_inner().st_size as u64 ++ } ++ ++ fn st_atime(&self) -> i64 { ++ self.as_inner().as_inner().st_atime as i64 ++ } ++ ++ fn st_atime_nsec(&self) -> i64 { ++ self.as_inner().as_inner().st_atime_nsec as i64 ++ } ++ ++ fn st_mtime(&self) -> i64 { ++ self.as_inner().as_inner().st_mtime as i64 ++ } ++ ++ fn st_mtime_nsec(&self) -> i64 { ++ self.as_inner().as_inner().st_mtime_nsec as i64 ++ } ++ ++ fn st_ctime(&self) -> i64 { ++ self.as_inner().as_inner().st_ctime as i64 ++ } ++ ++ fn st_ctime_nsec(&self) -> i64 { ++ self.as_inner().as_inner().st_ctime_nsec as i64 ++ } ++ ++ fn st_blksize(&self) -> u64 { ++ self.as_inner().as_inner().st_blksize as u64 ++ } ++ ++ fn st_blocks(&self) -> u64 { ++ self.as_inner().as_inner().st_blocks as u64 ++ } ++} +diff --git rust-host-workdir/library/std/src/os/aero/mod.rs rust-host-workdir/library/std/src/os/aero/mod.rs +new file mode 100644 +index 0000000..ea3291a +--- /dev/null ++++ rust-host-workdir/library/std/src/os/aero/mod.rs +@@ -0,0 +1,6 @@ ++//! Aero-specific definitions ++ ++#![stable(feature = "raw_ext", since = "1.1.0")] ++ ++pub mod fs; ++pub mod raw; +diff --git rust-host-workdir/library/std/src/os/aero/raw.rs rust-host-workdir/library/std/src/os/aero/raw.rs +new file mode 100644 +index 0000000..0569409 +--- /dev/null ++++ rust-host-workdir/library/std/src/os/aero/raw.rs +@@ -0,0 +1,76 @@ ++//! Aero-specific raw type definitions ++ ++#![stable(feature = "raw_ext", since = "1.1.0")] ++#![deprecated( ++ since = "1.8.0", ++ note = "these type aliases are no longer supported by \ ++ the standard library, the `libc` crate on \ ++ crates.io should be used instead for the correct \ ++ definitions" ++)] ++#![allow(deprecated)] ++ ++#[stable(feature = "pthread_t", since = "1.8.0")] ++pub type pthread_t = usize; // TODO: This is completely wrong tbh ++ ++#[stable(feature = "raw_ext", since = "1.1.0")] ++pub type dev_t = libc::dev_t; ++ ++#[stable(feature = "raw_ext", since = "1.1.0")] ++pub type ino_t = libc::ino_t; ++ ++#[stable(feature = "raw_ext", since = "1.1.0")] ++pub type mode_t = libc::mode_t; ++ ++#[stable(feature = "raw_ext", since = "1.1.0")] ++pub type nlink_t = libc::nlink_t; ++ ++#[stable(feature = "raw_ext", since = "1.1.0")] ++pub type off_t = libc::off_t; ++ ++#[stable(feature = "raw_ext", since = "1.1.0")] ++pub type time_t = libc::time_t; ++ ++#[stable(feature = "raw_ext", since = "1.1.0")] ++pub type blkcnt_t = libc::blkcnt_t; ++ ++#[stable(feature = "raw_ext", since = "1.1.0")] ++pub type blksize_t = libc::blksize_t; ++ ++#[repr(C)] ++#[derive(Clone)] ++#[stable(feature = "raw_ext", since = "1.1.0")] ++pub struct stat { ++ #[stable(feature = "raw_ext", since = "1.1.0")] ++ pub st_dev: libc::dev_t, ++ #[stable(feature = "raw_ext", since = "1.1.0")] ++ pub st_ino: libc::ino_t, ++ #[stable(feature = "raw_ext", since = "1.1.0")] ++ pub st_mode: libc::mode_t, ++ #[stable(feature = "raw_ext", since = "1.1.0")] ++ pub st_nlink: libc::nlink_t, ++ #[stable(feature = "raw_ext", since = "1.1.0")] ++ pub st_uid: libc::uid_t, ++ #[stable(feature = "raw_ext", since = "1.1.0")] ++ pub st_gid: libc::gid_t, ++ #[stable(feature = "raw_ext", since = "1.1.0")] ++ pub st_rdev: libc::dev_t, ++ #[stable(feature = "raw_ext", since = "1.1.0")] ++ pub st_size: libc::off_t, ++ #[stable(feature = "raw_ext", since = "1.1.0")] ++ pub st_atime: libc::time_t, ++ #[stable(feature = "raw_ext", since = "1.1.0")] ++ pub st_atime_nsec: libc::c_long, ++ #[stable(feature = "raw_ext", since = "1.1.0")] ++ pub st_mtime: libc::time_t, ++ #[stable(feature = "raw_ext", since = "1.1.0")] ++ pub st_mtime_nsec: libc::c_long, ++ #[stable(feature = "raw_ext", since = "1.1.0")] ++ pub st_ctime: libc::time_t, ++ #[stable(feature = "raw_ext", since = "1.1.0")] ++ pub st_ctime_nsec: libc::c_long, ++ #[stable(feature = "raw_ext", since = "1.1.0")] ++ pub st_blksize: libc::blksize_t, ++ #[stable(feature = "raw_ext", since = "1.1.0")] ++ pub st_blocks: libc::blkcnt_t, ++} +diff --git rust-host-clean/library/std/src/os/mod.rs rust-host-workdir/library/std/src/os/mod.rs +index 6e11b92..96ba192 100644 +--- rust-host-clean/library/std/src/os/mod.rs ++++ rust-host-workdir/library/std/src/os/mod.rs +@@ -113,6 +113,8 @@ pub mod fortanix_sgx; + pub mod freebsd; + #[cfg(target_os = "fuchsia")] + pub mod fuchsia; ++#[cfg(target_os = "aero")] ++pub mod aero; + #[cfg(target_os = "haiku")] + pub mod haiku; + #[cfg(target_os = "hermit")] +diff --git rust-host-clean/library/std/src/os/unix/mod.rs rust-host-workdir/library/std/src/os/unix/mod.rs +index 5ba8719..21d5e8d 100644 +--- rust-host-clean/library/std/src/os/unix/mod.rs ++++ rust-host-workdir/library/std/src/os/unix/mod.rs +@@ -37,6 +37,8 @@ use crate::os::linux as platform; + + #[cfg(not(doc))] + mod platform { ++ #[cfg(target_os = "aero")] ++ pub use crate::os::aero::*; + #[cfg(target_os = "aix")] + pub use crate::os::aix::*; + #[cfg(target_os = "android")] +@@ -95,7 +97,11 @@ pub mod process; + pub mod raw; + pub mod thread; + +-#[unstable(feature = "peer_credentials_unix_socket", issue = "42839", reason = "unstable")] ++#[unstable( ++ feature = "peer_credentials_unix_socket", ++ issue = "42839", ++ reason = "unstable" ++)] + #[cfg(any( + target_os = "android", + target_os = "linux", +diff --git rust-host-clean/library/std/src/sys/unix/args.rs rust-host-workdir/library/std/src/sys/unix/args.rs +index 2da17fa..a1bdb2c 100644 +--- rust-host-clean/library/std/src/sys/unix/args.rs ++++ rust-host-workdir/library/std/src/sys/unix/args.rs +@@ -73,6 +73,7 @@ impl DoubleEndedIterator for Args { + target_os = "aix", + target_os = "nto", + target_os = "hurd", ++ target_os = "aero", + ))] + mod imp { + use super::Args; +diff --git rust-host-clean/library/std/src/sys/unix/env.rs rust-host-workdir/library/std/src/sys/unix/env.rs +index 3bb492f..1a680fa 100644 +--- rust-host-clean/library/std/src/sys/unix/env.rs ++++ rust-host-workdir/library/std/src/sys/unix/env.rs +@@ -1,3 +1,14 @@ ++#[cfg(target_os = "aero")] ++pub mod os { ++ pub const FAMILY: &str = "unix"; ++ pub const OS: &str = "aero"; ++ pub const DLL_PREFIX: &str = "lib"; ++ pub const DLL_SUFFIX: &str = ".so"; ++ pub const DLL_EXTENSION: &str = ""; ++ pub const EXE_SUFFIX: &str = ""; ++ pub const EXE_EXTENSION: &str = ""; ++} ++ + #[cfg(target_os = "linux")] + pub mod os { + pub const FAMILY: &str = "unix"; +diff --git rust-host-clean/library/std/src/sys/unix/fs.rs rust-host-workdir/library/std/src/sys/unix/fs.rs +index 40eb910..994558c 100644 +--- rust-host-clean/library/std/src/sys/unix/fs.rs ++++ rust-host-workdir/library/std/src/sys/unix/fs.rs +@@ -954,6 +954,7 @@ impl DirEntry { + target_os = "aix", + target_os = "nto", + target_os = "hurd", ++ target_os = "aero", + ))] + pub fn ino(&self) -> u64 { + self.entry.d_ino as u64 +diff --git rust-host-clean/library/std/src/sys/unix/os.rs rust-host-workdir/library/std/src/sys/unix/os.rs +index dc3c037..0b405a8 100644 +--- rust-host-clean/library/std/src/sys/unix/os.rs ++++ rust-host-workdir/library/std/src/sys/unix/os.rs +@@ -40,7 +40,7 @@ cfg_if::cfg_if! { + } + + extern "C" { +- #[cfg(not(any(target_os = "dragonfly", target_os = "vxworks")))] ++ #[cfg(not(any(target_os = "dragonfly", target_os = "vxworks", target_os = "aero")))] + #[cfg_attr( + any( + target_os = "linux", +@@ -79,18 +79,46 @@ extern "C" { + } + + /// Returns the platform-specific value of errno +-#[cfg(not(any(target_os = "dragonfly", target_os = "vxworks")))] ++#[cfg(not(any(target_os = "dragonfly", target_os = "vxworks", target_os = "aero")))] + pub fn errno() -> i32 { + unsafe { (*errno_location()) as i32 } + } + + /// Sets the platform-specific value of errno +-#[cfg(all(not(target_os = "dragonfly"), not(target_os = "vxworks")))] // needed for readdir and syscall! ++#[cfg(all(not(target_os = "dragonfly"), not(target_os = "vxworks"), not(target_os = "aero")))] // needed for readdir and syscall! + #[allow(dead_code)] // but not all target cfgs actually end up using it + pub fn set_errno(e: i32) { + unsafe { *errno_location() = e as c_int } + } + ++#[cfg(target_os = "aero")] ++pub fn errno() -> i32 { ++ extern "C" { ++ #[thread_local] ++ static __mlibc_errno: c_int; ++ } ++ ++ unsafe { __mlibc_errno as i32 } ++} ++ ++#[cfg(target_os = "aero")] ++#[allow(dead_code)] ++pub fn set_errno(e: i32) { ++ extern "C" { ++ #[thread_local] ++ static mut __mlibc_errno: c_int; ++ } ++ ++ unsafe { ++ __mlibc_errno = e; ++ } ++} ++ ++#[cfg(target_os = "aero")] ++pub fn current_exe() -> io::Result { ++ unimplemented!() ++} ++ + #[cfg(target_os = "vxworks")] + pub fn errno() -> i32 { + unsafe { libc::errnoGet() } +diff --git rust-host-clean/library/std/src/sys/unix/thread.rs rust-host-workdir/library/std/src/sys/unix/thread.rs +index 29db946..d8b595d 100644 +--- rust-host-clean/library/std/src/sys/unix/thread.rs ++++ rust-host-workdir/library/std/src/sys/unix/thread.rs +@@ -116,6 +116,13 @@ impl Thread { + debug_assert_eq!(ret, 0); + } + ++ #[cfg(target_os = "aero")] ++ pub fn set_name(name: &CStr) { ++ unsafe { ++ libc::pthread_setname_np(libc::pthread_self(), name.as_ptr()); ++ } ++ } ++ + #[cfg(target_os = "android")] + pub fn set_name(name: &CStr) { + const PR_SET_NAME: libc::c_int = 15; +diff --git rust-host-clean/library/std/src/sys/unix/thread_local_dtor.rs rust-host-workdir/library/std/src/sys/unix/thread_local_dtor.rs +index 06399e8..297032e 100644 +--- rust-host-clean/library/std/src/sys/unix/thread_local_dtor.rs ++++ rust-host-workdir/library/std/src/sys/unix/thread_local_dtor.rs +@@ -12,7 +12,7 @@ + // compiling from a newer linux to an older linux, so we also have a + // fallback implementation to use as well. + #[allow(unexpected_cfgs)] +-#[cfg(any(target_os = "linux", target_os = "fuchsia", target_os = "redox", target_os = "hurd"))] ++#[cfg(any(target_os = "linux", target_os = "fuchsia", target_os = "redox", target_os = "hurd", target_os = "aero"))] + // FIXME: The Rust compiler currently omits weakly function definitions (i.e., + // __cxa_thread_atexit_impl) and its metadata from LLVM IR. + #[no_sanitize(cfi, kcfi)] diff --git a/patches/rust-libloading/rust-libloading.patch b/patches/rust-libloading/rust-libloading.patch deleted file mode 100644 index ac3ec05e6f1..00000000000 --- a/patches/rust-libloading/rust-libloading.patch +++ /dev/null @@ -1,50 +0,0 @@ -From f5fab150ee8fbfdef46888837b6e6d43fd3ec1c0 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Sun, 20 Nov 2022 13:39:51 +1100 -Subject: [PATCH] - ---- - src/os/unix/consts.rs | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/src/os/unix/consts.rs b/src/os/unix/consts.rs -index dbe4df9..fbdd2e3 100644 ---- a/src/os/unix/consts.rs -+++ b/src/os/unix/consts.rs -@@ -58,7 +58,7 @@ mod posix { - use self::cfg_if::cfg_if; - use super::c_int; - cfg_if! { -- if #[cfg(target_os = "haiku")] { -+ if #[cfg(any(target_os = "haiku", target_os = "aero"))] { - pub(super) const RTLD_LAZY: c_int = 0; - } else if #[cfg(any( - target_os = "linux", -@@ -90,7 +90,7 @@ mod posix { - } - - cfg_if! { -- if #[cfg(target_os = "haiku")] { -+ if #[cfg(any(target_os = "haiku", target_os = "aero"))] { - pub(super) const RTLD_NOW: c_int = 1; - } else if #[cfg(any( - target_os = "linux", -@@ -126,6 +126,7 @@ mod posix { - cfg_if! { - if #[cfg(any( - target_os = "haiku", -+ target_os = "aero", - all(target_os = "android",target_pointer_width = "32"), - ))] { - pub(super) const RTLD_GLOBAL: c_int = 2; -@@ -193,6 +194,7 @@ mod posix { - - target_os = "fuchsia", - target_os = "redox", -+ target_os = "aero", - ))] { - pub(super) const RTLD_LOCAL: c_int = 0; - } else { --- -2.38.1 - diff --git a/patches/rust-mio-0.6/rust-mio-0.6.patch b/patches/rust-mio-0.6/rust-mio-0.6.patch deleted file mode 100644 index 7b37510c61e..00000000000 --- a/patches/rust-mio-0.6/rust-mio-0.6.patch +++ /dev/null @@ -1,94 +0,0 @@ -From 1459849ab415fe1e9459b108a2908c22c8b1c029 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Sun, 20 Nov 2022 13:08:41 +1100 -Subject: [PATCH] - ---- - src/event_imp.rs | 10 ++++++---- - src/sys/unix/mod.rs | 2 ++ - src/sys/unix/ready.rs | 7 +++++-- - 3 files changed, 13 insertions(+), 6 deletions(-) - -diff --git a/src/event_imp.rs b/src/event_imp.rs -index f93e1fd..0109f74 100644 ---- a/src/event_imp.rs -+++ b/src/event_imp.rs -@@ -512,8 +512,9 @@ impl ops::Sub for PollOpt { - } - } - --#[deprecated(since = "0.6.10", note = "removed")] --#[cfg(feature = "with-deprecated")] -+// Hack: causes errors for us since this isn't upstream. -+// #[deprecated(since = "0.6.10", note = "removed")] -+// #[cfg(feature = "with-deprecated")] - #[doc(hidden)] - impl ops::Not for PollOpt { - type Output = PollOpt; -@@ -999,8 +1000,9 @@ impl> ops::SubAssign for Ready { - } - } - --#[deprecated(since = "0.6.10", note = "removed")] --#[cfg(feature = "with-deprecated")] -+// Hack: causes errors for us since this isn't upstream. -+// #[deprecated(since = "0.6.10", note = "removed")] -+// #[cfg(feature = "with-deprecated")] - #[doc(hidden)] - impl ops::Not for Ready { - type Output = Ready; -diff --git a/src/sys/unix/mod.rs b/src/sys/unix/mod.rs -index c5726c0..b702d35 100644 ---- a/src/sys/unix/mod.rs -+++ b/src/sys/unix/mod.rs -@@ -6,6 +6,7 @@ pub mod dlsym; - #[cfg(any( - target_os = "android", - target_os = "illumos", -+ target_os = "aero", - target_os = "linux", - target_os = "solaris" - ))] -@@ -14,6 +15,7 @@ mod epoll; - #[cfg(any( - target_os = "android", - target_os = "illumos", -+ target_os = "aero", - target_os = "linux", - target_os = "solaris" - ))] -diff --git a/src/sys/unix/ready.rs b/src/sys/unix/ready.rs -index ef90147..50237e0 100644 ---- a/src/sys/unix/ready.rs -+++ b/src/sys/unix/ready.rs -@@ -276,6 +276,7 @@ impl UnixReady { - #[cfg(any( - target_os = "android", - target_os = "illumos", -+ target_os = "aero", - target_os = "linux", - target_os = "solaris" - ))] -@@ -407,6 +408,7 @@ impl UnixReady { - #[cfg(any( - target_os = "android", - target_os = "illumos", -+ target_os = "aero", - target_os = "linux", - target_os = "solaris" - ))] -@@ -477,8 +479,9 @@ impl ops::Sub for UnixReady { - } - } - --#[deprecated(since = "0.6.10", note = "removed")] --#[cfg(feature = "with-deprecated")] -+// Hack: causes errors for us since this isn't upstream. -+// #[deprecated(since = "0.6.10", note = "removed")] -+// #[cfg(feature = "with-deprecated")] - #[doc(hidden)] - impl ops::Not for UnixReady { - type Output = UnixReady; --- -2.38.1 - diff --git a/patches/rust-mio-0.8/rust-mio-0.8.patch b/patches/rust-mio-0.8/rust-mio-0.8.patch deleted file mode 100644 index e148c6f788f..00000000000 --- a/patches/rust-mio-0.8/rust-mio-0.8.patch +++ /dev/null @@ -1,73 +0,0 @@ -From de6c2d83e3db2040ca4933ca97006f1c2ad82a64 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Sun, 20 Nov 2022 12:29:48 +1100 -Subject: [PATCH] - ---- - src/sys/unix/pipe.rs | 2 ++ - src/sys/unix/selector/mod.rs | 2 ++ - src/sys/unix/waker.rs | 4 ++-- - 3 files changed, 6 insertions(+), 2 deletions(-) - -diff --git a/src/sys/unix/pipe.rs b/src/sys/unix/pipe.rs -index b2865cd..df56531 100644 ---- a/src/sys/unix/pipe.rs -+++ b/src/sys/unix/pipe.rs -@@ -150,6 +150,7 @@ pub fn new() -> io::Result<(Sender, Receiver)> { - #[cfg(any( - target_os = "android", - target_os = "dragonfly", -+ target_os = "aero", - target_os = "freebsd", - target_os = "linux", - target_os = "netbsd", -@@ -189,6 +190,7 @@ pub fn new() -> io::Result<(Sender, Receiver)> { - target_os = "dragonfly", - target_os = "freebsd", - target_os = "linux", -+ target_os = "aero", - target_os = "netbsd", - target_os = "openbsd", - target_os = "ios", -diff --git a/src/sys/unix/selector/mod.rs b/src/sys/unix/selector/mod.rs -index 9ae4c14..cb1ce72 100644 ---- a/src/sys/unix/selector/mod.rs -+++ b/src/sys/unix/selector/mod.rs -@@ -3,6 +3,7 @@ - target_os = "illumos", - target_os = "linux", - target_os = "redox", -+ target_os = "aero", - ))] - mod epoll; - -@@ -11,6 +12,7 @@ mod epoll; - target_os = "illumos", - target_os = "linux", - target_os = "redox", -+ target_os = "aero", - ))] - pub(crate) use self::epoll::{event, Event, Events, Selector}; - -diff --git a/src/sys/unix/waker.rs b/src/sys/unix/waker.rs -index de88e31..714ac55 100644 ---- a/src/sys/unix/waker.rs -+++ b/src/sys/unix/waker.rs -@@ -1,4 +1,4 @@ --#[cfg(any(target_os = "linux", target_os = "android"))] -+#[cfg(any(target_os = "linux", target_os = "android", target_os = "aero"))] - mod eventfd { - use crate::sys::Selector; - use crate::{Interest, Token}; -@@ -58,7 +58,7 @@ mod eventfd { - } - } - --#[cfg(any(target_os = "linux", target_os = "android"))] -+#[cfg(any(target_os = "linux", target_os = "android", target_os = "aero"))] - pub use self::eventfd::Waker; - - #[cfg(any(target_os = "freebsd", target_os = "ios", target_os = "macos"))] --- -2.38.1 - diff --git a/patches/rust-nix/rust-nix.patch b/patches/rust-nix/rust-nix.patch deleted file mode 100644 index 32bf6442d21..00000000000 --- a/patches/rust-nix/rust-nix.patch +++ /dev/null @@ -1,708 +0,0 @@ -From 608f6dc307498272ec3a6317cac3bbbe2a8b74b1 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Sun, 20 Nov 2022 12:21:43 +1100 -Subject: [PATCH] - ---- - src/errno.rs | 217 +++++++++++++++++++++++++++++++++++++++++ - src/lib.rs | 12 ++- - src/sys/mod.rs | 10 +- - src/sys/socket/addr.rs | 16 +-- - src/sys/socket/mod.rs | 5 +- - src/sys/termios.rs | 54 +++++++++- - src/unistd.rs | 27 +++++ - 7 files changed, 327 insertions(+), 14 deletions(-) - -diff --git a/src/errno.rs b/src/errno.rs -index 9c2dfe4..d26d63d 100644 ---- a/src/errno.rs -+++ b/src/errno.rs -@@ -22,6 +22,7 @@ cfg_if! { - } else if #[cfg(any(target_os = "linux", - target_os = "redox", - target_os = "dragonfly", -+ target_os = "aero", - target_os = "fuchsia"))] { - unsafe fn errno_location() -> *mut c_int { - libc::__errno_location() -@@ -183,6 +184,9 @@ fn last() -> Errno { - - fn desc(errno: Errno) -> &'static str { - use self::Errno::*; -+ // TODO: This is completely broken on aero -+ #[allow(unreachable_patterns)] -+ #[allow(unused_variables)] - match errno { - UnknownErrno => "Unknown errno", - EPERM => "Operation not permitted", -@@ -1557,6 +1561,219 @@ mod consts { - } - } - -+#[cfg(target_os = "aero")] -+mod consts { -+ #[derive(Clone, Copy, Debug, Eq, PartialEq)] -+ #[repr(i32)] -+ pub enum Errno { -+ UnknownErrno = 0, -+ E2BIG = libc::E2BIG, -+ EACCES = libc::EACCES, -+ EADDRINUSE = libc::EADDRINUSE, -+ EADDRNOTAVAIL = libc::EADDRNOTAVAIL, -+ // EAFNOSUPPORT = libc::EAFNOSUPPORT, -+ EAGAIN = libc::EAGAIN, -+ // EALREADY = libc::EALREADY, -+ // EAUTH = libc::EAUTH, -+ EBADF = libc::EBADF, -+ // EBADMSG = libc::EBADMSG, -+ // EBADRPC = libc::EBADRPC, -+ // EBUSY = libc::EBUSY, -+ // ECANCELED = libc::ECANCELED, -+ // ECHILD = libc::ECHILD, -+ ECONNABORTED = libc::ECONNABORTED, -+ ECONNREFUSED = libc::ECONNREFUSED, -+ ECONNRESET = libc::ECONNRESET, -+ EDEADLK = libc::EDEADLK, -+ // EDESTADDRREQ = libc::EDESTADDRREQ, -+ // EDOM = libc::EDOM, -+ // EDQUOT = libc::EDQUOT, -+ EEXIST = libc::EEXIST, -+ // EFAULT = libc::EFAULT, -+ // EFBIG = libc::EFBIG, -+ // EFTYPE = libc::EFTYPE, -+ // EHOSTDOWN = libc::EHOSTDOWN, -+ // EHOSTUNREACH = libc::EHOSTUNREACH, -+ // EIDRM = libc::EIDRM, -+ // EILSEQ = libc::EILSEQ, -+ EINPROGRESS = libc::EINPROGRESS, -+ EINTR = libc::EINTR, -+ EINVAL = libc::EINVAL, -+ // EIO = libc::EIO, -+ // EISCONN = libc::EISCONN, -+ // EISDIR = libc::EISDIR, -+ // ELOOP = libc::ELOOP, -+ // EMFILE = libc::EMFILE, -+ // EMLINK = libc::EMLINK, -+ // EMSGSIZE = libc::EMSGSIZE, -+ // EMULTIHOP = libc::EMULTIHOP, -+ ENAMETOOLONG = libc::ENAMETOOLONG, -+ // ENEEDAUTH = libc::ENEEDAUTH, -+ // ENETDOWN = libc::ENETDOWN, -+ // ENETRESET = libc::ENETRESET, -+ // ENETUNREACH = libc::ENETUNREACH, -+ // ENFILE = libc::ENFILE, -+ // ENOATTR = libc::ENOATTR, -+ // ENOBUFS = libc::ENOBUFS, -+ // ENODATA = libc::ENODATA, -+ // ENODEV = libc::ENODEV, -+ ENOENT = libc::ENOENT, -+ // ENOEXEC = libc::ENOEXEC, -+ // ENOLCK = libc::ENOLCK, -+ // ENOLINK = libc::ENOLINK, -+ // ENOMEM = libc::ENOMEM, -+ // ENOMSG = libc::ENOMSG, -+ // ENOPROTOOPT = libc::ENOPROTOOPT, -+ // ENOSPC = libc::ENOSPC, -+ // ENOSR = libc::ENOSR, -+ // ENOSTR = libc::ENOSTR, -+ ENOSYS = libc::ENOSYS, -+ // ENOTBLK = libc::ENOTBLK, -+ ENOTCONN = libc::ENOTCONN, -+ // ENOTDIR = libc::ENOTDIR, -+ // ENOTEMPTY = libc::ENOTEMPTY, -+ // ENOTSOCK = libc::ENOTSOCK, -+ // ENOTSUP = libc::ENOTSUP, -+ ENOTTY = libc::ENOTTY, -+ // ENXIO = libc::ENXIO, -+ // EOPNOTSUPP = libc::EOPNOTSUPP, -+ // EOVERFLOW = libc::EOVERFLOW, -+ EPERM = libc::EPERM, -+ // EPFNOSUPPORT = libc::EPFNOSUPPORT, -+ EPIPE = libc::EPIPE, -+ // EPROCLIM = libc::EPROCLIM, -+ // EPROCUNAVAIL = libc::EPROCUNAVAIL, -+ // EPROGMISMATCH = libc::EPROGMISMATCH, -+ // EPROGUNAVAIL = libc::EPROGUNAVAIL, -+ EPROTO = libc::EPROTO, -+ // EPROTONOSUPPORT = libc::EPROTONOSUPPORT, -+ // EPROTOTYPE = libc::EPROTOTYPE, -+ ERANGE = libc::ERANGE, -+ // EREMOTE = libc::EREMOTE, -+ // EROFS = libc::EROFS, -+ // ERPCMISMATCH = libc::ERPCMISMATCH, -+ // ESHUTDOWN = libc::ESHUTDOWN, -+ // ESOCKTNOSUPPORT = libc::ESOCKTNOSUPPORT, -+ // ESPIPE = libc::ESPIPE, -+ // ESRCH = libc::ESRCH, -+ // ESTALE = libc::ESTALE, -+ // ETIME = libc::ETIME, -+ ETIMEDOUT = libc::ETIMEDOUT, -+ // ETOOMANYREFS = libc::ETOOMANYREFS, -+ // ETXTBSY = libc::ETXTBSY, -+ // EUSERS = libc::EUSERS, -+ // EXDEV = libc::EXDEV, -+ } -+ -+ // pub const ELAST: Errno = Errno::ENOTSUP; -+ pub const EWOULDBLOCK: Errno = Errno::EAGAIN; -+ -+ // pub const EL2NSYNC: Errno = Errno::UnknownErrno; -+ -+ pub fn from_i32(e: i32) -> Errno { -+ use self::Errno::*; -+ -+ match e { -+ // libc::E2BIG => E2BIG, -+ libc::EACCES => EACCES, -+ libc::EADDRINUSE => EADDRINUSE, -+ libc::EADDRNOTAVAIL => EADDRNOTAVAIL, -+ // libc::EAFNOSUPPORT => EAFNOSUPPORT, -+ libc::EAGAIN => EAGAIN, -+ // libc::EALREADY => EALREADY, -+ // libc::EAUTH => EAUTH, -+ libc::EBADF => EBADF, -+ // libc::EBADMSG => EBADMSG, -+ // libc::EBADRPC => EBADRPC, -+ // libc::EBUSY => EBUSY, -+ // libc::ECANCELED => ECANCELED, -+ // libc::ECHILD => ECHILD, -+ libc::ECONNABORTED => ECONNABORTED, -+ libc::ECONNREFUSED => ECONNREFUSED, -+ libc::ECONNRESET => ECONNRESET, -+ libc::EDEADLK => EDEADLK, -+ // libc::EDESTADDRREQ => EDESTADDRREQ, -+ // libc::EDOM => EDOM, -+ // libc::EDQUOT => EDQUOT, -+ libc::EEXIST => EEXIST, -+ // libc::EFAULT => EFAULT, -+ // libc::EFBIG => EFBIG, -+ // libc::EFTYPE => EFTYPE, -+ // libc::EHOSTDOWN => EHOSTDOWN, -+ // libc::EHOSTUNREACH => EHOSTUNREACH, -+ // libc::EIDRM => EIDRM, -+ // libc::EILSEQ => EILSEQ, -+ libc::EINPROGRESS => EINPROGRESS, -+ libc::EINTR => EINTR, -+ libc::EINVAL => EINVAL, -+ // libc::EIO => EIO, -+ // libc::EISCONN => EISCONN, -+ // libc::EISDIR => EISDIR, -+ // libc::ELOOP => ELOOP, -+ // libc::EMFILE => EMFILE, -+ // libc::EMLINK => EMLINK, -+ // libc::EMSGSIZE => EMSGSIZE, -+ // libc::EMULTIHOP => EMULTIHOP, -+ libc::ENAMETOOLONG => ENAMETOOLONG, -+ // libc::ENEEDAUTH => ENEEDAUTH, -+ // libc::ENETDOWN => ENETDOWN, -+ // libc::ENETRESET => ENETRESET, -+ // libc::ENETUNREACH => ENETUNREACH, -+ // libc::ENFILE => ENFILE, -+ // libc::ENOATTR => ENOATTR, -+ // libc::ENOBUFS => ENOBUFS, -+ // libc::ENODATA => ENODATA, -+ // libc::ENODEV => ENODEV, -+ libc::ENOENT => ENOENT, -+ // libc::ENOEXEC => ENOEXEC, -+ // libc::ENOLCK => ENOLCK, -+ // libc::ENOLINK => ENOLINK, -+ // libc::ENOMEM => ENOMEM, -+ // libc::ENOMSG => ENOMSG, -+ // libc::ENOPROTOOPT => ENOPROTOOPT, -+ // libc::ENOSPC => ENOSPC, -+ // libc::ENOSR => ENOSR, -+ // libc::ENOSTR => ENOSTR, -+ libc::ENOSYS => ENOSYS, -+ // libc::ENOTBLK => ENOTBLK, -+ libc::ENOTCONN => ENOTCONN, -+ // libc::ENOTDIR => ENOTDIR, -+ // libc::ENOTEMPTY => ENOTEMPTY, -+ // libc::ENOTSOCK => ENOTSOCK, -+ // libc::ENOTSUP => ENOTSUP, -+ // libc::ENOTTY => ENOTTY, -+ // libc::ENXIO => ENXIO, -+ // libc::EOPNOTSUPP => EOPNOTSUPP, -+ // libc::EOVERFLOW => EOVERFLOW, -+ libc::EPERM => EPERM, -+ // libc::EPFNOSUPPORT => EPFNOSUPPORT, -+ libc::EPIPE => EPIPE, -+ // libc::EPROCLIM => EPROCLIM, -+ // libc::EPROCUNAVAIL => EPROCUNAVAIL, -+ // libc::EPROGMISMATCH => EPROGMISMATCH, -+ // libc::EPROGUNAVAIL => EPROGUNAVAIL, -+ // libc::EPROTO => EPROTO, -+ // libc::EPROTONOSUPPORT => EPROTONOSUPPORT, -+ // libc::EPROTOTYPE => EPROTOTYPE, -+ libc::ERANGE => ERANGE, -+ // libc::EREMOTE => EREMOTE, -+ // libc::EROFS => EROFS, -+ // libc::ERPCMISMATCH => ERPCMISMATCH, -+ // libc::ESHUTDOWN => ESHUTDOWN, -+ // libc::ESOCKTNOSUPPORT => ESOCKTNOSUPPORT, -+ // libc::ESPIPE => ESPIPE, -+ // libc::ESRCH => ESRCH, -+ // libc::ESTALE => ESTALE, -+ // libc::ETIME => ETIME, -+ libc::ETIMEDOUT => ETIMEDOUT, -+ // libc::ETOOMANYREFS => ETOOMANYREFS, -+ // libc::ETXTBSY => ETXTBSY, -+ // libc::EUSERS => EUSERS, -+ // libc::EXDEV => EXDEV, -+ _ => UnknownErrno, -+ } -+ } -+} - - #[cfg(target_os = "dragonfly")] - mod consts { -diff --git a/src/lib.rs b/src/lib.rs -index 3b534a5..f7c8495 100644 ---- a/src/lib.rs -+++ b/src/lib.rs -@@ -5,12 +5,13 @@ - #![crate_name = "nix"] - #![cfg(unix)] - #![allow(non_camel_case_types)] -+#![allow(non_snake_case)] - // latest bitflags triggers a rustc bug with cross-crate macro expansions causing dead_code - // warnings even though the macro expands into something with allow(dead_code) - #![allow(dead_code)] - #![cfg_attr(test, deny(warnings))] - #![recursion_limit = "500"] --#![deny(unused)] -+// #![deny(unused)] - #![deny(unstable_features)] - #![deny(missing_copy_implementations)] - #![deny(missing_debug_implementations)] -@@ -22,11 +23,13 @@ pub use libc; - #[macro_use] mod macros; - - // Public crates --#[cfg(not(target_os = "redox"))] -+#[cfg(not(any(target_os = "redox", target_os = "aero")))] - pub mod dir; -+#[cfg(not(target_os = "aero"))] - pub mod env; - pub mod errno; - #[deny(missing_docs)] -+#[cfg(not(target_os = "aero"))] - pub mod features; - pub mod fcntl; - #[deny(missing_docs)] -@@ -54,15 +57,18 @@ pub mod mount; - target_os = "netbsd"))] - pub mod mqueue; - #[deny(missing_docs)] --#[cfg(not(target_os = "redox"))] -+#[cfg(not(any(target_os = "redox", target_os = "aero")))] - pub mod net; - #[deny(missing_docs)] -+#[cfg(not(target_os = "aero"))] - pub mod poll; - #[deny(missing_docs)] - #[cfg(not(any(target_os = "redox", target_os = "fuchsia")))] - pub mod pty; -+#[cfg(not(target_os = "aero"))] - pub mod sched; - pub mod sys; -+#[cfg(not(target_os = "aero"))] - pub mod time; - // This can be implemented for other platforms as soon as libc - // provides bindings for them. -diff --git a/src/sys/mod.rs b/src/sys/mod.rs -index 43877a1..20dd8e5 100644 ---- a/src/sys/mod.rs -+++ b/src/sys/mod.rs -@@ -6,7 +6,7 @@ - target_os = "netbsd"))] - pub mod aio; - --#[cfg(any(target_os = "android", target_os = "linux"))] -+#[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] - pub mod epoll; - - #[cfg(any(target_os = "dragonfly", -@@ -42,6 +42,7 @@ pub mod mman; - #[cfg(target_os = "linux")] - pub mod personality; - -+#[cfg(not(target_os = "aero"))] - pub mod pthread; - - #[cfg(any(target_os = "android", -@@ -59,7 +60,8 @@ pub mod quota; - #[cfg(any(target_os = "linux"))] - pub mod reboot; - --#[cfg(not(target_os = "redox"))] -+// #[cfg(not(target_os = "redox"))] -+#[cfg(not(any(target_os = "redox", target_os = "aero")))] - pub mod select; - - #[cfg(any(target_os = "android", -@@ -69,6 +71,7 @@ pub mod select; - target_os = "macos"))] - pub mod sendfile; - -+#[cfg(not(target_os = "aero"))] - pub mod signal; - - #[cfg(any(target_os = "android", target_os = "linux"))] -@@ -89,6 +92,7 @@ pub mod stat; - ))] - pub mod statfs; - -+#[cfg(not(target_os = "aero"))] - pub mod statvfs; - - #[cfg(any(target_os = "android", target_os = "linux"))] -@@ -100,8 +104,10 @@ pub mod time; - - pub mod uio; - -+#[cfg(not(target_os = "aero"))] - pub mod utsname; - -+#[cfg(not(target_os = "aero"))] - pub mod wait; - - #[cfg(any(target_os = "android", target_os = "linux"))] -diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs -index d486056..b367e18 100644 ---- a/src/sys/socket/addr.rs -+++ b/src/sys/socket/addr.rs -@@ -17,6 +17,7 @@ use std::os::unix::io::RawFd; - use crate::sys::socket::addr::sys_control::SysControlAddr; - #[cfg(any(target_os = "android", - target_os = "dragonfly", -+ target_os = "aero", - target_os = "freebsd", - target_os = "ios", - target_os = "linux", -@@ -46,6 +47,7 @@ pub enum AddressFamily { - /// Low level packet interface (see [`packet(7)`](https://man7.org/linux/man-pages/man7/packet.7.html)) - #[cfg(any(target_os = "android", - target_os = "linux", -+ target_os = "aero", - target_os = "illumos", - target_os = "fuchsia", - target_os = "solaris"))] -@@ -245,7 +247,7 @@ impl AddressFamily { - libc::AF_NETLINK => Some(AddressFamily::Netlink), - #[cfg(any(target_os = "macos", target_os = "macos"))] - libc::AF_SYSTEM => Some(AddressFamily::System), -- #[cfg(any(target_os = "android", target_os = "linux"))] -+ #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] - libc::AF_PACKET => Some(AddressFamily::Packet), - #[cfg(any(target_os = "dragonfly", - target_os = "freebsd", -@@ -653,6 +655,7 @@ pub enum SockAddr { - /// Datalink address (MAC) - #[cfg(any(target_os = "android", - target_os = "dragonfly", -+ target_os = "aero", - target_os = "freebsd", - target_os = "ios", - target_os = "linux", -@@ -705,7 +708,7 @@ impl SockAddr { - SockAddr::Alg(..) => AddressFamily::Alg, - #[cfg(any(target_os = "ios", target_os = "macos"))] - SockAddr::SysControl(..) => AddressFamily::System, -- #[cfg(any(target_os = "android", target_os = "linux"))] -+ #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] - SockAddr::Link(..) => AddressFamily::Packet, - #[cfg(any(target_os = "dragonfly", - target_os = "freebsd", -@@ -738,7 +741,7 @@ impl SockAddr { - if addr.is_null() { - None - } else { -- match AddressFamily::from_i32(i32::from((*addr).sa_family)) { -+ match AddressFamily::from_i32((*addr).sa_family as i32) { - Some(AddressFamily::Unix) => None, - Some(AddressFamily::Inet) => Some(SockAddr::Inet( - InetAddr::V4(*(addr as *const libc::sockaddr_in)))), -@@ -750,7 +753,7 @@ impl SockAddr { - #[cfg(any(target_os = "ios", target_os = "macos"))] - Some(AddressFamily::System) => Some(SockAddr::SysControl( - SysControlAddr(*(addr as *const libc::sockaddr_ctl)))), -- #[cfg(any(target_os = "android", target_os = "linux"))] -+ #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] - Some(AddressFamily::Packet) => Some(SockAddr::Link( - LinkAddr(*(addr as *const libc::sockaddr_ll)))), - #[cfg(any(target_os = "dragonfly", -@@ -833,7 +836,7 @@ impl SockAddr { - mem::size_of_val(sa) as libc::socklen_t - - ), -- #[cfg(any(target_os = "android", target_os = "linux"))] -+ #[cfg(any(target_os = "android", target_os = "linux", target_os = "aero"))] - SockAddr::Link(LinkAddr(ref addr)) => ( - // This cast is always allowed in C - unsafe { -@@ -879,6 +882,7 @@ impl fmt::Display for SockAddr { - #[cfg(any(target_os = "ios", target_os = "macos"))] - SockAddr::SysControl(ref sc) => sc.fmt(f), - #[cfg(any(target_os = "android", -+ target_os = "aero", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "ios", -@@ -1064,7 +1068,7 @@ pub mod sys_control { - } - - --#[cfg(any(target_os = "android", target_os = "linux", target_os = "fuchsia"))] -+#[cfg(any(target_os = "android", target_os = "linux", target_os = "aero", target_os = "fuchsia"))] - mod datalink { - use super::{fmt, AddressFamily}; - -diff --git a/src/sys/socket/mod.rs b/src/sys/socket/mod.rs -index da5573c..3bac136 100644 ---- a/src/sys/socket/mod.rs -+++ b/src/sys/socket/mod.rs -@@ -251,6 +251,7 @@ libc_bitflags!{ - /// - /// Only used in [`recvmsg`](fn.recvmsg.html) function. - #[cfg(any(target_os = "android", -+ target_os = "aero", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "linux", -@@ -866,13 +867,13 @@ impl<'a> ControlMessage<'a> { - - /// The value of CMSG_LEN on this message. - /// Safe because CMSG_LEN is always safe -- #[cfg(any(target_os = "android", -+ #[cfg(any(target_os = "android", target_os = "aero", - all(target_os = "linux", not(target_env = "musl"))))] - fn cmsg_len(&self) -> usize { - unsafe{CMSG_LEN(self.len() as libc::c_uint) as usize} - } - -- #[cfg(not(any(target_os = "android", -+ #[cfg(not(any(target_os = "android", target_os = "aero", - all(target_os = "linux", not(target_env = "musl")))))] - fn cmsg_len(&self) -> libc::c_uint { - unsafe{CMSG_LEN(self.len() as libc::c_uint)} -diff --git a/src/sys/termios.rs b/src/sys/termios.rs -index 36a3601..c7bddc3 100644 ---- a/src/sys/termios.rs -+++ b/src/sys/termios.rs -@@ -467,10 +467,19 @@ impl From for u32 { - } - - // TODO: Add TCSASOFT, which will require treating this as a bitfield. -+#[cfg(target_os = "aero")] - libc_enum! { - /// Specify when a port configuration change should occur. - /// - /// Used as an argument to `tcsetattr()` -+ #[repr(i32)] -+ pub enum SetArg { -+ TCSANOW, -+ } -+} -+ -+#[cfg(not(target_os = "aero"))] -+libc_enum! { - #[repr(i32)] - pub enum SetArg { - /// The change will occur immediately -@@ -482,10 +491,19 @@ libc_enum! { - } - } - -+#[cfg(target_os = "aero")] - libc_enum! { - /// Specify a combination of the input and output buffers to flush - /// - /// Used as an argument to `tcflush()`. -+ #[repr(i32)] -+ pub enum FlushArg { -+ TCIFLUSH, -+ } -+} -+ -+#[cfg(not(target_os = "aero"))] -+libc_enum! { - #[repr(i32)] - pub enum FlushArg { - /// Flush data that was received but not read -@@ -515,8 +533,17 @@ libc_enum! { - } - - // TODO: Make this usable directly as a slice index. -+#[cfg(target_os = "aero")] - libc_enum! { - /// Indices into the `termios.c_cc` array for special characters. -+ #[repr(usize)] -+ pub enum SpecialCharacterIndices { -+ VEOF, -+ } -+} -+ -+#[cfg(not(target_os = "aero"))] -+libc_enum! { - #[repr(usize)] - pub enum SpecialCharacterIndices { - VDISCARD, -@@ -601,13 +628,22 @@ libc_bitflags! { - IXOFF; - #[cfg(not(target_os = "redox"))] - IXANY; -- #[cfg(not(target_os = "redox"))] -+ #[cfg(not(any(target_os = "redox", target_os = "aero")))] - IMAXBEL; - #[cfg(any(target_os = "android", target_os = "linux", target_os = "macos"))] - IUTF8; - } - } - -+#[cfg(target_os = "aero")] -+libc_bitflags! { -+ /// Flags for configuring the output mode of a terminal -+ pub struct OutputFlags: tcflag_t { -+ OPOST; -+ } -+} -+ -+#[cfg(not(target_os = "aero"))] - libc_bitflags! { - /// Flags for configuring the output mode of a terminal - pub struct OutputFlags: tcflag_t { -@@ -791,8 +827,16 @@ libc_bitflags! { - } - } - -+#[cfg(target_os = "aero")] - libc_bitflags! { - /// Flags for setting the control mode of a terminal -+ pub struct ControlFlags: tcflag_t { -+ CS5; -+ } -+} -+ -+#[cfg(not(target_os = "aero"))] -+lib_bitflags! { - pub struct ControlFlags: tcflag_t { - #[cfg(any(target_os = "dragonfly", - target_os = "freebsd", -@@ -859,8 +903,16 @@ libc_bitflags! { - } - } - -+#[cfg(target_os = "aero")] - libc_bitflags! { - /// Flags for setting any local modes -+ pub struct LocalFlags: tcflag_t { -+ ECHO; -+ } -+} -+ -+#[cfg(not(target_os = "aero"))] -+libc_bitflags! { - pub struct LocalFlags: tcflag_t { - #[cfg(not(target_os = "redox"))] - ECHOKE; -diff --git a/src/unistd.rs b/src/unistd.rs -index d94cb99..8e26266 100644 ---- a/src/unistd.rs -+++ b/src/unistd.rs -@@ -1081,6 +1081,7 @@ pub fn pipe() -> std::result::Result<(RawFd, RawFd), Error> { - /// See also [pipe(2)](https://man7.org/linux/man-pages/man2/pipe.2.html) - #[cfg(any(target_os = "android", - target_os = "dragonfly", -+ target_os = "aero", - target_os = "emscripten", - target_os = "freebsd", - target_os = "illumos", -@@ -1478,6 +1479,7 @@ pub fn getgroups() -> Result> { - pub fn setgroups(groups: &[Gid]) -> Result<()> { - cfg_if! { - if #[cfg(any(target_os = "dragonfly", -+ target_os = "aero", - target_os = "freebsd", - target_os = "illumos", - target_os = "ios", -@@ -1799,6 +1801,14 @@ pub fn mkstemp(template: &P) -> Result<(RawFd, PathBuf)> { - /// - [pathconf(2)](https://pubs.opengroup.org/onlinepubs/9699919799/functions/pathconf.html) - /// - [limits.h](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html) - /// - [unistd.h](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html) -+#[cfg(target_os = "aero")] -+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] -+#[repr(i32)] -+pub enum PathconfVar { -+ NAME_MAX = libc::_PC_NAME_MAX, -+} -+ -+#[cfg(not(target_os = "aero"))] - #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] - #[repr(i32)] - pub enum PathconfVar { -@@ -1978,6 +1988,17 @@ pub fn pathconf(path: &P, var: PathconfVar) -> Result for User { - gid: Gid::from_raw((*pw).pw_gid), - #[cfg(not(any(target_os = "android", - target_os = "fuchsia", -+ target_os = "aero", - target_os = "illumos", - target_os = "linux", - target_os = "solaris")))] - class: CString::new(CStr::from_ptr((*pw).pw_class).to_bytes()).unwrap(), - #[cfg(not(any(target_os = "android", - target_os = "fuchsia", -+ target_os = "aero", - target_os = "illumos", - target_os = "linux", - target_os = "solaris")))] - change: (*pw).pw_change, - #[cfg(not(any(target_os = "android", - target_os = "fuchsia", -+ target_os = "aero", - target_os = "illumos", - target_os = "linux", - target_os = "solaris")))] --- -2.38.1 diff --git a/patches/rust-num-cpus/rust-num-cpus.patch b/patches/rust-num-cpus/rust-num-cpus.patch deleted file mode 100644 index 8ab20459c41..00000000000 --- a/patches/rust-num-cpus/rust-num-cpus.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 69bdbf9a09b403cac206f0dba50663ebf1e161d9 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Wed, 12 Jan 2022 17:19:55 +1100 -Subject: [PATCH] aero specific changes - -Signed-off-by: Andy-Python-Programmer ---- - src/lib.rs | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/src/lib.rs b/src/lib.rs -index 6c8280f..e87efa8 100644 ---- a/src/lib.rs -+++ b/src/lib.rs -@@ -331,7 +331,8 @@ fn get_num_physical_cpus() -> usize { - target_os = "android", - target_os = "solaris", - target_os = "illumos", -- target_os = "fuchsia") -+ target_os = "fuchsia", -+ target_os = "aero") - )] - fn get_num_cpus() -> usize { - // On ARM targets, processors could be turned off to save power. -@@ -420,6 +421,7 @@ fn get_num_cpus() -> usize { - target_os = "netbsd", - target_os = "haiku", - target_os = "hermit", -+ target_os = "aero", - windows, - )))] - fn get_num_cpus() -> usize { --- -2.25.1 - diff --git a/patches/rust-shared-library/rust-shared-library.patch b/patches/rust-shared-library/rust-shared-library.patch deleted file mode 100644 index ed2c8cf25a0..00000000000 --- a/patches/rust-shared-library/rust-shared-library.patch +++ /dev/null @@ -1,45 +0,0 @@ -From ccb5e182dc9d035f5ea8316643a5e7e4e966f2d5 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Sun, 20 Nov 2022 13:23:56 +1100 -Subject: [PATCH] - ---- - Cargo.toml | 2 +- - src/dynamic_library.rs | 2 ++ - 2 files changed, 3 insertions(+), 1 deletion(-) - -diff --git a/Cargo.toml b/Cargo.toml -index e32011c..be74698 100644 ---- a/Cargo.toml -+++ b/Cargo.toml -@@ -1,6 +1,6 @@ - [package] - name = "shared_library" --version = "0.1.8" -+version = "0.1.9" - authors = ["Pierre Krieger "] - description = "Easily bind to and load shared libraries" - license = "Apache-2.0/MIT" -diff --git a/src/dynamic_library.rs b/src/dynamic_library.rs -index 753b632..d1398bb 100644 ---- a/src/dynamic_library.rs -+++ b/src/dynamic_library.rs -@@ -192,6 +192,7 @@ mod test { - #[test] - #[cfg(any(target_os = "linux", - target_os = "macos", -+ target_os = "aero", - target_os = "freebsd", - target_os = "fuchsia", - target_os = "netbsd", -@@ -213,6 +214,7 @@ mod test { - //TODO: use `unix` shortcut? - #[cfg(any(target_os = "linux", - target_os = "android", -+ target_os = "aero", - target_os = "macos", - target_os = "ios", - target_os = "fuchsia", --- -2.38.1 - diff --git a/patches/rust-users/rust-users.patch b/patches/rust-users/rust-users.patch deleted file mode 100644 index da45496c7bc..00000000000 --- a/patches/rust-users/rust-users.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 0dcaffa14eb80d3a8d1236a09d0bd2f28326c6db Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Wed, 12 Jan 2022 17:23:53 +1100 -Subject: [PATCH] aero specific changes - -Signed-off-by: Andy-Python-Programmer ---- - src/base.rs | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/src/base.rs b/src/base.rs -index ece499a..fc5f3cb 100644 ---- a/src/base.rs -+++ b/src/base.rs -@@ -923,7 +923,7 @@ pub mod os { - /// Although the `passwd` struct is common among Unix systems, its actual - /// format can vary. See the definitions in the `base` module to check which - /// fields are actually present. -- #[cfg(any(target_os = "linux", target_os = "android", target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", target_os = "netbsd", target_os = "solaris"))] -+ #[cfg(any(target_os = "linux", target_os = "android", target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", target_os = "netbsd", target_os = "solaris", target_os = "aero"))] - pub mod unix { - use std::ffi::{OsStr, OsString}; - use std::path::{Path, PathBuf}; -@@ -1176,11 +1176,11 @@ pub mod os { - pub type UserExtras = bsd::UserExtras; - - /// Any extra fields on a `User` specific to the current platform. -- #[cfg(any(target_os = "linux", target_os = "android", target_os = "solaris"))] -+ #[cfg(any(target_os = "linux", target_os = "android", target_os = "solaris", target_os = "aero"))] - pub type UserExtras = unix::UserExtras; - - /// Any extra fields on a `Group` specific to the current platform. -- #[cfg(any(target_os = "linux", target_os = "android", target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", target_os = "netbsd", target_os = "solaris"))] -+ #[cfg(any(target_os = "linux", target_os = "android", target_os = "macos", target_os = "freebsd", target_os = "dragonfly", target_os = "openbsd", target_os = "netbsd", target_os = "solaris", target_os = "aero"))] - pub type GroupExtras = unix::GroupExtras; - } - --- -2.25.1 - diff --git a/patches/rust-winit/rust-winit.patch b/patches/rust-winit/rust-winit.patch deleted file mode 100644 index e5e449da31d..00000000000 --- a/patches/rust-winit/rust-winit.patch +++ /dev/null @@ -1,122 +0,0 @@ -From 4e0723a7be1155a72b64eda807712460079a923e Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Thu, 1 Dec 2022 17:51:20 +1100 -Subject: [PATCH] - ---- - Cargo.toml | 2 +- - src/platform/run_return.rs | 1 + - src/platform/unix.rs | 1 + - src/platform_impl/linux/mod.rs | 8 ++++++++ - src/platform_impl/linux/wayland/mod.rs | 1 + - src/platform_impl/linux/x11/mod.rs | 1 + - src/platform_impl/mod.rs | 2 ++ - 7 files changed, 15 insertions(+), 1 deletion(-) - -diff --git a/Cargo.toml b/Cargo.toml -index b1e4159..08309aa 100644 ---- a/Cargo.toml -+++ b/Cargo.toml -@@ -84,7 +84,7 @@ features = [ - "timeapi" - ] - --[target.'cfg(any(target_os = "linux", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))'.dependencies] -+[target.'cfg(any(target_os = "linux", target_os = "aero", target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))'.dependencies] - wayland-client = { version = "0.29", default_features = false, features = ["use_system_lib"], optional = true } - wayland-protocols = { version = "0.29", features = [ "staging_protocols"], optional = true } - sctk = { package = "smithay-client-toolkit", version = "0.15.1", default_features = false, features = ["calloop"], optional = true } -diff --git a/src/platform/run_return.rs b/src/platform/run_return.rs -index 932d9e3..4983c4c 100644 ---- a/src/platform/run_return.rs -+++ b/src/platform/run_return.rs -@@ -1,5 +1,6 @@ - #![cfg(any( - target_os = "windows", -+ target_os = "aero", - target_os = "macos", - target_os = "android", - target_os = "linux", -diff --git a/src/platform/unix.rs b/src/platform/unix.rs -index ba600b1..cfa1f03 100644 ---- a/src/platform/unix.rs -+++ b/src/platform/unix.rs -@@ -1,5 +1,6 @@ - #![cfg(any( - target_os = "linux", -+ target_os = "aero", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", -diff --git a/src/platform_impl/linux/mod.rs b/src/platform_impl/linux/mod.rs -index 953fca1..4f9dbb0 100644 ---- a/src/platform_impl/linux/mod.rs -+++ b/src/platform_impl/linux/mod.rs -@@ -1,6 +1,7 @@ - #![cfg(any( - target_os = "linux", - target_os = "dragonfly", -+ target_os = "aero", - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd" -@@ -771,6 +772,13 @@ fn is_main_thread() -> bool { - unsafe { syscall(SYS_gettid) == getpid() as c_long } - } - -+#[cfg(any(target_os = "aero"))] -+fn is_main_thread() -> bool { -+ // This function is only used for assertions (to make sure that library consumers don't do -+ // anything wrong), but we don't currently implement gettid yet so just return true for now. -+ true -+} -+ - #[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))] - fn is_main_thread() -> bool { - use libc::pthread_main_np; -diff --git a/src/platform_impl/linux/wayland/mod.rs b/src/platform_impl/linux/wayland/mod.rs -index 4ed564a..502545e 100644 ---- a/src/platform_impl/linux/wayland/mod.rs -+++ b/src/platform_impl/linux/wayland/mod.rs -@@ -1,6 +1,7 @@ - #![cfg(any( - target_os = "linux", - target_os = "dragonfly", -+ target_os = "aero", - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd" -diff --git a/src/platform_impl/linux/x11/mod.rs b/src/platform_impl/linux/x11/mod.rs -index 27c92c4..7b3d7e3 100644 ---- a/src/platform_impl/linux/x11/mod.rs -+++ b/src/platform_impl/linux/x11/mod.rs -@@ -1,5 +1,6 @@ - #![cfg(any( - target_os = "linux", -+ target_os = "aero", - target_os = "dragonfly", - target_os = "freebsd", - target_os = "netbsd", -diff --git a/src/platform_impl/mod.rs b/src/platform_impl/mod.rs -index 152065d..a0d471b 100644 ---- a/src/platform_impl/mod.rs -+++ b/src/platform_impl/mod.rs -@@ -6,6 +6,7 @@ mod platform; - #[cfg(any( - target_os = "linux", - target_os = "dragonfly", -+ target_os = "aero", - target_os = "freebsd", - target_os = "netbsd", - target_os = "openbsd" -@@ -32,6 +33,7 @@ mod platform; - not(target_os = "macos"), - not(target_os = "android"), - not(target_os = "dragonfly"), -+ not(target_os = "aero"), - not(target_os = "freebsd"), - not(target_os = "netbsd"), - not(target_os = "openbsd"), --- -2.38.1 - diff --git a/patches/rust/0001-fix-bootstrap-build-target-in-x.py-and-bootstrap.patch b/patches/rust/0001-fix-bootstrap-build-target-in-x.py-and-bootstrap.patch deleted file mode 100644 index 2a474c60f55..00000000000 --- a/patches/rust/0001-fix-bootstrap-build-target-in-x.py-and-bootstrap.patch +++ /dev/null @@ -1,77 +0,0 @@ -From 1f0ded570575781c7e8dbd0d60c57a2ec72ec987 Mon Sep 17 00:00:00 2001 -From: Anhad Singh -Date: Wed, 18 Oct 2023 19:23:49 +1100 -Subject: [PATCH] fix(bootstrap): build target in x.py and bootstrap - -Signed-off-by: Anhad Singh ---- - src/bootstrap/bootstrap.py | 7 +++++-- - src/bootstrap/src/core/builder.rs | 6 ++++-- - 2 files changed, 9 insertions(+), 4 deletions(-) - -diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py -index 1a1125a107f..3f3171a9ddf 100644 ---- a/src/bootstrap/bootstrap.py -+++ b/src/bootstrap/bootstrap.py -@@ -881,7 +881,7 @@ class RustBuild(object): - ... "debug", "bootstrap") - True - """ -- return os.path.join(self.build_dir, "bootstrap", "debug", "bootstrap") -+ return os.path.join(self.build_dir, "bootstrap", self.build, "debug", "bootstrap") - - def build_bootstrap(self): - """Build bootstrap""" -@@ -903,7 +903,7 @@ class RustBuild(object): - build_dir = os.path.join(self.build_dir, "bootstrap") - if self.clean and os.path.exists(build_dir): - shutil.rmtree(build_dir) -- # `CARGO_BUILD_TARGET` breaks bootstrap build. -+ # `CARGO_BUILD_TARGET` and `build.target` breaks bootstrap build. - # See also: . - if "CARGO_BUILD_TARGET" in env: - del env["CARGO_BUILD_TARGET"] -@@ -987,6 +987,9 @@ class RustBuild(object): - except KeyError: - pass - -+ args.append("--target") -+ args.append(self.build) -+ - return args - - def build_triple(self): -diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs -index 039a87e760d..cbbbce4f515 100644 ---- a/src/bootstrap/src/core/builder.rs -+++ b/src/bootstrap/src/core/builder.rs -@@ -1587,6 +1587,8 @@ pub fn cargo( - self.clear_if_dirty(&out_dir, &self.rustc(compiler)); - } - -+ let artifact_dir = self.out.join("bootstrap/").join(self.build.build.triple).join("debug/"); -+ - // Customize the compiler we're running. Specify the compiler to cargo - // as our shim and then pass it some various options used to configure - // how the actual compiler itself is called. -@@ -1599,7 +1601,7 @@ pub fn cargo( - .env("RUSTC_STAGE", stage.to_string()) - .env("RUSTC_SYSROOT", &sysroot) - .env("RUSTC_LIBDIR", &libdir) -- .env("RUSTDOC", self.bootstrap_out.join("rustdoc")) -+ .env("RUSTDOC", artifact_dir.join("rustdoc")) - .env( - "RUSTDOC_REAL", - if cmd == "doc" || cmd == "rustdoc" || (cmd == "test" && want_rustdoc) { -@@ -1613,7 +1615,7 @@ pub fn cargo( - // Clippy support is a hack and uses the default `cargo-clippy` in path. - // Don't override RUSTC so that the `cargo-clippy` in path will be run. - if cmd != "clippy" { -- cargo.env("RUSTC", self.bootstrap_out.join("rustc")); -+ cargo.env("RUSTC", artifact_dir.join("rustc")); - } - - // Dealing with rpath here is a little special, so let's go into some --- -2.42.0 - diff --git a/patches/tcc/tcc.patch b/patches/tcc/tcc.patch deleted file mode 100644 index 914fb2e4828..00000000000 --- a/patches/tcc/tcc.patch +++ /dev/null @@ -1,166 +0,0 @@ -From d6759f3711877792de6eae84616f0077c5089b1e Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Fri, 31 Dec 2021 17:14:30 +1100 -Subject: [PATCH] add support for aero - -Signed-off-by: Andy-Python-Programmer ---- - .vscode/settings.json | 3 +++ - configure | 2 +- - include/stdarg.h | 6 ++++++ - lib/Makefile | 8 ++++---- - libtcc.c | 4 ++-- - tcc.c | 4 +++- - tcc.h | 4 ++++ - tccelf.c | 2 ++ - 8 files changed, 25 insertions(+), 8 deletions(-) - create mode 100644 .vscode/settings.json - -diff --git a/.vscode/settings.json b/.vscode/settings.json -new file mode 100644 -index 0000000..560faaa ---- /dev/null -+++ b/.vscode/settings.json -@@ -0,0 +1,3 @@ -+{ -+ "editor.formatOnSave": false, -+} -\ No newline at end of file -diff --git a/configure b/configure -index 1ee3acb..cab20ed 100755 ---- a/configure -+++ b/configure -@@ -49,7 +49,7 @@ gcc_major=0 - gcc_minor=0 - - # OS specific --targetos=`uname` -+targetos=Aero - case $targetos in - Darwin) - confvars="$confvars OSX" -diff --git a/include/stdarg.h b/include/stdarg.h -index 10ce733..405ac68 100644 ---- a/include/stdarg.h -+++ b/include/stdarg.h -@@ -1,6 +1,10 @@ - #ifndef _STDARG_H - #define _STDARG_H - -+#ifdef __need___va_list -+typedef char *__gnuc_va_list; -+#else -+ - #ifdef __x86_64__ - #ifndef _WIN64 - -@@ -76,4 +80,6 @@ typedef char *va_list; - typedef va_list __gnuc_va_list; - #define _VA_LIST_DEFINED - -+#endif -+ - #endif /* _STDARG_H */ -diff --git a/lib/Makefile b/lib/Makefile -index 0c1ec54..c546dff 100644 ---- a/lib/Makefile -+++ b/lib/Makefile -@@ -20,18 +20,18 @@ XCFG = $(or $(findstring -win,$T),-unx) - # in order to use gcc, tyoe: make -libtcc1-usegcc=yes - arm-libtcc1-usegcc ?= no - --ifeq "$($(T)-libtcc1-usegcc)" "yes" -+#ifeq "$($(T)-libtcc1-usegcc)" "yes" - XCC = $(CC) - XAR = $(AR) - XFLAGS = $(CFLAGS) -fPIC --endif -+#endif - - # only for native compiler - $(X)BCHECK_O = bcheck.o - --ifeq ($(CONFIG_musl)$(CONFIG_uClibc),yes) -+#ifeq ($(CONFIG_musl)$(CONFIG_uClibc),yes) - BCHECK_O = --endif -+#endif - - ifdef CONFIG_OSX - XFLAGS += -D_ANSI_SOURCE -diff --git a/libtcc.c b/libtcc.c -index 1e9dd97..30d27f0 100644 ---- a/libtcc.c -+++ b/libtcc.c -@@ -975,8 +975,8 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type) - if ((output_type == TCC_OUTPUT_EXE || output_type == TCC_OUTPUT_DLL) && - !s->nostdlib) { - if (output_type != TCC_OUTPUT_DLL) -- tcc_add_crt(s, "crt1.o"); -- tcc_add_crt(s, "crti.o"); -+ tcc_add_crt(s, "crt0.o"); -+ //tcc_add_crt(s, "crti.o"); - } - #endif - return 0; -diff --git a/tcc.c b/tcc.c -index cd887d1..1bb0c24 100644 ---- a/tcc.c -+++ b/tcc.c -@@ -1,6 +1,6 @@ - /* - * TCC - Tiny C Compiler -- * -+ * - * Copyright (c) 2001-2004 Fabrice Bellard - * - * This library is free software; you can redistribute it and/or -@@ -162,6 +162,8 @@ static const char version[] = - " Darwin" - #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - " FreeBSD" -+#elif defined(__aero__) -+ " Aero" - #else - " Linux" - #endif -diff --git a/tcc.h b/tcc.h -index cd67973..e42f5fe 100644 ---- a/tcc.h -+++ b/tcc.h -@@ -162,6 +162,8 @@ extern long double strtold (const char *__nptr, char **__endptr); - # endif - #endif - -+#if 0 -+ - #if defined TCC_IS_NATIVE && !defined CONFIG_TCCBOOT - # define CONFIG_TCC_BACKTRACE - # if (defined TCC_TARGET_I386 || defined TCC_TARGET_X86_64) \ -@@ -170,6 +172,8 @@ extern long double strtold (const char *__nptr, char **__endptr); - # endif - #endif - -+#endif -+ - /* ------------ path configuration ------------ */ - - #ifndef CONFIG_SYSROOT -diff --git a/tccelf.c b/tccelf.c -index 70d47e1..994ee59 100644 ---- a/tccelf.c -+++ b/tccelf.c -@@ -1202,8 +1202,10 @@ ST_FUNC void tcc_add_runtime(TCCState *s1) - #endif - tcc_add_support(s1, TCC_LIBTCC1); - /* add crt end if not memory output */ -+ /* - if (s1->output_type != TCC_OUTPUT_MEMORY) - tcc_add_crt(s1, "crtn.o"); -+ */ - } - } - --- -2.25.1 - diff --git a/patches/wayland/wayland.patch b/patches/wayland/wayland.patch deleted file mode 100644 index d0986504bd6..00000000000 --- a/patches/wayland/wayland.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 845a4f951b9165576f6b930385bfef82b61394fc Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Thu, 26 May 2022 19:09:39 +1000 -Subject: [PATCH] wayland: aero specific changes - -Signed-off-by: Andy-Python-Programmer ---- - .gitignore | 2 ++ - src/wayland-os.c | 1 + - src/wayland-server.c | 2 ++ - tests/test-runner.c | 1 + - 4 files changed, 6 insertions(+) - -diff --git a/.gitignore b/.gitignore -index 4fefe5d..7013a49 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -6,3 +6,5 @@ - *~ - cscope.out - ctags -+ -+.vscode -\ No newline at end of file -diff --git a/src/wayland-os.c b/src/wayland-os.c -index 27c6035..43f7b00 100644 ---- a/src/wayland-os.c -+++ b/src/wayland-os.c -@@ -27,6 +27,7 @@ - - #include "../config.h" - -+#include - #include - #include - #include -diff --git a/src/wayland-server.c b/src/wayland-server.c -index 02f1365..d4cf79b 100644 ---- a/src/wayland-server.c -+++ b/src/wayland-server.c -@@ -1490,6 +1490,7 @@ wl_socket_lock(struct wl_socket *socket) - { - struct stat socket_stat; - -+ /* lockfiles are currently not supported on aero. - snprintf(socket->lock_addr, sizeof socket->lock_addr, - "%s%s", socket->addr.sun_path, LOCK_SUFFIX); - -@@ -1518,6 +1519,7 @@ wl_socket_lock(struct wl_socket *socket) - socket_stat.st_mode & S_IWGRP) { - unlink(socket->addr.sun_path); - } -+ */ - - return 0; - err_fd: -diff --git a/tests/test-runner.c b/tests/test-runner.c -index c0247b5..47280d1 100644 ---- a/tests/test-runner.c -+++ b/tests/test-runner.c -@@ -27,6 +27,7 @@ - #define _GNU_SOURCE - - #include -+#include - #include - #include - #include --- -2.25.1 - diff --git a/patches/webkitgtk/0001-Initial-Aero-support.patch b/patches/webkitgtk/0001-Initial-Aero-support.patch deleted file mode 100644 index 82db1c0a73e..00000000000 --- a/patches/webkitgtk/0001-Initial-Aero-support.patch +++ /dev/null @@ -1,243 +0,0 @@ -From 610aa0dbb9c661c87172c0cf93de06efb019f80b Mon Sep 17 00:00:00 2001 -From: Dennis Bonke -Date: Sun, 2 Jan 2022 00:19:17 +0100 -Subject: [PATCH 1/2] Initial Aero support - -Signed-off-by: Dennis Bonke ---- - Source/JavaScriptCore/heap/BlockDirectory.cpp | 2 +- - Source/JavaScriptCore/runtime/MachineContext.h | 8 ++++---- - Source/JavaScriptCore/runtime/Options.cpp | 1 + - Source/ThirdParty/ANGLE/src/common/platform.h | 2 +- - Source/WTF/wtf/InlineASM.h | 8 +++++--- - Source/WTF/wtf/PlatformHave.h | 4 ++-- - Source/WTF/wtf/PlatformOS.h | 6 ++++++ - Source/WebCore/platform/sql/SQLiteDatabase.cpp | 6 +++--- - Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp | 2 +- - Source/WebKit/Platform/unix/SharedMemoryUnix.cpp | 4 +++- - 10 files changed, 27 insertions(+), 16 deletions(-) - -diff --git a/Source/JavaScriptCore/heap/BlockDirectory.cpp b/Source/JavaScriptCore/heap/BlockDirectory.cpp -index e2a3540f86..8b14455772 100644 ---- a/Source/JavaScriptCore/heap/BlockDirectory.cpp -+++ b/Source/JavaScriptCore/heap/BlockDirectory.cpp -@@ -60,7 +60,7 @@ void BlockDirectory::setSubspace(Subspace* subspace) - void BlockDirectory::updatePercentageOfPagedOutPages(SimpleStats& stats) - { - // FIXME: We should figure out a solution for Windows. --#if OS(UNIX) -+#if OS(UNIX) && !OS(AERO) - size_t pageSize = WTF::pageSize(); - ASSERT(!(MarkedBlock::blockSize % pageSize)); - auto numberOfPagesInMarkedBlock = MarkedBlock::blockSize / pageSize; -diff --git a/Source/JavaScriptCore/runtime/MachineContext.h b/Source/JavaScriptCore/runtime/MachineContext.h -index 7857bfc167..4e396fa853 100644 ---- a/Source/JavaScriptCore/runtime/MachineContext.h -+++ b/Source/JavaScriptCore/runtime/MachineContext.h -@@ -346,7 +346,7 @@ static inline void*& framePointerImpl(mcontext_t& machineContext) - #error Unknown Architecture - #endif - --#elif OS(FUCHSIA) || OS(LINUX) -+#elif OS(FUCHSIA) || OS(LINUX) || OS(AERO) - - // The following sequence depends on glibc's sys/ucontext.h. - #if CPU(X86) -@@ -497,7 +497,7 @@ static inline void*& instructionPointerImpl(mcontext_t& machineContext) - #error Unknown Architecture - #endif - --#elif OS(FUCHSIA) || OS(LINUX) -+#elif OS(FUCHSIA) || OS(LINUX) || OS(AERO) - - // The following sequence depends on glibc's sys/ucontext.h. - #if CPU(X86) -@@ -655,7 +655,7 @@ inline void*& argumentPointer<1>(mcontext_t& machineContext) - #error Unknown Architecture - #endif - --#elif OS(FUCHSIA) || OS(LINUX) -+#elif OS(FUCHSIA) || OS(LINUX) || OS(AERO) - - // The following sequence depends on glibc's sys/ucontext.h. - #if CPU(X86) -@@ -772,7 +772,7 @@ inline void*& llintInstructionPointer(mcontext_t& machineContext) - #error Unknown Architecture - #endif - --#elif OS(FUCHSIA) || OS(LINUX) -+#elif OS(FUCHSIA) || OS(LINUX) || OS(AERO) - - // The following sequence depends on glibc's sys/ucontext.h. - #if CPU(X86) -diff --git a/Source/JavaScriptCore/runtime/Options.cpp b/Source/JavaScriptCore/runtime/Options.cpp -index e54387ef28..d159806731 100644 ---- a/Source/JavaScriptCore/runtime/Options.cpp -+++ b/Source/JavaScriptCore/runtime/Options.cpp -@@ -35,6 +35,7 @@ - #include - #include - #include -+#include - #include - #include - #include -diff --git a/Source/ThirdParty/ANGLE/src/common/platform.h b/Source/ThirdParty/ANGLE/src/common/platform.h -index 41f3cf4ff7..745e1f4a56 100644 ---- a/Source/ThirdParty/ANGLE/src/common/platform.h -+++ b/Source/ThirdParty/ANGLE/src/common/platform.h -@@ -28,7 +28,7 @@ - # define ANGLE_PLATFORM_POSIX 1 - #elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \ - defined(__DragonFly__) || defined(__sun) || defined(__GLIBC__) || defined(__GNU__) || \ -- defined(__QNX__) || defined(__Fuchsia__) || defined(__HAIKU__) -+ defined(__QNX__) || defined(__Fuchsia__) || defined(__HAIKU__) || defined(__aero__) - # define ANGLE_PLATFORM_POSIX 1 - #else - # error Unsupported platform. -diff --git a/Source/WTF/wtf/InlineASM.h b/Source/WTF/wtf/InlineASM.h -index 8379a69659..f2780b7947 100644 ---- a/Source/WTF/wtf/InlineASM.h -+++ b/Source/WTF/wtf/InlineASM.h -@@ -43,11 +43,11 @@ - #define THUMB_FUNC_PARAM(name) - #endif - --#if (OS(LINUX) || OS(FREEBSD)) && CPU(X86_64) -+#if (OS(LINUX) || OS(FREEBSD) || OS(AERO)) && CPU(X86_64) - #define GLOBAL_REFERENCE(name) #name "@plt" - #elif CPU(X86) && COMPILER(MINGW) - #define GLOBAL_REFERENCE(name) "@" #name "@4" --#elif OS(LINUX) && CPU(X86) && defined(__PIC__) -+#elif (OS(LINUX) || OS(AERO)) && CPU(X86) && defined(__PIC__) - #define GLOBAL_REFERENCE(name) SYMBOL_STRING(name) "@plt" - #else - #define GLOBAL_REFERENCE(name) SYMBOL_STRING(name) -@@ -70,7 +70,8 @@ - || OS(FUCHSIA) \ - || OS(OPENBSD) \ - || OS(HPUX) \ -- || OS(NETBSD) -+ || OS(NETBSD) \ -+ || OS(AERO) - // ELF platform - #define HIDE_SYMBOL(name) ".hidden " #name - #else -@@ -88,6 +89,7 @@ - || OS(OPENBSD) \ - || OS(HURD) \ - || OS(NETBSD) \ -+ || OS(AERO) \ - || COMPILER(MINGW) - // GNU as-compatible syntax. - #define LOCAL_LABEL_STRING(name) ".L" #name -diff --git a/Source/WTF/wtf/PlatformHave.h b/Source/WTF/wtf/PlatformHave.h -index 61f13c2b73..c4ff4a6252 100644 ---- a/Source/WTF/wtf/PlatformHave.h -+++ b/Source/WTF/wtf/PlatformHave.h -@@ -226,7 +226,7 @@ - #define HAVE_HOSTED_CORE_ANIMATION 1 - #endif - --#if OS(DARWIN) || OS(FUCHSIA) || ((OS(FREEBSD) || OS(LINUX)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS))) -+#if OS(DARWIN) || OS(FUCHSIA) || OS(AERO) || ((OS(FREEBSD) || OS(LINUX)) && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(ARM64) || CPU(MIPS))) - #define HAVE_MACHINE_CONTEXT 1 - #endif - -@@ -238,7 +238,7 @@ - #define HAVE_BACKTRACE_SYMBOLS 1 - #endif - --#if OS(DARWIN) || OS(LINUX) -+#if OS(DARWIN) || OS(LINUX) || OS(AERO) - #define HAVE_DLADDR 1 - #endif - -diff --git a/Source/WTF/wtf/PlatformOS.h b/Source/WTF/wtf/PlatformOS.h -index e61715fb72..28cf97f28f 100644 ---- a/Source/WTF/wtf/PlatformOS.h -+++ b/Source/WTF/wtf/PlatformOS.h -@@ -118,6 +118,11 @@ - #define WTF_OS_WINDOWS 1 - #endif - -+/* OS(AERO) - Aero */ -+#if defined(__aero__) -+#define WTF_OS_AERO 1 -+#endif -+ - - /* OS(UNIX) - Any Unix-like system */ - #if OS(AIX) \ -@@ -128,6 +133,7 @@ - || OS(LINUX) \ - || OS(NETBSD) \ - || OS(OPENBSD) \ -+ || OS(AERO) \ - || defined(unix) \ - || defined(__unix) \ - || defined(__unix__) -diff --git a/Source/WebCore/platform/sql/SQLiteDatabase.cpp b/Source/WebCore/platform/sql/SQLiteDatabase.cpp -index 743ef3dc84..3a61bc1dc3 100644 ---- a/Source/WebCore/platform/sql/SQLiteDatabase.cpp -+++ b/Source/WebCore/platform/sql/SQLiteDatabase.cpp -@@ -148,8 +148,8 @@ bool SQLiteDatabase::open(const String& filename, OpenMode openMode) - LOG_ERROR("SQLite database could not set temp_store to memory"); - } - -- if (openMode != OpenMode::ReadOnly) -- useWALJournalMode(); -+ // if (openMode != OpenMode::ReadOnly) -+ // useWALJournalMode(); - - auto shmFileName = makeString(filename, "-shm"_s); - if (FileSystem::fileExists(shmFileName)) { -@@ -727,7 +727,7 @@ Expected SQLiteDatabase::prepareStatement(ASCIILiteral que - { - auto sqlStatement = constructAndPrepareStatement(*this, query.characters(), query.length()); - if (!sqlStatement) { -- RELEASE_LOG_ERROR(SQLDatabase, "SQLiteDatabase::prepareStatement: Failed to prepare statement %{public}s", query.characters()); -+ RELEASE_LOG_ERROR(SQLDatabase, "SQLiteDatabase::prepareStatement: Failed to prepare statement %s" /*%{public}s"*/, query.characters()); - return makeUnexpected(sqlStatement.error()); - } - return SQLiteStatement { *this, sqlStatement.value() }; -diff --git a/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp b/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp -index efcd663f84..81a425a037 100644 ---- a/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp -+++ b/Source/WebKit/Platform/IPC/unix/ConnectionUnix.cpp -@@ -46,7 +46,7 @@ - - // Although it's available on Darwin, SOCK_SEQPACKET seems to work differently - // than in traditional Unix so fallback to STREAM on that platform. --#if defined(SOCK_SEQPACKET) && !OS(DARWIN) -+#if defined(SOCK_SEQPACKET) && !OS(DARWIN) && !OS(AERO) - #define SOCKET_TYPE SOCK_SEQPACKET - #else - #if USE(GLIB) -diff --git a/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp b/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp -index 998a2a7679..51c5d38573 100644 ---- a/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp -+++ b/Source/WebKit/Platform/unix/SharedMemoryUnix.cpp -@@ -47,8 +47,10 @@ - - #if HAVE(LINUX_MEMFD_H) - #include -+#if !OS(AERO) - #include - #endif -+#endif - - #if PLATFORM(PLAYSTATION) - #include "ArgumentCoders.h" -@@ -132,7 +134,7 @@ static int createSharedMemory() - static bool isMemFdAvailable = true; - if (isMemFdAvailable) { - do { -- fileDescriptor = syscall(__NR_memfd_create, "WebKitSharedMemory", MFD_CLOEXEC); -+ fileDescriptor = memfd_create("WebKitSharedMemory", MFD_CLOEXEC); - } while (fileDescriptor == -1 && errno == EINTR); - - if (fileDescriptor != -1) --- -2.42.0 - diff --git a/patches/webkitgtk/0002-xxx.patch b/patches/webkitgtk/0002-xxx.patch deleted file mode 100644 index ae6402e7784..00000000000 --- a/patches/webkitgtk/0002-xxx.patch +++ /dev/null @@ -1,181 +0,0 @@ -From 4a70595e159ee5cc7336ed10c78f7f34284506e1 Mon Sep 17 00:00:00 2001 -From: Anhad Singh -Date: Sat, 14 Oct 2023 16:58:18 +1100 -Subject: [PATCH 2/2] - -Signed-off-by: Anhad Singh ---- - .../ANGLE/include/GLSLANG/ShaderVars.h | 1 + - Source/WTF/wtf/MallocPtr.h | 1 + - .../WTF/wtf/text/IntegerToStringConversion.h | 25 ++++++++++--------- - .../WebCore/accessibility/AXObjectCache.cpp | 2 ++ - .../graphics/BifurcatedGraphicsContext.cpp | 2 ++ - .../platform/graphics/x11/XUniqueResource.h | 2 ++ - 6 files changed, 21 insertions(+), 12 deletions(-) - -diff --git a/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderVars.h b/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderVars.h -index 68dc7e2e32..e127de3373 100644 ---- a/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderVars.h -+++ b/Source/ThirdParty/ANGLE/include/GLSLANG/ShaderVars.h -@@ -14,6 +14,7 @@ - #include - #include - #include -+#include - - // This type is defined here to simplify ANGLE's integration with glslang for SPIRv. - using ShCompileOptions = uint64_t; -diff --git a/Source/WTF/wtf/MallocPtr.h b/Source/WTF/wtf/MallocPtr.h -index 2cbd861efd..57e8e66100 100644 ---- a/Source/WTF/wtf/MallocPtr.h -+++ b/Source/WTF/wtf/MallocPtr.h -@@ -25,6 +25,7 @@ - - #pragma once - -+#include - #include - #include - -diff --git a/Source/WTF/wtf/text/IntegerToStringConversion.h b/Source/WTF/wtf/text/IntegerToStringConversion.h -index 03f5861c33..666e53e564 100644 ---- a/Source/WTF/wtf/text/IntegerToStringConversion.h -+++ b/Source/WTF/wtf/text/IntegerToStringConversion.h -@@ -21,15 +21,17 @@ - - #pragma once - -+#include - #include - - namespace WTF { - --enum PositiveOrNegativeNumber { PositiveNumber, NegativeNumber }; -+enum PositiveOrNegativeNumber { PositiveNumber, -+ NegativeNumber }; - --template struct IntegerToStringConversionTrait; -+template struct IntegerToStringConversionTrait; - --template -+template - static typename IntegerToStringConversionTrait::ReturnType numberToStringImpl(UnsignedIntegerType number, AdditionalArgumentType additionalArgument) - { - LChar buf[sizeof(UnsignedIntegerType) * 3 + 1]; -@@ -47,7 +49,7 @@ static typename IntegerToStringConversionTrait::ReturnType numberToStringImpl - return IntegerToStringConversionTrait::flush(p, static_cast(end - p), additionalArgument); - } - --template -+template - inline typename IntegerToStringConversionTrait::ReturnType numberToStringSigned(SignedIntegerType number, typename IntegerToStringConversionTrait::AdditionalArgumentType* additionalArgument = nullptr) - { - if (number < 0) -@@ -55,13 +57,13 @@ inline typename IntegerToStringConversionTrait::ReturnType numberToStringSign - return numberToStringImpl, PositiveNumber>(number, additionalArgument); - } - --template -+template - inline typename IntegerToStringConversionTrait::ReturnType numberToStringUnsigned(UnsignedIntegerType number, typename IntegerToStringConversionTrait::AdditionalArgumentType* additionalArgument = nullptr) - { - return numberToStringImpl(number, additionalArgument); - } - --template -+template - static void writeIntegerToBufferImpl(UnsignedIntegerType number, CharacterType* destination) - { - static_assert(!std::is_same_v>, "'bool' not supported"); -@@ -76,12 +78,12 @@ static void writeIntegerToBufferImpl(UnsignedIntegerType number, CharacterType* - - if (NumberType == NegativeNumber) - *--p = '-'; -- -+ - while (p < end) - *destination++ = static_cast(*p++); - } - --template -+template - inline void writeIntegerToBuffer(IntegerType integer, CharacterType* destination) - { - static_assert(std::is_integral_v); -@@ -95,7 +97,7 @@ inline void writeIntegerToBuffer(IntegerType integer, CharacterType* destination - return writeIntegerToBufferImpl(integer, destination); - } - --template -+template - constexpr unsigned lengthOfIntegerAsStringImpl(UnsignedIntegerType number) - { - unsigned length = 0; -@@ -111,15 +113,14 @@ constexpr unsigned lengthOfIntegerAsStringImpl(UnsignedIntegerType number) - return length; - } - --template -+template - constexpr unsigned lengthOfIntegerAsString(IntegerType integer) - { - static_assert(std::is_integral_v); - if constexpr (std::is_same_v) { - UNUSED_PARAM(integer); - return 1; -- } -- else if constexpr (std::is_signed_v) { -+ } else if constexpr (std::is_signed_v) { - if (integer < 0) - return lengthOfIntegerAsStringImpl, NegativeNumber>(-integer); - return lengthOfIntegerAsStringImpl, PositiveNumber>(integer); -diff --git a/Source/WebCore/accessibility/AXObjectCache.cpp b/Source/WebCore/accessibility/AXObjectCache.cpp -index a7a867f60d..a08ce5078d 100644 ---- a/Source/WebCore/accessibility/AXObjectCache.cpp -+++ b/Source/WebCore/accessibility/AXObjectCache.cpp -@@ -528,9 +528,11 @@ static bool isSimpleImage(const RenderObject& renderer) - || (is(node) && downcast(node)->hasAttributeWithoutSynchronization(usemapAttr))) - return false; - -+#if ENABLE(VIDEO) - // Exclude video and audio elements. - if (is(node)) - return false; -+#endif - - return true; - } -diff --git a/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp b/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp -index c0ce72c5ff..a2a58df7eb 100644 ---- a/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp -+++ b/Source/WebCore/platform/graphics/BifurcatedGraphicsContext.cpp -@@ -269,11 +269,13 @@ void BifurcatedGraphicsContext::drawPattern(NativeImage& nativeImage, const Floa - m_secondaryContext.drawPattern(nativeImage, imageSize, destRect, tileRect, patternTransform, phase, spacing, options); - } - -+#if ENABLE(VIDEO) - void BifurcatedGraphicsContext::paintFrameForMedia(MediaPlayer& player, const FloatRect& destination) - { - m_primaryContext.paintFrameForMedia(player, destination); - m_secondaryContext.paintFrameForMedia(player, destination); - } -+#endif - - void BifurcatedGraphicsContext::scale(const FloatSize& scale) - { -diff --git a/Source/WebCore/platform/graphics/x11/XUniqueResource.h b/Source/WebCore/platform/graphics/x11/XUniqueResource.h -index 0da8b0c9c0..9296efca23 100644 ---- a/Source/WebCore/platform/graphics/x11/XUniqueResource.h -+++ b/Source/WebCore/platform/graphics/x11/XUniqueResource.h -@@ -26,6 +26,8 @@ - #ifndef XUniqueResource_h - #define XUniqueResource_h - -+#include -+ - #if PLATFORM(X11) - - #if USE(GLX) --- -2.42.0 - diff --git a/patches/xf86-input-keyboard/xf86-input-keyboard.patch b/patches/xf86-input-keyboard/jinx-working-patch.patch similarity index 70% rename from patches/xf86-input-keyboard/xf86-input-keyboard.patch rename to patches/xf86-input-keyboard/jinx-working-patch.patch index 3e5fd43a031..0a158a9547e 100644 --- a/patches/xf86-input-keyboard/xf86-input-keyboard.patch +++ b/patches/xf86-input-keyboard/jinx-working-patch.patch @@ -1,31 +1,7 @@ -From 43c032ed1ae85352eca634ed92132242eee99f87 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Sat, 12 Nov 2022 19:22:14 +1100 -Subject: [PATCH] keydev: aero specific changes - -Signed-off-by: Andy-Python-Programmer ---- - .gitignore | 2 + - configure.ac | 5 +++ - src/Makefile.am | 7 +++- - src/aero_kbd.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ - 4 files changed, 122 insertions(+), 1 deletion(-) - create mode 100644 src/aero_kbd.c - -diff --git a/.gitignore b/.gitignore -index 5f04578..f10deba 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -76,3 +76,5 @@ core - # Edit the following section as needed - # For example, !report.pc overrides *.pc. See 'man gitignore' - # -+# editor configs: -+.vscode -diff --git a/configure.ac b/configure.ac -index c3ebdf3..33b36f9 100644 ---- a/configure.ac -+++ b/configure.ac +diff --git xf86-input-keyboard-clean/configure.ac xf86-input-keyboard-workdir/configure.ac +index 0f71ce3..60616eb 100644 +--- xf86-input-keyboard-clean/configure.ac ++++ xf86-input-keyboard-workdir/configure.ac @@ -69,6 +69,10 @@ case $host_os in IS_SOLARIS="yes" ;; @@ -37,26 +13,25 @@ index c3ebdf3..33b36f9 100644 gnu*) IS_HURD="yes" ;; -@@ -95,6 +99,7 @@ case $host_os in - esac - AC_SUBST([OS_FLAGS]) - -+AM_CONDITIONAL(AERO, [test "x$IS_AERO" = xyes]) - AM_CONDITIONAL(LINUX, [test "x$IS_LINUX" = xyes]) +@@ -98,6 +102,7 @@ AC_SUBST([OS_FLAGS]) AM_CONDITIONAL(BSD, [test "x$IS_BSD" = xyes]) AM_CONDITIONAL(SOLARIS, [test "x$IS_SOLARIS" = xyes]) -diff --git a/src/Makefile.am b/src/Makefile.am -index 8612c87..fac400e 100644 ---- a/src/Makefile.am -+++ b/src/Makefile.am -@@ -26,11 +26,16 @@ kbd_drv_la_SOURCES = kbd.c xf86OSKbd.h xf86Keymap.h atKeynames.h + AM_CONDITIONAL(HURD, [test "x$IS_HURD" = xyes]) ++AM_CONDITIONAL(AERO, [test "x$IS_AERO" = xyes]) + + DRIVER_NAME=kbd + AC_SUBST([DRIVER_NAME]) +diff --git xf86-input-keyboard-clean/src/Makefile.am xf86-input-keyboard-workdir/src/Makefile.am +index 52f5f4d..19bf4cb 100644 +--- xf86-input-keyboard-clean/src/Makefile.am ++++ xf86-input-keyboard-workdir/src/Makefile.am +@@ -26,10 +26,15 @@ kbd_drv_la_SOURCES = kbd.c xf86OSKbd.h xf86Keymap.h atKeynames.h kbd_drv_la_LIBADD = $(XORG_LIBS) kbd_drv_ladir = @inputdir@ +AERO_SRCS = aero_kbd.c at_scancode.c BSD_SRCS = bsd_KbdMap.c bsd_kbd.c bsd_kbd.h at_scancode.c HURD_SRCS = hurd_kbd.c at_scancode.c - LINUX_SRCS = lnx_KbdMap.c lnx_kbd.c lnx_kbd.h at_scancode.c SOLARIS_SRCS = sun_kbd.c sun_kbd.h sun_kbdMap.c +if AERO @@ -66,17 +41,17 @@ index 8612c87..fac400e 100644 if BSD kbd_drv_la_SOURCES += $(BSD_SRCS) endif -@@ -47,4 +52,4 @@ if HURD +@@ -42,4 +47,4 @@ if HURD kbd_drv_la_SOURCES += $(HURD_SRCS) endif --EXTRA_DIST = $(BSD_SRCS) $(HURD_SRCS) $(LINUX_SRCS) $(SOLARIS_SRCS) -+EXTRA_DIST = $(AERO_SRCS) $(BSD_SRCS) $(HURD_SRCS) $(LINUX_SRCS) $(SOLARIS_SRCS) -diff --git a/src/aero_kbd.c b/src/aero_kbd.c +-EXTRA_DIST = $(BSD_SRCS) $(HURD_SRCS) $(SOLARIS_SRCS) ++EXTRA_DIST = $(AERO_SRCS) $(BSD_SRCS) $(HURD_SRCS) $(SOLARIS_SRCS) +diff --git xf86-input-keyboard-workdir/src/aero_kbd.c xf86-input-keyboard-workdir/src/aero_kbd.c new file mode 100644 index 0000000..c9cbc4e --- /dev/null -+++ b/src/aero_kbd.c ++++ xf86-input-keyboard-workdir/src/aero_kbd.c @@ -0,0 +1,109 @@ +#ifdef HAVE_CONFIG_H +#include @@ -187,6 +162,3 @@ index 0000000..c9cbc4e + + return TRUE; +} --- -2.38.1 - diff --git a/patches/xf86-input-mouse/xf86-input-mouse.patch b/patches/xf86-input-mouse/jinx-working-patch.patch similarity index 69% rename from patches/xf86-input-mouse/xf86-input-mouse.patch rename to patches/xf86-input-mouse/jinx-working-patch.patch index 3b7fae010a9..44e626272e1 100644 --- a/patches/xf86-input-mouse/xf86-input-mouse.patch +++ b/patches/xf86-input-mouse/jinx-working-patch.patch @@ -1,47 +1,22 @@ -From 560b74fa3e234dced21e0bbf03ea444197b7da15 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Sat, 4 Feb 2023 13:21:25 +1100 -Subject: [PATCH xf86-input-mouse] - ---- - configure.ac | 3 ++ - src/Makefile.am | 2 +- - src/aero_mouse.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++ - 3 files changed, 119 insertions(+), 1 deletion(-) - create mode 100644 src/aero_mouse.c - -diff --git a/configure.ac b/configure.ac -index 6c453cd..a3dd16d 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -81,6 +81,9 @@ case $host_os in - solaris*) - OS_MOUSE_NAME=sun +diff --git xf86-input-mouse-clean/configure.ac xf86-input-mouse-workdir/configure.ac +index 1d871b2..63361c7 100644 +--- xf86-input-mouse-clean/configure.ac ++++ xf86-input-mouse-workdir/configure.ac +@@ -84,6 +84,9 @@ case $host_os in + gnu*) + OS_MOUSE_NAME=hurd ;; + aero*) + OS_MOUSE_NAME=aero + ;; - gnu*) - OS_MOUSE_NAME=hurd - ;; -diff --git a/src/Makefile.am b/src/Makefile.am -index aad8d0e..6de4354 100644 ---- a/src/Makefile.am -+++ b/src/Makefile.am -@@ -32,7 +32,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include $(XORG_CFLAGS) - - # We have to list all the mouse drivers here, even if we don't build them, so - # they get included in distcheck. --OS_SRCS = bsd_mouse.c hurd_mouse.c lnx_mouse.c sun_mouse.c -+OS_SRCS = bsd_mouse.c hurd_mouse.c lnx_mouse.c sun_mouse.c aero_mouse.c + esac + AC_SUBST([OS_MOUSE_NAME]) - @DRIVER_NAME@_drv_la_SOURCES = \ - mouse.c \ -diff --git a/src/aero_mouse.c b/src/aero_mouse.c +diff --git xf86-input-mouse-workdir/src/aero_mouse.c xf86-input-mouse-workdir/src/aero_mouse.c new file mode 100644 -index 0000000..de18985 +index 0000000..5247c21 --- /dev/null -+++ b/src/aero_mouse.c ++++ xf86-input-mouse-workdir/src/aero_mouse.c @@ -0,0 +1,115 @@ +#include "mouse.h" +#include @@ -158,7 +133,3 @@ index 0000000..de18985 + + return p; +} -\ No newline at end of file --- -2.39.1 - diff --git a/patches/xf86-video-fbdev/0001-fbdev-aero-specific-changes.patch b/patches/xf86-video-fbdev/jinx-working-patch.patch similarity index 54% rename from patches/xf86-video-fbdev/0001-fbdev-aero-specific-changes.patch rename to patches/xf86-video-fbdev/jinx-working-patch.patch index 8b91b6fd2f8..40f8d0a7575 100644 --- a/patches/xf86-video-fbdev/0001-fbdev-aero-specific-changes.patch +++ b/patches/xf86-video-fbdev/jinx-working-patch.patch @@ -1,43 +1,7 @@ -From 4a125d73f79cffc1edb41c4a9e9c0524bbc0abbd Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Sat, 2 Jul 2022 18:40:03 +1000 -Subject: [PATCH] fbdev: aero specific changes - -Signed-off-by: Andy-Python-Programmer ---- - .gitignore | 2 ++ - configure.ac | 8 +++++--- - src/Makefile.am | 2 +- - src/fbdev.c | 8 +++++--- - 4 files changed, 13 insertions(+), 7 deletions(-) - -diff --git a/.gitignore b/.gitignore -index 1c9de22..69be940 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -76,3 +76,5 @@ core - # Edit the following section as needed - # For example, !report.pc overrides *.pc. See 'man gitignore' - # -+# editor configs: -+.vscode -diff --git a/configure.ac b/configure.ac -index 27778cd..11f5e38 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -56,9 +56,9 @@ AC_ARG_ENABLE(pciaccess, AS_HELP_STRING([--enable-pciaccess], - [PCIACCESS=$enableval], [PCIACCESS=no]) - - # Store the list of server defined optional extensions in REQUIRED_MODULES --XORG_DRIVER_CHECK_EXT(RANDR, randrproto) --XORG_DRIVER_CHECK_EXT(RENDER, renderproto) --XORG_DRIVER_CHECK_EXT(XV, videoproto) -+# XORG_DRIVER_CHECK_EXT(RANDR, randrproto) -+# XORG_DRIVER_CHECK_EXT(RENDER, renderproto) -+# XORG_DRIVER_CHECK_EXT(XV, videoproto) - - # Obtain compiler/linker options for the driver dependencies - PKG_CHECK_MODULES(XORG, [xorg-server >= 1.0.99.901 xproto fontsproto $REQUIRED_MODULES]) +diff --git xf86-video-fbdev-clean/configure.ac xf86-video-fbdev-workdir/configure.ac +index 27778cd..67436db 100644 +--- xf86-video-fbdev-clean/configure.ac ++++ xf86-video-fbdev-workdir/configure.ac @@ -86,6 +86,8 @@ AC_SUBST([moduledir]) DRIVER_NAME=fbdev AC_SUBST([DRIVER_NAME]) @@ -47,23 +11,23 @@ index 27778cd..11f5e38 100644 AC_CONFIG_FILES([ Makefile src/Makefile -diff --git a/src/Makefile.am b/src/Makefile.am -index fbe420e..6e0779c 100644 ---- a/src/Makefile.am -+++ b/src/Makefile.am +diff --git xf86-video-fbdev-clean/src/Makefile.am xf86-video-fbdev-workdir/src/Makefile.am +index fbe420e..1ef5f49 100644 +--- xf86-video-fbdev-clean/src/Makefile.am ++++ xf86-video-fbdev-workdir/src/Makefile.am @@ -25,7 +25,7 @@ # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc. AM_CFLAGS = @XORG_CFLAGS@ fbdev_drv_la_LTLIBRARIES = fbdev_drv.la -fbdev_drv_la_LDFLAGS = -module -avoid-version -+fbdev_drv_la_LDFLAGS = -module -avoid-version -R@moduledir@ -L@SYSROOT@@moduledir@ -lfb -lfbdevhw -lshadow ++fbdev_drv_la_LDFLAGS = -module -avoid-version -R@moduledir@ -L@SYSROOT@@moduledir@ -lfbdevhw -lshadow fbdev_drv_ladir = @moduledir@/drivers fbdev_drv_la_SOURCES = \ -diff --git a/src/fbdev.c b/src/fbdev.c +diff --git xf86-video-fbdev-clean/src/fbdev.c xf86-video-fbdev-workdir/src/fbdev.c index f25ef72..7facb9f 100644 ---- a/src/fbdev.c -+++ b/src/fbdev.c +--- xf86-video-fbdev-clean/src/fbdev.c ++++ xf86-video-fbdev-workdir/src/fbdev.c @@ -339,7 +339,7 @@ FBDevProbe(DriverPtr drv, int flags) dev = xf86FindOptionValue(devSections[i]->options,"fbdev"); @@ -106,7 +70,3 @@ index f25ef72..7facb9f 100644 +#ifdef XV { XF86VideoAdaptorPtr *ptr; - --- -2.25.1 - diff --git a/patches/xorg-proto/0001-xorg-proto-aero-specific-changes.patch b/patches/xorg-proto/0001-xorg-proto-aero-specific-changes.patch deleted file mode 100644 index 853f1a8f78f..00000000000 --- a/patches/xorg-proto/0001-xorg-proto-aero-specific-changes.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 30656370d8418d469ed311fad84412d12fe0028e Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Tue, 28 Jun 2022 17:04:52 +1000 -Subject: [PATCH] xorg::proto: aero specific changes - -Signed-off-by: Andy-Python-Programmer ---- - .gitignore | 3 +++ - include/X11/Xos.h | 2 +- - include/X11/Xos_r.h | 2 +- - 3 files changed, 5 insertions(+), 2 deletions(-) - -diff --git a/.gitignore b/.gitignore -index 1baa360..dc18465 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -18,3 +18,6 @@ man/Xprint.7 - missing - stamp-h1 - stamp-h2 -+ -+# editor configs: -+.vscode -diff --git a/include/X11/Xos.h b/include/X11/Xos.h -index 28dfc67..1c4092e 100644 ---- a/include/X11/Xos.h -+++ b/include/X11/Xos.h -@@ -60,7 +60,7 @@ in this Software without prior written authorization from The Open Group. - */ - - # include --# if defined(__SCO__) || defined(__UNIXWARE__) || defined(__sun) || defined(__CYGWIN__) || defined(_AIX) || defined(__APPLE__) -+# if defined(__SCO__) || defined(__UNIXWARE__) || defined(__sun) || defined(__CYGWIN__) || defined(_AIX) || defined(__APPLE__) || defined(__aero__) - # include - # else - # ifndef index -diff --git a/include/X11/Xos_r.h b/include/X11/Xos_r.h -index f963b64..19ef5f4 100644 ---- a/include/X11/Xos_r.h -+++ b/include/X11/Xos_r.h -@@ -318,7 +318,7 @@ static __inline__ void _Xpw_copyPasswd(_Xgetpwparams p) - (_Xos_processUnlock), \ - (p).pwp ) - --#elif !defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(__APPLE__) -+#elif !defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(__APPLE__) && !defined(__aero__) - # define X_NEEDS_PWPARAMS - typedef struct { - struct passwd pws; --- -2.25.1 - diff --git a/patches/xorg-proto/jinx-working-patch.patch b/patches/xorg-proto/jinx-working-patch.patch new file mode 100644 index 00000000000..9c44f9bb503 --- /dev/null +++ b/patches/xorg-proto/jinx-working-patch.patch @@ -0,0 +1,27 @@ +diff --git xorg-proto-clean/include/X11/Xos.h xorg-proto-workdir/include/X11/Xos.h +index 75cc5b7..9adf88d 100644 +--- xorg-proto-clean/include/X11/Xos.h ++++ xorg-proto-workdir/include/X11/Xos.h +@@ -60,7 +60,7 @@ in this Software without prior written authorization from The Open Group. + */ + + # include +-# if defined(__SCO__) || defined(__UNIXWARE__) || defined(__sun) || defined(__CYGWIN__) || defined(_AIX) || defined(__APPLE__) || defined(__FreeBSD__) ++# if defined(__SCO__) || defined(__UNIXWARE__) || defined(__sun) || defined(__CYGWIN__) || defined(_AIX) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__aero__) + # include + # else + # ifndef index +diff --git xorg-proto-clean/include/X11/Xos_r.h xorg-proto-workdir/include/X11/Xos_r.h +index f963b64..5ade17b 100644 +--- xorg-proto-clean/include/X11/Xos_r.h ++++ xorg-proto-workdir/include/X11/Xos_r.h +@@ -318,7 +318,7 @@ static __inline__ void _Xpw_copyPasswd(_Xgetpwparams p) + (_Xos_processUnlock), \ + (p).pwp ) + +-#elif !defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(__APPLE__) ++#elif !defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(__APPLE__) && !defined(__aero__) + # define X_NEEDS_PWPARAMS + typedef struct { + struct passwd pws; + diff --git a/patches/xorg-server/xorg-server.patch b/patches/xorg-server/jinx-working-patch.patch similarity index 53% rename from patches/xorg-server/xorg-server.patch rename to patches/xorg-server/jinx-working-patch.patch index 9dc515d75fd..11667724116 100644 --- a/patches/xorg-server/xorg-server.patch +++ b/patches/xorg-server/jinx-working-patch.patch @@ -1,33 +1,27 @@ -From 6f785e20e4034b9016aa7e6cebc204f95b7808d6 Mon Sep 17 00:00:00 2001 -From: mintsuki -Date: Sun, 20 Feb 2022 06:19:57 +0100 -Subject: [PATCH] Lyre specific changes - ---- - configure.ac | 2 ++ - hw/xfree86/common/xf86Bus.c | 2 ++ - hw/xfree86/common/xf86Config.c | 2 ++ - hw/xfree86/common/xf86Configure.c | 2 ++ - hw/xfree86/common/xf86Events.c | 2 ++ - hw/xfree86/common/xf86Helper.c | 2 ++ - hw/xfree86/common/xf86Init.c | 2 ++ - hw/xfree86/fbdevhw/fbdevhw.c | 26 +++++++++++------------- - hw/xfree86/fbdevhw/fbdevhw.h | 4 ++-- - hw/xfree86/os-support/shared/posix_tty.c | 3 +++ - hw/xfree86/os-support/shared/sigio.c | 3 +++ - include/os.h | 1 + - mi/mibitblt.c | 2 ++ - os/access.c | 2 +- - os/ospoll.c | 2 ++ - os/utils.c | 4 ++-- - 16 files changed, 42 insertions(+), 19 deletions(-) - -diff --git a/configure.ac b/configure.ac -index 0909cc5..f551571 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -1966,6 +1966,8 @@ if test "x$XORG" = xyes; then - if test "x$DRM" = xyes; then +diff --git xorg-server-clean/configure.ac xorg-server-workdir/configure.ac +index fad7b57..ed4445c 100644 +--- xorg-server-clean/configure.ac ++++ xorg-server-workdir/configure.ac +@@ -1341,7 +1341,7 @@ AM_CONDITIONAL(INT10MODULE, test "x$INT10MODULE" = xyes) + AC_DEFINE(SHAPE, 1, [Support SHAPE extension]) + + if test "x$XKBPATH" = "xauto"; then +- XKBPATH=$(pkg-config --variable datadir xkbcomp || echo ${datadir})/X11/xkb ++ XKBPATH=$($PKG_CONFIG --variable datadir xkbcomp || echo ${datadir})/X11/xkb + fi + + AC_DEFINE_DIR(XKB_BASE_DIRECTORY, XKBPATH, [Path to XKB data]) +@@ -1351,7 +1351,7 @@ AC_ARG_WITH(xkb-bin-directory, + [XKB_BIN_DIRECTORY="auto"]) + + if test "x$XKB_BIN_DIRECTORY" = "xauto"; then +- XKB_BIN_DIRECTORY=$(pkg-config --variable bindir xkbcomp) ++ XKB_BIN_DIRECTORY=$($PKG_CONFIG --variable bindir xkbcomp) + if test -z $XKB_BIN_DIRECTORY; then + XKB_BIN_DIRECTORY="$bindir" + fi +@@ -1946,6 +1946,8 @@ if test "x$XORG" = xyes; then + if test "x$DRM" = xyes -a "x$DRI2" = xyes; then XORG_DRIVER_MODESETTING=yes fi + @@ -35,11 +29,20 @@ index 0909cc5..f551571 100644 AC_SUBST([XORG_LIBS]) AC_SUBST([XORG_SYS_LIBS]) -diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c -index a8f1073..1b1120a 100644 ---- a/hw/xfree86/common/xf86Bus.c -+++ b/hw/xfree86/common/xf86Bus.c -@@ -536,6 +536,7 @@ xf86GetDevFromEntity(int entityIndex, int instance) +@@ -2127,7 +2129,7 @@ dnl XWin requires OpenGL spec files in order to generate wrapper code for native + AC_MSG_RESULT(yes) + if test "x$KHRONOS_SPEC_DIR" = "xauto" ; then + PKG_CHECK_MODULES([KHRONOS_OPENGL_REGISTRY], [khronos-opengl-registry]) +- KHRONOS_SPEC_DIR=`pkg-config khronos-opengl-registry --variable=specdir` ++ KHRONOS_SPEC_DIR=`$PKG_CONFIG khronos-opengl-registry --variable=specdir` + fi + AC_SUBST(KHRONOS_SPEC_DIR) + fi +diff --git xorg-server-clean/hw/xfree86/common/xf86Bus.c xorg-server-workdir/hw/xfree86/common/xf86Bus.c +index fd144db..6eb018c 100644 +--- xorg-server-clean/hw/xfree86/common/xf86Bus.c ++++ xorg-server-workdir/hw/xfree86/common/xf86Bus.c +@@ -556,6 +556,7 @@ xf86GetDevFromEntity(int entityIndex, int instance) void xf86PostProbe(void) { @@ -47,18 +50,18 @@ index a8f1073..1b1120a 100644 if (fbSlotClaimed && ( #if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) sbusSlotClaimed || -@@ -551,6 +552,7 @@ xf86PostProbe(void) +@@ -571,6 +572,7 @@ xf86PostProbe(void) )) FatalError("Cannot run in framebuffer mode. Please specify busIDs " " for all framebuffer devices\n"); +*/ } - int -diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c -index 09d27ec..83be062 100644 ---- a/hw/xfree86/common/xf86Config.c -+++ b/hw/xfree86/common/xf86Config.c + Bool +diff --git xorg-server-clean/hw/xfree86/common/xf86Config.c xorg-server-workdir/hw/xfree86/common/xf86Config.c +index 5d814c1..14ebfe6 100644 +--- xorg-server-clean/hw/xfree86/common/xf86Config.c ++++ xorg-server-workdir/hw/xfree86/common/xf86Config.c @@ -49,6 +49,8 @@ #include #include @@ -68,10 +71,10 @@ index 09d27ec..83be062 100644 #include "xf86.h" #include "xf86Modes.h" #include "xf86Parser.h" -diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c -index 44e7591..86d48d5 100644 ---- a/hw/xfree86/common/xf86Configure.c -+++ b/hw/xfree86/common/xf86Configure.c +diff --git xorg-server-clean/hw/xfree86/common/xf86Configure.c xorg-server-workdir/hw/xfree86/common/xf86Configure.c +index 4347f6d..52594c6 100644 +--- xorg-server-clean/hw/xfree86/common/xf86Configure.c ++++ xorg-server-workdir/hw/xfree86/common/xf86Configure.c @@ -27,6 +27,8 @@ #include #endif @@ -81,10 +84,10 @@ index 44e7591..86d48d5 100644 #include "xf86.h" #include "xf86Config.h" #include "xf86_OSlib.h" -diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c -index 8a800bd..ec5d33d 100644 ---- a/hw/xfree86/common/xf86Events.c -+++ b/hw/xfree86/common/xf86Events.c +diff --git xorg-server-clean/hw/xfree86/common/xf86Events.c xorg-server-workdir/hw/xfree86/common/xf86Events.c +index 395bbc7..4bf86cb 100644 +--- xorg-server-clean/hw/xfree86/common/xf86Events.c ++++ xorg-server-workdir/hw/xfree86/common/xf86Events.c @@ -53,6 +53,8 @@ #include #endif @@ -94,10 +97,10 @@ index 8a800bd..ec5d33d 100644 #include #include #include -diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c -index 42a51dd..64af1dc 100644 ---- a/hw/xfree86/common/xf86Helper.c -+++ b/hw/xfree86/common/xf86Helper.c +diff --git xorg-server-clean/hw/xfree86/common/xf86Helper.c xorg-server-workdir/hw/xfree86/common/xf86Helper.c +index 0389945..b53b1a7 100644 +--- xorg-server-clean/hw/xfree86/common/xf86Helper.c ++++ xorg-server-workdir/hw/xfree86/common/xf86Helper.c @@ -38,6 +38,8 @@ #include #endif @@ -105,12 +108,12 @@ index 42a51dd..64af1dc 100644 +#include + #include + #include "mi.h" #include "os.h" - #include "servermd.h" -diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c -index 2ec6b2f..c1d9c24 100644 ---- a/hw/xfree86/common/xf86Init.c -+++ b/hw/xfree86/common/xf86Init.c +diff --git xorg-server-clean/hw/xfree86/common/xf86Init.c xorg-server-workdir/hw/xfree86/common/xf86Init.c +index 5695e71..96c2d15 100644 +--- xorg-server-clean/hw/xfree86/common/xf86Init.c ++++ xorg-server-workdir/hw/xfree86/common/xf86Init.c @@ -37,6 +37,8 @@ #include #include @@ -120,10 +123,10 @@ index 2ec6b2f..c1d9c24 100644 #undef HAS_UTSNAME #if !defined(WIN32) #define HAS_UTSNAME 1 -diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c -index 9508951..bce130c 100644 ---- a/hw/xfree86/fbdevhw/fbdevhw.c -+++ b/hw/xfree86/fbdevhw/fbdevhw.c +diff --git xorg-server-clean/hw/xfree86/fbdevhw/fbdevhw.c xorg-server-workdir/hw/xfree86/fbdevhw/fbdevhw.c +index 3d8b92e..f7be685 100644 +--- xorg-server-clean/hw/xfree86/fbdevhw/fbdevhw.c ++++ xorg-server-workdir/hw/xfree86/fbdevhw/fbdevhw.c @@ -10,12 +10,12 @@ #include "xf86_OSproc.h" @@ -161,7 +164,7 @@ index 9508951..bce130c 100644 /* only touch non-PCI devices on this path */ +/* { - char buf[PATH_MAX]; + char buf[PATH_MAX] = {0}; char *sysfs_path = NULL; @@ -344,6 +347,7 @@ fbdev_open(int scrnIndex, const char *dev, char **namep) } @@ -227,10 +230,10 @@ index 9508951..bce130c 100644 goto RETRY; default: fPtr->unsupported_ioctls |= (1 << FBIOBLANK_UNSUPPORTED); -diff --git a/hw/xfree86/fbdevhw/fbdevhw.h b/hw/xfree86/fbdevhw/fbdevhw.h +diff --git xorg-server-clean/hw/xfree86/fbdevhw/fbdevhw.h xorg-server-workdir/hw/xfree86/fbdevhw/fbdevhw.h index 4984ccf..bb3e2f8 100644 ---- a/hw/xfree86/fbdevhw/fbdevhw.h -+++ b/hw/xfree86/fbdevhw/fbdevhw.h +--- xorg-server-clean/hw/xfree86/fbdevhw/fbdevhw.h ++++ xorg-server-workdir/hw/xfree86/fbdevhw/fbdevhw.h @@ -16,9 +16,9 @@ extern _X_EXPORT void fbdevHWFreeRec(ScrnInfoPtr pScrn); extern _X_EXPORT int fbdevHWGetFD(ScrnInfoPtr pScrn); @@ -243,10 +246,10 @@ index 4984ccf..bb3e2f8 100644 char *device); extern _X_EXPORT char *fbdevHWGetName(ScrnInfoPtr pScrn); -diff --git a/hw/xfree86/os-support/shared/posix_tty.c b/hw/xfree86/os-support/shared/posix_tty.c +diff --git xorg-server-clean/hw/xfree86/os-support/shared/posix_tty.c xorg-server-workdir/hw/xfree86/os-support/shared/posix_tty.c index 0cb9788..e8cac5d 100644 ---- a/hw/xfree86/os-support/shared/posix_tty.c -+++ b/hw/xfree86/os-support/shared/posix_tty.c +--- xorg-server-clean/hw/xfree86/os-support/shared/posix_tty.c ++++ xorg-server-workdir/hw/xfree86/os-support/shared/posix_tty.c @@ -56,6 +56,9 @@ #include #endif @@ -257,10 +260,10 @@ index 0cb9788..e8cac5d 100644 #include #include #include "xf86.h" -diff --git a/hw/xfree86/os-support/shared/sigio.c b/hw/xfree86/os-support/shared/sigio.c -index 247bec7..216e8cd 100644 ---- a/hw/xfree86/os-support/shared/sigio.c -+++ b/hw/xfree86/os-support/shared/sigio.c +diff --git xorg-server-clean/hw/xfree86/os-support/shared/sigio.c xorg-server-workdir/hw/xfree86/os-support/shared/sigio.c +index ad8af60..6f81278 100644 +--- xorg-server-clean/hw/xfree86/os-support/shared/sigio.c ++++ xorg-server-workdir/hw/xfree86/os-support/shared/sigio.c @@ -56,6 +56,9 @@ #include #endif @@ -271,22 +274,22 @@ index 247bec7..216e8cd 100644 #include #include #include "xf86.h" -diff --git a/include/os.h b/include/os.h -index 2a1c29e..2a7fc76 100644 ---- a/include/os.h -+++ b/include/os.h -@@ -51,6 +51,7 @@ SOFTWARE. - #include - #include +diff --git xorg-server-clean/include/os.h xorg-server-workdir/include/os.h +index 7db2408..8862645 100644 +--- xorg-server-clean/include/os.h ++++ xorg-server-workdir/include/os.h +@@ -54,6 +54,7 @@ SOFTWARE. + #include /* for reallocarray */ + #endif #include +#include #ifdef MONOTONIC_CLOCK #include #endif -diff --git a/mi/mibitblt.c b/mi/mibitblt.c -index 43d9bd9..740c0d2 100644 ---- a/mi/mibitblt.c -+++ b/mi/mibitblt.c +diff --git xorg-server-clean/mi/mibitblt.c xorg-server-workdir/mi/mibitblt.c +index 0b13e49..aff6539 100644 +--- xorg-server-clean/mi/mibitblt.c ++++ xorg-server-workdir/mi/mibitblt.c @@ -49,6 +49,8 @@ SOFTWARE. #include #endif @@ -296,12 +299,12 @@ index 43d9bd9..740c0d2 100644 #include #include -diff --git a/os/access.c b/os/access.c -index 9724616..3c4376a 100644 ---- a/os/access.c -+++ b/os/access.c -@@ -117,7 +117,7 @@ SOFTWARE. - #endif +diff --git xorg-server-clean/os/access.c xorg-server-workdir/os/access.c +index 61ee8e3..24cabae 100644 +--- xorg-server-clean/os/access.c ++++ xorg-server-workdir/os/access.c +@@ -120,7 +120,7 @@ SOFTWARE. + #include #endif -#if defined(SVR4) || (defined(SYSV) && defined(__i386__)) || defined(__GNU__) @@ -309,10 +312,10 @@ index 9724616..3c4376a 100644 #include #endif #if defined(SYSV) && defined(__i386__) -diff --git a/os/ospoll.c b/os/ospoll.c +diff --git xorg-server-clean/os/ospoll.c xorg-server-workdir/os/ospoll.c index c68aabc..a3217dc 100644 ---- a/os/ospoll.c -+++ b/os/ospoll.c +--- xorg-server-clean/os/ospoll.c ++++ xorg-server-workdir/os/ospoll.c @@ -45,11 +45,13 @@ #define HAVE_OSPOLL 1 #endif @@ -327,11 +330,11 @@ index c68aabc..a3217dc 100644 #if !HAVE_OSPOLL #include "xserver_poll.h" -diff --git a/os/utils.c b/os/utils.c -index 2ba1c80..63dedc6 100644 ---- a/os/utils.c -+++ b/os/utils.c -@@ -1402,7 +1402,7 @@ System(const char *command) +diff --git xorg-server-clean/os/utils.c xorg-server-workdir/os/utils.c +index 92a66e8..f29b359 100644 +--- xorg-server-clean/os/utils.c ++++ xorg-server-workdir/os/utils.c +@@ -1403,7 +1403,7 @@ System(const char *command) return -1; } @@ -340,7 +343,16 @@ index 2ba1c80..63dedc6 100644 } static struct pid { -@@ -1632,7 +1632,7 @@ Pclose(void *iop) +@@ -1475,7 +1475,7 @@ Popen(const char *command, const char *type) + } + close(pdes[1]); + } +- execl("/bin/sh", "sh", "-c", command, (char *) NULL); ++ execl("/usr/bin/sh", "sh", "-c", command, (char *) NULL); + _exit(127); + } + +@@ -1633,7 +1633,7 @@ Pclose(void *iop) } #endif @@ -349,5 +361,3 @@ index 2ba1c80..63dedc6 100644 } int --- -2.35.1 diff --git a/patches/xorg-xinit/jinx-working-patch.patch b/patches/xorg-xinit/jinx-working-patch.patch new file mode 100644 index 00000000000..b21b01acafb --- /dev/null +++ b/patches/xorg-xinit/jinx-working-patch.patch @@ -0,0 +1,13 @@ +diff --git xorg-xinit-clean/startx.cpp xorg-xinit-workdir/startx.cpp +index dfbebe1..99a0586 100644 +--- xorg-xinit-clean/startx.cpp ++++ xorg-xinit-workdir/startx.cpp +@@ -127,6 +127,8 @@ if defaults read $X11_PREFS_DOMAIN 2> /dev/null | grep -q 'dpi' && defaults read + defaultserverargs="$defaultserverargs -dpi `defaults read $X11_PREFS_DOMAIN dpi`" + fi + ++#elif defined(__aero__) ++enable_xauth=0 + #else + enable_xauth=1 + #endif diff --git a/patches/xorg-xinit/xorg-xinit.patch b/patches/xorg-xinit/xorg-xinit.patch deleted file mode 100644 index 800ec95d404..00000000000 --- a/patches/xorg-xinit/xorg-xinit.patch +++ /dev/null @@ -1,25 +0,0 @@ -From e071d54e12c9feaa8bfd19f52247d13d45e94ab2 Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Sat, 10 Dec 2022 19:17:27 +1100 -Subject: [PATCH] - ---- - startx.cpp | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/startx.cpp b/startx.cpp -index 1c6fce0..e42051c 100644 ---- a/startx.cpp -+++ b/startx.cpp -@@ -113,6 +113,8 @@ if defaults read $X11_PREFS_DOMAIN 2> /dev/null | grep -q 'dpi' && defaults read - defaultserverargs="$defaultserverargs -dpi `defaults read $X11_PREFS_DOMAIN dpi`" - fi - -+#elif defined(__aero__) -+enable_xauth=0 - #else - enable_xauth=1 - #endif --- -2.38.1 - diff --git a/patches/zlib/0001-zlib-aero-specific-changes.patch b/patches/zlib/0001-zlib-aero-specific-changes.patch deleted file mode 100644 index 4efc38d0efa..00000000000 --- a/patches/zlib/0001-zlib-aero-specific-changes.patch +++ /dev/null @@ -1,26 +0,0 @@ -From b0efeeaf9b78c440328295f17224fa3128d85d7d Mon Sep 17 00:00:00 2001 -From: Andy-Python-Programmer -Date: Tue, 28 Jun 2022 17:38:43 +1000 -Subject: [PATCH] zlib: aero specific changes - -Signed-off-by: Andy-Python-Programmer ---- - configure | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/configure b/configure -index 52ff4a0..6fbfb91 100755 ---- a/configure -+++ b/configure -@@ -218,7 +218,7 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then - uname=`(uname -s || echo unknown) 2>/dev/null` - fi - case "$uname" in -- Linux* | linux* | GNU | GNU/* | solaris*) -+ Linux* | linux* | GNU | GNU/* | solaris* | aero*) - LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} ;; - *BSD | *bsd* | DragonFly) - LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1,--version-script,${SRCDIR}zlib.map"} --- -2.25.1 - diff --git a/recipes/at-spi2-core b/recipes/at-spi2-core new file mode 100644 index 00000000000..901136259c6 --- /dev/null +++ b/recipes/at-spi2-core @@ -0,0 +1,22 @@ +name=at-spi2-core +version=2.51.0 +revision=1 +tarball_url="https://download.gnome.org/sources/at-spi2-core/2.51/at-spi2-core-${version}.tar.xz" +tarball_blake2b="67a622f1ffba322183c6c04c8de6311bceb48f6ad6d34ad7bc33b22ab0c695a5395b5aad729eff699ab1c0525d1a4059c30899b03be8656e87204ec4333e432c" +imagedeps="meson ninja" +hostdeps="gcc pkg-config" +deps="core-libs dbus glib libxml" + +build() { + meson_configure \ + -Dsystemd_user_dir=/tmp \ + -Dintrospection=disabled + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + post_package_strip +} diff --git a/recipes/autoconf-archive b/recipes/autoconf-archive new file mode 100644 index 00000000000..5e70163b0cf --- /dev/null +++ b/recipes/autoconf-archive @@ -0,0 +1,12 @@ +name=autoconf-archive +version=2023.02.20 +revision=1 +tarball_url="https://ftp.gnu.org/gnu/autoconf-archive/autoconf-archive-${version}.tar.xz" +tarball_blake2b="a72469e61a6ef702cbf4e30712c7dbe36369da7dad6e2312eb7026af41a989a47ded0a27975349486b69155f9e8199f89720dc57f98440b2766294a0f8755ee6" + +package() { + mkdir -p "${dest_dir}${prefix}"/share/aclocal + cp -r "${source_dir}"/m4/. "${dest_dir}${prefix}"/share/aclocal/ + + post_package_strip +} diff --git a/recipes/base-files b/recipes/base-files new file mode 100644 index 00000000000..b29669d9ad3 --- /dev/null +++ b/recipes/base-files @@ -0,0 +1,8 @@ +name=base-files +version=0.0 +revision=1 +source_dir="base-files" + +package() { + cp -rpv ${source_dir}/. "${dest_dir}"/ +} diff --git a/recipes/bash b/recipes/bash new file mode 100644 index 00000000000..82e670a674c --- /dev/null +++ b/recipes/bash @@ -0,0 +1,30 @@ +name=bash +version=5.2.21 +revision=1 +tarball_url="https://ftp.gnu.org/gnu/bash/bash-${version}.tar.gz" +tarball_blake2b="6789c9a0d9eb1ad167d4199bf1438d77934a7bbeae9f9fdd7167cae006b17b3894852440248db1bb6e9cf6d930e8a18b6448a3bb4db8831b2e6d1445b56a2065" +source_hostdeps="autoconf automake libtool pkg-config" +imagedeps="gcc" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs ncurses readline" + +regenerate() { + AUTOHEADER=true autoreconf -fvi +} + +build() { + autotools_configure \ + --with-curses \ + --enable-readline \ + --without-bash-malloc \ + --with-installed-readline="${sysroot}/usr/lib" + + make -j${parallelism} +} + +package() { + make install DESTDIR="${dest_dir}" + ln -s bash "${dest_dir}${prefix}"/bin/sh + + post_package_strip +} diff --git a/recipes/binutils b/recipes/binutils new file mode 100644 index 00000000000..5328b30c325 --- /dev/null +++ b/recipes/binutils @@ -0,0 +1,40 @@ +name=binutils +version=2.41 +revision=1 +tarball_url="https://ftp.gnu.org/gnu/binutils/binutils-${version}.tar.xz" +tarball_blake2b="3bccec2b52f7e82a727121bf2a2e51a6249ba63dcd74c665fd834e858645c912ffd8245d848435288b938852830b482905606f55c40df4061215fd75c52ffc75" +source_hostdeps="autoconf-2.69 automake libtool pkg-config" +imagedeps="gcc" +hostdeps="gcc autoconf-2.69 automake libtool pkg-config" +deps="core-libs zlib gmp" + +regenerate() { + autotools_recursive_regen -I"$(realpath ./config)" + + cp -pv /usr/local/share/libtool/build-aux/{config.sub,config.guess,install-sh} libiberty/ +} + +build() { + autotools_configure \ + --target=${OS_TRIPLET} \ + --disable-werror \ + --disable-dependency-tracking \ + --enable-colored-disassembly \ + --with-system-zlib \ + --with-gmp=${sysroot_dir}/usr + + SFRAME_LIB_PATH="-L$(pwd -P)/libsframe/.libs" \ + make -j${parallelism} all +} + +package() { + DESTDIR="${dest_dir}" make install + + # Remove unnecessary directory + rm -rf "${dest_dir}${prefix}"/${OS_TRIPLET} + + # Remove static libraries + rm -rf "${dest_dir}${prefix}"/lib/*.a + + post_package_strip +} diff --git a/recipes/bzip2 b/recipes/bzip2 new file mode 100644 index 00000000000..f0f064df6af --- /dev/null +++ b/recipes/bzip2 @@ -0,0 +1,66 @@ +name=bzip2 +version=1.0.8 +revision=1 +tarball_url="https://sourceware.org/ftp/bzip2/bzip2-${version}.tar.gz" +tarball_blake2b="22ab3acd84f4db8c3d6f59340c252faedfd4447cea00dafbd652e65b6cf8a20adf6835c22e58563004cfafdb15348c924996230b4b23cae42da5e25eeac4bdad" +hostdeps="gcc pkg-config" +deps="core-libs" + +build() { + cp -r ${source_dir}/. . + sed -i 's/all: libbz2.a bzip2 bzip2recover test/all: libbz2.a bzip2 bzip2recover/g' Makefile + + make CC=${OS_TRIPLET}-gcc CFLAGS="$CFLAGS -fPIC" -f Makefile-libbz2_so + make clean + make CC=${OS_TRIPLET}-gcc AR=${OS_TRIPLET}-ar CFLAGS="$CFLAGS -fPIC" -j${parallelism} +} + +package() { + mkdir -p "${dest_dir}${prefix}/bin" "${dest_dir}${prefix}/lib" "${dest_dir}${prefix}/lib/pkgconfig" "${dest_dir}${prefix}/include" + install bzip2-shared "${dest_dir}${prefix}/bin/bzip2" + install bzip2recover "${dest_dir}${prefix}/bin/" + install bzdiff "${dest_dir}${prefix}/bin/" + install bzgrep "${dest_dir}${prefix}/bin/" + install bzmore "${dest_dir}${prefix}/bin/" + install libbz2.so.${version} "${dest_dir}${prefix}/lib/" + install -m 644 bzlib.h "${dest_dir}${prefix}/include/" + ln -sf libbz2.so.${version} "${dest_dir}${prefix}/lib/libbz2.so.1.0" + ln -sf libbz2.so.1.0 "${dest_dir}${prefix}/lib/libbz2.so.1" + ln -sf libbz2.so.1 "${dest_dir}${prefix}/lib/libbz2.so" + ln -sf bzdiff "${dest_dir}${prefix}/bin/bzcmp" + ln -sf bzgrep "${dest_dir}${prefix}/bin/bzegrep" + ln -sf bzgrep "${dest_dir}${prefix}/bin/bzfgrep" + ln -sf bzmore "${dest_dir}${prefix}/bin/bzless" + cat <"${dest_dir}${prefix}/lib/pkgconfig/bzip2.pc" +prefix=${prefix} +exec_prefix=${prefix}/bin +libdir=${prefix}/lib +sharedlibdir=${prefix}/lib +includedir=${prefix}/include + +Name: bzip2 +Description: BZip2 compression library +Version: ${version} + +Requires: +Libs: -L${prefix}/lib -lbz2 +Cflags: -I${prefix}/include +EOF + cat <"${dest_dir}${prefix}/lib/pkgconfig/libbz2.pc" +prefix=${prefix} +exec_prefix=${prefix}/bin +libdir=${prefix}/lib +sharedlibdir=${prefix}/lib +includedir=${prefix}/include + +Name: libbz2 +Description: BZip2 compression library +Version: ${version} + +Requires: +Libs: -L${prefix}/lib -lbz2 +Cflags: -I${prefix}/include +EOF + + post_package_strip +} diff --git a/recipes/cairo b/recipes/cairo new file mode 100644 index 00000000000..59ae52ed272 --- /dev/null +++ b/recipes/cairo @@ -0,0 +1,24 @@ +name=cairo +version=1.18.0 +revision=1 +tarball_url="https://cairographics.org/releases/cairo-${version}.tar.xz" +tarball_blake2b="6f6abedb2614e3dd1eed7fcb97cd11296584fb2072617ab3d532bee94e6a83db003ce770d39ba1df84c96a9f6880f4de357f78a22904daf1bb874c9570abd336" +imagedeps="meson ninja binutils" +hostdeps="gcc pkg-config" +deps="core-libs freetype2 fontconfig libpng pixman libxcb libx11 libxext mesa libxrender glib zlib" + +build() { + meson_configure \ + -Dxlib-xcb=enabled \ + -Dzlib=enabled \ + -Dtee=enabled \ + -Dtests=disabled + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + post_package_strip +} diff --git a/recipes/core-libs b/recipes/core-libs new file mode 100644 index 00000000000..32ab76cd3a8 --- /dev/null +++ b/recipes/core-libs @@ -0,0 +1,3 @@ +name=core-libs +revision=1 +deps="mlibc libgcc libstdc++ libintl libiconv libxcrypt" diff --git a/recipes/coreutils b/recipes/coreutils new file mode 100644 index 00000000000..0e228af75ef --- /dev/null +++ b/recipes/coreutils @@ -0,0 +1,40 @@ +name=coreutils +version=9.4 +revision=1 +tarball_url="https://ftp.gnu.org/gnu/coreutils/coreutils-${version}.tar.xz" +tarball_blake2b="83d41c48804c1d470c0e5eed38e692bb6875436dda3f6e2c29784ad6ef563d86e8e066a050e222621b400f78ea4630b1e127d20fc9b76f12096528c42677e35d" +source_imagedeps="gcc gperf" +source_hostdeps="automake autoconf libtool pkg-config" +imagedeps="gcc gperf" +hostdeps="gcc automake autoconf libtool pkg-config" +deps="core-libs tzdata" + +regenerate() { + autotools_recursive_regen + + # Huge hack: coreutils does not compile the build-machine binary make-prime-list + # using the build-machine compiler. Hence, build and invoke the binary manually here. + mkdir tmp_build_dir + pushd tmp_build_dir + + ../configure + make src/make-prime-list + ./src/make-prime-list 5000 > ../src/primes.h + + popd + rm -rf tmp_build_dir +} + +build() { + cp -rp "${source_dir}"/. ./ + + configure_script_path=./configure \ + CFLAGS="-DSLOW_BUT_NO_HACKS $CFLAGS" \ + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install-strip +} diff --git a/recipes/cxxshim b/recipes/cxxshim new file mode 100644 index 00000000000..b10c6bbc26c --- /dev/null +++ b/recipes/cxxshim @@ -0,0 +1,21 @@ +name=cxxshim +version=6f146a41dda736572879fc524cf729eb193dc0a6 +revision=1 +tarball_url="https://github.com/managarm/cxxshim/archive/${version}.tar.gz" +tarball_blake2b="05d8cbad3d46b4272c7e31b1c8041cc5e640cc66853dddf58af953aeba6697dcbc05decb01dc6d4669fec52acd18b3265706dbf710d11dd98e7c1771ac598a49" +imagedeps="meson ninja" +hostdeps="pkg-config" + +build() { + meson_configure \ + --includedir=share/cxxshim/include \ + -Dinstall_headers=true + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + post_package_strip +} diff --git a/recipes/dbus b/recipes/dbus new file mode 100644 index 00000000000..d1cc1b85d6e --- /dev/null +++ b/recipes/dbus @@ -0,0 +1,39 @@ +name=dbus +version=1.15.8 +revision=1 +tarball_url="https://dbus.freedesktop.org/releases/dbus/dbus-${version}.tar.xz" +tarball_blake2b="7c1962dfccc6a1b6250e80b0706d7f44536fabeff009013865ec4b1edaec6d4b47dcbe8f78caa61ef7aef4bac6b79f0e2027dd16bbb2baae328429e648bf8b8c" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="autoconf-archive" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs glib libexpat" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure \ + --runstatedir=/run \ + --disable-doxygen-docs \ + --disable-xml-docs \ + --with-systemdsystemunitdir=no \ + --with-systemduserunitdir=no \ + --with-system-pid-file=/run/dbus/pid \ + --with-system-socket=/run/dbus/system_bus_socket \ + --disable-selinux \ + --disable-apparmor \ + --disable-libaudit \ + --disable-kqueue \ + --disable-launchd \ + --disable-systemd \ + --disable-tests + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/fontconfig b/recipes/fontconfig new file mode 100644 index 00000000000..4e6189696c7 --- /dev/null +++ b/recipes/fontconfig @@ -0,0 +1,29 @@ +name=fontconfig +version=2.14.2 +revision=1 +tarball_url="https://www.freedesktop.org/software/fontconfig/release/fontconfig-${version}.tar.xz" +tarball_blake2b="4efeeb7f9a6705d493128d00b60e681a20a47556f4c0d7787a5c7a6d2cbbc22f150cad7988a9836a9e72aeb61e2b6a196c00a071c7042c62283c7720cdbb743d" +source_hostdeps="automake autoconf libtool pkg-config" +imagedeps="python gperf" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs freetype2 libexpat libxml" + +regenerate() { + autotools_recursive_regen + + # Make sure we regenerate this file + rm -f src/fcobjshash.h +} + +build() { + autotools_configure \ + --enable-libxml2 + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/freeglut b/recipes/freeglut new file mode 100644 index 00000000000..ca4e5d1f5ae --- /dev/null +++ b/recipes/freeglut @@ -0,0 +1,28 @@ +name=freeglut +version=3.4.0 +revision=1 +tarball_url="https://github.com/FreeGLUTProject/freeglut/releases/download/v${version}/freeglut-${version}.tar.gz" +tarball_blake2b="47b073c4e81473417358452ede3891b6fc36e324f66eec42fcbbadebb2144680e3b52caded504135239e170fd8f30a1fe8b6666a746b06d48cd7226c98a8114e" +imagedeps="gcc ninja python git" +hostdeps="gcc cmake pkg-config" +deps="core-libs libxi mesa glu" + +build() { + cmake \ + -GNinja \ + -DCMAKE_TOOLCHAIN_FILE=${base_dir}/userland/CMakeToolchain-x86_64.cmake \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=ON \ + -DFREEGLUT_BUILD_DEMOS=OFF \ + -DFREEGLUT_BUILD_STATIC_LIBS=OFF \ + ${source_dir} + + ninja +} + +package() { + DESTDIR="${dest_dir}" ninja install + + post_package_strip +} diff --git a/recipes/freetype2 b/recipes/freetype2 new file mode 100644 index 00000000000..a330732f3aa --- /dev/null +++ b/recipes/freetype2 @@ -0,0 +1,21 @@ +name=freetype2 +version=2.13.2 +revision=1 +tarball_url="https://download.savannah.gnu.org/releases/freetype/freetype-${version}.tar.xz" +tarball_blake2b="cebc82180d9afaeb112a65ba78903d7bf7a9295a803166a033585ad2325add6023f05066852240c4665e56285345ba503b01ecd461d48f0478a8f3f56136988e" +source_hostdeps="pkg-config" +imagedeps="meson gcc" +hostdeps="gcc pkg-config" +deps="core-libs bzip2 libpng zlib" + +build() { + meson_configure + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + post_package_strip +} diff --git a/recipes/fribidi b/recipes/fribidi new file mode 100644 index 00000000000..a49d73a6d22 --- /dev/null +++ b/recipes/fribidi @@ -0,0 +1,25 @@ +name=fribidi +version=1.0.13 +revision=1 +tarball_url="https://github.com/fribidi/fribidi/releases/download/v${version}/fribidi-${version}.tar.xz" +tarball_blake2b="8cc31220304ddbdeb0047b30ed9084921920b32ad3f1bdcf29ecbb2fafbd430c391bc99bb7f205546ff8482aea1ef7ed369da71deb3474aa623fc2aeace1b62a" +source_hostdeps="automake autoconf libtool pkg-config" +imagedeps="gcc" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/frigg b/recipes/frigg new file mode 100644 index 00000000000..84df948df6d --- /dev/null +++ b/recipes/frigg @@ -0,0 +1,22 @@ +name=frigg +version=a24e99eeb3125e7f48f657ff8afca26a9ac4aaae +revision=1 +tarball_url="https://github.com/managarm/frigg/archive/${version}.tar.gz" +tarball_blake2b="bb47eb23f4a0d6cc31d8d2345d424d713f4c0f7b02c28a5a17d937023e778961a9a3a553facfdd60ce58d45da2479e6018ecbb9b39f9bf87c30995bb19698666" +imagedeps="gcc meson ninja" +hostdeps="pkg-config" + +build() { + meson_configure \ + --includedir=share/frigg/include \ + --buildtype=debugoptimized \ + -Dbuild_tests=disabled + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + post_package_strip +} diff --git a/recipes/gcc b/recipes/gcc new file mode 100644 index 00000000000..9fe89c5f762 --- /dev/null +++ b/recipes/gcc @@ -0,0 +1,48 @@ +name=gcc +version=13.2.0 +revision=1 +tarball_url="https://ftp.gnu.org/gnu/gcc/gcc-${version}/gcc-${version}.tar.xz" +tarball_blake2b="0034b29d3d6cc05821f0c4253ce077805943aff7b370729dd203bda57d89c107edd657eeddc2fb1e69ea15c7b0323b961f46516c7f4af89a3ccf7fea84701be2" +source_hostdeps="automake autoconf-2.69 libtool pkg-config" +source_imagedeps="git" +hostdeps="gcc autoconf-2.69 automake libtool pkg-config" +deps="core-libs binutils zlib gmp mpfr mpc" +imagedeps="gcc" + +regenerate() { + for i in "${base_dir}"/patches/gcc-host/*; do + patch -p1 < "$i" + done + + autotools_recursive_regen -I"$(realpath ./config)" + + cp -pv /usr/local/share/libtool/build-aux/{config.sub,config.guess,install-sh} libiberty/ +} + +build() { + CXXFLAGS_FOR_TARGET="$CFLAGS" \ + CFLAGS_FOR_TARGET="$CFLAGS" \ + autotools_configure \ + --target=${OS_TRIPLET} \ + --with-sysroot=/ \ + --with-build-sysroot=${sysroot_dir} \ + --enable-languages=c,c++,lto \ + --enable-initfini-array \ + --disable-multilib \ + --with-system-zlib \ + --enable-host-shared \ + --with-pkgversion=aero \ + --with-bugurl="https://github.com/Andy-Python-Programmer/aero/issues" + + make -j${parallelism} all-gcc +} + +package() { + DESTDIR="${dest_dir}" make install-gcc + + ln -s gcc "${dest_dir}${prefix}"/bin/cc + # Remove static libraries + rm -rf "${dest_dir}${prefix}"/lib/*.a + + post_package_strip +} diff --git a/recipes/gdk-pixbuf b/recipes/gdk-pixbuf new file mode 100644 index 00000000000..3991fd4537f --- /dev/null +++ b/recipes/gdk-pixbuf @@ -0,0 +1,22 @@ +name=gdk-pixbuf +version=2.42.10 +revision=1 +tarball_url="https://download.gnome.org/sources/gdk-pixbuf/2.42/gdk-pixbuf-${version}.tar.xz" +tarball_blake2b="b6bec388b70a971ea5b336001920fdf433bcbc539d54e62c7b6198e968f0bd3560ef9adc94215b64b01e7d5db69c95d5a1d32654b38b051fceb75e93666b3385" +imagedeps="meson ninja" +hostdeps="gcc pkg-config" +deps="core-libs glib libjpeg-turbo libpng libx11 libtiff" + +build() { + meson_configure \ + -Dgio_sniffing=false \ + -Dman=false + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + post_package_strip +} diff --git a/recipes/gettext b/recipes/gettext new file mode 100644 index 00000000000..bdceb9d1f3c --- /dev/null +++ b/recipes/gettext @@ -0,0 +1,41 @@ +name=gettext +version=0.22.4 +revision=1 +tarball_url="https://ftp.gnu.org/gnu/gettext/gettext-${version}.tar.xz" +tarball_blake2b="3f93aa5aef8e40d2e01acaa5aeed11efefd0de43ea26d084a0b9e743019685f7584d8e1bf05c1fd5772a5576d21ee1f052b81366f52c7827b6d14bd4d9890edc" +source_hostdeps="automake autoconf libtool pkg-config" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs" + +regenerate() { + ( cd gettext-runtime/libasprintf && autoreconf -fvi ) + ( cd gettext-runtime/intl && autoreconf -fvi ) + ( cd gettext-runtime && autoreconf -fvi ) + ( cd gettext-tools && autoreconf -fvi ) + ( cd libtextstyle && autoreconf -fvi ) + autoreconf -fvi +} + +build() { + cp -rp ${source_dir}/. ./ + + ACLOCAL=true \ + AUTOCONF=true \ + AUTOMAKE=true \ + AUTOHEADER=true \ + configure_script_path=./configure \ + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + # Remove conflicting libintl files + rm -f "${dest_dir}${prefix}"/include/libintl.h + rm -f "${dest_dir}${prefix}"/lib/libintl.so* + rm -f "${dest_dir}${prefix}"/share/locale/locale.alias + + post_package_strip +} diff --git a/recipes/glib b/recipes/glib new file mode 100644 index 00000000000..665f67d72ea --- /dev/null +++ b/recipes/glib @@ -0,0 +1,21 @@ +name=glib +version=2.78.1 +revision=1 +tarball_url="https://download.gnome.org/sources/glib/2.78/glib-${version}.tar.xz" +tarball_blake2b="af8f2e83600dfb3ec84702399cb00a3aaedbc80087e35dc7cc2e2374d4fe5fdf82707ac8c911da1c53eb7b027c9da9ecfc1c0a8f56b39431fa4cf44cad5b10f7" +imagedeps="meson ninja" +hostdeps="gcc pkg-config" +deps="core-libs pcre2 libffi zlib" + +build() { + meson_configure \ + -Dxattr=false + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + post_package_strip +} diff --git a/recipes/glib-networking b/recipes/glib-networking new file mode 100644 index 00000000000..c36d6ab8ef0 --- /dev/null +++ b/recipes/glib-networking @@ -0,0 +1,22 @@ +name=glib-networking +version=2.78.0 +tarball_url="https://gitlab.gnome.org/GNOME/glib-networking/-/archive/${version}/glib-networking-${version}.tar.gz" +tarball_blake2b="a8b73a303f427c8069db9060f4037051b11a5bcc83f5c3673ac3ca630f22de31a911b9a31056e35e59ace52609718f2d4055aac08d1975a158d4a4a135a81204" +deps="core-libs glib openssl" +imagedeps="meson" +hostdeps="gcc pkg-config" + +build() { + meson_configure \ + -Dgnutls=disabled \ + -Dopenssl=enabled \ + -Dinstalled_tests=false \ + -Dlibproxy=disabled \ + -Dgnome_proxy=disabled + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install +} diff --git a/recipes/glu b/recipes/glu new file mode 100644 index 00000000000..70b3e68be9f --- /dev/null +++ b/recipes/glu @@ -0,0 +1,21 @@ +name=glu +version=9.0.3 +revision=1 +tarball_url="https://archive.mesa3d.org/glu/glu-${version}.tar.xz" +tarball_blake2b="a6fc842004dcca4243ef285e26806afdfb931d21985ad8f9a3f03f438e66b810718bf04e588044ed8db99990e49f806d346dc2ce69cfa91450f046a4dfa39136" +imagedeps="meson ninja" +hostdeps="gcc pkg-config" +deps="core-libs mesa" + +build() { + meson_configure \ + -Dgl_provider=gl + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + post_package_strip +} diff --git a/recipes/gmp b/recipes/gmp new file mode 100644 index 00000000000..7d8981748ff --- /dev/null +++ b/recipes/gmp @@ -0,0 +1,26 @@ +name=gmp +version=6.3.0 +revision=1 +tarball_url="https://ftp.gnu.org/gnu/gmp/gmp-${version}.tar.xz" +tarball_blake2b="a865129e2b3f634ec5bad7f97ed89532e43f5662ac47a7d8ab7f0df8c9f8d0886bd984651422e2573c2163bca69c0547c248147ec90880accbd53db97dc0ddee" +source_hostdeps="automake autoconf libtool pkg-config" +imagedeps="gcc" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs" + +regenerate() { + autoreconf -fvi +} + +build() { + autotools_configure \ + --enable-cxx + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/graphite2 b/recipes/graphite2 new file mode 100644 index 00000000000..88e477d300c --- /dev/null +++ b/recipes/graphite2 @@ -0,0 +1,25 @@ +name=graphite2 +version=1.3.14 +revision=1 +tarball_url="https://github.com/silnrsi/graphite/releases/download/${version}/graphite2-${version}.tgz" +tarball_blake2b="72bf6736aaa8476a89e44ef53c5b6c94f45d815fe1a451ba6b3696bfe023971210975dee4a9c8cb3042f36442e4efecf5baf171ef4230ad2b10694a89865f918" +imagedeps="ninja python" +hostdeps="gcc cmake pkg-config" +deps="core-libs" + +build() { + cmake \ + -GNinja \ + -DCMAKE_TOOLCHAIN_FILE=${base_dir}/userland/CMakeToolchain-x86_64.cmake \ + -DCMAKE_INSTALL_PREFIX=${prefix} \ + -DCMAKE_BUILD_TYPE=Release \ + ${source_dir} + + ninja +} + +package() { + DESTDIR="${dest_dir}" ninja install + + post_package_strip +} diff --git a/recipes/grep b/recipes/grep new file mode 100644 index 00000000000..6bc28b421fb --- /dev/null +++ b/recipes/grep @@ -0,0 +1,28 @@ +name=grep +version=3.11 +revision=1 +tarball_url="https://ftp.gnu.org/gnu/grep/grep-${version}.tar.xz" +tarball_blake2b="e21785bca20b5a090d32bb5dc525fb298af30165106ed4c289b1518ea3d2acdcacfd6309b12f13be29a4b958f19588546119c695deb2b7500d49dcff86357bdc" +source_hostdeps="automake autoconf libtool pkg-config" +imagedeps="gperf" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs pcre2" + +regenerate() { + autotools_recursive_regen +} + +build() { + cp -rp "${source_dir}"/. ./ + + configure_script_path=./configure \ + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/gsettings-desktop-schemas b/recipes/gsettings-desktop-schemas new file mode 100644 index 00000000000..f5d0e003206 --- /dev/null +++ b/recipes/gsettings-desktop-schemas @@ -0,0 +1,28 @@ +name=gsettings-desktop-schemas +version=45.0 +revision=1 +tarball_url="https://download.gnome.org/sources/gsettings-desktop-schemas/45/gsettings-desktop-schemas-${version}.tar.xz" +tarball_blake2b="b65c846654fac5a104ad9a7d67546c6fb3d54aada178d58c575d22a8c2adc0057c1f1dc177562740f7ae94d0e17743789ca902db7c2fcc42c844bb66e401eaec" +imagedeps="meson ninja" +hostdeps="gcc pkg-config" +deps="core-libs glib" + +regenerate() { + sed -i -r 's:"(/system):"/org/gnome\1:g' schemas/*.in +} + +build() { + meson_configure \ + -Dintrospection=false + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + glib-compile-schemas "${dest_dir}${prefix}"/share/glib-2.0/schemas + rm "${dest_dir}${prefix}"/share/glib-2.0/schemas/gschemas.compiled + + post_package_strip +} diff --git a/recipes/gtk+-3 b/recipes/gtk+-3 new file mode 100644 index 00000000000..6b39227fc57 --- /dev/null +++ b/recipes/gtk+-3 @@ -0,0 +1,29 @@ +name=gtk+-3 +version=3.24.41 +revision=1 +tarball_url="https://download.gnome.org/sources/gtk%2B/3.24/gtk%2B-${version}.tar.xz" +tarball_blake2b="fbded114fe2b5c1c7bffe79d0a22d559f97081eb972baf31b5c9bd7190bd1ea2875f1c632d3f3be8233377299f1df15bbffbe45d50cc7ff588e034eb41eb8f6e" +imagedeps="meson ninja gdk-pixbuf2" +hostdeps="gcc pkg-config" +deps="core-libs at-spi2-core cairo glib gdk-pixbuf libx11 libxext libxcb libxinerama libxrender libxrandr libxfixes libxdamage pango fribidi libepoxy libxkbcommon fontconfig freetype2 libxi harfbuzz libxcursor gsettings-desktop-schemas dbus" + +build() { + meson_configure \ + -Dprint_backends=file \ + -Dintrospection=false \ + -Dx11_backend=true \ + -Dbroadway_backend=true \ + -Dwayland_backend=false \ + -Dcolord=no + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + glib-compile-schemas "${dest_dir}${prefix}"/share/glib-2.0/schemas + rm "${dest_dir}${prefix}"/share/glib-2.0/schemas/gschemas.compiled + + post_package_strip +} diff --git a/recipes/harfbuzz b/recipes/harfbuzz new file mode 100644 index 00000000000..9de7c3b06ea --- /dev/null +++ b/recipes/harfbuzz @@ -0,0 +1,35 @@ +name=harfbuzz +version=8.3.0 +revision=1 +tarball_url="https://github.com/harfbuzz/harfbuzz/releases/download/${version}/harfbuzz-${version}.tar.xz" +tarball_blake2b="3749d2ff7955e135cf0d740bf6fe8b5c20a6bbf171480a29e6ae14fde8c26e1457506278b8c66e3b9630cbeb006874c19075c784a575e490c41297274a27fe59" +imagedeps="meson ninja" +hostdeps="gcc pkg-config" +deps="core-libs graphite2 glib zlib freetype2 cairo icu" + +build() { + cp -rp "${source_dir}"/. ./ + + mkdir build && cd build + + meson_source_dir=.. \ + meson_configure \ + -Dgraphite2=enabled \ + -Dglib=enabled \ + -Dgobject=disabled \ + -Dicu=enabled \ + -Dfreetype=enabled \ + -Dcairo=enabled \ + -Dintrospection=disabled \ + -Dtests=disabled + + ninja -j${parallelism} + + cd .. +} + +package() { + ( cd build && DESTDIR="${dest_dir}" ninja install ) + + post_package_strip +} diff --git a/recipes/icu b/recipes/icu new file mode 100644 index 00000000000..0471c276370 --- /dev/null +++ b/recipes/icu @@ -0,0 +1,36 @@ +name=icu +version=73.1 +revision=1 +tarball_url="https://github.com/unicode-org/icu/releases/download/release-73-1/icu4c-73_1-src.tgz" +tarball_blake2b="45de117efc4a49301c04a997963393967a70b8583abf1a9626331e275c5bc329cf2685de5c80b32f764c8ff2530b5594316d7119ce66503e5adba7842ca24424" +source_hostdeps="autoconf automake libtool pkg-config" +source_deps="autoconf-archive" +imagedeps="gcc" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs" + +regenerate() { + autotools_recursive_regen + cp source/config/{mh-linux,mh-unknown} +} + +build() { + mkdir cross-build + cd cross-build + ${source_dir}/source/configure \ + --prefix=/usr/local + make -j${parallelism} + cd .. + + configure_script_path=${source_dir}/source/configure \ + autotools_configure \ + --with-cross-build=$(realpath cross-build) + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/jwm b/recipes/jwm new file mode 100644 index 00000000000..ddf4baf9b91 --- /dev/null +++ b/recipes/jwm @@ -0,0 +1,29 @@ +name=jwm +version=2.4.3 +revision=1 +tarball_url="https://github.com/joewing/jwm/releases/download/v${version}/jwm-${version}.tar.xz" +tarball_blake2b="d0b0ff1088ab3390a90c054162ea2c2fe782b61f28b3fdb28464ace362143fdc94e25ec82f7f4178b86a26c9315cdfcf9a81bff2e76bb5e3d62f88968a4ee80b" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="gettext" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libx11 libxft libjpeg-turbo libxpm libxinerama libpng" + +regenerate() { + AUTOMAKE=true \ + autotools_recursive_regen +} + +build() { + cp -rp "${source_dir}"/. ./ + + autotools_configure \ + --disable-fribidi + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + cp -v "${base_dir}"/build-support/jwm/system.jwmrc "${dest_dir}"/etc/ + post_package_strip +} diff --git a/recipes/less b/recipes/less new file mode 100644 index 00000000000..8307c4b3e45 --- /dev/null +++ b/recipes/less @@ -0,0 +1,24 @@ +name=less +version=643 +revision=1 +tarball_url="https://www.greenwoodsoftware.com/less/less-${version}.tar.gz" +tarball_blake2b="6dc60dc2e8db05afdae466877a1d26a3008ff5378bbbf2fbdf9efc4f87c0fcfde5703d44a24d4355c98d3a5f438bdb51173150f2a69f801d9c8e4a7401d71b53" +source_hostdeps="autoconf automake libtool pkg-config" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs ncurses" + +regenerate() { + autoreconf -fvi +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + make install DESTDIR="${dest_dir}" + + post_package_strip +} diff --git a/recipes/libepoxy b/recipes/libepoxy new file mode 100644 index 00000000000..cbe4ca7b8c1 --- /dev/null +++ b/recipes/libepoxy @@ -0,0 +1,22 @@ +name=libepoxy +version=1.5.10 +revision=1 +tarball_url="https://download.gnome.org/sources/libepoxy/1.5/libepoxy-${version}.tar.xz" +tarball_blake2b="105267b1b19acf8c86e5e9d23741dfc738e014de4f0b30f88e7ec22f98497cc8e006d729f17b5698780ca1dd782bad99f73ae685b2bf882b77670bb6c4b959c9" +imagedeps="meson ninja" +hostdeps="gcc pkg-config" +deps="core-libs mesa xorg-proto libx11" + +build() { + meson_configure \ + -Degl=no \ + -Dtests=false + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + post_package_strip +} diff --git a/recipes/libexpat b/recipes/libexpat new file mode 100644 index 00000000000..72c936cf16f --- /dev/null +++ b/recipes/libexpat @@ -0,0 +1,24 @@ +name=libexpat +version=2.5.0 +revision=1 +tarball_url="https://github.com/libexpat/libexpat/releases/download/R_2_5_0/expat-${version}.tar.xz" +tarball_blake2b="670298d076ff3b512a0212170d40cb04c601a11d6b152f215a5302ad3238c69c2386393d7a6c70bc284be35ce97bf27d87115c3391f4bc17406e509d739d3e31" +source_hostdeps="automake autoconf libtool pkg-config" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs" + +regenerate() { + autoreconf -fvi +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libffi b/recipes/libffi new file mode 100644 index 00000000000..646bc260f24 --- /dev/null +++ b/recipes/libffi @@ -0,0 +1,24 @@ +name=libffi +version=3.4.4 +revision=1 +tarball_url="https://github.com/libffi/libffi/releases/download/v${version}/libffi-${version}.tar.gz" +tarball_blake2b="189fe1ffe9507f204581b0ab09995dc7e7b761bb4eac7e338e9f5ff81431aebcef6c182c1839c9f9acb2706697a260c67e6d1351cf7e2aed7c4eb5d694f6f8fd" +source_hostdeps="automake autoconf libtool pkg-config" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs" + +regenerate() { + autoreconf -fvi +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libfontenc b/recipes/libfontenc new file mode 100644 index 00000000000..da6703de92c --- /dev/null +++ b/recipes/libfontenc @@ -0,0 +1,25 @@ +name=libfontenc +version=1.1.7 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libfontenc-${version}.tar.gz" +tarball_blake2b="538dc45801dd2fc3b18527b5716fd468089206728ce4704416eb0ecd2ed528f951d64e7bf2f779a5852363670724458c966538afcec813a9823f5d04303d1bbb" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-font-util xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto zlib" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libgcc b/recipes/libgcc new file mode 100644 index 00000000000..b635a352529 --- /dev/null +++ b/recipes/libgcc @@ -0,0 +1,35 @@ +name=libgcc +revision=1 +hostdeps="gcc autoconf-2.69 automake libtool pkg-config" +imagedeps="gcc" +deps="mlibc" + +build() { + cd "${base_dir}"/host-builds/gcc/build + + make -j${parallelism} all-target-libgcc +} + +package() { + cd "${base_dir}"/host-builds/gcc/build + + rm -rf tmp_libgcc_dir + mkdir tmp_libgcc_dir + + DESTDIR="$(realpath tmp_libgcc_dir)" make install-target-libgcc + + mkdir -p "${dest_dir}${prefix}" + + cp -r tmp_libgcc_dir/usr/local/lib "${dest_dir}${prefix}"/ + cp -r tmp_libgcc_dir/usr/local/${OS_TRIPLET}/* "${dest_dir}${prefix}"/ + + rm "${dest_dir}${prefix}"/lib/gcc/${OS_TRIPLET}/13.2.0/crti.o + rm "${dest_dir}${prefix}"/lib/gcc/${OS_TRIPLET}/13.2.0/crtn.o + + # Copy libgcc into GCC's tree else it will complain. + mkdir -p "${base_dir}"/host-pkgs/gcc/usr/local/lib + cp -r tmp_libgcc_dir/usr/local/lib/* "${base_dir}"/host-pkgs/gcc/usr/local/lib/ + + rm "${base_dir}"/host-pkgs/gcc/usr/local/lib/gcc/${OS_TRIPLET}/13.2.0/crti.o + rm "${base_dir}"/host-pkgs/gcc/usr/local/lib/gcc/${OS_TRIPLET}/13.2.0/crtn.o +} diff --git a/recipes/libgcrypt b/recipes/libgcrypt new file mode 100644 index 00000000000..f5d51bdd739 --- /dev/null +++ b/recipes/libgcrypt @@ -0,0 +1,31 @@ +name=libgcrypt +version=1.10.3 +revision=1 +tarball_url="https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-${version}.tar.gz" +tarball_blake2b="86636e88a96ed531718eeed7915e7ab4e359b17500f648a075853f575e7a50fbb7dc78d1f2dbf2a96a7c46ced6cafdbbb4b6b31dd2f34e663f05df30f1096c85" +source_hostdeps="automake autoconf libtool pkg-config" +imagedeps="gcc" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libgpg-error" + +regenerate() { + autotools_recursive_regen +} + +build() { + cp -rp "${source_dir}"/. ./ + + configure_script_path=./configure \ + autotools_configure \ + --disable-dev-random \ + --disable-asm \ + --with-libgpg-error-prefix="${sysroot_dir}${prefix}" + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libgpg-error b/recipes/libgpg-error new file mode 100644 index 00000000000..26b81051a56 --- /dev/null +++ b/recipes/libgpg-error @@ -0,0 +1,30 @@ +name=libgpg-error +version=1.47 +revision=1 +tarball_url="https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-${version}.tar.gz" +tarball_blake2b="f1e185127192396cde5676030217471f31f46b5f8bde9314bfe74039297a608356f89208139245c9efce3cba1ba7609f230219c8c6cab9f24de05ad384c43c7d" +source_hostdeps="automake autoconf libtool pkg-config" +imagedeps="gcc" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs" + +regenerate() { + cp -v src/syscfg/lock-obj-pub.x86_64-unknown-linux-gnu.h src/syscfg/lock-obj-pub.aero.h + + autotools_recursive_regen +} + +build() { + cp -rp "${source_dir}"/. ./ + + configure_script_path=./configure \ + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libice b/recipes/libice new file mode 100644 index 00000000000..b5d07585061 --- /dev/null +++ b/recipes/libice @@ -0,0 +1,25 @@ +name=libice +version=1.1.1 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libICE-${version}.tar.gz" +tarball_blake2b="1acb1cdb5b0fd49451b6e4498061c16fff35711a19a5da2c2de0046b6b3ed6bd6bdccf8d45f7adcdb7f2f685245176488f149b41087e562945754088f18c220b" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto xtrans" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libiconv b/recipes/libiconv new file mode 100644 index 00000000000..f0bfd9cfaaa --- /dev/null +++ b/recipes/libiconv @@ -0,0 +1,32 @@ +name=libiconv +version=1.17 +revision=1 +tarball_url="https://ftp.gnu.org/gnu/libiconv/libiconv-${version}.tar.gz" +tarball_blake2b="1d317dd0655c680a2082c38561cdff51ac1a9181d4734a8bb1e86861dfd66f1a6c0846a90b5b88f3b38b1fa9983d9e563551f27e95a8e329896b71becceae52b" +source_hostdeps="automake autoconf libtool pkg-config" +imagedeps="binutils" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="mlibc libgcc libstdc++" + +regenerate() { + cp /usr/local/share/aclocal/libtool.m4 ./m4/ + cp /usr/local/share/aclocal/libtool.m4 ./libcharset/m4/ + cp /usr/local/share/libtool/build-aux/ltmain.sh ./build-aux/ + cp /usr/local/share/libtool/build-aux/ltmain.sh ./libcharset/build-aux/ + cp /usr/local/share/aclocal/ltversion.m4 ./m4/ + cp /usr/local/share/aclocal/ltversion.m4 ./libcharset/m4/ + + autotools_recursive_regen -I"${source_dir}"/m4 -I"${source_dir}"/srcm4 +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libintl b/recipes/libintl new file mode 100644 index 00000000000..9ed0db0bac8 --- /dev/null +++ b/recipes/libintl @@ -0,0 +1,39 @@ +name=libintl +from_source=gettext +revision=1 +hostdeps="gcc automake autoconf libtool pkg-config" +deps="mlibc libgcc libstdc++ libiconv" + +build() { + ACLOCAL=true \ + AUTOCONF=true \ + AUTOMAKE=true \ + AUTOHEADER=true \ + autotools_configure \ + --without-emacs \ + --without-lispdir \ + `# Normally this controls nls behavior in general, but the libintl` \ + `# subdir is skipped unless this is explicitly set.` \ + --enable-nls \ + `# This magic flag enables libintl.` \ + --with-included-gettext \ + --disable-c++ \ + --disable-libasprintf \ + --disable-java \ + --enable-threads=posix \ + --disable-curses \ + --without-git \ + --without-cvs \ + --without-bzip2 \ + --without-xz + + sed -i 's/touch $@//g' gettext-runtime/intl/Makefile + + make -C gettext-runtime/intl -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make -C gettext-runtime/intl install + + post_package_strip +} diff --git a/recipes/libjpeg-turbo b/recipes/libjpeg-turbo new file mode 100644 index 00000000000..321b873253c --- /dev/null +++ b/recipes/libjpeg-turbo @@ -0,0 +1,29 @@ +name=libjpeg-turbo +version=2.1.5.1 +revision=1 +tarball_url="https://github.com/libjpeg-turbo/libjpeg-turbo/archive/refs/tags/${version}.tar.gz" +tarball_blake2b="44a6f61594f0d0cfac3e3a63ddfa9dcc940a5249fcd69e6d5324749d62e8a5e575bb2c5de9b651d63f27d6f03927146367cd8b8275aa1f4f51fd412ebac95797" +imagedeps="gcc ninja python git cmake nasm" +hostdeps="gcc pkg-config" +deps="core-libs" + +build() { + cmake \ + -GNinja \ + -DCMAKE_TOOLCHAIN_FILE=${base_dir}/userland/CMakeToolchain-x86_64.cmake \ + -DCMAKE_INSTALL_PREFIX=${prefix} \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_STATIC=FALSE \ + -DCMAKE_INSTALL_DEFAULT_LIBDIR=lib \ + -DWITH_JPEGS=ON \ + -DCMAKE_SYSTEM_PROCESSOR=x86_64 \ + ${source_dir} + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + post_package_strip +} diff --git a/recipes/libnghttp2 b/recipes/libnghttp2 new file mode 100644 index 00000000000..bc08b96ed6f --- /dev/null +++ b/recipes/libnghttp2 @@ -0,0 +1,27 @@ +name=libnghttp2 +version=1.59.0 +tarball_url="https://github.com/nghttp2/nghttp2/releases/download/v${version}/nghttp2-${version}.tar.gz" +tarball_blake2b="167e973844131915ce8c50e8e4cfa6807ca56cdbacf0c5d03b0b9d8846c76020d7ffde492d62a9d5f91801024126f2ff52833a58e1458246dcbbafbf76b8b99c" +imagedeps="ninja python" +hostdeps="gcc cmake pkg-config" +deps="core-libs" + +build() { + cmake \ + -GNinja \ + -DCMAKE_TOOLCHAIN_FILE=${base_dir}/userland/CMakeToolchain-x86_64.cmake \ + -DCMAKE_INSTALL_PREFIX=${prefix} \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_STATIC=FALSE \ + -DCMAKE_INSTALL_DEFAULT_LIBDIR=lib \ + -DCMAKE_SYSTEM_PROCESSOR=x86_64 \ + ${source_dir} + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + post_package_strip +} diff --git a/recipes/libpng b/recipes/libpng new file mode 100644 index 00000000000..f515dd626cf --- /dev/null +++ b/recipes/libpng @@ -0,0 +1,24 @@ +name=libpng +version=1.6.40 +revision=1 +tarball_url="https://download.sourceforge.net/libpng/libpng-${version}.tar.xz" +tarball_blake2b="4dd2df57791ca68cc31ba966b9176ecb37458572c60eef34e31ff0d3266d25ad6ea9d2e8cae6bfaf7932b5c7bc231047d3ed139b3464304c41cc4d89611f5ba8" +source_hostdeps="automake autoconf libtool pkg-config" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs zlib" + +regenerate() { + autoreconf -fvi +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libpsl b/recipes/libpsl new file mode 100644 index 00000000000..53ed6a1333a --- /dev/null +++ b/recipes/libpsl @@ -0,0 +1,28 @@ +name=libpsl +version=0.21.5 +tarball_url="https://github.com/rockdaboot/libpsl/releases/download/${version}/libpsl-${version}.tar.gz" +tarball_blake2b="a0076f622b85df99f866de6707850ac216b764bdb68c6d516f4603da42dac8eae3ee4c53d68dbb6af6f779c2c7f1b9caab74c8b558209b1f6823f95c13fc3ceb" +deps="core-libs libunistring libiconv" +hostdeps="gcc pkg-config autoconf automake libtool" +source_hostdeps="automake autoconf libtool pkg-config" +source_imagedeps="gtk-doc" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure \ + --disable-asan \ + --disable-cfi \ + --disable-ubsan \ + --disable-man + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libsm b/recipes/libsm new file mode 100644 index 00000000000..570ea264f6a --- /dev/null +++ b/recipes/libsm @@ -0,0 +1,25 @@ +name=libsm +version=1.2.4 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libSM-${version}.tar.gz" +tarball_blake2b="9f05c36f933ddbe66e06a96c7b9f5c23a2b5218da724a838b42ef4b798195c24a2be13e1d5c61bccf7660a4880f78da8452fa93a668f483ce808ce840c2cfcfb" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto libice" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libsoup b/recipes/libsoup new file mode 100644 index 00000000000..02838d6237b --- /dev/null +++ b/recipes/libsoup @@ -0,0 +1,27 @@ +name=libsoup +version=3.4.4 +tarball_url="https://gitlab.gnome.org/GNOME/libsoup/-/archive/${version}/libsoup-${version}.tar.gz" +tarball_blake2b="006af4bd6f9e5be63421b33bb5b0204d0013fe1312ce2392cbd7fc609d650dc07fa38849f0d179d7907568e9faa0843a74f54e86fe6803e665865d5fed4d3b36" +deps="core-libs glib glib-networking zlib libxml libpsl sqlite libnghttp2" +imagedeps="meson" +hostdeps="gcc pkg-config" + +build() { + meson_configure \ + -Dintrospection=disabled \ + -Dinstalled_tests=false \ + -Dsysprof=disabled \ + -Ddocs=disabled \ + -Dvapi=disabled \ + -Dtls_check=false \ + -Dbrotli=disabled \ + -Dntlm=disabled \ + -Dgssapi=disabled \ + -Dtests=false + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install +} diff --git a/recipes/libstdc++ b/recipes/libstdc++ new file mode 100644 index 00000000000..3f908ac205b --- /dev/null +++ b/recipes/libstdc++ @@ -0,0 +1,33 @@ +name=libstdc++ +revision=1 +hostdeps="gcc autoconf-2.69 automake libtool pkg-config" +imagedeps="gcc" +deps="mlibc libgcc" + +build() { + cd "${base_dir}"/host-builds/gcc/build + + make -j${parallelism} all-target-libstdc++-v3 +} + +package() { + cd "${base_dir}"/host-builds/gcc/build + + rm -rf tmp_libstdc++_dir + mkdir tmp_libstdc++_dir + + DESTDIR="$(realpath tmp_libstdc++_dir)" make install-target-libstdc++-v3 + + # For some reason this also installs libgcc even though it shouldn't... + # Remove it. + rm -fv tmp_libstdc++_dir/usr/local/${OS_TRIPLET}/lib/libgcc* + + mkdir -p "${dest_dir}${prefix}" + + cp -r tmp_libstdc++_dir/usr/local/share "${dest_dir}${prefix}"/ + cp -r tmp_libstdc++_dir/usr/local/${OS_TRIPLET}/* "${dest_dir}${prefix}"/ + + # Copy libstdc++ and headers into GCC's tree else it will complain. + mkdir -p "${base_dir}"/host-pkgs/gcc/usr/local/${OS_TRIPLET} + cp -r tmp_libstdc++_dir/usr/local/${OS_TRIPLET}/* "${base_dir}"/host-pkgs/gcc/usr/local/${OS_TRIPLET}/ +} diff --git a/recipes/libtasn b/recipes/libtasn new file mode 100644 index 00000000000..16ea5d3bcc3 --- /dev/null +++ b/recipes/libtasn @@ -0,0 +1,29 @@ +name=libtasn +version=4.19.0 +revision=1 +tarball_url="https://au.mirrors.cicku.me/gnu/libtasn1/libtasn1-${version}.tar.gz" +tarball_blake2b="6e8232590cd87da3bfd9182ed44eccdfbdfcc85e88d8cf19fffdb3d600e04694b77079b95bbd822d2c3fff29458ddae0f0440f9c1c19c711923a2507bd19270f" +source_hostdeps="automake autoconf libtool pkg-config" +imagedeps="gcc" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs glib" +source_imagedeps="gtk-doc" + +regenerate() { + autotools_recursive_regen +} + +build() { + cp -rp "${source_dir}"/. ./ + + autotools_configure \ + --disable-doc + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libtiff b/recipes/libtiff new file mode 100644 index 00000000000..4c22e07b820 --- /dev/null +++ b/recipes/libtiff @@ -0,0 +1,31 @@ +name=libtiff +version=4.6.0 +revision=1 +tarball_url="https://download.osgeo.org/libtiff/tiff-${version}.tar.xz" +tarball_blake2b="3b508b02b0a536c5bc8e67fe4c1b09ae9c830252786ef4764202c14d673d1ef9634694de7a5893a3551dec684d00bad9d0442c7fea7bcd09238b9960d443cf62" +source_hostdeps="automake autoconf libtool pkg-config" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs freeglut libjpeg-turbo zlib zstd xz" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure \ + --without-x \ + --enable-zlib \ + --enable-zstd \ + --enable-jpeg \ + --enable-lzma \ + --disable-webp \ + --enable-cxx + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libunistring b/recipes/libunistring new file mode 100644 index 00000000000..14dce176227 --- /dev/null +++ b/recipes/libunistring @@ -0,0 +1,24 @@ +name=libunistring +version=1.1 +revision=1 +tarball_url="https://ftp.gnu.org/gnu/libunistring/libunistring-${version}.tar.xz" +tarball_blake2b="721adc90884006480055b95d0fa06cd862417aa02b467f1e14688292ad9c11f1e33520b14ed5dc2d2724c6df8713d3af1e8032014259d8355156cb72edfcb983" +source_hostdeps="automake autoconf libtool pkg-config" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libwebp b/recipes/libwebp new file mode 100644 index 00000000000..dc99cfc2076 --- /dev/null +++ b/recipes/libwebp @@ -0,0 +1,29 @@ +name=libwebp +version=1.3.2 +revision=1 +tarball_url="https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-${version}.tar.gz" +tarball_blake2b="12b3ff3aa9952dd32ce13656146556d5efb6a66860249a8676721980aee10253a1b0335685a769d995e9954cd305190a8ed1878ba4fefce9dcaf41a3976f9e3d" +source_hostdeps="automake autoconf libtool pkg-config" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libjpeg-turbo libpng freeglut sdl2 libtiff" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure \ + --enable-libwebpmux \ + --enable-libwebpdemux \ + --enable-libwebpdecoder \ + --enable-libwebpextras \ + --enable-swap-16bit-csp + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libx11 b/recipes/libx11 new file mode 100644 index 00000000000..97660737e5e --- /dev/null +++ b/recipes/libx11 @@ -0,0 +1,28 @@ +name=libx11 +version=1.8.7 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libX11-${version}.tar.xz" +tarball_blake2b="335d8af91c13aba11255c266c4687a7f66b021207a92485d723b4107601bbabb6a0e5535241a3bcff4ac9a99142730d2b3d2e2eaff86b507fee5b35a2590d792" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xtrans xorg-util-macros" +imagedeps="gcc" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto libxcb xtrans" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure \ + --disable-ipv6 \ + --with-keysymdefdir=${sysroot_dir}/usr/include/X11 + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxau b/recipes/libxau new file mode 100644 index 00000000000..8739b09e88a --- /dev/null +++ b/recipes/libxau @@ -0,0 +1,25 @@ +name=libxau +version=1.0.11 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libXau-${version}.tar.gz" +tarball_blake2b="2c1066e40fe64ebd8b095bb7bac436d3b0d518080b80e93d1def040af390bd08ed3f4f49feb0b4b390a5733e74bf7429c96ddac5f8fbfb904eb25b496676618a" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxaw b/recipes/libxaw new file mode 100644 index 00000000000..bd172a1db7a --- /dev/null +++ b/recipes/libxaw @@ -0,0 +1,25 @@ +name=libxaw +version=1.0.15 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libXaw-${version}.tar.gz" +tarball_blake2b="71d7b413f9a5178149871c810122589ec74fb4b1e78e884a1538871afd69ad775c3ff15e0c0b21115700f5c9c0965c65336b4c07c1d1069490e6c214ad0f3af0" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libxmu libxpm" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxcb b/recipes/libxcb new file mode 100644 index 00000000000..58a14a40a25 --- /dev/null +++ b/recipes/libxcb @@ -0,0 +1,27 @@ +name=libxcb +version=1.16 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libxcb-${version}.tar.xz" +tarball_blake2b="1ddd5c2e6be8400a0a77db4b5fbd4698996fd1a00984e370b1f712f6b9ce456c8ccfb6992f2973f5eaf8d5b6b75f39b9f51a1458c2432ddb41edd8199b91b3f9" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +imagedeps="python" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto libxau libxdmcp xcb-proto" + +regenerate() { + autotools_recursive_regen + sed -i 's/pthread-stubs//' "${source_dir}"/configure +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxcomposite b/recipes/libxcomposite new file mode 100644 index 00000000000..3ef215498dc --- /dev/null +++ b/recipes/libxcomposite @@ -0,0 +1,29 @@ +name=libxcomposite +version=0.4.6 +revision=1 +tarball_url="https://gitlab.freedesktop.org/xorg/lib/libxcomposite/-/archive/libXcomposite-${version}/libxcomposite-libXcomposite-${version}.tar.gz" +tarball_blake2b="6603273ca9481e540478d13b37f0f1267d110dc911cfe02cfe6a22d544071e864821cdfc57dc1348d7f17a0004d2cafc8bca00d5b565e2c85fe8a1149ed50224" +source_hostdeps="automake autoconf libtool pkg-config" +imagedeps="gcc" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libx11 libxfixes xorg-proto" +source_deps="xorg-util-macros" + +regenerate() { + autotools_recursive_regen +} + +build() { + cp -rp "${source_dir}"/. ./ + + autotools_configure \ + --disable-doc + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxcrypt b/recipes/libxcrypt new file mode 100644 index 00000000000..ff6307f100e --- /dev/null +++ b/recipes/libxcrypt @@ -0,0 +1,27 @@ +name=libxcrypt +version=4.4.36 +revision=1 +tarball_url="https://github.com/besser82/libxcrypt/releases/download/v${version}/libxcrypt-${version}.tar.xz" +tarball_blake2b="9f028e0fe2cb7bb4273f3f6d1e579e0fe93cd71eba21286aa7dc078c904ea3cdce38b2955bdcd618853f7657b01aea7e28c4d898680e69fdf75f812b5a304c1d" +source_hostdeps="autoconf automake libtool pkg-config" +imagedeps="python-passlib" +hostdeps="gcc automake autoconf libtool pkg-config" +deps="mlibc libgcc libstdc++" + +regenerate() { + autoreconf -fvi +} + +build() { + autotools_configure \ + --enable-obsolete-api=yes \ + --disable-xcrypt-compat-files + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxcursor b/recipes/libxcursor new file mode 100644 index 00000000000..7456af70e23 --- /dev/null +++ b/recipes/libxcursor @@ -0,0 +1,25 @@ +name=libxcursor +version=1.2.1 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libXcursor-${version}.tar.gz" +tarball_blake2b="42ee1c77f9c976541f51044474b6bf60935ee62d3d95298ce9d71c92e612bc12c460c4161c148d7f9c99a9ea76f74b34ca4f4b8980af2ccabd78fdad4752f2f5" +source_hostdeps="autoconf automake libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libxrender libxfixes libx11" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxcvt b/recipes/libxcvt new file mode 100644 index 00000000000..90ecdf9bf53 --- /dev/null +++ b/recipes/libxcvt @@ -0,0 +1,20 @@ +name=libxcvt +version=0.1.2 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libxcvt-${version}.tar.xz" +tarball_blake2b="8a4803eb6790fd0ea1520fd31e335f7a363c3606e74837a959453be8819ce0d450af7bb651887a891aa657a5eeac3e4983041060fa5c87b1238c83354e425de7" +imagedeps="meson ninja" +hostdeps="gcc pkg-config" +deps="core-libs" + +build() { + meson_configure + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + post_package_strip +} diff --git a/recipes/libxdamage b/recipes/libxdamage new file mode 100644 index 00000000000..8523be15e47 --- /dev/null +++ b/recipes/libxdamage @@ -0,0 +1,25 @@ +name=libxdamage +version=1.1.6 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libXdamage-${version}.tar.gz" +tarball_blake2b="e8fcdbb3b93b7f3a74b10adbb4ceaccc963c7f9ce4fe0edee5842fde7d26cbb2cf3061f073c9ca400baa8378d06ed83c8c751495febb1aeb86a27058d74b1543" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto libxfixes" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxdmcp b/recipes/libxdmcp new file mode 100644 index 00000000000..98bb4e98b2e --- /dev/null +++ b/recipes/libxdmcp @@ -0,0 +1,25 @@ +name=libxdmcp +version=1.1.4 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libXdmcp-${version}.tar.gz" +tarball_blake2b="83973212793c93253b06ee75902842873f1f322c53dc32f054954131243dcf5c31d6792dc5d216134c9536c142b4d5823c8fd998d048ec093383b4f7362fb066" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxext b/recipes/libxext new file mode 100644 index 00000000000..15f6708041c --- /dev/null +++ b/recipes/libxext @@ -0,0 +1,25 @@ +name=libxext +version=1.3.5 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libXext-${version}.tar.gz" +tarball_blake2b="74ee5d3fc3832fc5d9774f7f1a8e0d30ab1af97c35f0e3da0b314c228f8f511cdb106c74eeeb1de56db16d4c2b8aaab34b7ca886f02530319fde1a7ae7788598" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto libx11" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxfixes b/recipes/libxfixes new file mode 100644 index 00000000000..83eb909d284 --- /dev/null +++ b/recipes/libxfixes @@ -0,0 +1,25 @@ +name=libxfixes +version=6.0.1 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libXfixes-${version}.tar.gz" +tarball_blake2b="22be454b2db230057204932ae75aacb2b56523b25b14e501d7e7a2a664e57ae6bcbfa56b6fac4d42d3f8ef770c41debe0eec25451dd70baa9cfc83b1a10e4649" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto libx11" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxfont2 b/recipes/libxfont2 new file mode 100644 index 00000000000..12ba1a1319f --- /dev/null +++ b/recipes/libxfont2 @@ -0,0 +1,28 @@ +name=libxfont2 +version=2.0.6 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libXfont2-${version}.tar.gz" +tarball_blake2b="1a871c6d7c81beadf1c9a5e864a2df186b6429337e86f4fee0c8969d158cf284f10019f69a2f7e0c9298d9f6fa842d5315932152b5e70cb068c5530360e578a0" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto xtrans freetype2 bzip2 libfontenc zlib" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure \ + --with-bzip2 \ + --disable-devel-docs \ + --disable-selective-werror + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxft b/recipes/libxft new file mode 100644 index 00000000000..18e526bf8f3 --- /dev/null +++ b/recipes/libxft @@ -0,0 +1,25 @@ +name=libxft +version=2.3.8 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libXft-${version}.tar.gz" +tarball_blake2b="06d797ed53df793e5b9751bc7984a62a96c973e36d8aa99e4dc96a03e0e7013d6adc9e46f033e1ffcb4632cec2ac0318108ff2894beb4464d44d524254b15328" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libxrender fontconfig" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxi b/recipes/libxi new file mode 100644 index 00000000000..4d22d77d791 --- /dev/null +++ b/recipes/libxi @@ -0,0 +1,25 @@ +name=libxi +version=1.8.1 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libXi-${version}.tar.gz" +tarball_blake2b="473bf5a80c86ef853dcf21b2292eb07818148302b051ca4fb9bfdf42053ae0ae6c53d588de7c027d1c72d7b5a9dba775111f4913b36e771380f4d0fcb823e345" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto libxext libxfixes" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxinerama b/recipes/libxinerama new file mode 100644 index 00000000000..c0b0edcfd06 --- /dev/null +++ b/recipes/libxinerama @@ -0,0 +1,25 @@ +name=libxinerama +version=1.1.5 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libXinerama-${version}.tar.gz" +tarball_blake2b="ac24af05ae483e7f8476cb5fdf901ae80c592a766387e9f662ceeae5906a55e8529b35fcd01b6893289007e30788fd9e3a507af95870acfa6b25b25b159024a5" +source_hostdeps="autoconf automake libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libxext xorg-proto" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxkbcommon b/recipes/libxkbcommon new file mode 100644 index 00000000000..41fff7493a3 --- /dev/null +++ b/recipes/libxkbcommon @@ -0,0 +1,25 @@ +name=libxkbcommon +version=1.6.0 +revision=1 +tarball_url="https://xkbcommon.org/download/libxkbcommon-${version}.tar.xz" +tarball_blake2b="ffd373161f12ea6448a9206f57710355ab65b81ebab5dce74e4dfcee1bdc9175406fc434560648f5933b83cac163099c8564c3add6f51d34856def39ab077850" +imagedeps="meson ninja doxygen" +hostdeps="gcc pkg-config" +deps="core-libs libxcb libxml xkeyboard-config" + +build() { + meson_configure \ + -Dxkb-config-root="$prefix"/share/X11/xkb \ + -Denable-x11=true \ + -Denable-wayland=false + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + mkdir -p "${dest_dir}${prefix}/share/X11/xkb" + + post_package_strip +} diff --git a/recipes/libxkbfile b/recipes/libxkbfile new file mode 100644 index 00000000000..ce39d6814a2 --- /dev/null +++ b/recipes/libxkbfile @@ -0,0 +1,25 @@ +name=libxkbfile +version=1.1.2 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libxkbfile-${version}.tar.gz" +tarball_blake2b="192c0d7a9e9c8f555ccd0a120e79f5d0fb4d9843fe0eb437b5ed5ce62bd65366a50649037aeed9112cd2ca11db4e088282049d4b799bb26d11d2d9b07384a8e1" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libx11" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxml b/recipes/libxml new file mode 100644 index 00000000000..b8b63d8339a --- /dev/null +++ b/recipes/libxml @@ -0,0 +1,29 @@ +name=libxml +version=2.12.3 +revision=1 +tarball_url="https://download.gnome.org/sources/libxml2/2.12/libxml2-${version}.tar.xz" +tarball_blake2b="12a7c25d2a13d839aac918268b0948a9bd3c352bc29dd09bb975a9b4ff99d299a0e157b1a90f01bdce8ddc36ede9a6834b0dc26635ac775a41bd28d9b2ad7cff" +source_hostdeps="automake autoconf libtool pkg-config" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs zlib icu readline" + +regenerate() { + autoreconf -fvi +} + +build() { + autotools_configure \ + --with-threads \ + --disable-ipv6 \ + --without-python \ + --with-history \ + --with-icu + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxmu b/recipes/libxmu new file mode 100644 index 00000000000..92065a47e65 --- /dev/null +++ b/recipes/libxmu @@ -0,0 +1,25 @@ +name=libxmu +version=1.1.4 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libXmu-${version}.tar.gz" +tarball_blake2b="b95188ecd667ffa9d831e547803c16637a968199c4e20d11d8beaf8da19c327aeb655c886f21d6b7d1d2a2b9cce522a091ca791c2626ae74d77f838441fa4a90" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libxext libxt" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxpm b/recipes/libxpm new file mode 100644 index 00000000000..be321e49477 --- /dev/null +++ b/recipes/libxpm @@ -0,0 +1,25 @@ +name=libxpm +version=3.5.17 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libXpm-${version}.tar.gz" +tarball_blake2b="0acc342fb0aebad04a2d68f60106ad8f52910b2ca65d402bfda09e5914ab92b2b2b9d57680bbb6c6f1c8767971e9cffc1315337f6645fb61940a9cb5ccdf80c0" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libxext libxt" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxrandr b/recipes/libxrandr new file mode 100644 index 00000000000..e808fffc200 --- /dev/null +++ b/recipes/libxrandr @@ -0,0 +1,25 @@ +name=libxrandr +version=1.5.4 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libXrandr-${version}.tar.gz" +tarball_blake2b="d5dd5ef33c4452fac7d2c5f16afc15d9e2dcb4e721824ca6e412c6a990ab529003e1beea087afad9dedbcceab17953e066700dac7df0b2aac2cec404335ba93f" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto libx11 libxrender libxext" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxrender b/recipes/libxrender new file mode 100644 index 00000000000..095c7f39bc9 --- /dev/null +++ b/recipes/libxrender @@ -0,0 +1,25 @@ +name=libxrender +version=0.9.11 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libXrender-${version}.tar.gz" +tarball_blake2b="c8d5cf0c925ccf885634ac535b83b6280b49bc354a9c054375ed6db916350f1e5a1892f9937e0726d3d29fec0f531e787e03d76c3a0c0a22ca6c289c28f2287e" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto libx11" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxshmfence b/recipes/libxshmfence new file mode 100644 index 00000000000..0563afddcb8 --- /dev/null +++ b/recipes/libxshmfence @@ -0,0 +1,26 @@ +name=libxshmfence +version=1.3.2 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libxshmfence-${version}.tar.gz" +tarball_blake2b="ae99fff03f94c5b001bd901e446f56e4ed2edbfb140ab92ec471ab910af92d45ceeb623718e65e0b8e9bd301aacf0c5d5d3a31dab0246c824aabe0664957e78e" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure \ + --disable-futex + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxslt b/recipes/libxslt new file mode 100644 index 00000000000..13286647680 --- /dev/null +++ b/recipes/libxslt @@ -0,0 +1,36 @@ +name=libxslt +version=1.1.39 +tarball_url="https://gitlab.gnome.org/GNOME/libxslt/-/archive/v${version}/libxslt-v${version}.tar.gz" +tarball_blake2b="c534663795335273fbb0abccaa4bf7df4bf86200fc52a36c4f7e71ab30158630496665c8886cfd6ecfa3d43bcc475c7b8a1f2839fb288c442063e4b2f0b86d77" +imagedeps="ninja python" +hostdeps="gcc cmake pkg-config" +deps="core-libs libxml" + +build() { + cmake \ + -GNinja \ + -DCMAKE_TOOLCHAIN_FILE=${base_dir}/userland/CMakeToolchain-x86_64.cmake \ + -DCMAKE_INSTALL_PREFIX=${prefix} \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_STATIC=FALSE \ + -DCMAKE_INSTALL_DEFAULT_LIBDIR=lib \ + -DCMAKE_SYSTEM_PROCESSOR=x86_64 \ + -DLIBXSLT_WITH_DEBUGGER=OFF \ + -DLIBXSLT_WITH_CRYPTO=OFF \ + -DLIBXSLT_WITH_MEM_DEBUG=OFF \ + -DLIBXSLT_WITH_MODULES=ON \ + -DLIBXSLT_WITH_PROFILER=OFF \ + -DLIBXSLT_WITH_PYTHON=OFF \ + -DLIBXSLT_WITH_XSLT_DEBUG=OFF \ + -DLIBXSLT_WITH_TESTS=OFF \ + -DLIBXSLT_WITH_THREADS=ON \ + ${source_dir} + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + post_package_strip +} diff --git a/recipes/libxt b/recipes/libxt new file mode 100644 index 00000000000..e4dd3c0652b --- /dev/null +++ b/recipes/libxt @@ -0,0 +1,27 @@ +name=libxt +version=1.3.0 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libXt-${version}.tar.gz" +tarball_blake2b="3fc41d02802ccfda270030bcad73c0ca14c5b986d7353d8395339053a4d34352addda83fa2766af3d340c96416361de6a941688aff6e9b5bbc769a34af40bf53" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +imagedeps="gcc" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libx11 libsm" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure \ + --with-appdefaultdir=/etc/X11/app-defaults + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxv b/recipes/libxv new file mode 100644 index 00000000000..9e35ba9c3b8 --- /dev/null +++ b/recipes/libxv @@ -0,0 +1,25 @@ +name=libxv +version=1.0.12 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libXv-${version}.tar.gz" +tarball_blake2b="21d7d5f40391897d9731ca0772a918d5c33f7de8e3e1307d47e75a44009a74be73a2a47d7751f01e25eabdc6c6ab8889ecda4e266303968b5cec085c38c8edd8" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto libxext" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/libxxf86vm b/recipes/libxxf86vm new file mode 100644 index 00000000000..285986bed16 --- /dev/null +++ b/recipes/libxxf86vm @@ -0,0 +1,25 @@ +name=libxxf86vm +version=1.1.5 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/libXxf86vm-${version}.tar.gz" +tarball_blake2b="396676748546bf2903a9d5ee8603babc04634d6547b38baed07134a7fea81f1691c064c07a9cc4990aeaf1edc911b586b5e11c449aa7872c1ea5b46879029f5e" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto libxext" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/linux-headers b/recipes/linux-headers new file mode 100644 index 00000000000..08825729f00 --- /dev/null +++ b/recipes/linux-headers @@ -0,0 +1,21 @@ +name=linux-headers +version=6.6.12 +source_method=tarball +tarball_url="https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-${version}.tar.xz" +tarball_sha512="bb48a1a40d4db13da075ec46420e5abb0a80b4259fedd65883bcf4a67cd11e2d89026a57c370a11f704e9a41973c8bcbc52be12aa10a0e28e17ead59c9d6c4df" +imagedeps="base-devel rsync" + +regenerate() { + true +} + +build() { + cp -rp "${source_dir}"/. ./ +} + +package() { + make headers_install ARCH=x86_64 INSTALL_HDR_PATH=${dest_dir}/${prefix}/ + + # remove this file, as mlibc will override this file with one suited to mlibc + rm -rf ${dest_dir}/${prefix}/include/linux/libc-compat.h +} diff --git a/recipes/llvm b/recipes/llvm new file mode 100644 index 00000000000..8800987df7d --- /dev/null +++ b/recipes/llvm @@ -0,0 +1,33 @@ +name=llvm +version=17.0.6 +revision=1 +tarball_url="https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/llvm-project-${version}.src.tar.xz" +tarball_blake2b="d6ede1a9fda8756995c3e0654111941649e15794179641806f18919f1dc68c41ca0cabd5693b5096d05dccc3a391cd20d34af1137bf8af92ed3117a1ce84d1b2" +imagedeps="gcc ninja python git" +hostdeps="gcc cmake pkg-config" +deps="core-libs zlib" + +build() { + cmake \ + -GNinja \ + -DCMAKE_TOOLCHAIN_FILE=${base_dir}/userland/CMakeToolchain-x86_64.cmake \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_BUILD_TYPE=Release \ + -DLLVM_LINK_LLVM_DYLIB=ON \ + -DLLVM_ENABLE_RTTI=ON \ + -DLLVM_TARGETS_TO_BUILD=X86 \ + -DLLVM_TARGET_ARCH=x86_64 \ + -DLLVM_DEFAULT_TARGET_TRIPLE=${OS_TRIPLET} \ + -DLLVM_HOST_TRIPLE=${OS_TRIPLET} \ + -DLLVM_ENABLE_TERMINFO=OFF \ + -Wno-dev \ + ${source_dir}/llvm + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + post_package_strip +} diff --git a/recipes/mesa b/recipes/mesa new file mode 100644 index 00000000000..863d6609b25 --- /dev/null +++ b/recipes/mesa @@ -0,0 +1,25 @@ +name=mesa +version=23.3.3 +revision=1 +tarball_url="https://archive.mesa3d.org/mesa-${version}.tar.xz" +tarball_blake2b="6b57e99356abccf398c5fb84953fc1490ddf516dbeed1feca8d16344a04c1c15183325752717447a34a61dd4cdda897147e3194f869d8dbadfa5c45a0c95dab5" +imagedeps="binutils meson ninja python-mako" +hostdeps="gcc pkg-config" +deps="core-libs llvm zlib libxshmfence libxrandr libxdamage libxxf86vm libxfixes libx11 libxext libxcb libexpat" + +build() { + meson_configure \ + -Dglx=xlib \ + -Dplatforms=x11 \ + -Dgallium-drivers=swrast \ + -Dvulkan-drivers= \ + -Dllvm=enabled + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + post_package_strip +} diff --git a/recipes/mesa-demos b/recipes/mesa-demos new file mode 100644 index 00000000000..b3eeaf95831 --- /dev/null +++ b/recipes/mesa-demos @@ -0,0 +1,30 @@ +name=mesa-demos +version=8.5.0 +revision=1 +tarball_url="https://archive.mesa3d.org/demos/${version}/mesa-demos-${version}.tar.gz" +tarball_blake2b="82ded42d845449d925809046d605a30d3f66b5aba57716fdfee99611750001a80aebbda5c66099c3ee9525b655d86e8cf4aeb43adbc939182705ba8fa2ab9c92" +source_hostdeps="automake autoconf libtool pkg-config" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs freetype2 mesa glu libx11 libxext" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure \ + --enable-autotools \ + --disable-gles1 \ + --disable-osmesa \ + --disable-libdrm \ + --with-system-data-files \ + --with-glut=no + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/mlibc b/recipes/mlibc new file mode 100644 index 00000000000..8c4ed720ee7 --- /dev/null +++ b/recipes/mlibc @@ -0,0 +1,28 @@ +name=mlibc +version=0dd4dbdd377dc776e6f7d698281ac6781d652922 +revision=1 +tarball_url="https://github.com/aero-os/mlibc/archive/${version}.tar.gz" +tarball_blake2b="a4886c2d6a85c781293db9139c0773469c3877e5db2a76f1a735e2cc04ee78fef5b8fc1693b724f9fc8879322464ddf48eac8c018ebfd4f8aa983141013d64e3" +imagedeps="meson ninja" +hostdeps="gcc pkg-config libgcc-binaries" +builddeps="cxxshim frigg linux-headers" +deps="mlibc-headers" + +build() { + LDFLAGS="-Wl,/usr/local/libgcc-binaries/libgcc-x86_64.a" \ + meson_configure \ + --buildtype=debugoptimized \ + -Dmlibc_no_headers=true \ + -Ddefault_library=both \ + -Ddisable_crypt_option=true \ + -Ddisable_iconv_option=true \ + -Ddisable_intl_option=true \ + -Ddisable_libgcc_dependency=true \ + -Dlinux_kernel_headers=${sysroot_dir}/${prefix}/include + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install +} diff --git a/recipes/mlibc-headers b/recipes/mlibc-headers new file mode 100644 index 00000000000..e5830247827 --- /dev/null +++ b/recipes/mlibc-headers @@ -0,0 +1,25 @@ +name=mlibc-headers +from_source=mlibc +revision=1 +hostdeps="pkg-config" +imagedeps="meson ninja" +deps="linux-headers" +builddeps="cxxshim frigg" + +build() { + meson setup \ + --cross-file ${base_dir}/userland/cross-file.ini \ + --prefix=${prefix} \ + -Dheaders_only=true \ + -Ddisable_crypt_option=true \ + -Ddisable_iconv_option=true \ + -Ddisable_intl_option=true \ + -Dlinux_kernel_headers=${sysroot_dir}/${prefix}/include \ + ${source_dir} + + ninja +} + +package() { + DESTDIR="${dest_dir}" ninja install +} diff --git a/recipes/mpc b/recipes/mpc new file mode 100644 index 00000000000..0358d280947 --- /dev/null +++ b/recipes/mpc @@ -0,0 +1,26 @@ +name=mpc +version=1.3.1 +revision=1 +tarball_url="https://ftp.gnu.org/gnu/mpc/mpc-${version}.tar.gz" +tarball_blake2b="76434e6f8830af3571836d51576bfebbc9701e9bbb5c4686f134081cd96cd90ae02f7ff42bf9e3957c7a7ba92b6b2d9cdabe18f0269271147521cd7f6a2d551c" +source_imagedeps="git" +source_hostdeps="automake autoconf libtool pkg-config" +imagedeps="gcc" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs gmp mpfr" + +regenerate() { + autoreconf -fvi +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/mpfr b/recipes/mpfr new file mode 100644 index 00000000000..b702c670c62 --- /dev/null +++ b/recipes/mpfr @@ -0,0 +1,33 @@ +name=mpfr +version=4.2.1 +revision=1 +tarball_url="https://ftp.gnu.org/gnu/mpfr/mpfr-${version}.tar.xz" +tarball_blake2b="ad69f53bc910294647523e7613b18a683f1d0f3dd994168ab2a46b66d0371ffa9b8e7cb59495f898470aea69d343e83fc722f11babe4af7b3a12665a1e65860c" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="autoconf-archive" +imagedeps="gcc" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs gmp" + +regenerate() { + autoreconf -fvi +} + +build() { + cp -rp "${source_dir}"/. ./ + + configure_script_path=./configure \ + autotools_configure \ + --enable-static=no \ + --enable-shared=yes \ + --enable-thread-safe \ + --with-pic + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/ncurses b/recipes/ncurses new file mode 100644 index 00000000000..e11c0788c8b --- /dev/null +++ b/recipes/ncurses @@ -0,0 +1,51 @@ +name=ncurses +version=6.4.20231111 +revision=1 +tarball_url="https://github.com/ThomasDickey/ncurses-snapshots/archive/refs/tags/v6_4_20231111.tar.gz" +tarball_blake2b="0d7b490b50e58281250cc4ebdac8f35cbb3fbf0e13578524003ae4c26c10507d59fb8dd2a4d67102067df77d857c41e6c37c509d9a7cee8661dd3bb80f7cbfef" +source_hostdeps="autoconf automake libtool pkg-config" +imagedeps="gcc ncurses patchelf" +hostdeps="gcc automake autoconf libtool pkg-config" +deps="core-libs" + +regenerate() { + cp -pv /usr/local/share/libtool/build-aux/config.guess ./ + cp -pv /usr/local/share/libtool/build-aux/config.sub ./ +} + +build() { + cf_cv_func_nanosleep=yes \ + autotools_configure \ + --enable-widec \ + --enable-pc-files \ + --with-shared \ + --with-cxx-shared \ + --without-normal \ + --without-debug \ + --with-manpage-format=normal \ + --with-pkg-config-libdir=/usr/lib/pkgconfig \ + --with-termlib + + make -j${parallelism} +} + +package() { + make install DESTDIR="${dest_dir}" + + # As we build ncurses with wide character support, make some compatibility links + for lib in ncurses ncurses++ form panel menu tinfo ; do + rm -vf "${dest_dir}${prefix}"/lib/lib${lib}.so + echo "INPUT(-l${lib}w)" > "${dest_dir}${prefix}"/lib/lib${lib}.so + ln -sfv ${lib}w.pc "${dest_dir}${prefix}"/lib/pkgconfig/${lib}.pc + # Set library soname + patchelf --set-soname lib${lib}w.so "${dest_dir}${prefix}"/lib/lib${lib}w.so + done + rm -vf "${dest_dir}${prefix}"/lib/libcursesw.so + echo "INPUT(-lncursesw)" > "${dest_dir}${prefix}"/lib/libcursesw.so + ln -sfv libncurses.so "${dest_dir}${prefix}"/lib/libcurses.so + + # Remove static libraries + rm -rf "${dest_dir}${prefix}"/lib/*.a + + post_package_strip +} diff --git a/recipes/neofetch b/recipes/neofetch new file mode 100644 index 00000000000..b832d5ca503 --- /dev/null +++ b/recipes/neofetch @@ -0,0 +1,9 @@ +name=neofetch +version=534b1c8cdbda567066517aeb75d8bdde3641dab7 +tarball_url="https://github.com/Andy-Python-Programmer/neofetch/archive/${version}.tar.gz" +tarball_blake2b="9f9f49a941e70dfe764c38c039c69e21bdf33c72ffbc2cd64a0287c0f8220f8a5ed456ef227da6dc843ef55602f20c9e0ac181cee261e65c373f69ceb5951668" + +package() { + mkdir -p "${dest_dir}/usr/bin" + cp -f "${source_dir}"/neofetch "${dest_dir}"/usr/bin/neofetch +} diff --git a/recipes/nettle b/recipes/nettle new file mode 100644 index 00000000000..c9b60ffba02 --- /dev/null +++ b/recipes/nettle @@ -0,0 +1,25 @@ +name=nettle +version=3.9.1 +revision=1 +tarball_url="https://ftp.gnu.org/gnu/nettle/nettle-${version}.tar.gz" +tarball_blake2b="e3ceaefa19491e58f26b900beaf8b4e746feb2357c7677f5c050f257f4a23c304773446b6283a42a82cf9640e16522b8a71c47f137759f1df23cdeee4625d142" +source_hostdeps="automake autoconf libtool pkg-config" +imagedeps="gcc" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs gmp" + +regenerate() { + autoreconf -fvi +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/openssl b/recipes/openssl new file mode 100644 index 00000000000..951693b31d8 --- /dev/null +++ b/recipes/openssl @@ -0,0 +1,32 @@ +name=openssl +version=1.1.1w +revision=1 +tarball_url="https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-${version}.tar.gz" +tarball_blake2b="2fdba6ca0188928ab2f74e606136afca66cfa0467170fa6298ef160b64ac6fdcad1e81e5dd14013ce0e9921d0f7417edec531cd0beaf1196fec704c2c6d48395" +hostdeps="gcc pkg-config" +deps="core-libs zlib" + +build() { + CC=${OS_TRIPLET}-gcc \ + CXX=${OS_TRIPLET}-g++ \ + AR=${OS_TRIPLET}-ar \ + ${source_dir}/Configure \ + --prefix=${prefix} \ + --openssldir=/etc/ssl \ + --libdir=lib \ + ${OS_TRIPLET} \ + shared \ + zlib-dynamic \ + no-afalgeng + + make -j${parallelism} +} + +package() { + # Disable installing static libraries. + sed -i '/INSTALL_LIBS/s/libcrypto.a libssl.a//' Makefile + + DESTDIR="${dest_dir}" make DESTDIR="${dest_dir}" MANSUFFIX=ssl install + + post_package_strip +} diff --git a/recipes/pango b/recipes/pango new file mode 100644 index 00000000000..2412c5c14e9 --- /dev/null +++ b/recipes/pango @@ -0,0 +1,21 @@ +name=pango +version=1.51.0 +revision=1 +tarball_url="https://download.gnome.org/sources/pango/1.51/pango-${version}.tar.xz" +tarball_blake2b="d7d343d5fb005b92dc70fc6f65c62d1d22cc81887185612d276e63614e622272117b64051f46aa1ae0348d4ccfbed0a473f9482703d51d5da7e81d1851b49071" +imagedeps="meson ninja" +hostdeps="gcc pkg-config" +deps="core-libs glib fontconfig freetype2 fribidi cairo xorg-proto libx11 xtrans libxext harfbuzz libxft" + +build() { + meson_configure \ + -Dintrospection=disabled + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + post_package_strip +} diff --git a/recipes/pcre2 b/recipes/pcre2 new file mode 100644 index 00000000000..baf6c779c99 --- /dev/null +++ b/recipes/pcre2 @@ -0,0 +1,31 @@ +name=pcre2 +version=10.42 +revision=1 +tarball_url="https://github.com/PCRE2Project/pcre2/releases/download/pcre2-${version}/pcre2-${version}.tar.gz" +tarball_blake2b="19233ee4a63d3bc0828f68c646ecbeb8161c242e52c9242976d80b805d5863699766a8f3a23946ac50ced75f48aad6d948bd9aa3fdc7540bd9193065ea7ee9d1" +source_hostdeps="automake autoconf libtool pkg-config" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs bzip2 ncurses readline zlib" + +regenerate() { + autoreconf -fvi +} + +build() { + autotools_configure \ + --enable-unicode \ + --enable-jit \ + --enable-pcre2-16 \ + --enable-pcre2-32 \ + --enable-pcre2grep-libz \ + --enable-pcre2grep-libbz2 \ + --enable-pcre2test-libreadline + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/pixman b/recipes/pixman new file mode 100644 index 00000000000..f1f294f5fa9 --- /dev/null +++ b/recipes/pixman @@ -0,0 +1,24 @@ +name=pixman +version=0.42.2 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/pixman-${version}.tar.xz" +tarball_blake2b="6286a9d064a5a24017fccbb0a6e9f6ef932077c2e33ec043826d4a7a6c707c9111d3de4b806cbcdb47fc2794f1f930d24d078de1ff2912061967db0890540957" +source_hostdeps="automake autoconf libtool pkg-config" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libpng" + +regenerate() { + autoreconf -fvi +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/readline b/recipes/readline new file mode 100644 index 00000000000..2f72afa724c --- /dev/null +++ b/recipes/readline @@ -0,0 +1,32 @@ +name=readline +version=8.2 +revision=1 +tarball_url="https://ftp.gnu.org/gnu/readline/readline-${version}.tar.gz" +tarball_blake2b="7974322b9c092a756a79e537df08e8532f8e0fcb598f77732e28287c33ebec9e9837ed88b43334c310892d56a871b423903f0f564def2fbe700a1004f2ae7b18" +source_hostdeps="automake autoconf libtool pkg-config" +imagedeps="patchelf" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs ncurses" + +regenerate() { + AUTOHEADER=true autoreconf -fvi +} + +build() { + autotools_configure \ + --enable-multibyte \ + --with-curses + + make SHLIB_LIBS="-lncursesw" -j${parallelism} +} + +package() { + make SHLIB_LIBS="-lncursesw" install DESTDIR="${dest_dir}" + + # libraries are created without soname... fix that + for lib in libhistory.so.8 libreadline.so.8; do + patchelf --set-soname $lib "${dest_dir}${prefix}/lib/$lib" + done + + post_package_strip +} diff --git a/recipes/sdl2 b/recipes/sdl2 new file mode 100644 index 00000000000..1d571174de4 --- /dev/null +++ b/recipes/sdl2 @@ -0,0 +1,59 @@ +name=sdl2 +version=2.28.5 +revision=1 +tarball_url="https://github.com/libsdl-org/SDL/releases/download/release-${version}/SDL2-${version}.tar.gz" +tarball_blake2b="c96481bc02af6b6d077247238f7e46b0e3ec216664584add29cafb0a91d06dc6ddc637a01519dbd7182d4fa59cfaf26ad6733f72583021cf65849416f9c4b698" +imagedeps="gcc ninja git" +hostdeps="gcc cmake pkg-config" +deps="core-libs libx11 libxext libxcursor libxi libxfixes libxrandr libxrender libxxf86vm mesa" + +build() { + cmake \ + -GNinja \ + -DCMAKE_TOOLCHAIN_FILE=${base_dir}/userland/CMakeToolchain-x86_64.cmake \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_BUILD_TYPE=Release \ + -DSDL_ALTIVEC=OFF \ + -DSDL_DISKAUDIO=OFF \ + -DSDL_DIRECTFB=ON \ + -DSDL_OPENGL=ON \ + -DSDL_OPENGLES=ON \ + -DSDL_PTHREADS=ON \ + -DSDL_PTHREADS_SEM=OFF \ + -DSDL_OSS=OFF \ + -DSDL_ALSA=OFF \ + -DSDL_JACK=OFF \ + -DSDL_ESD=OFF \ + -DSDL_PULSEAUDIO=OFF \ + -DSDL_ARTS=OFF \ + -DSDL_NAS=OFF \ + -DSDL_SNDIO=OFF \ + -DSDL_FUSIONSOUND=OFF \ + -DSDL_LIBSAMPLERATE=OFF \ + -DSDL_RPATH=OFF \ + -DSDL_X11=ON \ + -DSDL_WAYLAND=OFF \ + -DSDL_WAYLAND_QT_TOUCH=OFF \ + -DSDL_RPI=OFF \ + -DSDL_COCOA=OFF \ + -DSDL_DIRECTX=OFF \ + -DSDL_WASAPI=OFF \ + -DSDL_RENDER_D3D=OFF \ + -DSDL_VIVANTE=OFF \ + -DSDL_VULKAN=OFF \ + -DSDL_KMSDRM=OFF \ + -DSDL_HIDAPI=OFF \ + -DSDL_SHARED=ON \ + -DSDL_STATIC=OFF \ + ${source_dir} + + ninja -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" ninja install + + rm "${dest_dir}${prefix}"/lib/{libSDL2_test.a,libSDL2main.a} + + post_package_strip +} diff --git a/recipes/sqlite b/recipes/sqlite new file mode 100644 index 00000000000..3263142a692 --- /dev/null +++ b/recipes/sqlite @@ -0,0 +1,27 @@ +name=sqlite +version=3.45.0 +revision=1 +tarball_url="https://sqlite.org/2024/sqlite-autoconf-3450000.tar.gz" +tarball_blake2b="04ba8522be5fa8c0a0a101824f90030f83ad131b53dff622e0449d31b3ee3e50888ed0d8a663c5be3f7338d5d5b6efef1b828374fa599a675ab892bbbb3abec9" +source_hostdeps="automake autoconf libtool pkg-config" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs readline zlib" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure \ + --enable-readline \ + --enable-fts5 \ + CFLAGS="$CFLAGS -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_UNLOCK_NOTIFY=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1 -DSQLITE_SECURE_DELETE=1 -DSQLITE_ENABLE_FTS3_TOKENIZER=1" + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/ttf-dejavu b/recipes/ttf-dejavu new file mode 100644 index 00000000000..8ea14bc4732 --- /dev/null +++ b/recipes/ttf-dejavu @@ -0,0 +1,15 @@ +name=ttf-dejavu +version=2.37 +revision=1 +tarball_url="https://sourceforge.net/projects/dejavu/files/dejavu/${version}/dejavu-fonts-ttf-${version}.tar.bz2" +tarball_blake2b="d8614907887f20967fc7c75cb33b636a0eb5c682a076ccc7aef09f4ac243507afc005ef90d0b2aeee6a4a6a1ff3d5ce4fac0d1722a382525b3883ef53cdec26a" +deps="core-libs" + +build() { + cp -r ${source_dir}/. ./ +} + +package() { + mkdir -p "${dest_dir}${prefix}/share/fonts/truetype" + cp -r ttf/* "${dest_dir}${prefix}/share/fonts/truetype/" +} diff --git a/recipes/tzdata b/recipes/tzdata new file mode 100644 index 00000000000..a550b3957c1 --- /dev/null +++ b/recipes/tzdata @@ -0,0 +1,57 @@ +name=tzdata +version=2023c +revision=1 +tarball_url="https://data.iana.org/time-zones/releases/tzdata${version}.tar.gz" +tarball_blake2b="8a50aa5f338565d86b8fa5428c138b251bd8dcc3ea66c144b49625d02c5c7aa27f1ace66babd36f10f75cf5eb832ec327b9c2e8adb0384c450130d1ee8c45562" +imagedeps="tzdata" +hostdeps="gcc binutils" +deps="core-libs" + +build() { + cp -r ${source_dir}/. ./ +} + +package() { + # Create the required directories + mkdir -p ${dest_dir}/etc + mkdir -p ${dest_dir}/usr/share/zoneinfo/posix + mkdir -p ${dest_dir}/usr/share/zoneinfo/right + + # Create the time zone files without leap seconds, convention puts these in both zoneinfo and zoneinfo/posix. + # After that. create time time zone files with leap seconds + zic -L /dev/null -d "${dest_dir}"/usr/share/zoneinfo etcetera + zic -L /dev/null -d "${dest_dir}"/usr/share/zoneinfo/posix etcetera + zic -L "${source_dir}"/leapseconds -d "${dest_dir}"/usr/share/zoneinfo/right etcetera + zic -L /dev/null -d "${dest_dir}"/usr/share/zoneinfo southamerica + zic -L /dev/null -d "${dest_dir}"/usr/share/zoneinfo/posix southamerica + zic -L "${source_dir}"/leapseconds -d "${dest_dir}"/usr/share/zoneinfo/right southamerica + zic -L /dev/null -d "${dest_dir}"/usr/share/zoneinfo northamerica + zic -L /dev/null -d "${dest_dir}"/usr/share/zoneinfo/posix northamerica + zic -L "${source_dir}"/leapseconds -d "${dest_dir}"/usr/share/zoneinfo/right northamerica + zic -L /dev/null -d "${dest_dir}"/usr/share/zoneinfo europe + zic -L /dev/null -d "${dest_dir}"/usr/share/zoneinfo/posix europe + zic -L "${source_dir}"/leapseconds -d "${dest_dir}"/usr/share/zoneinfo/right europe + zic -L /dev/null -d "${dest_dir}"/usr/share/zoneinfo africa + zic -L /dev/null -d "${dest_dir}"/usr/share/zoneinfo/posix africa + zic -L "${source_dir}"/leapseconds -d "${dest_dir}"/usr/share/zoneinfo/right africa + zic -L /dev/null -d "${dest_dir}"/usr/share/zoneinfo antarctica + zic -L /dev/null -d "${dest_dir}"/usr/share/zoneinfo/posix antarctica + zic -L "${source_dir}"/leapseconds -d "${dest_dir}"/usr/share/zoneinfo/right antarctica + zic -L /dev/null -d "${dest_dir}"/usr/share/zoneinfo asia + zic -L /dev/null -d "${dest_dir}"/usr/share/zoneinfo/posix asia + zic -L "${source_dir}"/leapseconds -d "${dest_dir}"/usr/share/zoneinfo/right asia + zic -L /dev/null -d "${dest_dir}"/usr/share/zoneinfo australasia + zic -L /dev/null -d "${dest_dir}"/usr/share/zoneinfo/posix australasia + zic -L "${source_dir}"/leapseconds -d "${dest_dir}"/usr/share/zoneinfo/right australasia + zic -L /dev/null -d "${dest_dir}"/usr/share/zoneinfo backward + zic -L /dev/null -d "${dest_dir}"/usr/share/zoneinfo/posix backward + zic -L "${source_dir}"/leapseconds -d "${dest_dir}"/usr/share/zoneinfo/right backward + + # Create the posixrules file, POSIX requires daylight saving rules to be in accordance with US rules, thus use New York + zic -d ${dest_dir}/usr/share/zoneinfo -p America/New_York + + # Default to UTC for localtime, this should be fixed, but that is pending xbstrap support. + ln -sf /usr/share/zoneinfo/UTC "${dest_dir}"/etc/localtime + + post_package_strip +} diff --git a/recipes/userland b/recipes/userland new file mode 100644 index 00000000000..042300a924f --- /dev/null +++ b/recipes/userland @@ -0,0 +1,19 @@ +name=userland +version=0.0 +revision=1 +source_dir="userland" +hostdeps="gcc binutils" +deps="core-libs" +imagedeps="rust" +allow_network=yes + +build() { + cp -r "${source_dir}"/. ./ + + make -j${parallelism} CC=x86_64-aero-gcc CXX=x86_64-aero-g++ +} + +package() { + make install PREFIX="${prefix}" DESTDIR="${dest_dir}" + post_package_strip +} diff --git a/recipes/xcb-proto b/recipes/xcb-proto new file mode 100644 index 00000000000..bee617424e3 --- /dev/null +++ b/recipes/xcb-proto @@ -0,0 +1,25 @@ +name=xcb-proto +version=1.16.0 +revision=1 +tarball_url="https://www.x.org/archive/individual/proto/xcb-proto-${version}.tar.xz" +tarball_blake2b="1c59ae4c71e697bd4f0298f6e0ea5235fc47baa9cf584e079258f1da8be538d1b67dc45f1325d82495247d0f8020d0244ca334de3794b410a1feaceabd6b285e" +source_hostdeps="automake autoconf libtool pkg-config" +imagedeps="python libxml2" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs" + +regenerate() { + autoreconf -fvi +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/xf86-input-keyboard b/recipes/xf86-input-keyboard new file mode 100644 index 00000000000..0bc813a7d52 --- /dev/null +++ b/recipes/xf86-input-keyboard @@ -0,0 +1,25 @@ +name=xf86-input-keyboard +version=2.0.0 +revision=1 +tarball_url="https://www.x.org/releases/individual/driver/xf86-input-keyboard-${version}.tar.gz" +tarball_blake2b="f3aa3fca15fc75f8314b7b7248ccb757d667b2c46b22c8e23278d144f30d56515d1aa4190ca82e0c15770550a16dd860fd98a81172dab2e97b04e65fceb2a333" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-server xorg-util-macros libx11" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/xf86-input-mouse b/recipes/xf86-input-mouse new file mode 100644 index 00000000000..e9dc1dd7458 --- /dev/null +++ b/recipes/xf86-input-mouse @@ -0,0 +1,25 @@ +name=xf86-input-mouse +version=1.9.5 +revision=1 +tarball_url="https://xorg.freedesktop.org/archive/individual/driver/xf86-input-mouse-${version}.tar.gz" +tarball_blake2b="67f4de10424d640913fcafc2292f342a1e993d33e4ecc3c152e818953e19deaba796b96c29e0c07a4f4b74a1eb3bc1c41c3e5ab868cade02c21a90e2556da53f" +source_hostdeps="autoconf automake libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-server xorg-util-macros libx11" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/xf86-video-fbdev b/recipes/xf86-video-fbdev new file mode 100644 index 00000000000..c4bed64eb79 --- /dev/null +++ b/recipes/xf86-video-fbdev @@ -0,0 +1,27 @@ +name=xf86-video-fbdev +version=0.5.0 +revision=1 +tarball_url="https://www.x.org/releases/individual/driver/xf86-video-fbdev-${version}.tar.gz" +tarball_blake2b="0e37c9145582d317c690c8adcfd5bf4b6046cc60e0b9a59382d1cb39878664e46a47d810d8d0d75c7c6b74630ae5e9f377217b51b23d6cfb2661d901a8bf41e2" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-server xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-server xorg-util-macros" + +regenerate() { + autotools_recursive_regen +} + +build() { + SYSROOT=${sysroot_dir} \ + autotools_configure \ + --disable-pciaccess + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/xkeyboard-config b/recipes/xkeyboard-config new file mode 100644 index 00000000000..7089177e1f8 --- /dev/null +++ b/recipes/xkeyboard-config @@ -0,0 +1,27 @@ +name=xkeyboard-config +version=2.34 +revision=1 +tarball_url="https://www.x.org/archive/individual/data/xkeyboard-config/xkeyboard-config-${version}.tar.gz" +tarball_blake2b="dcd4e7b0b8daf146b92fbb56c64eb32b7d2f42d75a8716226e5bc13b30624aca3ac95e97541561ba2429d5089f6dad495111b1a3f4a76b02d10dbe249461f921" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +imagedeps="python" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-xkbcomp" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure \ + --with-xkb-rules-symlink=xorg + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/xorg-font-util b/recipes/xorg-font-util new file mode 100644 index 00000000000..91d91bab718 --- /dev/null +++ b/recipes/xorg-font-util @@ -0,0 +1,25 @@ +name=xorg-font-util +version=1.4.1 +revision=1 +tarball_url="https://www.x.org/archive/individual/font/font-util-${version}.tar.xz" +tarball_blake2b="5a7cee52aa58cecc85f5168963038b65d921bc33615e86a833cba5aec007d61bb05fa3b200ed9b192d9ab9291d53065443711f8eac976242b2013cd7b9fc494a" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/xorg-proto b/recipes/xorg-proto new file mode 100644 index 00000000000..c914cf0042a --- /dev/null +++ b/recipes/xorg-proto @@ -0,0 +1,25 @@ +name=xorg-proto +version=2023.2 +revision=1 +tarball_url="https://www.x.org/releases/individual/proto/xorgproto-${version}.tar.xz" +tarball_blake2b="ff255b91770ad11cdcc48d12815317285d8d16d28011a86166f3e07af18b30fdf35c2eb7b6537504eb4c0e9ca65b3116493422b6faebe04ee80e6aee92387675" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/xorg-server b/recipes/xorg-server new file mode 100644 index 00000000000..ce2985cbc62 --- /dev/null +++ b/recipes/xorg-server @@ -0,0 +1,52 @@ +name=xorg-server +version=21.1.11 +revision=1 +tarball_url="https://www.x.org/releases/individual/xserver/xorg-server-${version}.tar.xz" +tarball_blake2b="0a18840979bb8b20b02eca9d737f20ddcf92a4771386074c38692df8a1c9b0f471af2211f3006f845ad0dd887b3844b7e7aac761bc12fc4e4177f1ada32ec503" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xtrans xorg-font-util xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto xcb-proto xtrans libxinerama libxcvt libxshmfence libx11 libxaw libxxf86vm libxkbfile libxmu libxfont2 libepoxy libxi libxv libxdamage libxrender libxrandr libxcb libxfixes libxext nettle xorg-xkbcomp xkeyboard-config pixman" + +regenerate() { + autotools_recursive_regen +} + +build() { + CFLAGS="-Wno-error=array-bounds ${common_flags}" \ + autotools_configure \ + --with-xkb-bin-directory=/usr/bin \ + --with-xkb-path=/usr/share/X11/xkb \ + --with-xkb-output=/var/lib/xkb \ + --with-fontrootdir=/usr/share/fonts/X11 \ + --enable-xorg \ + --enable-xv \ + --enable-xvfb \ + --disable-xephyr \ + --disable-xnest \ + --disable-suid-wrapper \ + --disable-pciaccess \ + --disable-dpms \ + --disable-screensaver \ + --disable-xres \ + --disable-xvmc \ + --disable-systemd-logind \ + --disable-secure-rpc \ + --disable-config-udev \ + --disable-dri \ + --disable-dri2 \ + --disable-dri3 \ + --disable-int10-module \ + --disable-vgahw \ + --disable-libdrm \ + --disable-glamor \ + --disable-glx + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/xorg-util-macros b/recipes/xorg-util-macros new file mode 100644 index 00000000000..8d798f7f3fb --- /dev/null +++ b/recipes/xorg-util-macros @@ -0,0 +1,24 @@ +name=xorg-util-macros +version=1.20.0 +revision=1 +tarball_url="https://www.x.org/archive/individual/util/util-macros-${version}.tar.gz" +tarball_blake2b="4c79c7076281ede6a240be2a2a9ffd47edd523d4a1b839589301a21eeb73100f134eced7d81fbd5ad71516174d3d4c8ab9f63e53987cb0f9a59b4fe6496157d8" +source_hostdeps="automake autoconf libtool pkg-config" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs" + +regenerate() { + autoreconf -fvi +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/xorg-xclock b/recipes/xorg-xclock new file mode 100644 index 00000000000..1ddd738ffcf --- /dev/null +++ b/recipes/xorg-xclock @@ -0,0 +1,27 @@ +name=xorg-xclock +version=1.1.1 +revision=1 +tarball_url="https://xorg.freedesktop.org/archive/individual/app/xclock-${version}.tar.gz" +tarball_blake2b="4fd77b8f1f0962774dd0e6295f7482c05be8107e1606a9705ccd2864d2c9b37adda4a41a6704c6e1363edd2b7e704324799c4feaff39e218b326b66274b48187" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros gettext" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libx11 libxaw libxft libxkbfile libxmu libxrender" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure \ + --with-appdefaultdir=/etc/X11/app-defaults \ + --disable-selective-werror + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/xorg-xeyes b/recipes/xorg-xeyes new file mode 100644 index 00000000000..bac153bb7f3 --- /dev/null +++ b/recipes/xorg-xeyes @@ -0,0 +1,26 @@ +name=xorg-xeyes +version=1.2.0 +revision=1 +tarball_url="https://xorg.freedesktop.org/archive/individual/app/xeyes-${version}.tar.gz" +tarball_blake2b="de152dff4bffb8ce43f7a8ae6b3362088f829acfa2a276b714cb5f92fb7af2935553f685a5cbe9d5f4362177fa71afc5b9e2aabe18010d247a16bad7892c8a7c" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libx11 libxcb libxext libxi libxmu libxrender libxt" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure \ + --disable-selective-werror + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/xorg-xfontsel b/recipes/xorg-xfontsel new file mode 100644 index 00000000000..7ae92585b46 --- /dev/null +++ b/recipes/xorg-xfontsel @@ -0,0 +1,26 @@ +name=xorg-xfontsel +version=1.1.0 +revision=1 +tarball_url="https://www.x.org/pub/individual/app/xfontsel-${version}.tar.xz" +tarball_blake2b="e4cb8f25b64e1feb68cdf7ae7982c8e8e6086fb6ad31019b115986220cd9f347edbe738d8d43d0650fd783ef96d2e93a247e462611b0fb33a3aa0a6dc2d2529e" +source_hostdeps="autoconf automake libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libxmu libxaw" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure \ + --with-appdefaultdir=/etc/X11/app-defaults + + make -j${parallelism} +} + +package() { + make DESTDIR=${dest_dir} install + + post_package_strip +} diff --git a/recipes/xorg-xinit b/recipes/xorg-xinit new file mode 100644 index 00000000000..5272d84a92b --- /dev/null +++ b/recipes/xorg-xinit @@ -0,0 +1,25 @@ +name=xorg-xinit +version=1.4.2 +tarball_url="https://gitlab.freedesktop.org/xorg/app/xinit/-/archive/xinit-${version}/xinit-xinit-${version}.tar.gz" +tarball_blake2b="23a48ddee9eab2510fc3322dc203a994f886b765f49c3c92c34b75ed871c844e860ae47581167d905ae59822a8e69fcd1b94e680db933aea251596286d19617b" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libx11 xorg-proto" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure +} + +package() { + DESTDIR="${dest_dir}" make install + + # We have our own xinitrc. + rm -rf "${dest_dir}/etc/X11/xinit/xinitrc" + + post_package_strip +} diff --git a/recipes/xorg-xkbcomp b/recipes/xorg-xkbcomp new file mode 100644 index 00000000000..aa44578f23c --- /dev/null +++ b/recipes/xorg-xkbcomp @@ -0,0 +1,25 @@ +name=xorg-xkbcomp +version=1.4.6 +revision=1 +tarball_url="https://www.x.org/archive/individual/app/xkbcomp-${version}.tar.gz" +tarball_blake2b="bc0fe69ef4eb809ac9e82fdc40b990bf27b7dd3e358efdb87ab7e34be8ddd0d8bd54e57ab7473f9e22f2714964e2cfb3322ccc2006a64de10dd6f2fc4fa35017" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libxkbfile" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/xorg-xlsfonts b/recipes/xorg-xlsfonts new file mode 100644 index 00000000000..8ec9a1452af --- /dev/null +++ b/recipes/xorg-xlsfonts @@ -0,0 +1,24 @@ +name=xorg-xlsfonts +version=1.0.7 +revision=1 +tarball_url="https://www.x.org/pub/individual/app/xlsfonts-${version}.tar.xz" +tarball_blake2b="13f2e2007c38f7d1724e6ffd0c7fe9a3b887a150f50107b892327c3620e4ffdbd4ae1191a9764cc4000d6422fe0f331dcbef11c0b50013ff2d94b699c0cba1ee" +source_hostdeps="autoconf automake libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libxmu libxaw" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + make DESTDIR=${dest_dir} install + post_package_strip +} diff --git a/recipes/xtrans b/recipes/xtrans new file mode 100644 index 00000000000..18e4de6fa62 --- /dev/null +++ b/recipes/xtrans @@ -0,0 +1,25 @@ +name=xtrans +version=1.5.0 +revision=1 +tarball_url="https://www.x.org/archive/individual/lib/xtrans-${version}.tar.gz" +tarball_blake2b="25a18ba2398e445a1fedec3f0f5a102aef733b621fb83a81d193a2e4a702b8090b70ccea1c6784293050fd26b20e2d4b2d433954c9740c3a94c53362dc88cc9b" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/xz b/recipes/xz new file mode 100644 index 00000000000..861cea5478e --- /dev/null +++ b/recipes/xz @@ -0,0 +1,24 @@ +name=xz +version=5.4.6 +revision=1 +tarball_url="https://github.com/tukaani-project/xz/releases/download/v${version}/xz-${version}.tar.gz" +tarball_blake2b="f0bbd33ea7cd64d475c3501f6e76080c8c0080e377f23462f5f76459935f4e621538ddaa8452d2feaed278d62a596e38ed2aca18ed9e76512c4ec77fa2f4cc5f" +source_hostdeps="automake autoconf libtool pkg-config" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/zlib b/recipes/zlib new file mode 100644 index 00000000000..4591965f905 --- /dev/null +++ b/recipes/zlib @@ -0,0 +1,27 @@ +name=zlib +version=1.3 +revision=1 +tarball_url="https://github.com/madler/zlib/archive/refs/tags/v${version}.tar.gz" +tarball_blake2b="e663d8041a613b544d76313e61b6340adacb53322422d4b6392455627c80cbac430b9fd0fb4a69e59b0fa110f120d29a1e9513bb37888442cc1b9d5075f47ea6" +imagedeps="patchelf" +hostdeps="gcc pkg-config" +deps="core-libs" + +build() { + prefix="${prefix}" \ + CHOST="${OS_TRIPLET}" \ + ${source_dir}/configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + # Remove static libraries + rm -rf "${dest_dir}${prefix}"/lib/*.a + + # libz.so.${version} is created without soname... fix that + patchelf --set-soname libz.so.${version} "${dest_dir}${prefix}/lib/libz.so.${version}" + + post_package_strip +} diff --git a/recipes/zstd b/recipes/zstd new file mode 100644 index 00000000000..5633699c717 --- /dev/null +++ b/recipes/zstd @@ -0,0 +1,29 @@ +name=zstd +version=1.5.5 +revision=1 +tarball_url="https://github.com/facebook/zstd/releases/download/v${version}/zstd-${version}.tar.gz" +tarball_blake2b="7680e27a0adacfb809d9fc81e06d3f99bf74df30374d3b5cb2d58f667dd1b7d5c41697e608592709e17c0e32277f20a6d615edee409b5d7cdcb15da2799a2350" +hostdeps="gcc pkg-config" +deps="core-libs zlib xz" + +build() { + cp -rp "${source_dir}"/. ./ + + CC=${OS_TRIPLET}-gcc \ + CXX=${OS_TRIPLET}-g++ \ + AR=${OS_TRIPLET}-ar \ + PREFIX="${prefix}" \ + make -j${parallelism} +} + +package() { + CC=${OS_TRIPLET}-gcc \ + DESTDIR="${dest_dir}" \ + PREFIX="${prefix}" \ + make install + + # Remove static libraries. + rm -rf "${dest_dir}${prefix}"/lib/*.a + + post_package_strip +} diff --git a/scripts/mkimage b/scripts/mkimage new file mode 100755 index 00000000000..985c735ae2a --- /dev/null +++ b/scripts/mkimage @@ -0,0 +1,48 @@ +# set -x -e + +# IMAGE_PATH="$base_dir/target/disk.img" +# LOOPBACK_DEV_PATH="$base_dir/target/loopback_dev" + +# ls /dev + +# # echo $in_container +# # whoami + +# # # ls $base_dir + +IMAGE_PATH="./target/disk.img" + +dd if=/dev/zero bs=1G count=0 seek=512 of=$IMAGE_PATH +parted -s $IMAGE_PATH mklabel gpt +parted -s $IMAGE_PATH mkpart primary 2048s 100% + +# # # ensure loop kernel module is enabled +# # if ! lsmod | grep -q 'loop'; then +# # echo 'mkimage: `loop` kernel module not found, attempting to load' +# # modprobe loop +# # fi + +# # losetup -Pf --show $IMAGE_PATH > $LOOPBACK_DEV_PATH +# # losetup -d `cat $LOOPBACK_DEV_PATH` + +# # # echo $in_container +# # # ls /de + +# -L: volume-label +# -N: Overrides the default calculation of the number of inodes that should be reserved for the filesystem. +# -O: Features (disabled are prefixed with `^`) +# -d: root-directory +# -m: reserved-blocks-percentage +# -r: fs-revision-level +# # -t: filesystem-type +# mke2fs \ +# -L '' \ +# -N 0 \ +# -O ^64bit \ +# -d "./sysroot" \ +# -m 5 \ +# -r 1 \ +# -t ext2 \ +# "./target/disk.img" \ +# 5G \ +# ; diff --git a/source-recipes/autoconf b/source-recipes/autoconf new file mode 100644 index 00000000000..09be1b2004c --- /dev/null +++ b/source-recipes/autoconf @@ -0,0 +1,4 @@ +name=autoconf +version=2.72 +tarball_url="https://ftp.gnu.org/gnu/autoconf/autoconf-${version}.tar.gz" +tarball_blake2b="48fff54704176cbf2642230229c628b75c43ef3f810c39eea40cae91dd02e1203d04a544407de96f9172419a94b952865909d969d9e9b6c10879a9d9aeea5ad0" diff --git a/source-recipes/autoconf-2.69 b/source-recipes/autoconf-2.69 new file mode 100644 index 00000000000..3986c79acb4 --- /dev/null +++ b/source-recipes/autoconf-2.69 @@ -0,0 +1,4 @@ +name=autoconf-2.69 +version=2.69 +tarball_url="https://ftp.gnu.org/gnu/autoconf/autoconf-${version}.tar.gz" +tarball_blake2b="7e8a513bbfcabadad1577919c048cc05ca0a084788850b42570f88afc2fa9c25fb32277412f135b81ba1c0d8079465a6b581d2d78662c991d2183b739fac407c" diff --git a/source-recipes/automake b/source-recipes/automake new file mode 100644 index 00000000000..0c58eb68b0c --- /dev/null +++ b/source-recipes/automake @@ -0,0 +1,8 @@ +name=automake +version=1.16.5 +tarball_url="https://ftp.gnu.org/gnu/automake/automake-${version}.tar.gz" +tarball_blake2b="5ccdcbe2d3deb2b0baed4a8590b07714cd7098fbda251afebe83232ed03f4db84abbe023cf0544622dbc5137254347273247428eb5420564a167b86de95d113e" + +regenerate() { + true +} diff --git a/source-recipes/cmake b/source-recipes/cmake new file mode 100644 index 00000000000..1821d68b1a2 --- /dev/null +++ b/source-recipes/cmake @@ -0,0 +1,4 @@ +name=cmake +version=3.27.7 +tarball_url="https://github.com/Kitware/CMake/releases/download/v${version}/cmake-${version}.tar.gz" +tarball_blake2b="a20fac503ba54b4b7e85896056a614b67aa346ad2636e7ab1bf09a2660b92a52754485527f36101e59d47713e7445d27797577c1fa6a8ebe59acb4675227c6da" diff --git a/source-recipes/gcc-host b/source-recipes/gcc-host new file mode 100644 index 00000000000..38d73211c97 --- /dev/null +++ b/source-recipes/gcc-host @@ -0,0 +1,16 @@ +name=gcc-host +version=13.2.0 +tarball_url="https://ftp.gnu.org/gnu/gcc/gcc-${version}/gcc-${version}.tar.xz" +tarball_blake2b="0034b29d3d6cc05821f0c4253ce077805943aff7b370729dd203bda57d89c107edd657eeddc2fb1e69ea15c7b0323b961f46516c7f4af89a3ccf7fea84701be2" +hostdeps="automake autoconf-2.69 libtool pkg-config" +imagedeps="git" +allow_network="yes" + +regenerate() { + ./contrib/download_prerequisites + + autotools_recursive_regen -I"$(realpath ./config)" + + cp -pv /usr/local/share/libtool/build-aux/{config.sub,config.guess,install-sh} libiberty/ + cp -pv /usr/local/share/libtool/build-aux/{config.sub,config.guess,install-sh} libgcc/ +} diff --git a/source-recipes/gnulib b/source-recipes/gnulib new file mode 100644 index 00000000000..623e07de9e4 --- /dev/null +++ b/source-recipes/gnulib @@ -0,0 +1,4 @@ +name=gnulib +version=4f6545e79c4a7cd7feb2c8f23f1d5167e7165907 +tarball_url="https://git.savannah.gnu.org/cgit/gnulib.git/snapshot/gnulib-${version}.tar.gz" +tarball_blake2b="0206d3bdeb25bdc3562065dc1832d3ea2ac95920b84ed0461626efba83de3edfcdcbc257c493a9a3d6035d0edb09526248c2483f898110be774ac31caf650e58" diff --git a/source-recipes/libgcc-binaries b/source-recipes/libgcc-binaries new file mode 100644 index 00000000000..749340993f1 --- /dev/null +++ b/source-recipes/libgcc-binaries @@ -0,0 +1,4 @@ +name=libgcc-binaries +version=1e4b24ef15a7d9a2db7570d1c9283fc474dcbd73 +tarball_url="https://github.com/mintsuki/libgcc-binaries/archive/${version}.tar.gz" +tarball_blake2b="77b8af0466577ca5af9b16d968865d24d42fb422566de2f03dd5b2d984f70015da6b1bd28878855889ee665f0ace4419cee3c40d20ac1176b0c500a1e50302bd" diff --git a/source-recipes/libtool b/source-recipes/libtool new file mode 100644 index 00000000000..c5d13fc2df2 --- /dev/null +++ b/source-recipes/libtool @@ -0,0 +1,11 @@ +name=libtool +version=2.4.7 +tarball_url="https://ftp.gnu.org/gnu/libtool/libtool-${version}.tar.gz" +tarball_blake2b="3b7c66050237931443008d6be9c0c30f4938402bf68576cdf02f2248b216bb68c6b797bbfdb8a92caa5e12cb10208cd19771cdcb6b0d83572ad60bfc03e67e98" +hostdeps="autoconf automake gnulib" +imagedeps="help2man" + +regenerate() { + cp -r ${base_dir}/sources/gnulib ./ + ./bootstrap --force --skip-git --skip-po --gnulib-srcdir=`pwd`/gnulib +} diff --git a/source-recipes/limine b/source-recipes/limine new file mode 100644 index 00000000000..8f96cc8e020 --- /dev/null +++ b/source-recipes/limine @@ -0,0 +1,12 @@ +name=limine +version=7.0.0 +revision=1 +tarball_url="https://github.com/limine-bootloader/limine/releases/download/v${version}/limine-${version}.tar.xz" +tarball_blake2b="7986d948fe84c80b338e5cc66edca5f511d277d2e854484c87183666bf1b075480b61213c177b6e39a1145502cc9e07b9e1442c3dcf3171339af5b55ac9c184f" +hostdeps="gcc libtool pkg-config autoconf automake" +deps="core-libs" +imagedeps="mtools nasm" + +regenerate() { + autoreconf -fvi +} \ No newline at end of file diff --git a/source-recipes/llvm-host b/source-recipes/llvm-host new file mode 100644 index 00000000000..af821a6152f --- /dev/null +++ b/source-recipes/llvm-host @@ -0,0 +1,11 @@ +name=llvm-host +version=17.0.6 +tarball_url="https://github.com/llvm/llvm-project/releases/download/llvmorg-${version}/llvm-project-${version}.src.tar.xz" +tarball_blake2b="d6ede1a9fda8756995c3e0654111941649e15794179641806f18919f1dc68c41ca0cabd5693b5096d05dccc3a391cd20d34af1137bf8af92ed3117a1ce84d1b2" + +regenerate() { + echo "Regenerating LLVM..." + for i in "${base_dir}"/patches/llvm/*; do + patch -p1 < "$i" + done +} diff --git a/source-recipes/pkg-config b/source-recipes/pkg-config new file mode 100644 index 00000000000..1195750a296 --- /dev/null +++ b/source-recipes/pkg-config @@ -0,0 +1,9 @@ +name=pkg-config +version=2.1.0 +tarball_url="https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-${version}.tar.gz" +tarball_blake2b="ab0f03494c37659c18a882ff03e6bb746c3cfe0ad66b7a9d9d0b2de66bec89258b2374addd3eb3a571442d8bab3c1311410e296379b697d16aaebe2bc89b318c" +hostdeps="autoconf automake libtool" + +regenerate() { + autoreconf -fvi +} diff --git a/source-recipes/rust-host b/source-recipes/rust-host new file mode 100644 index 00000000000..80122e1c151 --- /dev/null +++ b/source-recipes/rust-host @@ -0,0 +1,33 @@ +name=rust-host +version=1.75.0 +tarball_url="https://static.rust-lang.org/dist/rustc-${version}-src.tar.xz" +tarball_blake2b="8937b80585eddaa3e1f1ef948899d14a170308518c6fef9fe569560cdd870053776956743f796055f2119399b9ca6c0df12fedd789ae46324d071e5126c4e495" + +regenerate() { + cat > ${source_dir}/config.toml < super::Result { + let offset = self.offset.load(Ordering::SeqCst); + let new_offset = self.inode.inode().write_at(offset, buffer)?; + self.offset.fetch_add(new_offset, Ordering::SeqCst); Ok(new_offset) @@ -108,15 +126,6 @@ impl FileHandle { } } - pub fn write(&self, buffer: &[u8]) -> super::Result { - let offset = self.offset.load(Ordering::SeqCst); - let new_offset = self.inode.inode().write_at(offset, buffer)?; - - self.offset.fetch_add(new_offset, Ordering::SeqCst); - - Ok(new_offset) - } - pub fn dirnode(&self) -> DirCacheItem { self.inode.clone() } diff --git a/src/aero_kernel/src/fs/mod.rs b/src/aero_kernel/src/fs/mod.rs index 65400e1181d..c0e64579de8 100644 --- a/src/aero_kernel/src/fs/mod.rs +++ b/src/aero_kernel/src/fs/mod.rs @@ -166,6 +166,11 @@ impl Path { unsafe { &*(path as *const str as *const Path) } } + #[inline] + pub fn is_empty(&self) -> bool { + self.0.is_empty() + } + /// Returns [`true`] if the path is absolute. pub fn is_absolute(&self) -> bool { self.0.starts_with('/') @@ -275,10 +280,11 @@ pub fn lookup_path_with( let resolved_path = Path::new(&resolved_path_str); if resolved_path.is_absolute() { - return lookup_path(resolved_path); + cwd = lookup_path(resolved_path)?; + continue; } - return lookup_path_with(parent, resolved_path, LookupMode::None); + cwd = lookup_path_with(parent, resolved_path, LookupMode::None)?; } else if metadata.is_directory() { if let Ok(mount_point) = MOUNT_MANAGER.find_mount(cwd.clone()) { cwd = mount_point.root_entry; diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index 7c08d2fd31f..5baacc6178f 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -48,8 +48,8 @@ naked_functions, // https://github.com/rust-lang/rust/issues/32408 cfg_match, // https://github.com/rust-lang/rust/issues/115585 strict_provenance, - offset_of, - associated_type_defaults + associated_type_defaults, + trait_upcasting )] // TODO(andypython): can we remove the dependency of "prelude_import" and "lang_items"? // `lang_items` => is currently used for the personality function (`rust_eh_personality`). diff --git a/src/aero_kernel/src/rendy.rs b/src/aero_kernel/src/rendy.rs index 2b773f09557..027e70fa391 100644 --- a/src/aero_kernel/src/rendy.rs +++ b/src/aero_kernel/src/rendy.rs @@ -267,6 +267,15 @@ impl IndexMut for ColorList { } } +impl Index for ColorList { + type Output = u32; + + #[inline] + fn index(&self, idx: usize) -> &Self::Output { + &self.0[idx] + } +} + pub struct Inner<'this> { buffer: &'this mut [u32], info: RendyInfo, @@ -869,6 +878,7 @@ impl<'a> vte::ansi::Handler for Inner<'a> { Attr::Foreground(color) => { let code = match color { vte::ansi::Color::Named(c) => self.color_list[c], + vte::ansi::Color::Indexed(c) => self.color_list[c as usize], _ => unimplemented!(), }; diff --git a/src/aero_kernel/src/syscall/fs.rs b/src/aero_kernel/src/syscall/fs.rs index a9d6aeb45c1..2ba5633ca5c 100644 --- a/src/aero_kernel/src/syscall/fs.rs +++ b/src/aero_kernel/src/syscall/fs.rs @@ -19,7 +19,7 @@ use core::fmt; use aero_syscall::prelude::*; use aero_syscall::signal::SigProcMask; -use aero_syscall::{OpenFlags, Stat, SyscallError, TimeSpec, AT_FDCWD}; +use aero_syscall::{AtFlags, OpenFlags, Stat, SyscallError, TimeSpec, AT_FDCWD}; use alloc::sync::Arc; use crate::fs::cache::{self, DirCacheImpl}; @@ -29,6 +29,7 @@ use crate::fs::file_table::{DuplicateHint, FileHandle}; use crate::fs::inode::{DirEntry, PollTable}; use crate::fs::pipe::Pipe; use crate::fs::{self, lookup_path, LookupMode}; +use crate::syscall::SysArg; use crate::userland::scheduler; use crate::fs::Path; @@ -103,7 +104,7 @@ pub fn read(fd: FileDescriptor, buffer: &mut [u8]) -> Result Result { let dir = match fd as isize { - AT_FDCWD => { + 0 => { if !path.is_absolute() { scheduler::get_scheduler().current_task().cwd_dirent() } else { @@ -111,7 +112,9 @@ pub fn open(fd: usize, path: &Path, mode: usize) -> Result } } - _ => todo!(), + _ => { + todo!() + } }; let mut flags = OpenFlags::from_bits(mode).ok_or(SyscallError::EINVAL)?; @@ -253,9 +256,14 @@ pub fn rmdir(path: &str) -> Result { #[syscall] pub fn getcwd(buffer: &mut [u8]) -> Result { - let cwd = scheduler::get_scheduler().current_task().get_cwd(); + let cwd = scheduler::current_thread().get_cwd(); + log::debug!("getcwd: {}", cwd); + // FIXME: fix this before commiting + buffer.fill(0); buffer[..cwd.len()].copy_from_slice(cwd.as_bytes()); + + // TOOD: mlibc doesnt give a shit and will increase the buf size till it fits. make it smarter. Ok(cwd.len()) } @@ -440,8 +448,30 @@ pub fn fcntl(fd: FileDescriptor, command: usize, arg: usize) -> Result Result { - *stat = fd.handle()?.inode().stat()?; +pub fn fstat(fd: usize, path: &Path, flags: usize, stat: &mut Stat) -> Result { + let at = match fd as isize { + AT_FDCWD if !path.is_absolute() => scheduler::current_thread().cwd_dirent(), + _ if !path.is_absolute() => FileDescriptor::from_usize(fd).handle()?.inode.clone(), + _ => fs::root_dir().clone(), + }; + + // TODO: derive(SysArg) for bitflags. + let flags = AtFlags::from_bits(flags).ok_or(SyscallError::EINVAL)?; + dbg!(flags); + + if path.is_empty() { + if !flags.contains(AtFlags::EMPTY_PATH) { + return Err(SyscallError::EINVAL); + } + + *stat = at.inode().stat()?; + return Ok(0); + } + + log::debug!("{}", at.absolute_path_str()); + + let ent = fs::lookup_path_with(at, path, LookupMode::None)?; + *stat = ent.inode().stat()?; Ok(0) } diff --git a/src/aero_kernel/src/syscall/mod.rs b/src/aero_kernel/src/syscall/mod.rs index 2d57d128146..b6275ec0949 100644 --- a/src/aero_kernel/src/syscall/mod.rs +++ b/src/aero_kernel/src/syscall/mod.rs @@ -229,7 +229,7 @@ pub fn generic_do_syscall( SYS_DUP2 => fs::dup2(b, c, d), SYS_FCNTL => fs::fcntl(b, c, d), SYS_STAT => fs::stat(b, c, d), - SYS_FSTAT => fs::fstat(b, c), + SYS_FSTAT => fs::fstat(b, c, d, e, f), SYS_READ_LINK => fs::read_link(b, c, d, e), SYS_EVENT_FD => fs::event_fd(b, c), SYS_LINK => fs::link(b, c, d, e), diff --git a/src/aero_kernel/src/userland/task/mod.rs b/src/aero_kernel/src/userland/task/mod.rs index ab4cde12ce4..86d60ba3723 100644 --- a/src/aero_kernel/src/userland/task/mod.rs +++ b/src/aero_kernel/src/userland/task/mod.rs @@ -527,6 +527,12 @@ impl Task { *self.cwd.write() = Some(Cwd::new()) } + // if executable.absolute_path_str().contains("gcc") + // || executable.absolute_path_str().contains("ls") + // { + // self.enable_systrace(); + // } + *self.mem_tags.lock() = HashMap::new(); self.file_table.close_on_exec(); @@ -625,7 +631,12 @@ impl Task { } pub fn parent_pid(&self) -> TaskId { - self.get_parent().unwrap().pid() + if let Some(parent) = self.get_parent() { + parent.pid() + } else { + // On top of the family tree. + self.pid() + } } pub fn tid(&self) -> TaskId { diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs index 21f8279bfb9..d3936622d24 100644 --- a/src/aero_kernel/src/userland/vm.rs +++ b/src/aero_kernel/src/userland/vm.rs @@ -1152,7 +1152,7 @@ impl VmProtected { } else { // end let mut mapping = map.clone(); - mapping.start_addr = end; + mapping.start_addr = start; mapping.protection = prot; map.end_addr = start; diff --git a/src/aero_proc/Cargo.toml b/src/aero_proc/Cargo.toml index 04f2a19be45..f13c4edc75c 100644 --- a/src/aero_proc/Cargo.toml +++ b/src/aero_proc/Cargo.toml @@ -12,9 +12,9 @@ default = [] proc-macro = true [dependencies] -proc-macro2 = "1.0.63" +proc-macro2 = "1.0.78" proc-macro-error = "1.0.4" -quote = "1.0.18" +quote = "1" [dependencies.syn] features = ["full"] diff --git a/src/aero_syscall/src/lib.rs b/src/aero_syscall/src/lib.rs index 98ce5533487..10ed83e6d37 100644 --- a/src/aero_syscall/src/lib.rs +++ b/src/aero_syscall/src/lib.rs @@ -16,7 +16,7 @@ // along with Aero. If not, see . #![no_std] -#![feature(decl_macro)] +// #![feature(decl_macro)] // cc #![allow(clippy::bad_bit_mask)] @@ -713,3 +713,14 @@ pub struct Stat { pub st_blksize: u64, pub st_blocks: u64, } + +bitflags::bitflags! { + #[repr(transparent)] + pub struct AtFlags: usize { + const EMPTY_PATH = 1; + const SYMLINK_FOLLOW = 2; + const SYMLINK_NOFOLLOW = 4; + const REMOVEDIR = 8; + const EACCESS = 512; + } +} diff --git a/src/aero_syscall/src/syscall.rs b/src/aero_syscall/src/syscall.rs index 1b20e34f5e2..f699c6f03f6 100644 --- a/src/aero_syscall/src/syscall.rs +++ b/src/aero_syscall/src/syscall.rs @@ -17,27 +17,29 @@ use core::arch::asm; -macro define_syscall_fns($(pub fn $sys_fn:ident($a:ident $(,$b:ident $(,$c:ident $(,$d:ident $(,$e:ident $(,$f:ident $(,$g:ident)?)?)?)?)?)?) -> usize;)+) { - $( - pub fn $sys_fn(mut $a: usize, $($b: usize, $($c: usize, $($d: usize, $($e: usize, $($f: usize, $($g: usize)?)?)?)?)?)?) -> usize { - #[cfg(target_arch = "x86_64")] - unsafe { - asm!( - "syscall", - inout("rax") $a, - $(in("rdi") $b, $(in("rsi") $c, $(in("rdx") $d, $(in("r10") $e, $(in("r8") $f, $(in("r9") $g,)?)?)?)?)?)? - out("rcx") _, - out("r11") _, - options(nostack), - ); +macro_rules! define_syscall_fns{ + ($(pub fn $sys_fn:ident($a:ident $(,$b:ident $(,$c:ident $(,$d:ident $(,$e:ident $(,$f:ident $(,$g:ident)?)?)?)?)?)?) -> usize;)+) => { + $( + pub fn $sys_fn(mut $a: usize, $($b: usize, $($c: usize, $($d: usize, $($e: usize, $($f: usize, $($g: usize)?)?)?)?)?)?) -> usize { + #[cfg(target_arch = "x86_64")] + unsafe { + asm!( + "syscall", + inout("rax") $a, + $(in("rdi") $b, $(in("rsi") $c, $(in("rdx") $d, $(in("r10") $e, $(in("r8") $f, $(in("r9") $g,)?)?)?)?)?)? + out("rcx") _, + out("r11") _, + options(nostack), + ); - $a - } + $a + } - #[cfg(target_arch = "aarch64")] - unreachable!("aarch64 is not supported yet"); - } - )+ + #[cfg(target_arch = "aarch64")] + unreachable!("aarch64 is not supported yet"); + } + )+ + } } define_syscall_fns!( diff --git a/userland/CMakeToolchain-x86_64.cmake b/userland/CMakeToolchain-x86_64.cmake index 37b45861653..1e305c84a70 100644 --- a/userland/CMakeToolchain-x86_64.cmake +++ b/userland/CMakeToolchain-x86_64.cmake @@ -1,6 +1,6 @@ -set(CMAKE_SYSTEM_NAME aero) +set(CMAKE_SYSTEM_NAME Aero) -set(CMAKE_FIND_ROOT_PATH $ENV{XBSTRAP_SYSROOT_DIR}) +set(CMAKE_FIND_ROOT_PATH /sysroot) set(CMAKE_C_COMPILER x86_64-aero-gcc) set(CMAKE_CXX_COMPILER x86_64-aero-g++) diff --git a/userland/Cargo.lock b/userland/Cargo.lock deleted file mode 100644 index a3b9233381b..00000000000 --- a/userland/Cargo.lock +++ /dev/null @@ -1,355 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "aero_ipc" -version = "0.1.0" -dependencies = [ - "aero_syscall", - "lazy_static", - "postcard", - "serde", - "spin 0.9.8", -] - -[[package]] -name = "aero_syscall" -version = "0.1.0" -dependencies = [ - "bitflags", - "byte_endian", - "num-derive", - "num-traits", - "static_assertions", -] - -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom", - "once_cell", - "version_check", -] - -[[package]] -name = "atomic-polyfill" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ff7eb3f316534d83a8a2c3d1674ace8a5a71198eba31e2e2b597833f699b28" -dependencies = [ - "critical-section", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "byte_endian" -version = "0.1.0" -source = "git+https://github.com/aero-os/byte_endian#47cec808e9c2813563f3a103ac2da2106c65f755" - -[[package]] -name = "byteorder" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "critical-section" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6548a0ad5d2549e111e1f6a11a6c2e2d00ce6a3dafe22948d67c2b443f775e52" - -[[package]] -name = "getrandom" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" -dependencies = [ - "cfg-if", - "libc 0.2.139 (registry+https://github.com/rust-lang/crates.io-index)", - "wasi", -] - -[[package]] -name = "hash32" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c35f58762feb77d74ebe43bdbc3210f09be9fe6742234d573bacc26ed92b67" -dependencies = [ - "byteorder", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash", -] - -[[package]] -name = "heapless" -version = "0.7.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db04bc24a18b9ea980628ecf00e6c0264f3c1426dac36c00cb49b6fbad8b0743" -dependencies = [ - "atomic-polyfill", - "hash32", - "rustc_version", - "serde", - "spin 0.9.8", - "stable_deref_trait", -] - -[[package]] -name = "init" -version = "0.1.0" -dependencies = [ - "aero_syscall", - "libc 0.2.139 (git+https://github.com/Andy-Python-Programmer/libc)", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -dependencies = [ - "spin 0.5.2", -] - -[[package]] -name = "libc" -version = "0.2.139" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" - -[[package]] -name = "libc" -version = "0.2.139" -source = "git+https://github.com/Andy-Python-Programmer/libc#0a8654ec90fe3940d4a1750fcf69cf67f49bc2b9" - -[[package]] -name = "lock_api" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "num-derive" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "num-traits" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" -dependencies = [ - "autocfg", -] - -[[package]] -name = "once_cell" -version = "1.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" - -[[package]] -name = "postcard" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a25c0b0ae06fcffe600ad392aabfa535696c8973f2253d9ac83171924c58a858" -dependencies = [ - "heapless", - "postcard-cobs", - "serde", -] - -[[package]] -name = "postcard-cobs" -version = "0.1.5-pre" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c68cb38ed13fd7bc9dd5db8f165b7c8d9c1a315104083a2b10f11354c2af97f" - -[[package]] -name = "proc-macro2" -version = "1.0.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78803b62cbf1f46fde80d7c0e803111524b9877184cfe7c3033659490ac7a7da" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "scopeguard" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" - -[[package]] -name = "semver" -version = "1.0.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" - -[[package]] -name = "serde" -version = "1.0.152" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.152" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "syn" -version = "1.0.107" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "system_server" -version = "0.1.0" -dependencies = [ - "aero_ipc", - "aero_syscall", - "hashbrown", - "spin 0.9.8", -] - -[[package]] -name = "systrace" -version = "0.1.0" -dependencies = [ - "aero_syscall", -] - -[[package]] -name = "unicode-ident" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "window_server" -version = "0.1.0" -dependencies = [ - "aero_ipc", - "aero_syscall", - "hashbrown", - "libc 0.2.139 (git+https://github.com/Andy-Python-Programmer/libc)", - "spin 0.9.8", -] - -[[package]] -name = "window_test" -version = "0.1.0" -dependencies = [ - "aero_ipc", - "aero_syscall", -] diff --git a/userland/Cargo.toml b/userland/Cargo.toml deleted file mode 100644 index c2e6b521c9c..00000000000 --- a/userland/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[workspace] -resolver = "2" -members = ["apps/*", "servers/*"] - -[profile.release] -debug = true diff --git a/userland/Makefile b/userland/Makefile new file mode 100644 index 00000000000..efbbbf40bf8 --- /dev/null +++ b/userland/Makefile @@ -0,0 +1,37 @@ +.PHONY: all clean install + +override TARGET_DIR := target + +override SYSTRACE_DIR := apps/systrace +override SYSTRACE_TARGET := $(TARGET_DIR)/systrace + +override TEST_DIR := tests +override TEST_TARGET = $(TARGET_DIR)/utest + +override INIT_DIR := init +override INIT_TARGET := $(TARGET_DIR)/init + +all: $(INIT_TARGET) $(SYSTRACE_TARGET) $(TEST_TARGET) + +$(INIT_TARGET): $(INIT_DIR)/init.c + mkdir -p $(TARGET_DIR) + $(CC) -o $@ $^ + +$(SYSTRACE_TARGET): $(SYSTRACE_DIR) + mkdir -p $(TARGET_DIR) + cd $(SYSTRACE_DIR) && cargo build --release + cp $(SYSTRACE_DIR)/target/x86_64-unknown-aero/release/systrace $(SYSTRACE_TARGET) + +$(TEST_TARGET): $(TEST_DIR)/utest.cc + mkdir -p $(TARGET_DIR) + $(CXX) -o $@ $^ + +clean: + rm -rf $(INIT_TARGET) + rm -rf $(SYSTRACE_TARGET) + +install: + install -d "$(DESTDIR)$(PREFIX)/bin" + install $(INIT_TARGET) "$(DESTDIR)$(PREFIX)/bin/" + install $(SYSTRACE_TARGET) "$(DESTDIR)$(PREFIX)/bin/" + install $(TEST_TARGET) "$(DESTDIR)$(PREFIX)/bin/" diff --git a/userland/aero.cmake b/userland/aero.cmake deleted file mode 100644 index 4f11498b9d8..00000000000 --- a/userland/aero.cmake +++ /dev/null @@ -1 +0,0 @@ -include(Platform/UnixPaths) \ No newline at end of file diff --git a/userland/apps/systrace/Cargo.toml b/userland/apps/systrace/Cargo.toml index 88e5bf272f2..c9865830a45 100644 --- a/userland/apps/systrace/Cargo.toml +++ b/userland/apps/systrace/Cargo.toml @@ -4,4 +4,4 @@ version = "0.1.0" edition = "2021" [dependencies] -aero_syscall = { path = "../../../src/aero_syscall" } +aero_syscall = { path = "/base_dir/src/aero_syscall" } diff --git a/userland/cross-file.ini b/userland/cross-file.ini index 87deb26d1ee..08d220581b6 100644 --- a/userland/cross-file.ini +++ b/userland/cross-file.ini @@ -5,7 +5,7 @@ ar = 'x86_64-aero-ar' strip = 'x86_64-aero-strip' ld = 'x86_64-aero-ld' pkgconfig = 'x86_64-aero-pkg-config' -# sed adds binaries here. +llvm-config = '/base_dir/build-support/cross-llvm-config' [host_machine] system = 'aero' diff --git a/userland/cross-llvm-config b/userland/cross-llvm-config deleted file mode 100755 index e238874164b..00000000000 --- a/userland/cross-llvm-config +++ /dev/null @@ -1,153 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import os -import sys - -our_version = 14 - - -def do_version(): - return "{}.0.1".format(our_version) - - -def do_components(): - return " ".join( - [ - "all", - "all-targets", - "analysis", - "asmparser", - "asmprinter", - "binaryformat", - "bitreader", - "bitwriter", - "codegen", - "core", - "coroutines", - "coverage", - "debuginfocodeview", - "debuginfodwarf", - "debuginfomsf", - "debuginfopdb", - "demangle", - "dlltooldriver", - "engine", - "executionengine", - "fuzzmutate", - "globalisel", - "gtest", - "gtest_main", - "instcombine", - "instrumentation", - "interpreter", - "ipo", - "irreader", - "libdriver", - "lineeditor", - "linker", - "lto", - "mc", - "mcdisassembler", - "mcjit", - "mcparser", - "mirparser", - "native", - "nativecodegen", - "objcarcopts", - "object", - "objectyaml", - "option", - "orcjit", - "passes", - "profiledata", - "runtimedyld", - "scalaropts", - "selectiondag", - "support", - "symbolize", - "tablegen", - "target", - "testingsupport", - "transformutils", - "vectorize", - "windowsmanifest", - "x86", - "x86asmparser", - "x86asmprinter", - "x86codegen", - "x86desc", - "x86disassembler", - "x86info", - "x86utils", - ] - ) - - -def do_targets_built(): - return "X86" - - -def get_includedir(): - sysroot = os.environ["XBSTRAP_SYSROOT_DIR"] - return sysroot + "/usr/include" - - -def get_libdir(): - sysroot = os.environ["XBSTRAP_SYSROOT_DIR"] - return sysroot + "/usr/lib" - - -def do_has_rtti(): - return "YES" - - -def do_shared_mode(): - return "shared" - - -def do_libs(): - return "-lLLVM-{}".format(our_version) - - -def do_system_libs(): - return "-lLLVM-{}".format(our_version) - - -def do_cppflags(): - return "" - - -def do_cxxflags(): - return "" - - -def do_ldflags(): - return "-L" + get_libdir() - - -parser = argparse.ArgumentParser() -parser.add_argument("--version", action="append_const", dest="command", const=do_version) -parser.add_argument( - "--targets-built", action="append_const", dest="command", const=do_targets_built -) -parser.add_argument("--components", action="append_const", dest="command", const=do_components) -parser.add_argument("--includedir", action="append_const", dest="command", const=get_includedir) -parser.add_argument("--libdir", action="append_const", dest="command", const=get_libdir) -parser.add_argument("--has-rtti", action="append_const", dest="command", const=do_has_rtti) -parser.add_argument("--shared-mode", action="append_const", dest="command", const=do_shared_mode) -parser.add_argument("--link-shared", action="store_const", dest="link", const="shared") -parser.add_argument("--cppflags", action="append_const", dest="command", const=do_cppflags) -parser.add_argument("--cxxflags", action="append_const", dest="command", const=do_cxxflags) -parser.add_argument("--ldflags", action="append_const", dest="command", const=do_ldflags) -parser.add_argument("--libs", action="append_const", dest="command", const=do_libs) -parser.add_argument("--system-libs", action="append_const", dest="command", const=do_system_libs) -parser.add_argument("components", type=str, nargs="*") - -print("cross-llvm-config:", sys.argv, file=sys.stderr) - -args = parser.parse_args() -for command in args.command: - result = command() - print("cross-llvm-config yields:", result, file=sys.stderr) - print(result) diff --git a/userland/init/init.c b/userland/init/init.c new file mode 100644 index 00000000000..2f7a6e78e70 --- /dev/null +++ b/userland/init/init.c @@ -0,0 +1,30 @@ +#include +#include +#include +#include +#include +#include + +int main() { + int fd_stdin = open("/dev/vtty", O_RDONLY); + int fd_stdout = open("/dev/vtty", O_WRONLY); + int fd_stderr = open("/dev/vtty", O_WRONLY); + + printf("Hello world\n"); + + setenv("TERM", "linux", 1); + setenv("USER", "root", 1); + setenv("PATH", "/usr/local/bin:/usr/bin", 1); + + int pid = fork(); + + if (!pid) { + char *args[] = {"/usr/bin/bash", "-l", NULL}; + execvp("/usr/bin/bash", args); + } else { + int status; + waitpid(pid, &status, 0); + } + + return 0; +} diff --git a/userland/tests/getchar.cc b/userland/tests/getchar.cc deleted file mode 100644 index 7b2ac57058e..00000000000 --- a/userland/tests/getchar.cc +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - -int main() { - std::string line; - char c; - - while ((c = getchar()) != EOF) { - std::cout << "Got: " << c << std::endl; - // FIXME: Should we also break on \r? - if (c == '\n') - break; - line.push_back(c); - } - - std::cout << line << std::endl; - return 0; -} diff --git a/userland/tests/test.cc b/userland/tests/utest.cc similarity index 95% rename from userland/tests/test.cc rename to userland/tests/utest.cc index e7a01c6b7f8..47c700cc612 100644 --- a/userland/tests/test.cc +++ b/userland/tests/utest.cc @@ -259,37 +259,37 @@ namespace { template void runChecks(Func &&f) { - // pid_t pid = fork(); - // assert_errno("fork", pid >= 0); - - // struct sigaction sa, old_sa; - // sigemptyset(&sa.sa_mask); - // sa.sa_sigaction = signalHandler; - // sa.sa_flags = SA_SIGINFO; - - // int ret = sigaction(SIGSEGV, &sa, &old_sa); - // assert_errno("sigaction", ret != -1); - - // if (pid == 0) { - // f(); - // exit(0); - // } else { - // int status = 0; - // while (waitpid(pid, &status, 0) == -1) { - // if (errno == EINTR) continue; - // assert_errno("waitpid", false); - // } - - // if (WIFSIGNALED(status) || WEXITSTATUS(status) != 0) { - // fprintf(stderr, "Test failed on subprocess!\n"); - // abort(); - // } - - // f(); - // } - - // ret = sigaction(SIGSEGV, &old_sa, nullptr); - // assert_errno("sigaction", ret != -1); + pid_t pid = fork(); + assert_errno("fork", pid >= 0); + + struct sigaction sa, old_sa; + sigemptyset(&sa.sa_mask); + sa.sa_sigaction = signalHandler; + sa.sa_flags = SA_SIGINFO; + + int ret = sigaction(SIGSEGV, &sa, &old_sa); + assert_errno("sigaction", ret != -1); + + if (pid == 0) { + f(); + exit(0); + } else { + int status = 0; + while (waitpid(pid, &status, 0) == -1) { + if (errno == EINTR) continue; + assert_errno("waitpid", false); + } + + if (WIFSIGNALED(status) || WEXITSTATUS(status) != 0) { + fprintf(stderr, "Test failed on subprocess!\n"); + abort(); + } + + f(); + } + + ret = sigaction(SIGSEGV, &old_sa, nullptr); + assert_errno("sigaction", ret != -1); } const size_t pageSize = sysconf(_SC_PAGESIZE); diff --git a/web/index.html b/web/index.html index 6876844fbdf..3acaa6b29e7 100644 --- a/web/index.html +++ b/web/index.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file From 6e784a42024d530ea0cbdea650ff556461773f6f Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 24 Feb 2024 19:27:47 +1100 Subject: [PATCH 028/112] kernel: make syscall handlers naked functions Signed-off-by: Anhad Singh --- Makefile | 13 +- build-support/mkiso.sh | 2 +- improving-build-times.txt | 4 +- src/.cargo/config.toml | 5 +- src/.cargo/x86_64-aero_os.json | 21 --- src/aero_kernel/build.rs | 3 + src/aero_kernel/src/arch/x86_64/gdt.rs | 9 +- src/aero_kernel/src/arch/x86_64/registers.S | 40 +++++ src/aero_kernel/src/arch/x86_64/syscall.rs | 155 +++++++++++++++- .../src/arch/x86_64/syscall_handler.asm | 169 ------------------ src/aero_kernel/src/arch/x86_64/task.asm | 95 ---------- src/aero_kernel/src/arch/x86_64/task.rs | 121 ++++++++++--- src/aero_kernel/src/fs/block/mod.rs | 2 +- src/aero_kernel/src/main.rs | 3 +- src/aero_kernel/src/userland/task/mod.rs | 2 +- userland/tests/utest.cc | 122 ++++++++++++- 16 files changed, 435 insertions(+), 331 deletions(-) delete mode 100644 src/.cargo/x86_64-aero_os.json create mode 100644 src/aero_kernel/src/arch/x86_64/registers.S delete mode 100644 src/aero_kernel/src/arch/x86_64/syscall_handler.asm delete mode 100644 src/aero_kernel/src/arch/x86_64/task.asm diff --git a/Makefile b/Makefile index f5b44ca4165..4881d45424c 100644 --- a/Makefile +++ b/Makefile @@ -14,23 +14,22 @@ distro: jinx SOURCE_DIR := src USERLAND_DIR := userland USERLAND_TARGET := builds/userland/target/init -KERNEL_TARGET := src/target/x86_64-aero_os/release/aero_kernel +KERNEL_TARGET := src/target/x86_64-unknown-none/release/aero_kernel .PHONY: clean clean: rm -rf src/target $(KERNEL_TARGET): $(shell find $(SOURCE_DIR) -type f -not -path '$(SOURCE_DIR)/target/*') - cd src && cargo build --package aero_kernel --target .cargo/x86_64-aero_os.json --release - @$(MAKE) iso + cd src && cargo build --package aero_kernel --release + ./build-support/mkiso.sh $(USERLAND_TARGET): $(shell find $(USERLAND_DIR) -type f -not -path '$(USERLAND_DIR)/target/*') ./target/jinx/jinx rebuild userland @$(MAKE) distro-image .PHONY: iso -iso: $(KERNEL_TARGET) - ./build-support/mkiso.sh +iso: $(KERNEL_TARGET) .PHONY: distro-image distro-image: distro @@ -38,10 +37,10 @@ distro-image: distro .PHONY: qemu qemu: $(KERNEL_TARGET) $(USERLAND_TARGET) - ${QEMU_PATH}/qemu-system-x86_64 -cdrom target/aero.iso -m 8G -serial stdio --boot d -s -enable-kvm -cpu host -drive file=target/disk.img,if=none,id=NVME1,format=raw -device nvme,drive=NVME1,serial=nvme + ${QEMU_PATH}/qemu-system-x86_64 -cdrom target/aero.iso -m 8G -serial stdio --boot d -s -enable-kvm -cpu host,+vmx -drive file=target/disk.img,if=none,id=NVME1,format=raw -device nvme,drive=NVME1,serial=nvme .PHONY: doc doc: rm -rf target/doc - cd src && cargo doc --package aero_kernel --target .cargo/x86_64-aero_os.json --release --target-dir=../target/doc/ + cd src && cargo doc --package aero_kernel --release --target-dir=../target/doc/ cp web/index.html target/doc/index.html diff --git a/build-support/mkiso.sh b/build-support/mkiso.sh index 46435fd04bf..42b2fea86bf 100755 --- a/build-support/mkiso.sh +++ b/build-support/mkiso.sh @@ -5,7 +5,7 @@ set -ex rm -rf target/iso_root mkdir -pv target/iso_root/boot -cp src/target/x86_64-aero_os/release/aero_kernel target/iso_root/aero +cp src/target/x86_64-unknown-none/release/aero_kernel target/iso_root/aero cp build-support/limine.cfg src/.cargo/term_background.bmp target/iso_root/ # Install the limine binaries diff --git a/improving-build-times.txt b/improving-build-times.txt index 6c4026a4d07..856726f3ede 100644 --- a/improving-build-times.txt +++ b/improving-build-times.txt @@ -1,2 +1,2 @@ -28.36s - +total_build: 28.36s +rebuild: 8.27s diff --git a/src/.cargo/config.toml b/src/.cargo/config.toml index c583ec52b03..6b5e72fb681 100644 --- a/src/.cargo/config.toml +++ b/src/.cargo/config.toml @@ -3,7 +3,7 @@ build-std = ["core", "compiler_builtins", "alloc"] build-std-features = ["compiler-builtins-mem"] [build] -target = "./.cargo/x86_64-aero_os.json" +target = "x86_64-unknown-none" rustflags = [ # Miscellaneous: "-Cforce-frame-pointers=yes", @@ -14,4 +14,7 @@ rustflags = [ "-Zthreads=8", # https://blog.rust-lang.org/inside-rust/2023/12/22/trait-system-refactor-initiative.html "-Znext-solver=coherence", + + # Linker flags: + "-Clink-arg=--no-pie", ] diff --git a/src/.cargo/x86_64-aero_os.json b/src/.cargo/x86_64-aero_os.json deleted file mode 100644 index 3259a444b56..00000000000 --- a/src/.cargo/x86_64-aero_os.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "llvm-target": "x86_64-unknown-none", - "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", - "arch": "x86_64", - "target-endian": "little", - "target-pointer-width": "64", - "target-c-int-width": "32", - "os": "none", - "executables": true, - "linker-flavor": "ld.lld", - "linker": "rust-lld", - "disable-redzone": true, - "features": "-mmx,-sse,+soft-float", - "code-model": "kernel", - "pre-link-args": { - "ld.lld": [ - "--gc-sections", - "--script=.cargo/kernel.ld" - ] - } -} \ No newline at end of file diff --git a/src/aero_kernel/build.rs b/src/aero_kernel/build.rs index 6e10d97a25e..aee21c04642 100644 --- a/src/aero_kernel/build.rs +++ b/src/aero_kernel/build.rs @@ -113,6 +113,9 @@ fn main() -> Result<(), Box> { } })?; + // Tell cargo to pass the linker script to the linker.. + println!("cargo:rustc-link-arg=-T.cargo/kernel.ld"); + // ..and to re-run if it changes. println!("cargo:rerun-if-changed=.cargo/kernel.ld"); Ok(()) diff --git a/src/aero_kernel/src/arch/x86_64/gdt.rs b/src/aero_kernel/src/arch/x86_64/gdt.rs index 272b732d626..dd3c197f8f8 100644 --- a/src/aero_kernel/src/arch/x86_64/gdt.rs +++ b/src/aero_kernel/src/arch/x86_64/gdt.rs @@ -54,6 +54,7 @@ bitflags::bitflags! { #[derive(Debug, Clone, Copy, PartialEq)] pub enum Ring { Ring0 = 0b00, + Ring3 = 0b11, } const BOOT_GDT_ENTRY_COUNT: usize = 4; @@ -175,10 +176,13 @@ impl GdtAccessFlags { pub struct GdtEntryType; +#[rustfmt::skip] impl GdtEntryType { pub const KERNEL_CODE: u16 = 1; pub const KERNEL_DATA: u16 = 2; pub const KERNEL_TLS: u16 = 3; + pub const USER_DATA: u16 = 4; + pub const USER_CODE: u16 = 5; pub const TSS: u16 = 8; pub const TSS_HI: u16 = 9; } @@ -266,7 +270,7 @@ pub struct Tss { /// The full 64-bit canonical forms of the stack pointers (RSP) for /// privilege levels 0-2. pub rsp: [u64; 3], // offset 0x04 - reserved2: u64, // offset 0x1C + pub reserved2: u64, // offset 0x1C /// The full 64-bit canonical forms of the interrupt stack table /// (IST) pointers. @@ -317,6 +321,9 @@ pub fn init_boot() { static STK: [u8; 4096 * 16] = [0; 4096 * 16]; +pub const USER_SS: SegmentSelector = SegmentSelector::new(GdtEntryType::USER_DATA, Ring::Ring3); +pub const USER_CS: SegmentSelector = SegmentSelector::new(GdtEntryType::USER_CODE, Ring::Ring3); + /// Initialize the *actual* GDT stored in TLS. /// /// ## Safety diff --git a/src/aero_kernel/src/arch/x86_64/registers.S b/src/aero_kernel/src/arch/x86_64/registers.S new file mode 100644 index 00000000000..91e38b91b15 --- /dev/null +++ b/src/aero_kernel/src/arch/x86_64/registers.S @@ -0,0 +1,40 @@ +.macro pop_preserved + pop r15 + pop r14 + pop r13 + pop r12 + pop rbp + pop rbx +.endm + +.macro pop_scratch + pop r11 + pop r10 + pop r9 + pop r8 + pop rsi + pop rdi + pop rdx + pop rcx + pop rax +.endm + +.macro push_scratch + push rcx + push rdx + push rdi + push rsi + push r8 + push r9 + push r10 + push r11 +.endm + +.macro push_preserved + push rbx + push rbp + push r12 + push r13 + push r14 + push r15 +.endm diff --git a/src/aero_kernel/src/arch/x86_64/syscall.rs b/src/aero_kernel/src/arch/x86_64/syscall.rs index 5cd9d9a7ac6..e0e672d8764 100644 --- a/src/aero_kernel/src/arch/x86_64/syscall.rs +++ b/src/aero_kernel/src/arch/x86_64/syscall.rs @@ -1,7 +1,7 @@ use aero_syscall::SyscallError; use raw_cpuid::CpuId; -use crate::arch::gdt::GdtEntryType; +use crate::arch::gdt::{GdtEntryType, Tss, USER_CS, USER_SS}; use crate::mem::paging::VirtAddr; use crate::userland::scheduler::{self, ExitStatus}; use crate::utils::sync::IrqGuard; @@ -9,16 +9,158 @@ use crate::utils::sync::IrqGuard; use super::interrupts::InterruptErrorStack; use super::io; -extern "C" { - fn x86_64_syscall_handler(); - fn x86_64_sysenter_handler(); -} +use core::mem::offset_of; const ARCH_SET_GS: usize = 0x1001; const ARCH_SET_FS: usize = 0x1002; const ARCH_GET_FS: usize = 0x1003; const ARCH_GET_GS: usize = 0x1004; +core::arch::global_asm!(include_str!("./registers.S")); + +/// 64-bit SYSCALL instruction entry point. +/// +/// The instruction supports to to 6 arguments in registers. +/// +/// Registers state on entry: +/// * `RAX` - system call number +/// * `RCX` - return address +/// * `R11` - saved flags (note: R11 is callee-clobbered register in C ABI) +/// * `RDI` - argument 1 +/// * `RSI` - argument 2 +/// * `RDX` - argument 3 +/// * `R10` - argument 4 (needs to be moved to RCX to conform to C ABI) +/// * `R8` - argument 5 +/// * `R9` - argument 6 +/// +/// (note: `R12`..`R15`, `RBP`, `RBX` are callee-preserved in C ABI) +/// +/// The instruction saves the `RIP` to `RCX`, clears `RFLAGS.RF` then saves `RFLAGS` to `R11`. +/// Followed by, it loads the new `SS`, `CS`, and `RIP` from previously programmed MSRs. +/// +/// The instruction also does not save anything on the stack and does *not* change the `RSP`. +#[naked] +unsafe extern "C" fn x86_64_syscall_handler() { + asm!( + // make the GS base point to the kernel TLS + "swapgs", + // save the user stack pointer + "mov qword ptr gs:{tss_temp_ustack_off}, rsp", + // restore kernel stack + "mov rsp, qword ptr gs:{tss_rsp0_off}", + "push {userland_ss}", + // push userspace stack ptr + "push qword ptr gs:{tss_temp_ustack_off}", + "push r11", + "push {userland_cs}", + "push rcx", + + "push rax", + "push_scratch", + "push_preserved", + + // push a fake error code to match with the layout of `InterruptErrorStack` + "push 0", + + "mov rdi, rsp", + + "cld", + "call {x86_64_do_syscall}", + "cli", + + // pop the fake error code + "add rsp, 8", + + "pop_preserved", + "pop_scratch", + + // cook the sysret frame + "pop rcx", + "add rsp, 8", + "pop r11", + "pop rsp", + + // restore user GS + "swapgs", + "sysretq", + + // constants: + userland_cs = const USER_CS.bits(), + userland_ss = const USER_SS.bits(), + // XXX: add 8 bytes to skip the x86_64 cpu local self ptr + tss_temp_ustack_off = const offset_of!(Tss, reserved2) + core::mem::size_of::(), + tss_rsp0_off = const offset_of!(Tss, rsp) + core::mem::size_of::(), + x86_64_do_syscall = sym x86_64_do_syscall, + options(noreturn) + ) +} + +/// 64-bit SYSENTER instruction entry point. +/// +/// The SYSENTER mechanism performs a fast transition to the kernel. +/// +/// The new `CS` is loaded from the `IA32_SYSENTER_CS` MSR, and the new instruction and stack +/// pointers are loaded from `IA32_SYSENTER_EIP` and `IA32_SYSENTER_ESP`, respectively. `RFLAGS.IF` +/// is cleared, but other flags are unchanged. +/// +/// As the instruction does not save *any* state, the user is required to provide the return `RIP` +/// and `RSP` in the `RCX` and `R11` registers, respectively. These addresses must be canonical. +/// +/// The instruction expects the call number and arguments in the same registers as for SYSCALL. +#[naked] +unsafe extern "C" fn x86_64_sysenter_handler() { + asm!( + "swapgs", + // Build the interrupt frame expected by the kernel. + "push {userland_ss}", + "push r11", + "pushfq", + "push {userland_cs}", + "push rcx", + // Mask the same flags as for SYSCALL. + // XXX: Up to this point the code can be single-stepped if the user sets TF. + "pushfq", + "and dword ptr [rsp], 0x300", + "popfq", + "push rax", + "push_scratch", + "push_preserved", + "push 0", + // Store the stack pointer (interrupt frame ptr) in `RBP` for safe keeping, and align the + // stack as specified by the SysV calling convention. + "mov rbp, rsp", + "and rsp, ~0xf", + "mov rdi, rbp", + "call {x86_64_check_sysenter}", + "mov rdi, rbp", + "call {x86_64_do_syscall}", + // Reload the stack pointer, skipping the error code. + "lea rsp, [rbp + 8]", + "pop_preserved", + "pop_scratch", + // Pop the `IRET` frame into the registers expected by `SYSEXIT`. + "pop rdx", // return `RIP` in `RDX` + "add rsp, 8", + "popfq", // restore saved `RFLAGS` + "pop rcx", // return `RSP` in `RCX` + // SAFETY: The above call to `x86_64_check_sysenter` is guarantees that we execute + // `sysexit` with canonical addresses in RCX and RDX. Otherwise we would fault in the + // kernel having already swapped back to the user's GS. + "swapgs", + // SYSEXIT does *not* restore `IF` to re-enable interrupts. + // This is done here, rather then when restoring `RFLAGS` above, since `STI` will keep + "sti", + // interrupts inhibited until after the *following* instruction executes. + "sysexitq", + // constants: + userland_cs = const USER_CS.bits(), + userland_ss = const USER_SS.bits(), + x86_64_check_sysenter = sym x86_64_check_sysenter, + x86_64_do_syscall = sym x86_64_do_syscall, + options(noreturn) + ) +} + fn arch_prctl(command: usize, address: usize) -> Result { match command { ARCH_SET_FS => unsafe { @@ -63,7 +205,6 @@ fn arch_prctl(command: usize, address: usize) -> Result { /// /// We cannot execute `sysexit` on return with non-canonical return addresses, or we /// will take a fault in the kernel with the user's GS base already swapped back. -#[no_mangle] pub(super) extern "sysv64" fn x86_64_check_sysenter(stack: &mut InterruptErrorStack) { let rip = stack.stack.iret.rip; let rsp = stack.stack.iret.rsp; @@ -77,7 +218,6 @@ pub(super) extern "sysv64" fn x86_64_check_sysenter(stack: &mut InterruptErrorSt } } -#[no_mangle] pub(super) extern "C" fn x86_64_do_syscall(stack: &mut InterruptErrorStack) { let stack = &mut stack.stack; @@ -156,6 +296,7 @@ pub(super) fn init() { .map_or(false, |i| i.has_sysenter_sysexit()); if has_sysenter { + log::info!("enabling support for sysenter"); unsafe { io::wrmsr( io::IA32_SYSENTER_CS, diff --git a/src/aero_kernel/src/arch/x86_64/syscall_handler.asm b/src/aero_kernel/src/arch/x86_64/syscall_handler.asm deleted file mode 100644 index e9a519d0c9c..00000000000 --- a/src/aero_kernel/src/arch/x86_64/syscall_handler.asm +++ /dev/null @@ -1,169 +0,0 @@ -; Copyright (C) 2021 The Aero Project Developers. -; -; This file is part of The Aero Project. -; -; Aero is free software: you can redistribute it and/or modify -; it under the terms of the GNU General Public License as published by -; the Free Software Foundation, either version 3 of the License, or -; (at your option) any later version. -; -; Aero is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with Aero. If not, see . - -bits 64 - -%include "registers.inc" - -extern x86_64_do_syscall -extern x86_64_check_sysenter -global x86_64_syscall_handler - -%define TSS_TEMP_USTACK_OFF 0x24 -%define TSS_RSP0_OFF 0xc - -%define USERLAND_SS 0x23 -%define USERLAND_CS 0x2b - -%define FMASK 0x300 ; TF | DF - -; 64-bit SYSCALL instruction entry point. The instruction supports -; to to 6 arguments in registers. -; -; Registers state on entry: -; RAX - system call number -; RCX - return address -; R11 - saved flags (note: R11 is callee-clobbered register in C ABI) -; RDI - argument 1 -; RSI - argument 2 -; RDX - argument 3 -; R10 - argument 4 (needs to be moved to RCX to conform to C ABI) -; R8 - argument 5 -; R9 - argument 6 -; -; (note: R12..R15, RBP, RBX are callee-preserved in C ABI) -; -; The instruction saves the RIP to RCX, clears RFLAGS.RF then saves -; RFLAGS to R11. Followed by, it loads the new SS, CS, and RIP from -; previously programmed MSRs. -; -; The instruction also does not save anything on the stack and does -; *not* change the RSP. -x86_64_syscall_handler: - ; swap the GS base to ensure that it points to the - ; kernel PCR. - swapgs - - mov [gs:TSS_TEMP_USTACK_OFF], rsp ; save the user stack pointer - mov rsp, [gs:TSS_RSP0_OFF] ; restore the kernel stack pointer - push qword USERLAND_SS ; push userspace SS - push qword [gs:TSS_TEMP_USTACK_OFF] ; push userspace stack pointer - push r11 ; push RFLAGS - push qword USERLAND_CS ; push userspace CS - push rcx ; push userspace return pointer - - push rax - push_scratch - push_preserved - - ; push a "fake" error code to match with the layout of the - ; `InterruptErrorStack` structure. - push 0 - - mov rdi, rsp - - cld - call x86_64_do_syscall - cli - - ; pop the "fake" error code - add rsp, 8 - - pop_preserved - pop_scratch - - ; make the sysret frame - pop rcx - add rsp, 8 - pop r11 - - pop rsp - - swapgs - o64 sysret - -; 64-bit SYSENTER entry point -; -; The SYSENTER mechanism performs a fast transition to the kernel. -; The new CS is loaded from the IA32_SYSENTER_CS MSR, and the new instruction -; and stack pointers are loaded from IA32_SYSENTER_EIP and IA32_SYSENTER_ESP, -; respectively. RFLAGS.IF is cleared, but other flags are unchanged. -; -; As the instruction does not save *any* state, the user is required to provide -; the return RIP and RSP in the RCX and R11 registers, respectively. These -; addresses must be canonical. -; -; The instruction expects the call number and arguments in the same registers as -; for SYSCALL. -; -section .text.x86_64_sysenter_handler -global x86_64_sysenter_handler:function (x86_64_sysenter_handler.end - x86_64_sysenter_handler) -align 16 -x86_64_sysenter_handler: - swapgs - - ; Build the interrupt frame expected by the kernel. - push USERLAND_SS - push r11 - pushfq - push USERLAND_CS - push rcx - - ; Mask the same flags as for SYSCALL. - ; Note that up to this point the code can be single-stepped if the user sets TF. - pushfq - and dword [rsp], 0x300 - popfq - - push rax - push_scratch - push_preserved - push 0 - - ; Store the stack pointer (interrupt frame pointer) in RBP for safe keeping, - ; and align the stack as specified by the SysV calling convention. - mov rbp, rsp - and rsp, ~0xf - - mov rdi, rbp - call x86_64_check_sysenter - - mov rdi, rbp - call x86_64_do_syscall - - ; Reload the stack pointer, skipping the error code. - lea rsp, [rbp + 8] - pop_preserved - pop_scratch - - ; Pop the IRET frame into the registers expected by SYSEXIT. - pop rdx ; return RIP in RDX - add rsp, 8 - popfq ; restore saved RFLAGS - pop rcx ; return RSP in RCX - - ; SAFETY: The above call to `x86_64_check_sysenter` is guarantees that we - ; execute `sysexit` with canonical addresses in RCX and RDX. Otherwise we would - ; fault in the kernel having already swapped back to the user's GS. - swapgs - - ; SYSEXIT does *not* restore IF to re-enable interrupts. - ; This is done here, rather then when restoring RFLAGS above, since STI will - ; keep interrupts inhibited until after the *following* instruction executes. - sti - o64 sysexit -.end: diff --git a/src/aero_kernel/src/arch/x86_64/task.asm b/src/aero_kernel/src/arch/x86_64/task.asm deleted file mode 100644 index 029eb3d87d3..00000000000 --- a/src/aero_kernel/src/arch/x86_64/task.asm +++ /dev/null @@ -1,95 +0,0 @@ -; Copyright (C) 2021 The Aero Project Developers. -; -; This file is part of The Aero Project. -; -; Aero is free software: you can redistribute it and/or modify -; it under the terms of the GNU General Public License as published by -; the Free Software Foundation, either version 3 of the License, or -; (at your option) any later version. -; -; Aero is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -; GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public License -; along with Aero. If not, see . - -bits 64 - -%include "registers.inc" - -global jump_userland_exec -global task_spinup -global iretq_init -global fork_init - -jump_userland_exec: - push rdi ; Param: stack - push rsi ; Param: RIP - push rdx ; Param: RFLAGS - - cli - - pop r11 - pop rcx - pop rsp - - swapgs - o64 sysret - -iretq_init: - cli - - ; pop the error code - add rsp, 8 - - pop_preserved - pop_scratch - - iretq - -fork_init: - cli - - ; pop the error code - add rsp, 8 - - pop_preserved - pop_scratch - - swapgs - iretq - -; extern "C" fn task_spinup(prev: &mut Context, next: &mut Context) -; -; Saves the current context into `prev` and restore the context from `next`. -task_spinup: - ; save callee-saved registers and this must match - ; the ordering of the fields in the `Context` struct. - push rbp - push rbx - push r12 - push r13 - push r14 - push r15 - - mov rax, cr3 ; save CR3 - push rax - - mov [rdi], rsp ; update old context pointer with current stack pointer - mov rsp, rsi ; switch to new stack - - pop rax ; restore CR3 - mov cr3, rax - - ; restore callee-saved registers - pop r15 - pop r14 - pop r13 - pop r12 - pop rbx - pop rbp - - ; resume the next thread - ret diff --git a/src/aero_kernel/src/arch/x86_64/task.rs b/src/aero_kernel/src/arch/x86_64/task.rs index 57851514a03..8102cc1f982 100644 --- a/src/aero_kernel/src/arch/x86_64/task.rs +++ b/src/aero_kernel/src/arch/x86_64/task.rs @@ -116,6 +116,107 @@ const USERLAND_STACK_SIZE: u64 = 0x64000; const USERLAND_STACK_TOP: VirtAddr = VirtAddr::new(0x7fffffffe000); const USERLAND_STACK_BOTTOM: VirtAddr = USERLAND_STACK_TOP.const_sub_u64(USERLAND_STACK_SIZE); +core::arch::global_asm!( + " + .macro pop_preserved + pop r15 + pop r14 + pop r13 + pop r12 + pop rbp + pop rbx + .endm + + .macro pop_scratch + pop r11 + pop r10 + pop r9 + pop r8 + pop rsi + pop rdi + pop rdx + pop rcx + pop rax + .endm + " +); + +#[naked] +unsafe extern "C" fn jump_userland_exec(stack: VirtAddr, rip: VirtAddr, rflags: u64) { + asm!( + "push rdi", // stack + "push rsi", // rip + "push rdx", // rflags + "cli", + "pop r11", + "pop rcx", + "pop rsp", + "swapgs", + "sysretq", + options(noreturn) + ); +} + +#[naked] +unsafe extern "C" fn task_spinup(prev: &mut Unique, next: &Context) { + asm!( + // save callee-saved registers + "push rbp", + "push rbx", + "push r12", + "push r13", + "push r14", + "push r15", + // save CR3 + "mov rax, cr3", + "push rax", + // update old context + "mov [rdi], rsp", + // switch to new stack + "mov rsp, rsi", + // restore CR3 + "pop rax", + "mov cr3, rax", + // restore callee-saved registers + "pop r15", + "pop r14", + "pop r13", + "pop r12", + "pop rbx", + "pop rbp", + // resume the next thread + "ret", + options(noreturn) + ); +} + +#[naked] +unsafe extern "C" fn iretq_init() { + asm!( + "cli", + // pop the error code + "add rsp, 8", + "pop_preserved", + "pop_scratch", + "iretq", + options(noreturn) + ) +} + +#[naked] +unsafe extern "C" fn fork_init() { + asm!( + "cli", + // pop the error code + "add rsp, 8", + "pop_preserved", + "pop_scratch", + "swapgs", + "iretq", + options(noreturn) + ) +} + pub struct ArchTask { context: Unique, @@ -168,10 +269,6 @@ impl ArchTask { kframe.stack.iret.rsp = task_stack as u64; kframe.stack.iret.rflags = if enable_interrupts { 0x200 } else { 0x00 }; - extern "C" { - fn iretq_init(); - } - let context = unsafe { stack.offset::() }; *context = Context::default(); @@ -224,10 +321,6 @@ impl ArchTask { let context = unsafe { new_stack.offset::() }; - extern "C" { - fn fork_init(); - } - *context = Context::default(); context.rip = fork_init as _; context.cr3 = address_space.cr3().start_address().as_u64(); @@ -279,10 +372,6 @@ impl ArchTask { // Prepare the trampoline... let context = unsafe { new_stack.offset::() }; - extern "C" { - fn fork_init(); - } - *context = Context::default(); context.rip = fork_init as u64; context.cr3 = new_address_space.cr3().start_address().as_u64(); @@ -370,10 +459,6 @@ impl ArchTask { self.fpu_storage = Some(fpu_storage); - extern "C" { - fn jump_userland_exec(stack: VirtAddr, rip: VirtAddr, rflags: u64); - } - let mut stack_addr = USERLAND_STACK_TOP.as_u64(); let mut stack = StackHelper::new(&mut stack_addr); @@ -615,10 +700,6 @@ fn xrstor(fpu: &FpuState) { /// Check out the module level documentation for more information. pub fn arch_task_spinup(from: &mut ArchTask, to: &ArchTask) { - extern "C" { - fn task_spinup(from: &mut Unique, to: &Context); - } - unsafe { if let Some(fpu) = from.fpu_storage.as_mut() { xsave(fpu); diff --git a/src/aero_kernel/src/fs/block/mod.rs b/src/aero_kernel/src/fs/block/mod.rs index 6255ded512f..d74ad267fb9 100644 --- a/src/aero_kernel/src/fs/block/mod.rs +++ b/src/aero_kernel/src/fs/block/mod.rs @@ -241,7 +241,7 @@ pub trait CachedAccess: BlockDeviceInterface { let page_offset = offset % Size4KiB::SIZE as usize; let size = core::cmp::min(Size4KiB::SIZE as usize - page_offset, buffer.len() - loc); - MaybeUninit::write_slice( + MaybeUninit::copy_from_slice( &mut page.data_mut()[page_offset..page_offset + size], &buffer[loc..loc + size], ); diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index 5baacc6178f..a7ccae9f2fc 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -49,7 +49,8 @@ cfg_match, // https://github.com/rust-lang/rust/issues/115585 strict_provenance, associated_type_defaults, - trait_upcasting + trait_upcasting, + asm_const )] // TODO(andypython): can we remove the dependency of "prelude_import" and "lang_items"? // `lang_items` => is currently used for the personality function (`rust_eh_personality`). diff --git a/src/aero_kernel/src/userland/task/mod.rs b/src/aero_kernel/src/userland/task/mod.rs index 86d60ba3723..10ddda4fe5c 100644 --- a/src/aero_kernel/src/userland/task/mod.rs +++ b/src/aero_kernel/src/userland/task/mod.rs @@ -530,7 +530,7 @@ impl Task { // if executable.absolute_path_str().contains("gcc") // || executable.absolute_path_str().contains("ls") // { - // self.enable_systrace(); + self.enable_systrace(); // } *self.mem_tags.lock() = HashMap::new(); diff --git a/userland/tests/utest.cc b/userland/tests/utest.cc index 47c700cc612..2fc71f96fcc 100644 --- a/userland/tests/utest.cc +++ b/userland/tests/utest.cc @@ -2,6 +2,7 @@ // // xbstrap runtool host-gcc -- x86_64-aero-g++ ../userland/tests/test.cc -o system-root/torture +#include #include #include #include @@ -21,6 +22,14 @@ #include #include +#if defined(__aero__) +#include +#elif defined(__linux__) +#include +#else +#error "unknown platform" +#endif + #define NAMED_PATH "/tmp/sockname" #define DEFINE_TEST(s, f) static test_case test_##s{#s, f}; @@ -601,6 +610,109 @@ DEFINE_TEST(mprotect_check_whether_three_way_split_mappings_are_handled_correctl }); })) +static inline bool cpuid(uint32_t leaf, uint32_t subleaf, + uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { + uint32_t cpuid_max; + asm volatile ("cpuid" + : "=a" (cpuid_max) + : "a" (leaf & 0x80000000) : "rbx", "rcx", "rdx"); + if (leaf > cpuid_max) + return false; + asm volatile ("cpuid" + : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) + : "a" (leaf), "c" (subleaf)); + return true; +} + +// Returns [`true`] if the `SYSENTER` and `SYSEXIT` and associated MSRs are supported. +bool has_sysenter_sysexit() { + uint32_t eax, ebx, ecx, edx; + // LEAF 1: Processor and Processor Feature Identifiers + if (!cpuid(1, 0, &eax, &ebx, &ecx, &edx)) { + return false; + } + return edx & (1 << 11); +} + +#if defined(__aero__) +DEFINE_TEST(bad_sysenter, ([] { + if (!has_sysenter_sysexit()) { + printf("test skipped... sysenter not supported\n"); + return; + } + + int pid = fork(); + + if (!pid) { + register long r11 __asm__("r11") = (size_t)0xf0f0 << 48; + register long rcx __asm__("rcx") = (size_t)0xf0f0 << 48; + + asm volatile( + "sysenter\n" + : + : "r"(r11), "r"(rcx) + ); + + __builtin_unreachable(); + } else { + int status = 0; + if (!waitpid(pid, &status, 0)) + assert(!"waitpid() failed"); + + // FIXME: should we get killed with SIGSEGV instead? + assert(WIFEXITED(status)); + } +})) +#endif + +#if defined(__aero__) +DEFINE_TEST(sysenter_system_call, ([] { + if (!has_sysenter_sysexit()) { + printf("test skipped... sysenter not supported\n"); + return; + } + + int fds[2]; + if (pipe(fds) == -1) + assert(!"pipe() failed"); + + int pid = fork(); + + if (!pid) { + close(fds[0]); + + const char *buf = "Hello, world!\n"; + size_t buf_size = strlen(buf); + + __asm__ __volatile__ ( + "mov %%rsp, %%r11\n\t" + "lea 1f(%%rip), %%rcx\n\t" + "sysenter\n\t" + "1:" + : + : "a"(uint64_t(1)), "D"(uint64_t(fds[1])), "S"(buf), "d"(buf_size + 1) + : "rcx", "r11" + ); + + exit(0); + } else { + close(fds[1]); + + int status = 0; + if (!waitpid(pid, &status, 0)) + assert(!"waitpid() failed"); + + assert(WIFEXITED(status)); + + char tmp[15]; + ssize_t n = read(fds[0], tmp, sizeof(tmp)); + + assert(n == 15); + assert(!strcmp(tmp, "Hello, world!\n")); + } +})) +#endif + std::vector &test_case_ptrs() { static std::vector singleton; return singleton; @@ -612,8 +724,10 @@ void abstract_test_case::register_case(abstract_test_case *tcp) { int main() { // Go through all tests and run them. - for(abstract_test_case *tcp : test_case_ptrs()) { - std::cout << "tests: Running " << tcp->name() << std::endl; - tcp->run(); - } + // for(abstract_test_case *tcp : test_case_ptrs()) { + // std::cout << "tests: Running " << tcp->name() << std::endl; + // tcp->run(); + // } + test_bad_sysenter.run(); + test_sysenter_system_call.run(); } From 3af6b5548200c5a63bc3b3e0c13b5a0e2e2151c0 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 24 Feb 2024 19:35:19 +1100 Subject: [PATCH 029/112] fix: update README build instructions Signed-off-by: Anhad Singh --- README.md | 86 +++++++------------------------------------------------ 1 file changed, 11 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index 2dbc173adec..0adf36cfa1e 100644 --- a/README.md +++ b/README.md @@ -40,8 +40,8 @@ No, Aero runs its own kernel that does *not* originate from Linux and does not s # How to Build and Run Aero -Please make sure you have a **unix-like** host system before building -Aero. If you are using windows, its highly recommended to use WSL 2. +Please make sure you have a Linux host system before building +Aero. If you are using windows, use WSL 2. ## Dependencies @@ -49,27 +49,12 @@ Before building Aero, you need the following things installed: - `rust` (should be the **latest nightly**) - `nasm` - `qemu` (optional: required if you want to run it in the Qemu emulator) - -If you are building Aero with sysroot, run the following helper script to install additional dependencies. -```sh -# make sure to run the script with root privileges! -./tools/deps.sh -``` -You can optionally set the environment variable `VERBOSE` to `true`, which will pass through the output of your package manager for troubleshooting. -```sh -VERBOSE=true ./tools/deps.sh -``` - -Note: If your host operating system is not in the list below, you will need to determine the dependency packages' names for your package manager (contributions to this tool are welcome!) -- Arch Linux/based (pacman) -- Debian Linux/based (apt) -- macOS (homebrew) - +- `make` ## Hardware The following are *not* requirements but are *recommendations*: -- ~15GB of free disk space +- ~15GB of free disk space (this will vary depending on the amount of packages you want to build) - \>= 8GB RAM - \>= 2 cores - Internet access @@ -86,63 +71,14 @@ $ cd aero ## Building Aero -Aero uses a custom build system, that wraps `cargo` and takes care of building the kernel and -userland for you. It also builds the initramfs and disk image for you. - -The main command we will focus on is `./aero.py`. The source code can be found in the -root of the repository and, as the file name states, it is written in Python. - -By default if you run `./aero.py` without any arguments it will build the kernel and userland -in release mode with debug symbols and run it in QEMU. You can configure the behavior of the -build system though. If you want to, you can use the `--help` option to read a brief description -of what it can do. - -The build system acknowledges few different build modes, which cannot be used together -and they are: `--clean`, `--check`, `--test` and `--document`. - -- `--clean` option will clean all the build outputs. -- `--check` will build the kernel and userland using cargo's `check` command, - this build mode will not produce a disk image, if you want one without actually - running Aero in the emulator read ahead -- `--test` will run the built-in Aero test suite -- `--document` will generate web-based docs using cargo's `doc` command -- `--sysroot` will build the full userland sysroot. If not passed, then the sysroot will only contain -the `aero_shell` and the `init` binaries. - - **Note**: This command will require a relatively large amount of storage -space. You may want to have upwards of 10 or 15 gigabytes available if building with full sysroot. - -Each of these modes can be used with additional flags, that will alter the behavior in different -ways, some of them will not work for some of these modes - for example: the `--la57` option -will not have any effect when you are simply checking or documenting the build. - -- `--debug` toggles off the release build flag when calling cargo. - - **Summary**: If the `--debug` flag is not passed then it will build Aero in release mode - and debug symbols will be available. On the other hand, if the debug flag is passed - then it will be built in debug mode and debug symbols will be still available. By default - Aero is built in release mode (with debug symbols) since it generates faster and smaller - binaries which are easier to test. -- `--no-run` prevents from running the built disk image in the emulator -- `--bios` lets you choose the firmware the emulator will use when booting Aero, - currently supported values are: `legacy` and `uefi` -- `--features` accepts a single comma-separated list of kernel crate features, please - keep in mind that there cannot be spaces in between the values -- `--target` lets you override the target architecture for which the kernel is built, - currently the default value is `x86_64-aero_os` -- `--la57` tells the emulator to use 5 level paging, if it supports it - -The built disk image is stored in the `build` directory under the name `aero.iso`. Both the -disk root and initramfs root are preserved in case you want to inspect them manually. - -## Running Aero in an emulator - -If you haven't used the `--no-run` option and you aren't using the `--check` or `--document` build -mode, the build system will run Aero in the emulator for you. - -## Nightly Images +```shell +make distro-image +make qemu -Want to give Aero a shot, without building it! You can go to the [latest job](https://github.com/Andy-Python-Programmer/aero/actions/workflows/build.yml?query=is%3Asuccess+branch%3Amaster) and download the latest nightly image (`aero.iso`), under artifacts. +# To build documentation run the following command. The documentation will be outputed to the `target/doc` directory. +make doc +# The documentation will be available in the `target/doc` directory. +``` # Contributing From f981b2ac63288c4f5397f415db12ce1388c3c468 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 24 Feb 2024 19:44:20 +1100 Subject: [PATCH 030/112] feat(makefile): add open option for doc * add open option for doc command * document this flag in readme Signed-off-by: Anhad Singh --- Makefile | 4 +++- README.md | 8 +++++--- web/index.html | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 4881d45424c..b21ee99701d 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,8 @@ qemu: $(KERNEL_TARGET) $(USERLAND_TARGET) .PHONY: doc doc: - rm -rf target/doc cd src && cargo doc --package aero_kernel --release --target-dir=../target/doc/ cp web/index.html target/doc/index.html +ifeq ($(open),yes) + xdg-open target/doc/index.html +endif diff --git a/README.md b/README.md index 0adf36cfa1e..1c13f332d82 100644 --- a/README.md +++ b/README.md @@ -75,9 +75,11 @@ $ cd aero make distro-image make qemu -# To build documentation run the following command. The documentation will be outputed to the `target/doc` directory. -make doc -# The documentation will be available in the `target/doc` directory. +# To build documentation run the following command. The documentation will be outputed +# to the `target/doc` directory. +# +# Optionally you can pass `open=yes` to open the documentation in the default browser. +make doc open=yes ``` # Contributing diff --git a/web/index.html b/web/index.html index 3acaa6b29e7..acc3e9a4cd5 100644 --- a/web/index.html +++ b/web/index.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file From 97db318a62b4e2d71225ef41a79ea3a94d062ec2 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 24 Feb 2024 19:48:11 +1100 Subject: [PATCH 031/112] fix(recipes::userland): add rust as a dep Signed-off-by: Anhad Singh --- recipes/userland | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/userland b/recipes/userland index 042300a924f..f8ad9d22568 100644 --- a/recipes/userland +++ b/recipes/userland @@ -2,7 +2,7 @@ name=userland version=0.0 revision=1 source_dir="userland" -hostdeps="gcc binutils" +hostdeps="gcc binutils rust" deps="core-libs" imagedeps="rust" allow_network=yes From dd504bac72337940e0a11987afc1b097f78db81f Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 24 Feb 2024 22:19:49 +1100 Subject: [PATCH 032/112] fix(build): pin Jinx version Signed-off-by: Anhad Singh --- Makefile | 9 +++++---- build-support/mkimage.sh | 2 +- build-support/mkiso.sh | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index b21ee99701d..86fc4651f18 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ jinx: - if [ ! -d "target/jinx" ]; then \ - git clone https://github.com/mintsuki/jinx target/jinx; \ + if [ ! -f "target/jinx" ]; then \ + curl -Lo target/jinx https://github.com/mintsuki/jinx/raw/30e7d5487bff67a66dfba332113157a08a324820/jinx; \ + chmod +x target/jinx; \ fi # FIXME: autosync @@ -9,7 +10,7 @@ jinx: .PHONY: distro distro: jinx - ./target/jinx/jinx build-all + ./target/jinx build-all SOURCE_DIR := src USERLAND_DIR := userland @@ -25,7 +26,7 @@ $(KERNEL_TARGET): $(shell find $(SOURCE_DIR) -type f -not -path '$(SOURCE_DIR)/t ./build-support/mkiso.sh $(USERLAND_TARGET): $(shell find $(USERLAND_DIR) -type f -not -path '$(USERLAND_DIR)/target/*') - ./target/jinx/jinx rebuild userland + ./target/jinx rebuild userland @$(MAKE) distro-image .PHONY: iso diff --git a/build-support/mkimage.sh b/build-support/mkimage.sh index ce7a8cbb9ce..eb6bb7b792d 100755 --- a/build-support/mkimage.sh +++ b/build-support/mkimage.sh @@ -1,6 +1,6 @@ IMAGE_PATH=target/disk.img -./target/jinx/jinx sysroot +./target/jinx sysroot rm -rf $IMAGE_PATH diff --git a/build-support/mkiso.sh b/build-support/mkiso.sh index 42b2fea86bf..7e0a6ebecf9 100755 --- a/build-support/mkiso.sh +++ b/build-support/mkiso.sh @@ -1,6 +1,6 @@ set -ex -./target/jinx/jinx host-build limine +./target/jinx host-build limine rm -rf target/iso_root mkdir -pv target/iso_root/boot From da9661ab2327250311c8cef8b65c7efcf37cf56e Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 15 Mar 2024 17:53:58 +1100 Subject: [PATCH 033/112] fix(host-rust): make it build Signed-off-by: Anhad Singh --- host-recipes/rust | 10 ++++------ host-recipes/rust-libc | 3 +++ source-recipes/rust-libc | 2 +- src/aero_kernel/src/main.rs | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 host-recipes/rust-libc diff --git a/host-recipes/rust b/host-recipes/rust index 9a7a03c1350..fcd627d46e4 100644 --- a/host-recipes/rust +++ b/host-recipes/rust @@ -1,22 +1,20 @@ name=rust revision=1 from_source=rust-host -hostdeps="llvm gcc" +hostdeps="llvm gcc rust-libc" source_deps="rust-libc" imagedeps="python git wget gcc" allow_network="yes" -#unset CARGO_HOME - build() { # Rust memes. - # cp -rp "${source_dir}/." ./ + cp -rp "${source_dir}/." ./ - ./x.py build --stage 2 -j${parallelism} + CARGO_HOME=/tmp/cargo ./x.py build --stage 2 -j${parallelism} } package() { - DESTDIR="${dest_dir}" ./x.py install -j${parallelism} + CARGO_HOME=/tmp/cargo DESTDIR="${dest_dir}" ./x.py install -j${parallelism} find ${dest_dir} -name "*.old" -delete diff --git a/host-recipes/rust-libc b/host-recipes/rust-libc new file mode 100644 index 00000000000..1b29226398a --- /dev/null +++ b/host-recipes/rust-libc @@ -0,0 +1,3 @@ +name=rust-libc +from_source=rust-libc +revision=1 diff --git a/source-recipes/rust-libc b/source-recipes/rust-libc index 48458aeb56f..ce25dcda481 100644 --- a/source-recipes/rust-libc +++ b/source-recipes/rust-libc @@ -1,4 +1,4 @@ name=rust-libc version=fe4e9cda46b0be8421b0f56df0b63b8c4dcaf5e6 tarball_url="https://github.com/Andy-Python-Programmer/libc/archive/${version}.tar.gz" -tarball_blake2b="xadfdf" +tarball_blake2b="7a97d83784dfb6cdfd189d880f367facd2e06e43468248b41aa0239d3043172dfb508eca0209a7adb0ec12fda06887bfbdc37f41ebcb65b1a48967754c940b8f" diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index a7ccae9f2fc..d2ec2b07b69 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -133,7 +133,7 @@ pub fn relocate_self() { for section in kernel_elf.section_iter() { if let Ok(SectionData::Rela64(rela)) = section.get_data(kernel_elf) { for item in rela { - if !item.get_type() == STT_GNU_IFUNC { + if item.get_type() != STT_GNU_IFUNC { continue; } From a6f265e6502a7b5a4dfe330a9b514fe5faa516e5 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 16 Mar 2024 13:31:57 +1100 Subject: [PATCH 034/112] misc(kernel): bump limine crate to v2 Signed-off-by: Anhad Singh --- src/Cargo.lock | 16 ++-- src/aero_kernel/Cargo.toml | 6 +- .../x86_64/{registers.S => asm_macros.rs} | 24 +++-- src/aero_kernel/src/arch/x86_64/mod.rs | 88 +++++++------------ src/aero_kernel/src/arch/x86_64/syscall.rs | 20 ++--- src/aero_kernel/src/arch/x86_64/task.rs | 35 ++------ src/aero_kernel/src/cmdline.rs | 13 ++- src/aero_kernel/src/main.rs | 3 +- src/aero_kernel/src/mem/paging/frame.rs | 25 +++--- src/aero_kernel/src/mem/paging/mod.rs | 6 +- src/aero_kernel/src/rendy.rs | 33 ++++--- src/aero_kernel/src/userland/task/mod.rs | 2 +- 12 files changed, 121 insertions(+), 150 deletions(-) rename src/aero_kernel/src/arch/x86_64/{registers.S => asm_macros.rs} (68%) diff --git a/src/Cargo.lock b/src/Cargo.lock index 2d039f2d091..7bb3e2773e4 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -110,9 +110,9 @@ source = "git+https://github.com/aero-os/byte_endian#540be6149cd9408088a9e45be2d [[package]] name = "bytemuck" -version = "1.14.1" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed2490600f404f2b94c167e31d3ed1d5f3c225a0f3b80230053b3e0b7b962bd9" +checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" [[package]] name = "cc" @@ -245,8 +245,12 @@ checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" [[package]] name = "limine" -version = "0.1.12" -source = "git+https://github.com/limine-bootloader/limine-rs#fd967c9fbb8545715842594f8ce0a01113170091" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "846c87e24d089e8717a61098cba72b378e3525c46a87cf75b71352dcf668e68c" +dependencies = [ + "bitflags 2.4.2", +] [[package]] name = "log" @@ -256,9 +260,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "lru" -version = "0.12.1" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2994eeba8ed550fd9b47a0b38f0242bc3344e496483c6180b69139cc2fa5d1d7" +checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" dependencies = [ "hashbrown", ] diff --git a/src/aero_kernel/Cargo.toml b/src/aero_kernel/Cargo.toml index d12e3d35e24..bc94f6272ef 100644 --- a/src/aero_kernel/Cargo.toml +++ b/src/aero_kernel/Cargo.toml @@ -40,9 +40,9 @@ lai = { git = "https://github.com/aero-os/lai-rs" } uapi = { path = "../uapi" } cpio_reader = { git = "https://github.com/Andy-Python-Programmer/cpio_reader" } static_assertions = "1.1.0" -lru = "0.12.1" -bytemuck = "1.14.1" -limine = { git = "https://github.com/limine-bootloader/limine-rs" } +lru = "0.12.3" +bytemuck = "1.15.0" +limine = "0.2.0" num-traits = { version = "0.2", default-features = false } vte = { version = "0.13.0", features = ["ansi"] } diff --git a/src/aero_kernel/src/arch/x86_64/registers.S b/src/aero_kernel/src/arch/x86_64/asm_macros.rs similarity index 68% rename from src/aero_kernel/src/arch/x86_64/registers.S rename to src/aero_kernel/src/arch/x86_64/asm_macros.rs index 91e38b91b15..21c986e52b5 100644 --- a/src/aero_kernel/src/arch/x86_64/registers.S +++ b/src/aero_kernel/src/arch/x86_64/asm_macros.rs @@ -1,13 +1,16 @@ -.macro pop_preserved +pub macro pop_preserved() { + " pop r15 pop r14 pop r13 pop r12 pop rbp pop rbx -.endm + " +} -.macro pop_scratch +pub macro pop_scratch() { + " pop r11 pop r10 pop r9 @@ -17,9 +20,11 @@ pop rdx pop rcx pop rax -.endm + " +} -.macro push_scratch +pub macro push_scratch() { + " push rcx push rdx push rdi @@ -28,13 +33,16 @@ push r9 push r10 push r11 -.endm + " +} -.macro push_preserved +pub macro push_preserved() { + " push rbx push rbp push r12 push r13 push r14 push r15 -.endm + " +} diff --git a/src/aero_kernel/src/arch/x86_64/mod.rs b/src/aero_kernel/src/arch/x86_64/mod.rs index 113ba35123b..928404c15b3 100644 --- a/src/aero_kernel/src/arch/x86_64/mod.rs +++ b/src/aero_kernel/src/arch/x86_64/mod.rs @@ -30,6 +30,9 @@ pub mod time; pub mod tls; pub mod user_copy; +mod asm_macros; + +use core::cell::SyncUnsafeCell; use core::sync::atomic::Ordering; use crate::acpi::aml; @@ -42,32 +45,31 @@ use crate::{drivers, logger, rendy}; use raw_cpuid::CpuId; -use limine::*; +use limine::request::*; +use limine::smp::Cpu; + use spin::Once; use self::interrupts::INTERRUPT_CONTROLLER; -static MEMMAP: MemmapRequest = MemmapRequest::new(0); -static SMP: SmpRequest = SmpRequest::new(0); -static KERNEL_FILE: KernelFileRequest = KernelFileRequest::new(0); -static MODULES: ModuleRequest = ModuleRequest::new(0); -static FRAMEBUFFER: FramebufferRequest = FramebufferRequest::new(0); -static RSDP: RsdpRequest = RsdpRequest::new(0); -static BOOT_TIME: BootTimeRequest = BootTimeRequest::new(0); -static STACK: StackSizeRequest = StackSizeRequest::new(0).stack_size(0x1000 * 32); // 16KiB of stack for both the BSP and the APs -static HHDM: HhdmRequest = HhdmRequest::new(0); +static SMP: SyncUnsafeCell = SyncUnsafeCell::new(SmpRequest::new()); +static MEMMAP: SyncUnsafeCell = SyncUnsafeCell::new(MemoryMapRequest::new()); + +static KERNEL_FILE: KernelFileRequest = KernelFileRequest::new(); +static MODULES: ModuleRequest = ModuleRequest::new(); +static FRAMEBUFFER: FramebufferRequest = FramebufferRequest::new(); +static RSDP: RsdpRequest = RsdpRequest::new(); +static BOOT_TIME: BootTimeRequest = BootTimeRequest::new(); +static STACK: StackSizeRequest = StackSizeRequest::new().with_size(0x1000 * 32); // 16KiB of stack for both the BSP and the APs +static HHDM: HhdmRequest = HhdmRequest::new(); #[no_mangle] extern "C" fn arch_aero_main() -> ! { let kernel_file_resp = KERNEL_FILE .get_response() - .get() .expect("limine: invalid kernel file response"); - let kernel_file = kernel_file_resp - .kernel_file - .get() - .expect("limine: invalid kernel file pointer"); + let kernel_file = kernel_file_resp.file(); // Before we start the initialization process, we need to make sure // the unwind info is available; just in case if there is a kernel @@ -76,13 +78,10 @@ extern "C" fn arch_aero_main() -> ! { use crate::unwind::UnwindInfo; use xmas_elf::ElfFile; - let start = kernel_file - .base - .as_ptr() - .expect("limine: invalid kernel file base"); + let start = kernel_file.addr(); // SAFETY: The bootloader will provide a valid pointer to the kernel file. - let elf_slice = unsafe { core::slice::from_raw_parts(start, kernel_file.length as usize) }; + let elf_slice = unsafe { core::slice::from_raw_parts(start, kernel_file.size() as usize) }; let elf = ElfFile::new(elf_slice).expect("limine: invalid kernel file"); UnwindInfo::new(elf) @@ -91,22 +90,18 @@ extern "C" fn arch_aero_main() -> ! { crate::relocate_self(); unsafe { - core::ptr::read_volatile(STACK.get_response().as_ptr().unwrap()); + core::ptr::read_volatile(STACK.get_response().unwrap()); } // SAFETY: We have exclusive access to the memory map. - let memmap = MEMMAP - .get_response() - .get_mut() - .expect("limine: invalid memmap response") - .memmap_mut(); + let memmap = unsafe { &mut *MEMMAP.get() }.get_response_mut().unwrap(); unsafe { interrupts::disable_interrupts(); } unsafe { - crate::PHYSICAL_MEMORY_OFFSET = VirtAddr::new(HHDM.get_response().get().unwrap().offset); + crate::PHYSICAL_MEMORY_OFFSET = VirtAddr::new(HHDM.get_response().unwrap().offset()); } // Now that we have unwind info, we can initialize the COM ports. This @@ -120,23 +115,11 @@ extern "C" fn arch_aero_main() -> ! { let modules = MODULES .get_response() - .get() .expect("limine: invalid modules response") .modules(); - // Now, we need to parse the kernel command line so we can - // setup the debug renderer. - // - // SAFETY: The `cmdline` is a valid, aligned, and NULL terminated string. - let command_line = kernel_file - .cmdline - .to_str() - .expect("limine: bad command line"); - - let command_line = cmdline::parse( - command_line.to_str().expect("cmdline: invalid utf8"), - modules, - ); + let command_line = core::str::from_utf8(kernel_file.cmdline()).unwrap(); + let command_line = cmdline::parse(command_line, modules); paging::init(memmap).unwrap(); log::info!("loaded paging"); @@ -145,17 +128,17 @@ extern "C" fn arch_aero_main() -> ! { log::info!("loaded heap"); // SMP initialization. - let smp_response = SMP.get_response().get_mut().unwrap(); - let bsp_lapic_id = smp_response.bsp_lapic_id; + let smp_response = unsafe { &mut *SMP.get() }.get_response_mut().unwrap(); + let bsp_lapic_id = smp_response.bsp_lapic_id(); - for cpu in smp_response.cpus().iter_mut() { + for cpu in smp_response.cpus_mut() { apic::CPU_COUNT.fetch_add(1, Ordering::SeqCst); if cpu.lapic_id == bsp_lapic_id { continue; } - cpu.goto_address = x86_64_aero_ap_main; + cpu.goto_address.write(x86_64_aero_ap_main); } gdt::init_boot(); @@ -165,10 +148,9 @@ extern "C" fn arch_aero_main() -> ! { let framebuffer = FRAMEBUFFER .get_response() - .get() .expect("limine: invalid framebuffer response") .framebuffers() - .first() + .next() .expect("limine: no framebuffer found!"); rendy::init(framebuffer, &command_line); @@ -180,7 +162,7 @@ extern "C" fn arch_aero_main() -> ! { apic::init(); log::info!("loaded APIC"); - let rsdp = VirtAddr::new(RSDP.get_response().get().unwrap().address.as_ptr().unwrap() as u64); + let rsdp = VirtAddr::new(RSDP.get_response().unwrap().address().addr() as u64); acpi::init(rsdp); log::info!("loaded ACPI"); @@ -196,18 +178,16 @@ extern "C" fn arch_aero_main() -> ! { syscall::init(); - let boot_time = BOOT_TIME.get_response().get().unwrap(); - time::EPOCH.store(boot_time.boot_time as _, Ordering::SeqCst); + let boot_time = BOOT_TIME.get_response().unwrap(); + time::EPOCH.store(boot_time.boot_time().as_secs() as usize, Ordering::SeqCst); // Architecture init is done. Now we can initialize and start the init // process in the non-architecture specific part of the kernel. crate::aero_main(); } -#[no_mangle] -extern "C" fn x86_64_aero_ap_main(boot_info: *const SmpInfo) -> ! { - let boot_info = unsafe { &*boot_info }; - let ap_id = boot_info.processor_id as usize; +extern "C" fn x86_64_aero_ap_main(cpu: &Cpu) -> ! { + let ap_id = cpu.id as usize; log::debug!("booting CPU {}", ap_id); diff --git a/src/aero_kernel/src/arch/x86_64/syscall.rs b/src/aero_kernel/src/arch/x86_64/syscall.rs index e0e672d8764..433ce0ef505 100644 --- a/src/aero_kernel/src/arch/x86_64/syscall.rs +++ b/src/aero_kernel/src/arch/x86_64/syscall.rs @@ -7,7 +7,7 @@ use crate::userland::scheduler::{self, ExitStatus}; use crate::utils::sync::IrqGuard; use super::interrupts::InterruptErrorStack; -use super::io; +use super::{asm_macros, io}; use core::mem::offset_of; @@ -16,8 +16,6 @@ const ARCH_SET_FS: usize = 0x1002; const ARCH_GET_FS: usize = 0x1003; const ARCH_GET_GS: usize = 0x1004; -core::arch::global_asm!(include_str!("./registers.S")); - /// 64-bit SYSCALL instruction entry point. /// /// The instruction supports to to 6 arguments in registers. @@ -56,8 +54,8 @@ unsafe extern "C" fn x86_64_syscall_handler() { "push rcx", "push rax", - "push_scratch", - "push_preserved", + asm_macros::push_scratch!(), + asm_macros::push_preserved!(), // push a fake error code to match with the layout of `InterruptErrorStack` "push 0", @@ -71,8 +69,8 @@ unsafe extern "C" fn x86_64_syscall_handler() { // pop the fake error code "add rsp, 8", - "pop_preserved", - "pop_scratch", + asm_macros::pop_preserved!(), + asm_macros::pop_scratch!(), // cook the sysret frame "pop rcx", @@ -123,8 +121,8 @@ unsafe extern "C" fn x86_64_sysenter_handler() { "and dword ptr [rsp], 0x300", "popfq", "push rax", - "push_scratch", - "push_preserved", + asm_macros::push_scratch!(), + asm_macros::push_preserved!(), "push 0", // Store the stack pointer (interrupt frame ptr) in `RBP` for safe keeping, and align the // stack as specified by the SysV calling convention. @@ -136,8 +134,8 @@ unsafe extern "C" fn x86_64_sysenter_handler() { "call {x86_64_do_syscall}", // Reload the stack pointer, skipping the error code. "lea rsp, [rbp + 8]", - "pop_preserved", - "pop_scratch", + asm_macros::pop_preserved!(), + asm_macros::pop_scratch!(), // Pop the `IRET` frame into the registers expected by `SYSEXIT`. "pop rdx", // return `RIP` in `RDX` "add rsp, 8", diff --git a/src/aero_kernel/src/arch/x86_64/task.rs b/src/aero_kernel/src/arch/x86_64/task.rs index 8102cc1f982..94f91bd9ae1 100644 --- a/src/aero_kernel/src/arch/x86_64/task.rs +++ b/src/aero_kernel/src/arch/x86_64/task.rs @@ -49,7 +49,7 @@ use crate::syscall::ExecArgs; use crate::userland::vm::Vm; use crate::utils::StackHelper; -use super::{controlregs, io}; +use super::{asm_macros, controlregs, io}; use crate::mem::AddressSpace; @@ -116,31 +116,6 @@ const USERLAND_STACK_SIZE: u64 = 0x64000; const USERLAND_STACK_TOP: VirtAddr = VirtAddr::new(0x7fffffffe000); const USERLAND_STACK_BOTTOM: VirtAddr = USERLAND_STACK_TOP.const_sub_u64(USERLAND_STACK_SIZE); -core::arch::global_asm!( - " - .macro pop_preserved - pop r15 - pop r14 - pop r13 - pop r12 - pop rbp - pop rbx - .endm - - .macro pop_scratch - pop r11 - pop r10 - pop r9 - pop r8 - pop rsi - pop rdi - pop rdx - pop rcx - pop rax - .endm - " -); - #[naked] unsafe extern "C" fn jump_userland_exec(stack: VirtAddr, rip: VirtAddr, rflags: u64) { asm!( @@ -196,8 +171,8 @@ unsafe extern "C" fn iretq_init() { "cli", // pop the error code "add rsp, 8", - "pop_preserved", - "pop_scratch", + asm_macros::pop_preserved!(), + asm_macros::pop_scratch!(), "iretq", options(noreturn) ) @@ -209,8 +184,8 @@ unsafe extern "C" fn fork_init() { "cli", // pop the error code "add rsp, 8", - "pop_preserved", - "pop_scratch", + asm_macros::pop_preserved!(), + asm_macros::pop_scratch!(), "swapgs", "iretq", options(noreturn) diff --git a/src/aero_kernel/src/cmdline.rs b/src/aero_kernel/src/cmdline.rs index b64e1ad5648..cbcc33ef639 100644 --- a/src/aero_kernel/src/cmdline.rs +++ b/src/aero_kernel/src/cmdline.rs @@ -17,9 +17,10 @@ use core::num::ParseIntError; -use limine::NonNullPtr; use spin::Once; +use limine::file::File; + use crate::rendy; static RAW_CMDLINE_STR: Once<&'static str> = Once::new(); @@ -44,16 +45,14 @@ impl CommandLine { } } -fn resolve_module(modules: &[NonNullPtr], name: &str) -> &'static [u8] { +fn resolve_module(modules: &[&File], name: &str) -> &'static [u8] { modules .iter() .find(|m| { - let n = m.cmdline.to_str().unwrap().to_str().unwrap(); + let n = core::str::from_utf8(m.cmdline()).unwrap(); n == name }) - .map(|m| unsafe { - core::slice::from_raw_parts(m.base.as_ptr().unwrap(), m.length as usize) - }) + .map(|m| unsafe { core::slice::from_raw_parts(m.addr(), m.size() as usize) }) .expect("resolve_module: invalid operand") } @@ -72,7 +71,7 @@ fn parse_number(mut string: &str) -> Result { } } -pub fn parse(cmdline: &'static str, modules: &[NonNullPtr]) -> CommandLine { +pub fn parse(cmdline: &'static str, modules: &[&File]) -> CommandLine { RAW_CMDLINE_STR.call_once(|| cmdline); // Chew up the leading spaces. diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index d2ec2b07b69..c91fa84262a 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -50,7 +50,8 @@ strict_provenance, associated_type_defaults, trait_upcasting, - asm_const + asm_const, + sync_unsafe_cell )] // TODO(andypython): can we remove the dependency of "prelude_import" and "lang_items"? // `lang_items` => is currently used for the personality function (`rust_eh_personality`). diff --git a/src/aero_kernel/src/mem/paging/frame.rs b/src/aero_kernel/src/mem/paging/frame.rs index 8333f2a6a7a..6a310d4e4dc 100644 --- a/src/aero_kernel/src/mem/paging/frame.rs +++ b/src/aero_kernel/src/mem/paging/frame.rs @@ -20,7 +20,8 @@ use core::ptr::NonNull; use core::sync::atomic::{AtomicUsize, Ordering}; use alloc::vec::Vec; -use limine::{MemmapEntry, MemoryMapEntryType, NonNullPtr}; + +use limine::memory_map; use spin::Once; use super::mapper::*; @@ -72,7 +73,7 @@ impl LockedFrameAllocator { } /// Initializes the inner locked global frame allocator. - pub(super) fn init(&self, memory_map: &mut [NonNullPtr]) { + pub(super) fn init(&self, memory_map: &mut limine::response::MemoryMapResponse) { self.0 .call_once(|| Mutex::new(GlobalFrameAllocator::new(memory_map))); } @@ -134,7 +135,7 @@ unsafe impl FrameAllocator for LockedFrameAllocator { } struct RangeMemoryIter<'a> { - iter: core::slice::Iter<'a, NonNullPtr>, + iter: core::slice::Iter<'a, &'a memory_map::Entry>, cursor_base: PhysAddr, cursor_end: PhysAddr, @@ -150,12 +151,12 @@ impl<'a> Iterator for RangeMemoryIter<'a> { // the memory map and set the cursor to the start of it. let next = self.iter.next()?; - if next.typ == MemoryMapEntryType::Usable { + if next.entry_type == memory_map::EntryType::USABLE { break Some(next); } } { self.cursor_base = PhysAddr::new(entry.base).align_up(Size4KiB::SIZE); - self.cursor_end = PhysAddr::new(entry.base + entry.len); + self.cursor_end = PhysAddr::new(entry.base + entry.length); } else { // We reached the end of the memory map. return None; @@ -295,7 +296,9 @@ pub struct GlobalFrameAllocator { } impl GlobalFrameAllocator { - fn new(memory_map: &mut [NonNullPtr]) -> Self { + fn new(memory_map_resp: &mut limine::response::MemoryMapResponse) -> Self { + let memory_map = memory_map_resp.entries_mut(); + // Find a memory map entry that is big enough to fit all of the items in // range memory iter. let requested_size = (core::mem::size_of::() * memory_map.len()) as u64; @@ -305,16 +308,16 @@ impl GlobalFrameAllocator { let entry = &mut memory_map[i]; // Make sure that the memory map entry is marked as usable. - if entry.typ != MemoryMapEntryType::Usable { + if entry.entry_type != memory_map::EntryType::USABLE { continue; } // Found a big enough memory map entry. - if entry.len >= requested_size { + if entry.length >= requested_size { let base = entry.base; entry.base += requested_size; - entry.len -= requested_size; + entry.length -= requested_size; region = Some(PhysAddr::new(base)); @@ -322,7 +325,7 @@ impl GlobalFrameAllocator { } } - let mut iter = memory_map.iter(); + let mut iter = memory_map_resp.entries().iter(); let cursor = iter .next() @@ -341,7 +344,7 @@ impl GlobalFrameAllocator { iter, cursor_base: PhysAddr::new(cursor.base), - cursor_end: PhysAddr::new(cursor.base + cursor.len), + cursor_end: PhysAddr::new(cursor.base + cursor.length), }; // Lets goo! Now lets initialize the bootstrap allocator so we can initialize diff --git a/src/aero_kernel/src/mem/paging/mod.rs b/src/aero_kernel/src/mem/paging/mod.rs index cffac2f2894..f04e7f4021e 100644 --- a/src/aero_kernel/src/mem/paging/mod.rs +++ b/src/aero_kernel/src/mem/paging/mod.rs @@ -27,8 +27,6 @@ pub use self::mapper::*; pub use self::page::*; pub use self::page_table::*; -use limine::{MemmapEntry, NonNullPtr}; - pub use frame::LockedFrameAllocator; use crate::PHYSICAL_MEMORY_OFFSET; @@ -77,12 +75,12 @@ pub const fn level_5_paging_enabled() -> bool { /// Initialize paging. pub fn init( - memory_regions: &mut [NonNullPtr], + mmap_resp: &mut limine::response::MemoryMapResponse, ) -> Result, MapToError> { let active_level_4 = unsafe { active_level_4_table() }; let offset_table = unsafe { OffsetPageTable::new(active_level_4, PHYSICAL_MEMORY_OFFSET) }; - FRAME_ALLOCATOR.init(memory_regions); + FRAME_ALLOCATOR.init(mmap_resp); Ok(offset_table) } diff --git a/src/aero_kernel/src/rendy.rs b/src/aero_kernel/src/rendy.rs index 027e70fa391..32829b49df2 100644 --- a/src/aero_kernel/src/rendy.rs +++ b/src/aero_kernel/src/rendy.rs @@ -23,7 +23,7 @@ use core::{fmt, u8}; use alloc::boxed::Box; -use limine::Framebuffer; +use limine::framebuffer::Framebuffer; use spin::Once; use vte::ansi::{Handler, NamedColor, Timeout}; @@ -1027,28 +1027,33 @@ pub unsafe fn force_unlock() { } } -pub fn init(framebuffer_tag: &Framebuffer, cmdline: &CommandLine) { +pub fn init(fb_info: Framebuffer, cmdline: &CommandLine) { + let stride = fb_info.pitch() as usize; + let height = fb_info.height() as usize; + let bits_per_pixel = fb_info.bpp() as usize; + let byte_len = stride * height * (bits_per_pixel / 8); + let framebuffer_info = RendyInfo { - byte_len: framebuffer_tag.size(), - bits_per_pixel: framebuffer_tag.bpp as usize, - horizontal_resolution: framebuffer_tag.width as usize, - vertical_resolution: framebuffer_tag.height as usize, + byte_len, + bits_per_pixel, + horizontal_resolution: fb_info.width() as usize, + vertical_resolution: height, pixel_format: PixelFormat::BGR, - stride: framebuffer_tag.pitch as usize, + stride, - red_mask_shift: framebuffer_tag.red_mask_shift, - red_mask_size: framebuffer_tag.red_mask_size, + red_mask_shift: fb_info.red_mask_shift(), + red_mask_size: fb_info.red_mask_size(), - green_mask_shift: framebuffer_tag.green_mask_shift, - green_mask_size: framebuffer_tag.green_mask_size, + green_mask_shift: fb_info.green_mask_shift(), + green_mask_size: fb_info.green_mask_size(), - blue_mask_shift: framebuffer_tag.blue_mask_shift, - blue_mask_size: framebuffer_tag.blue_mask_size, + blue_mask_shift: fb_info.blue_mask_shift(), + blue_mask_size: fb_info.blue_mask_size(), }; let framebuffer = unsafe { core::slice::from_raw_parts_mut::( - framebuffer_tag.address.as_ptr().unwrap().cast::(), + fb_info.addr().cast::(), framebuffer_info.byte_len, ) }; diff --git a/src/aero_kernel/src/userland/task/mod.rs b/src/aero_kernel/src/userland/task/mod.rs index 10ddda4fe5c..86d60ba3723 100644 --- a/src/aero_kernel/src/userland/task/mod.rs +++ b/src/aero_kernel/src/userland/task/mod.rs @@ -530,7 +530,7 @@ impl Task { // if executable.absolute_path_str().contains("gcc") // || executable.absolute_path_str().contains("ls") // { - self.enable_systrace(); + // self.enable_systrace(); // } *self.mem_tags.lock() = HashMap::new(); From 2bfe5ad67f183261801c8bbdec18787986f63d37 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 16 Mar 2024 14:12:14 +1100 Subject: [PATCH 035/112] fix(kernel): fix warnings about any intermediate references created Signed-off-by: Anhad Singh --- src/aero_kernel/src/arch/x86_64/cpu_local.rs | 14 ++++------ src/aero_kernel/src/arch/x86_64/gdt.rs | 3 ++- .../src/arch/x86_64/interrupts/idt.rs | 3 ++- src/aero_kernel/src/modules.rs | 27 +++++++++---------- src/aero_kernel/src/utils/mod.rs | 14 ++++++++-- 5 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/aero_kernel/src/arch/x86_64/cpu_local.rs b/src/aero_kernel/src/arch/x86_64/cpu_local.rs index 9e0a911ce0e..245921105a9 100644 --- a/src/aero_kernel/src/arch/x86_64/cpu_local.rs +++ b/src/aero_kernel/src/arch/x86_64/cpu_local.rs @@ -18,16 +18,11 @@ use core::alloc::Layout; use core::ops::{Deref, DerefMut}; +use crate::extern_sym; use crate::mem::paging::VirtAddr; -use crate::utils::LinkerSymbol; use super::io; -extern "C" { - static __cpu_local_start: LinkerSymbol; - static __cpu_local_end: LinkerSymbol; -} - #[repr(C)] pub struct CpuLocal(T); @@ -49,7 +44,7 @@ impl CpuLocal { } let self_addr = VirtAddr::new(self as *const _ as u64); - let section_addr = VirtAddr::new(unsafe { &__cpu_local_start as *const _ as u64 }); + let section_addr = VirtAddr::new(extern_sym!(__cpu_local_start) as u64); let offset = self_addr - section_addr; VirtAddr::new(val) + offset @@ -81,9 +76,10 @@ static SELF_PTR: u64 = 0; static mut CPUID: usize = 0; pub fn init(cpu_id: usize) { + let start = VirtAddr::new(extern_sym!(__cpu_local_start).addr() as u64); + let end = VirtAddr::new(extern_sym!(__cpu_local_end).addr() as u64); + unsafe { - let start = VirtAddr::new(&__cpu_local_start as *const _ as u64); - let end = VirtAddr::new(&__cpu_local_end as *const _ as u64); let size = end - start; let layout = Layout::from_size_align_unchecked(size as _, 64); diff --git a/src/aero_kernel/src/arch/x86_64/gdt.rs b/src/aero_kernel/src/arch/x86_64/gdt.rs index dd3c197f8f8..e8dd2e467f8 100644 --- a/src/aero_kernel/src/arch/x86_64/gdt.rs +++ b/src/aero_kernel/src/arch/x86_64/gdt.rs @@ -26,6 +26,7 @@ use core::alloc::Layout; use core::mem; +use core::ptr::addr_of; use alloc::alloc::alloc_zeroed; @@ -302,7 +303,7 @@ pub fn init_boot() { unsafe { let gdt_descriptor = GdtDescriptor::new( (mem::size_of::<[GdtEntry; BOOT_GDT_ENTRY_COUNT]>() - 1) as u16, - (&BOOT_GDT as *const _) as u64, + addr_of!(BOOT_GDT).addr() as u64, ); load_gdt(&gdt_descriptor); diff --git a/src/aero_kernel/src/arch/x86_64/interrupts/idt.rs b/src/aero_kernel/src/arch/x86_64/interrupts/idt.rs index 3399dac4f5d..457569238fb 100644 --- a/src/aero_kernel/src/arch/x86_64/interrupts/idt.rs +++ b/src/aero_kernel/src/arch/x86_64/interrupts/idt.rs @@ -24,6 +24,7 @@ const IDT_ENTRIES: usize = 256; pub(super) static mut IDT: [IdtEntry; IDT_ENTRIES] = [IdtEntry::NULL; IDT_ENTRIES]; use core::mem::size_of; +use core::ptr::addr_of; use crate::arch::gdt::SegmentSelector; use crate::utils::sync::Mutex; @@ -216,7 +217,7 @@ pub fn init() { unsafe { let idt_descriptor = IdtDescriptor::new( ((IDT.len() * size_of::()) - 1) as u16, - (&IDT as *const _) as u64, + addr_of!(IDT).addr() as u64, ); load_idt(&idt_descriptor); diff --git a/src/aero_kernel/src/modules.rs b/src/aero_kernel/src/modules.rs index 40686669825..8f809a01021 100644 --- a/src/aero_kernel/src/modules.rs +++ b/src/aero_kernel/src/modules.rs @@ -29,20 +29,22 @@ //! aero_kernel::module_exit!(hello_exit); //! ``` -use crate::{drivers, fs}; +use core::mem::size_of; + +use crate::{drivers, extern_sym, fs}; /// Inner helper function to make sure the function provided to the [module_init] macro /// has a valid function signature. This function returns the passed module init function as /// a const void pointer. -#[derive(Debug, PartialEq, PartialOrd, Eq, Ord)] +#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Eq, Ord)] #[repr(C)] pub enum ModuleType { Block = 0, Other = 1, } -#[derive(Debug)] +#[derive(Debug, Clone)] #[repr(C)] pub struct Module { pub init: *const (), @@ -69,20 +71,15 @@ macro_rules! module_init { /// we cannot read the ext2 root filesystem, we link all of the kernel modules into the kernel /// itself (this is temporary and modules will be loaded from the filesystem in the future). pub(crate) fn init() { - extern "C" { - static mut __kernel_modules_start: u8; - static mut __kernel_modules_end: u8; - } + let modules_start = extern_sym!(__kernel_modules_start).cast::(); + let modules_end = extern_sym!(__kernel_modules_end).cast::(); - unsafe { - let size = &__kernel_modules_end as *const u8 as usize - - &__kernel_modules_start as *const u8 as usize; - - let modules = core::slice::from_raw_parts_mut( - &mut __kernel_modules_start as *mut u8 as *mut Module, - size / core::mem::size_of::(), - ); + let size = (modules_end.addr() - modules_start.addr()) / size_of::(); + let modules = unsafe { core::slice::from_raw_parts(modules_start, size) }; + unsafe { + // TODO: refactor this out + let mut modules = modules.to_vec(); modules.sort_by(|e, a| e.ty.cmp(&a.ty)); let mut launched_fs = false; diff --git a/src/aero_kernel/src/utils/mod.rs b/src/aero_kernel/src/utils/mod.rs index d2cabaa058b..9281e7eaceb 100644 --- a/src/aero_kernel/src/utils/mod.rs +++ b/src/aero_kernel/src/utils/mod.rs @@ -223,5 +223,15 @@ impl<'a> StackHelper<'a> { } } -#[repr(transparent)] -pub struct LinkerSymbol(core::cell::UnsafeCell); +#[macro_export] +macro_rules! extern_sym { + ($sym:ident) => {{ + extern "C" { + static $sym: ::core::ffi::c_void; + } + + // SAFETY: The value is not accessed, we only take its address. The `addr_of!()` ensures + // that no intermediate references is created. + unsafe { ::core::ptr::addr_of!($sym) } + }}; +} From 27d18d618750fb0933a9bf721e0ec0ecc12c5e26 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 16 Mar 2024 14:36:12 +1100 Subject: [PATCH 036/112] misc(kernel): cleanup Signed-off-by: Anhad Singh --- .vscode/settings.json | 2 +- src/aero_kernel/src/arch/x86_64/gdt.rs | 2 +- src/aero_kernel/src/arch/x86_64/task.rs | 4 +-- src/aero_kernel/src/arch/x86_64/tls.rs | 2 +- src/aero_kernel/src/main.rs | 2 +- src/aero_kernel/src/mem/paging/frame.rs | 32 ++++++++---------------- src/aero_kernel/src/mem/paging/mapper.rs | 13 ++++------ src/aero_kernel/src/rendy.rs | 4 ++- src/aero_kernel/src/userland/vm.rs | 8 +++--- src/aero_kernel/src/utils/mod.rs | 2 +- 10 files changed, 29 insertions(+), 42 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 8cbe5c341c6..887a54e7cd9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,5 +16,5 @@ "termios.h": "c", "termios-c_iflag.h": "c" }, - // "rust-analyzer.check.command": "clippy", + "rust-analyzer.check.command": "clippy", } \ No newline at end of file diff --git a/src/aero_kernel/src/arch/x86_64/gdt.rs b/src/aero_kernel/src/arch/x86_64/gdt.rs index e8dd2e467f8..e3a1a5968dd 100644 --- a/src/aero_kernel/src/arch/x86_64/gdt.rs +++ b/src/aero_kernel/src/arch/x86_64/gdt.rs @@ -337,7 +337,7 @@ pub fn init() { let gdt_size = gdt_ent_size * GDT_ENTRY_COUNT; let layout = Layout::from_size_align_unchecked(gdt_size, gdt_ent_align); - let ptr = alloc_zeroed(layout) as *mut GdtEntry; + let ptr = alloc_zeroed(layout).cast::(); core::slice::from_raw_parts_mut::(ptr, GDT_ENTRY_COUNT) }; diff --git a/src/aero_kernel/src/arch/x86_64/task.rs b/src/aero_kernel/src/arch/x86_64/task.rs index 94f91bd9ae1..6e269809608 100644 --- a/src/aero_kernel/src/arch/x86_64/task.rs +++ b/src/aero_kernel/src/arch/x86_64/task.rs @@ -661,7 +661,7 @@ fn xsave(fpu: &mut FpuState) { use core::arch::x86_64::_fxsave64; - unsafe { _fxsave64(fpu as *mut FpuState as *mut _) } + unsafe { _fxsave64((fpu as *mut FpuState).cast()) } } fn xrstor(fpu: &FpuState) { @@ -670,7 +670,7 @@ fn xrstor(fpu: &FpuState) { // options(nomem, nostack)); } use core::arch::x86_64::_fxrstor64; - unsafe { _fxrstor64(fpu as *const FpuState as *const _) } + unsafe { _fxrstor64((fpu as *const FpuState).cast()) } } /// Check out the module level documentation for more information. diff --git a/src/aero_kernel/src/arch/x86_64/tls.rs b/src/aero_kernel/src/arch/x86_64/tls.rs index f202b64aa83..d9bf49d81cf 100644 --- a/src/aero_kernel/src/arch/x86_64/tls.rs +++ b/src/aero_kernel/src/arch/x86_64/tls.rs @@ -119,7 +119,7 @@ pub fn init() { .map(|(name, _)| name) .collect::>() }) - .unwrap_or(Vec::new()); + .unwrap_or_default(); CPU_INFO.lock().push(CpuInfo { cpuid: 0, diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index c91fa84262a..54a6d418e72 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -63,7 +63,7 @@ #![no_std] #![no_main] #![reexport_test_harness_main = "test_main"] -// #![warn(clippy::pedantic)] +#![deny(clippy::ptr_as_ptr)] #[macro_use] extern crate aero_proc; diff --git a/src/aero_kernel/src/mem/paging/frame.rs b/src/aero_kernel/src/mem/paging/frame.rs index 6a310d4e4dc..8cf3d583cbf 100644 --- a/src/aero_kernel/src/mem/paging/frame.rs +++ b/src/aero_kernel/src/mem/paging/frame.rs @@ -299,31 +299,19 @@ impl GlobalFrameAllocator { fn new(memory_map_resp: &mut limine::response::MemoryMapResponse) -> Self { let memory_map = memory_map_resp.entries_mut(); - // Find a memory map entry that is big enough to fit all of the items in - // range memory iter. let requested_size = (core::mem::size_of::() * memory_map.len()) as u64; - let mut region = None; - for i in 0..memory_map.len() { - let entry = &mut memory_map[i]; - - // Make sure that the memory map entry is marked as usable. - if entry.entry_type != memory_map::EntryType::USABLE { - continue; - } - - // Found a big enough memory map entry. - if entry.length >= requested_size { - let base = entry.base; - - entry.base += requested_size; - entry.length -= requested_size; + let entry = memory_map + .iter_mut() + .find(|entry| { + entry.entry_type == memory_map::EntryType::USABLE && entry.length >= requested_size + }) + .expect("OOM"); - region = Some(PhysAddr::new(base)); + let region = PhysAddr::new(entry.base); - break; - } - } + entry.base += requested_size; + entry.length -= requested_size; let mut iter = memory_map_resp.entries().iter(); @@ -332,7 +320,7 @@ impl GlobalFrameAllocator { .expect("stivale2: unexpected end of the memory map"); let ranges = unsafe { - let virt_addr = region.expect("stivale2: out of memory").as_hhdm_virt(); + let virt_addr = region.as_hhdm_virt(); core::slice::from_raw_parts_mut::( virt_addr.as_mut_ptr(), diff --git a/src/aero_kernel/src/mem/paging/mapper.rs b/src/aero_kernel/src/mem/paging/mapper.rs index 2efa178dd3d..2f3caaaba01 100644 --- a/src/aero_kernel/src/mem/paging/mapper.rs +++ b/src/aero_kernel/src/mem/paging/mapper.rs @@ -676,17 +676,14 @@ impl<'a, P: PageTableFrameMapping> Mapper for MappedPageTable<'a, P> { page: Page, flags: PageTableFlags, ) -> Result, FlagUpdateError> { - let p4; - - if self.level_5_paging_enabled { + let p4 = if self.level_5_paging_enabled { let p5 = &mut self.page_table; - p4 = self - .page_table_walker - .next_table_mut(&mut p5[page.p5_index()])?; + self.page_table_walker + .next_table_mut(&mut p5[page.p5_index()])? } else { - p4 = &mut self.page_table; - } + &mut self.page_table + }; let p3 = self .page_table_walker diff --git a/src/aero_kernel/src/rendy.rs b/src/aero_kernel/src/rendy.rs index 32829b49df2..659dec79dda 100644 --- a/src/aero_kernel/src/rendy.rs +++ b/src/aero_kernel/src/rendy.rs @@ -371,7 +371,9 @@ impl<'a> Inner<'a> { for x in xstart..xend { let img_pixel = unsafe { - (image.image.as_ptr()).add(fixedp6_to_int(img_x) * col_size + off) as *const u32 + (image.image.as_ptr()) + .add(fixedp6_to_int(img_x) * col_size + off) + .cast::() }; let i = blender(x, y, unsafe { *img_pixel }); diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs index d3936622d24..32d4e8ca459 100644 --- a/src/aero_kernel/src/userland/vm.rs +++ b/src/aero_kernel/src/userland/vm.rs @@ -65,7 +65,7 @@ fn parse_elf_header<'header>(file: DirCacheItem) -> Result, ElfL .read_at(0, pt1_hdr_slice) .map_err(ElfLoadError::IOError)?; - let pt1_header: &'header _ = unsafe { &*(pt1_hdr_slice.as_ptr() as *const HeaderPt1) }; + let pt1_header: &'header _ = unsafe { &*pt1_hdr_slice.as_ptr().cast::() }; // 2. Ensure that the header has the correct magic number: if pt1_header.magic != ELF_HEADER_MAGIC { @@ -82,7 +82,7 @@ fn parse_elf_header<'header>(file: DirCacheItem) -> Result, ElfL .map_err(ElfLoadError::IOError)?; let pt2_header_ptr = pt2_hdr_slice.as_ptr(); - let pt2_header: &'header _ = unsafe { &*(pt2_header_ptr as *const HeaderPt2_) }; + let pt2_header: &'header _ = unsafe { &*pt2_header_ptr.cast::>() }; Ok(HeaderPt2::Header64(pt2_header)) } @@ -130,13 +130,13 @@ fn parse_program_header<'pheader>( match header.pt1.class() { // 3. Cast and return the 64-bit program header: Class::SixtyFour => { - let phdr: &'pheader _ = unsafe { &*(phdr_ptr as *const ProgramHeader64) }; + let phdr: &'pheader _ = unsafe { &*phdr_ptr.cast::() }; Ok(ProgramHeader::Ph64(phdr)) } // 3. Cast and return the 32-bit program header: Class::ThirtyTwo => { - let phdr: &'pheader _ = unsafe { &*(phdr_ptr as *const ProgramHeader32) }; + let phdr: &'pheader _ = unsafe { &*phdr_ptr.cast::() }; Ok(ProgramHeader::Ph32(phdr)) } diff --git a/src/aero_kernel/src/utils/mod.rs b/src/aero_kernel/src/utils/mod.rs index 9281e7eaceb..7d143b05b7d 100644 --- a/src/aero_kernel/src/utils/mod.rs +++ b/src/aero_kernel/src/utils/mod.rs @@ -132,7 +132,7 @@ impl PerCpu { let cpu_count = get_cpu_count(); let size = mem::size_of::() * cpu_count; - let raw = unsafe { alloc_zeroed(Layout::from_size_align_unchecked(size, 8)) as *mut T }; + let raw = unsafe { alloc_zeroed(Layout::from_size_align_unchecked(size, 8)).cast::() }; unsafe { for i in 0..cpu_count { From 2b3de08c7cd9843531dfe61fb883ca52854be908 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 16 Mar 2024 17:16:53 +1100 Subject: [PATCH 037/112] misc(kernel): bump `bitflags` to 2.4.2 Signed-off-by: Anhad Singh --- src/Cargo.lock | 2 +- src/aero_kernel/Cargo.toml | 2 +- .../src/arch/x86_64/controlregs.rs | 1 + src/aero_kernel/src/arch/x86_64/gdt.rs | 139 ++++++++++++------ .../src/arch/x86_64/interrupts/idt.rs | 109 ++++++++------ src/aero_kernel/src/arch/x86_64/syscall.rs | 8 +- src/aero_kernel/src/drivers/block/ahci.rs | 16 +- .../src/drivers/block/ide/channel.rs | 2 +- src/aero_kernel/src/drivers/block/nvme/mod.rs | 1 + src/aero_kernel/src/drivers/e1000.rs | 14 +- src/aero_kernel/src/drivers/mouse.rs | 2 +- src/aero_kernel/src/drivers/uart_16550.rs | 1 + src/aero_kernel/src/mem/paging/mod.rs | 1 + src/aero_kernel/src/mem/paging/page_table.rs | 1 + 14 files changed, 192 insertions(+), 107 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index 7bb3e2773e4..7245802877d 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -9,7 +9,7 @@ dependencies = [ "aero_proc", "aero_syscall", "bit_field", - "bitflags 1.3.2", + "bitflags 2.4.2", "byte_endian", "bytemuck", "cpio_reader", diff --git a/src/aero_kernel/Cargo.toml b/src/aero_kernel/Cargo.toml index bc94f6272ef..9f3499b9593 100644 --- a/src/aero_kernel/Cargo.toml +++ b/src/aero_kernel/Cargo.toml @@ -26,7 +26,7 @@ spin = { version = "0.9.8", default-features = false, features = [ "rwlock", "once", ] } -bitflags = "1.2.1" +bitflags = "2.4.2" bit_field = "0.10.2" log = "0.4.20" xmas-elf = "0.9.1" diff --git a/src/aero_kernel/src/arch/x86_64/controlregs.rs b/src/aero_kernel/src/arch/x86_64/controlregs.rs index 93516f60a22..13edf5a06ed 100644 --- a/src/aero_kernel/src/arch/x86_64/controlregs.rs +++ b/src/aero_kernel/src/arch/x86_64/controlregs.rs @@ -184,6 +184,7 @@ bitflags::bitflags! { } bitflags::bitflags! { + #[derive(Debug)] pub struct MxCsr: u32 { const INVALID_OPERATION = 1 << 0; const DENORMAL = 1 << 1; diff --git a/src/aero_kernel/src/arch/x86_64/gdt.rs b/src/aero_kernel/src/arch/x86_64/gdt.rs index e3a1a5968dd..35e10f37e9e 100644 --- a/src/aero_kernel/src/arch/x86_64/gdt.rs +++ b/src/aero_kernel/src/arch/x86_64/gdt.rs @@ -30,32 +30,24 @@ use core::ptr::addr_of; use alloc::alloc::alloc_zeroed; -bitflags::bitflags! { - /// Specifies which element to load into a segment from - /// descriptor tables (i.e., is a index to LDT or GDT table - /// with some additional flags). - pub struct SegmentSelector: u16 { - const RPL_0 = 0b00; - const RPL_1 = 0b01; - const RPL_2 = 0b10; - const RPL_3 = 0b11; - const TI_GDT = 0 << 2; - const TI_LDT = 1 << 2; - } -} - bitflags::bitflags! { struct GdtEntryFlags: u8 { - const NULL = 0; const PROTECTED_MODE = 1 << 6; const LONG_MODE = 1 << 5; } } -#[derive(Debug, Clone, Copy, PartialEq)] -pub enum Ring { - Ring0 = 0b00, - Ring3 = 0b11, +#[derive(Debug, Copy, Clone, PartialEq)] +#[repr(u8)] +pub enum PrivilegeLevel { + Ring0 = 0, + Ring3 = 3, +} + +impl PrivilegeLevel { + pub fn is_user(&self) -> bool { + matches!(self, Self::Ring3) + } } const BOOT_GDT_ENTRY_COUNT: usize = 4; @@ -155,7 +147,7 @@ static GDT: [GdtEntry; GDT_ENTRY_COUNT] = [ // GDT TSS descriptor. GdtEntry::new( GdtAccessFlags::PRESENT | GdtAccessFlags::RING_3 | GdtAccessFlags::TSS_AVAIL, - GdtEntryFlags::NULL, + GdtEntryFlags::empty(), ), // GDT null descriptor as the TSS should be 16 bytes long // and twice the normal size. @@ -175,10 +167,10 @@ impl GdtAccessFlags { const TSS_AVAIL: u8 = 9; } -pub struct GdtEntryType; +pub struct GdtEntryIndex; #[rustfmt::skip] -impl GdtEntryType { +impl GdtEntryIndex { pub const KERNEL_CODE: u16 = 1; pub const KERNEL_DATA: u16 = 2; pub const KERNEL_TLS: u16 = 3; @@ -188,10 +180,32 @@ impl GdtEntryType { pub const TSS_HI: u16 = 9; } +#[derive(Debug, Copy, Clone)] +#[repr(transparent)] +pub struct SegmentSelector(u16); + impl SegmentSelector { - const fn new(index: u16, rpl: Ring) -> Self { - Self { - bits: index << 3 | (rpl as u16), + pub const fn empty() -> Self { + Self(0) + } + + pub const fn new(index: u16, privilege_level: PrivilegeLevel) -> Self { + Self(index << 3 | (privilege_level as u16)) + } + + pub const fn bits(&self) -> u16 { + self.0 + } + + pub const fn from_bits(value: u16) -> Self { + Self(value) + } + + pub const fn privilege_level(&self) -> PrivilegeLevel { + match self.bits() & 0b11 { + 0 => PrivilegeLevel::Ring0, + 3 => PrivilegeLevel::Ring3, + _ => unreachable!(), } } } @@ -230,7 +244,7 @@ pub(super) struct GdtEntry { } impl GdtEntry { - const NULL: Self = Self::new(GdtAccessFlags::NULL, GdtEntryFlags::NULL); + const NULL: Self = Self::new(GdtAccessFlags::NULL, GdtEntryFlags::empty()); const fn new(access_flags: u8, entry_flags: GdtEntryFlags) -> Self { Self { @@ -311,19 +325,45 @@ pub fn init_boot() { // Load the GDT segments. unsafe { - load_cs(SegmentSelector::new(GdtEntryType::KERNEL_CODE, Ring::Ring0)); - load_ds(SegmentSelector::new(GdtEntryType::KERNEL_DATA, Ring::Ring0)); - load_es(SegmentSelector::new(GdtEntryType::KERNEL_DATA, Ring::Ring0)); - load_fs(SegmentSelector::new(GdtEntryType::KERNEL_DATA, Ring::Ring0)); - load_gs(SegmentSelector::new(GdtEntryType::KERNEL_TLS, Ring::Ring0)); - load_ss(SegmentSelector::new(GdtEntryType::KERNEL_DATA, Ring::Ring0)); + load_cs(SegmentSelector::new( + GdtEntryIndex::KERNEL_CODE, + PrivilegeLevel::Ring0, + )); + + load_ds(SegmentSelector::new( + GdtEntryIndex::KERNEL_DATA, + PrivilegeLevel::Ring0, + )); + + load_es(SegmentSelector::new( + GdtEntryIndex::KERNEL_DATA, + PrivilegeLevel::Ring0, + )); + + load_fs(SegmentSelector::new( + GdtEntryIndex::KERNEL_DATA, + PrivilegeLevel::Ring0, + )); + + load_gs(SegmentSelector::new( + GdtEntryIndex::KERNEL_TLS, + PrivilegeLevel::Ring0, + )); + + load_ss(SegmentSelector::new( + GdtEntryIndex::KERNEL_DATA, + PrivilegeLevel::Ring0, + )); } } static STK: [u8; 4096 * 16] = [0; 4096 * 16]; -pub const USER_SS: SegmentSelector = SegmentSelector::new(GdtEntryType::USER_DATA, Ring::Ring3); -pub const USER_CS: SegmentSelector = SegmentSelector::new(GdtEntryType::USER_CODE, Ring::Ring3); +pub const USER_SS: SegmentSelector = + SegmentSelector::new(GdtEntryIndex::USER_DATA, PrivilegeLevel::Ring3); + +pub const USER_CS: SegmentSelector = + SegmentSelector::new(GdtEntryIndex::USER_CODE, PrivilegeLevel::Ring3); /// Initialize the *actual* GDT stored in TLS. /// @@ -347,9 +387,9 @@ pub fn init() { unsafe { let tss_ptr = TSS.addr().as_mut_ptr::(); - gdt[GdtEntryType::TSS as usize].set_offset(tss_ptr as u32); - gdt[GdtEntryType::TSS as usize].set_limit(mem::size_of::() as u32); - gdt[GdtEntryType::TSS_HI as usize].set_raw((tss_ptr as u64) >> 32); + gdt[GdtEntryIndex::TSS as usize].set_offset(tss_ptr as u32); + gdt[GdtEntryIndex::TSS as usize].set_limit(mem::size_of::() as u32); + gdt[GdtEntryIndex::TSS_HI as usize].set_raw((tss_ptr as u64) >> 32); TSS.rsp[0] = STK.as_ptr().offset(4096 * 16) as u64; @@ -361,13 +401,28 @@ pub fn init() { load_gdt(&gdt_descriptor); // Reload the GDT segments. - load_cs(SegmentSelector::new(GdtEntryType::KERNEL_CODE, Ring::Ring0)); - load_ds(SegmentSelector::new(GdtEntryType::KERNEL_DATA, Ring::Ring0)); - load_es(SegmentSelector::new(GdtEntryType::KERNEL_DATA, Ring::Ring0)); - load_ss(SegmentSelector::new(GdtEntryType::KERNEL_DATA, Ring::Ring0)); + load_cs(SegmentSelector::new( + GdtEntryIndex::KERNEL_CODE, + PrivilegeLevel::Ring0, + )); + load_ds(SegmentSelector::new( + GdtEntryIndex::KERNEL_DATA, + PrivilegeLevel::Ring0, + )); + load_es(SegmentSelector::new( + GdtEntryIndex::KERNEL_DATA, + PrivilegeLevel::Ring0, + )); + load_ss(SegmentSelector::new( + GdtEntryIndex::KERNEL_DATA, + PrivilegeLevel::Ring0, + )); // Load the Task State Segment. - load_tss(SegmentSelector::new(GdtEntryType::TSS, Ring::Ring0)); + load_tss(SegmentSelector::new( + GdtEntryIndex::TSS, + PrivilegeLevel::Ring0, + )); } // // Now we update the per-cpu storage to store a reference diff --git a/src/aero_kernel/src/arch/x86_64/interrupts/idt.rs b/src/aero_kernel/src/arch/x86_64/interrupts/idt.rs index 457569238fb..57319b4a1d7 100644 --- a/src/aero_kernel/src/arch/x86_64/interrupts/idt.rs +++ b/src/aero_kernel/src/arch/x86_64/interrupts/idt.rs @@ -21,26 +21,15 @@ const IDT_ENTRIES: usize = 256; -pub(super) static mut IDT: [IdtEntry; IDT_ENTRIES] = [IdtEntry::NULL; IDT_ENTRIES]; +pub(super) static mut IDT: [IdtEntry; IDT_ENTRIES] = [IdtEntry::EMPTY; IDT_ENTRIES]; use core::mem::size_of; use core::ptr::addr_of; -use crate::arch::gdt::SegmentSelector; -use crate::utils::sync::Mutex; +use bit_field::BitField; -bitflags::bitflags! { - pub struct IDTFlags: u8 { - const PRESENT = 1 << 7; - const RING_0 = 0 << 5; - const RING_1 = 1 << 5; - const RING_2 = 2 << 5; - const RING_3 = 3 << 5; - const SS = 1 << 4; - const INTERRUPT = 0xE; - const TRAP = 0xF; - } -} +use crate::arch::gdt::{GdtEntryIndex, PrivilegeLevel, SegmentSelector}; +use crate::utils::sync::Mutex; #[repr(C, packed)] struct IdtDescriptor { @@ -56,47 +45,72 @@ impl IdtDescriptor { } } +#[derive(Debug, Copy, Clone)] +#[repr(C)] +struct EntryOptions { + cs: SegmentSelector, + bits: u16, +} + +impl EntryOptions { + #[inline] + const fn default() -> Self { + Self { + cs: SegmentSelector::empty(), + // bits 11:8 specify the gate-descriptor type, default to 64-bit interrupt gate (0xe). + bits: 0b1110_0000_0000, + } + } + + #[inline] + fn set_privilege_level(&mut self, dpl: PrivilegeLevel) { + self.bits.set_bits(13..15, dpl as u16); + } + + #[inline] + fn set_code_segment(&mut self, cs: SegmentSelector) { + self.cs = cs; + } + + #[inline] + fn set_present(&mut self, present: bool) { + self.bits.set_bit(15, present); + } +} + #[derive(Copy, Clone)] -#[repr(C, packed)] +#[repr(C)] pub(super) struct IdtEntry { - offset_low: u16, - selector: u16, - ist: u8, - type_attr: u8, - offset_middle: u16, - offset_hi: u32, + ptr_low: u16, + options: EntryOptions, + ptr_middle: u16, + ptr_high: u32, ignore: u32, } impl IdtEntry { - /// IDT entry with all values defaulted to 0, ie `null`. - const NULL: Self = Self { - offset_low: 0x00, - selector: 0x00, - ist: 0x00, - type_attr: 0x00, - offset_middle: 0x00, - offset_hi: 0x00, - ignore: 0x00, + const EMPTY: Self = Self { + ptr_low: 0, + options: EntryOptions::default(), + ptr_middle: 0, + ptr_high: 0, + ignore: 0, }; - /// Set the IDT entry flags. - fn set_flags(&mut self, flags: IDTFlags) { - self.type_attr = flags.bits; - } + pub(crate) fn set_function(&mut self, ptr: *const u8) { + self.options.set_privilege_level(PrivilegeLevel::Ring0); + self.options.set_code_segment(SegmentSelector::new( + GdtEntryIndex::KERNEL_CODE, + PrivilegeLevel::Ring0, + )); - /// Set the IDT entry offset. - fn set_offset(&mut self, selector: u16, base: usize) { - self.selector = selector; - self.offset_low = base as u16; - self.offset_middle = (base >> 16) as u16; - self.offset_hi = (base >> 32) as u32; - } + let addr = ptr.addr(); + + self.ptr_low = addr as u16; + self.ptr_middle = (addr >> 16) as u16; + self.ptr_high = (addr >> 32) as u32; - /// Set the handler function of the IDT entry. - pub(crate) fn set_function(&mut self, handler: *const u8) { - self.set_flags(IDTFlags::PRESENT | IDTFlags::RING_0 | IDTFlags::INTERRUPT); - self.set_offset(8, handler as usize); + self.options.set_present(true); } } @@ -137,7 +151,8 @@ pub struct IretRegisters { impl IretRegisters { pub fn is_user(&self) -> bool { - SegmentSelector::from_bits_truncate(self.cs as u16).contains(SegmentSelector::RPL_3) + let selector = SegmentSelector::from_bits(self.cs as u16); + selector.privilege_level().is_user() } } diff --git a/src/aero_kernel/src/arch/x86_64/syscall.rs b/src/aero_kernel/src/arch/x86_64/syscall.rs index 433ce0ef505..e8ed006ac7c 100644 --- a/src/aero_kernel/src/arch/x86_64/syscall.rs +++ b/src/aero_kernel/src/arch/x86_64/syscall.rs @@ -1,7 +1,7 @@ use aero_syscall::SyscallError; use raw_cpuid::CpuId; -use crate::arch::gdt::{GdtEntryType, Tss, USER_CS, USER_SS}; +use crate::arch::gdt::{GdtEntryIndex, Tss, USER_CS, USER_SS}; use crate::mem::paging::VirtAddr; use crate::userland::scheduler::{self, ExitStatus}; use crate::utils::sync::IrqGuard; @@ -267,8 +267,8 @@ pub(super) fn init() { unsafe { // Enable support for `syscall` and `sysret` instructions if the current // CPU supports them and the target pointer width is 64. - let syscall_base = GdtEntryType::KERNEL_CODE << 3; - let sysret_base = (GdtEntryType::KERNEL_TLS << 3) | 3; + let syscall_base = GdtEntryIndex::KERNEL_CODE << 3; + let sysret_base = (GdtEntryIndex::KERNEL_TLS << 3) | 3; let star_hi = syscall_base as u32 | ((sysret_base as u32) << 16); @@ -298,7 +298,7 @@ pub(super) fn init() { unsafe { io::wrmsr( io::IA32_SYSENTER_CS, - (GdtEntryType::KERNEL_CODE << 3) as u64, + (GdtEntryIndex::KERNEL_CODE << 3) as u64, ); io::wrmsr(io::IA32_SYSENTER_EIP, x86_64_sysenter_handler as u64); } diff --git a/src/aero_kernel/src/drivers/block/ahci.rs b/src/aero_kernel/src/drivers/block/ahci.rs index dab2c669946..02b05f04345 100644 --- a/src/aero_kernel/src/drivers/block/ahci.rs +++ b/src/aero_kernel/src/drivers/block/ahci.rs @@ -91,6 +91,7 @@ bitflags::bitflags! { } bitflags::bitflags! { + #[derive(Debug, Copy, Clone)] struct HbaHostCont: u32 { const HR = 1 << 0; // HBA Reset const IE = 1 << 1; // Interrupt Enable @@ -100,6 +101,7 @@ bitflags::bitflags! { } bitflags::bitflags! { + #[derive(Debug, Copy, Clone)] struct HbaPortIS: u32 { const DHRS = 1 << 0; // Device to Host Register FIS Interrupt const PSS = 1 << 1; // PIO Setup FIS Interrupt @@ -122,6 +124,7 @@ bitflags::bitflags! { } bitflags::bitflags! { + #[derive(Debug, Copy, Clone)] struct HbaPortIE: u32 { const DHRE = 1 << 0; // Device to Host Register FIS Interrupt const PSE = 1 << 1; // PIO Setup FIS Interrupt @@ -144,6 +147,7 @@ bitflags::bitflags! { } bitflags::bitflags! { + #[derive(Debug, Copy, Clone)] struct HbaPortCmd: u32 { const ST = 1 << 0; // Start const SUD = 1 << 1; // Spin-Up Device @@ -168,8 +172,12 @@ bitflags::bitflags! { } } +#[derive(Debug, Copy, Clone)] +#[repr(transparent)] +struct HbaCmdHeaderFlags(u16); + bitflags::bitflags! { - struct HbaCmdHeaderFlags: u16 { + impl HbaCmdHeaderFlags: u16 { const A = 1 << 5; // ATAPI const W = 1 << 6; // Write const P = 1 << 7; // Prefetchable @@ -180,11 +188,11 @@ bitflags::bitflags! { } impl HbaCmdHeaderFlags { - /// Sets the length of the command FIS. The HBA uses this field to know the - /// length of the FIS it shall send to the device. + /// Sets the length of the command FIS. The HBA uses this field to know the length of the FIS it + /// shall send to the device. #[inline] fn set_command_fis_size(&mut self, size: usize) { - self.bits.set_bits(0..=4, size as _); + self.0.set_bits(0..=4, size as _); } } diff --git a/src/aero_kernel/src/drivers/block/ide/channel.rs b/src/aero_kernel/src/drivers/block/ide/channel.rs index a64340807c3..420a2c45a8a 100644 --- a/src/aero_kernel/src/drivers/block/ide/channel.rs +++ b/src/aero_kernel/src/drivers/block/ide/channel.rs @@ -126,7 +126,7 @@ impl IdeChannelData { let status = self.base.status(); - if status == BaseStatusReg::empty() { + if status.is_empty() { return false; } diff --git a/src/aero_kernel/src/drivers/block/nvme/mod.rs b/src/aero_kernel/src/drivers/block/nvme/mod.rs index e60e438b8b1..01959e339d7 100644 --- a/src/aero_kernel/src/drivers/block/nvme/mod.rs +++ b/src/aero_kernel/src/drivers/block/nvme/mod.rs @@ -63,6 +63,7 @@ impl Version { } bitflags::bitflags! { + #[derive(Debug)] struct CommandSetsSupported: u8 { /// Controller supports the NVM command set. const NVM = 1 << 0; diff --git a/src/aero_kernel/src/drivers/e1000.rs b/src/aero_kernel/src/drivers/e1000.rs index 7fc30e2cc6d..fd9b6ff80be 100644 --- a/src/aero_kernel/src/drivers/e1000.rs +++ b/src/aero_kernel/src/drivers/e1000.rs @@ -123,8 +123,10 @@ bitflags::bitflags! { } } +struct TCtl(u32); + bitflags::bitflags! { - struct TCtl: u32 { + impl TCtl: u32 { const EN = 1 << 1; // Transmit Enable const PSP = 1 << 3; // Pad Short Packets const SWXOFF = 1 << 22; // Software XOFF Transmission @@ -136,13 +138,13 @@ impl TCtl { /// Sets the number of attempts at retransmission prior to giving /// up on the packet (not including the first transmission attempt). fn set_collision_threshold(&mut self, value: u8) { - self.bits |= (value as u32) << 4; + self.0 |= (value as u32) << 4; } /// Sets the minimum number of byte times which must elapse for /// proper CSMA/CD operation. fn set_collision_distance(&mut self, value: u8) { - self.bits |= (value as u32) << 12; + self.0 |= (value as u32) << 12; } } @@ -158,7 +160,7 @@ bitflags::bitflags! { const RDMTS_HALF = 0 << 8; // Free Buffer Threshold is 1/2 of RDLEN const RDMTS_QUARTER = 1 << 8; // Free Buffer Threshold is 1/4 of RDLEN const RDMTS_EIGHTH = 2 << 8; // Free Buffer Threshold is 1/8 of RDLEN - const MO_36 = 0 << 12; // Multicast Offset - bits 47:36 + // const MO_36 = 0 << 12; // Multicast Offset - bits 47:36 const MO_35 = 1 << 12; // Multicast Offset - bits 46:35 const MO_34 = 2 << 12; // Multicast Offset - bits 45:34 const MO_32 = 3 << 12; // Multicast Offset - bits 43:32 @@ -174,7 +176,7 @@ bitflags::bitflags! { const BSIZE_256 = 3 << 16; const BSIZE_512 = 2 << 16; const BSIZE_1024 = 1 << 16; - const BSIZE_2048 = 0 << 16; + // const BSIZE_2048 = 0 << 16; const BSIZE_4096 = (3 << 16) | (1 << 25); const BSIZE_8192 = (2 << 16) | (1 << 25); const BSIZE_16384 = (1 << 16) | (1 << 25); @@ -466,7 +468,7 @@ impl E1000 { self.write(Register::TxDescHead, 0); self.write(Register::TxDescTail, 0); - let mut flags = TCtl { bits: 1 << 28 } | TCtl::EN | TCtl::PSP | TCtl::RTLC; + let mut flags = TCtl(1 << 28) | TCtl::EN | TCtl::PSP | TCtl::RTLC; flags.set_collision_distance(64); flags.set_collision_threshold(15); diff --git a/src/aero_kernel/src/drivers/mouse.rs b/src/aero_kernel/src/drivers/mouse.rs index 17c47f4f19d..bde3783c788 100644 --- a/src/aero_kernel/src/drivers/mouse.rs +++ b/src/aero_kernel/src/drivers/mouse.rs @@ -27,7 +27,7 @@ use crate::utils::sync::{Mutex, WaitQueue}; bitflags::bitflags! { /// Represents the flags currently set for the mouse. - #[derive(Default)] + #[derive(Default, Debug, Copy, Clone)] pub struct MouseFlags: u8 { const LEFT_BUTTON = 0b0000_0001; const RIGHT_BUTTON = 0b0000_0010; diff --git a/src/aero_kernel/src/drivers/uart_16550.rs b/src/aero_kernel/src/drivers/uart_16550.rs index bcbed46d368..d644a7a1aa6 100644 --- a/src/aero_kernel/src/drivers/uart_16550.rs +++ b/src/aero_kernel/src/drivers/uart_16550.rs @@ -35,6 +35,7 @@ bitflags::bitflags! { } bitflags::bitflags! { + #[derive(Debug, Copy, Clone)] pub struct LineStatus: u8 { const INPUT_FULL = 1; const OUTPUT_EMPTY = 1 << 5; diff --git a/src/aero_kernel/src/mem/paging/mod.rs b/src/aero_kernel/src/mem/paging/mod.rs index f04e7f4021e..7ed5a571793 100644 --- a/src/aero_kernel/src/mem/paging/mod.rs +++ b/src/aero_kernel/src/mem/paging/mod.rs @@ -35,6 +35,7 @@ pub static FRAME_ALLOCATOR: LockedFrameAllocator = LockedFrameAllocator::new_uni bitflags::bitflags! { /// Describes an page fault error code. + #[derive(Debug, Copy, Clone)] #[repr(transparent)] pub struct PageFaultErrorCode: u64 { /// If this flag is set, the page fault was caused by a page-protection violation, diff --git a/src/aero_kernel/src/mem/paging/page_table.rs b/src/aero_kernel/src/mem/paging/page_table.rs index 5698a7c6d7a..90a3af6de88 100644 --- a/src/aero_kernel/src/mem/paging/page_table.rs +++ b/src/aero_kernel/src/mem/paging/page_table.rs @@ -182,6 +182,7 @@ impl fmt::Debug for PageTableEntry { bitflags! { /// Possible flags for a page table entry. + #[derive(Debug, Copy, Clone)] pub struct PageTableFlags: u64 { /// Specifies whether the mapped frame or page table is loaded in memory. const PRESENT = 1; From 028732cb2c8586e48bf378520b3ae82d98fd18e2 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 16 Mar 2024 19:36:00 +1100 Subject: [PATCH 038/112] misc(kernel): bump log Signed-off-by: Anhad Singh --- improving-build-times.txt | 5 ++++ src/Cargo.lock | 61 ++++++++++++++++---------------------- src/aero_kernel/Cargo.toml | 2 +- 3 files changed, 32 insertions(+), 36 deletions(-) diff --git a/improving-build-times.txt b/improving-build-times.txt index 856726f3ede..6b611793f40 100644 --- a/improving-build-times.txt +++ b/improving-build-times.txt @@ -1,2 +1,7 @@ total_build: 28.36s rebuild: 8.27s + +16/3/2024 +--------- +total_build: 27.29s +rebuild: 9.50s diff --git a/src/Cargo.lock b/src/Cargo.lock index 7245802877d..4c373e1600e 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -57,9 +57,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.7" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", "once_cell", @@ -116,12 +116,9 @@ checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" [[package]] name = "cc" -version = "1.0.83" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" [[package]] name = "cfg-if" @@ -190,9 +187,9 @@ checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991" [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "hashbrown" @@ -237,12 +234,6 @@ dependencies = [ "spin 0.5.2", ] -[[package]] -name = "libc" -version = "0.2.152" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" - [[package]] name = "limine" version = "0.2.0" @@ -254,9 +245,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "lru" @@ -298,9 +289,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] @@ -337,9 +328,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" dependencies = [ "unicode-ident", ] @@ -364,9 +355,9 @@ dependencies = [ [[package]] name = "rayon" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" +checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" dependencies = [ "either", "rayon-core", @@ -390,35 +381,35 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "ryu" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" +checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" [[package]] name = "serde" -version = "1.0.195" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63261df402c67811e9ac6def069e4786148c4563f4b50fd4bf30aa370d626b02" +checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.195" +version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46fe8f8603d81ba86327b23a2e9cdf49e1255fb94a4c5f297f6ee0547178ea2c" +checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", @@ -456,9 +447,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.48" +version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", @@ -543,5 +534,5 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.48", + "syn 2.0.52", ] diff --git a/src/aero_kernel/Cargo.toml b/src/aero_kernel/Cargo.toml index 9f3499b9593..720e47c8360 100644 --- a/src/aero_kernel/Cargo.toml +++ b/src/aero_kernel/Cargo.toml @@ -28,7 +28,7 @@ spin = { version = "0.9.8", default-features = false, features = [ ] } bitflags = "2.4.2" bit_field = "0.10.2" -log = "0.4.20" +log = "0.4.21" xmas-elf = "0.9.1" hashbrown = "0.14.3" rustc-demangle = "0.1.23" From 0ca27da527fdd26ceeed7b9c8e079fce1f1e328f Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 28 Mar 2024 17:24:50 +1100 Subject: [PATCH 039/112] fix(host-rust): make it build Signed-off-by: Anhad Singh --- build-support/rust/host-config.toml | 2 ++ host-recipes/rust | 6 ++++-- source-recipes/rust-libc | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 build-support/rust/host-config.toml diff --git a/build-support/rust/host-config.toml b/build-support/rust/host-config.toml new file mode 100644 index 00000000000..2ab356d1e3e --- /dev/null +++ b/build-support/rust/host-config.toml @@ -0,0 +1,2 @@ +[patch.crates-io] +libc = { path = "/base_dir/sources/rust-libc" } diff --git a/host-recipes/rust b/host-recipes/rust index fcd627d46e4..f81ef8402f5 100644 --- a/host-recipes/rust +++ b/host-recipes/rust @@ -7,10 +7,12 @@ imagedeps="python git wget gcc" allow_network="yes" build() { - # Rust memes. + echo "Patching out rust memes..." cp -rp "${source_dir}/." ./ - CARGO_HOME=/tmp/cargo ./x.py build --stage 2 -j${parallelism} + mkdir /tmp/cargo + cp ${base_dir}/build-support/rust/host-config.toml /tmp/cargo/config.toml + CARGO_HOME=/tmp/cargo ./x.py build --stage 2 -j${parallelism} --verbose } package() { diff --git a/source-recipes/rust-libc b/source-recipes/rust-libc index ce25dcda481..f07f1d4cdef 100644 --- a/source-recipes/rust-libc +++ b/source-recipes/rust-libc @@ -1,4 +1,4 @@ name=rust-libc -version=fe4e9cda46b0be8421b0f56df0b63b8c4dcaf5e6 +version=cf112e9aab32267f6f92c519cb3ebe59f754059d tarball_url="https://github.com/Andy-Python-Programmer/libc/archive/${version}.tar.gz" -tarball_blake2b="7a97d83784dfb6cdfd189d880f367facd2e06e43468248b41aa0239d3043172dfb508eca0209a7adb0ec12fda06887bfbdc37f41ebcb65b1a48967754c940b8f" +tarball_blake2b="74427da3af0c4c7fcd7b178d8084556e4a8e5f7707918d96612d05e3713255da4cc2a55626eacf31a7b7400deedb0df9433ca563bcac1714accfa37f55ed2bc0" From 93a215b71dc2a580f804a67ec913508ab728cb2b Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 29 Mar 2024 15:24:03 +1100 Subject: [PATCH 040/112] feat(ports): add python Signed-off-by: Anhad Singh --- Makefile | 4 + .../python/python-config-site | 0 patches/python/jinx-working-patch.patch | 54 ++++++ recipes/python | 46 +++++ src/aero_kernel/src/arch/x86_64/task.rs | 3 - src/aero_kernel/src/arch/x86_64/time.rs | 2 +- src/aero_kernel/src/drivers/mouse.rs | 2 +- src/aero_kernel/src/fs/devfs.rs | 2 +- src/aero_kernel/src/fs/eventfd.rs | 4 +- src/aero_kernel/src/fs/ext2/mod.rs | 3 +- src/aero_kernel/src/fs/file_table.rs | 2 +- src/aero_kernel/src/fs/inode.rs | 3 +- src/aero_kernel/src/fs/mod.rs | 90 +++------- src/aero_kernel/src/fs/path.rs | 162 ++++++++++++++++++ src/aero_kernel/src/fs/procfs.rs | 24 +-- src/aero_kernel/src/fs/ramfs.rs | 2 +- src/aero_kernel/src/main.rs | 3 +- src/aero_kernel/src/mem/paging/mod.rs | 2 - src/aero_kernel/src/syscall/fs.rs | 32 +++- src/aero_kernel/src/syscall/mod.rs | 9 +- src/aero_kernel/src/syscall/net.rs | 3 +- src/aero_kernel/src/userland/signals.rs | 5 +- src/aero_kernel/src/userland/task/mod.rs | 3 +- 23 files changed, 354 insertions(+), 106 deletions(-) rename {extra-files => build-support}/python/python-config-site (100%) create mode 100644 patches/python/jinx-working-patch.patch create mode 100644 recipes/python create mode 100644 src/aero_kernel/src/fs/path.rs diff --git a/Makefile b/Makefile index 86fc4651f18..f31c027278c 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,10 @@ KERNEL_TARGET := src/target/x86_64-unknown-none/release/aero_kernel clean: rm -rf src/target +.PHONY: check +check: + cd src && cargo check + $(KERNEL_TARGET): $(shell find $(SOURCE_DIR) -type f -not -path '$(SOURCE_DIR)/target/*') cd src && cargo build --package aero_kernel --release ./build-support/mkiso.sh diff --git a/extra-files/python/python-config-site b/build-support/python/python-config-site similarity index 100% rename from extra-files/python/python-config-site rename to build-support/python/python-config-site diff --git a/patches/python/jinx-working-patch.patch b/patches/python/jinx-working-patch.patch new file mode 100644 index 00000000000..b26ff6d122b --- /dev/null +++ b/patches/python/jinx-working-patch.patch @@ -0,0 +1,54 @@ +diff --git python-clean/configure.ac python-workdir/configure.ac +index cd69f0e..74fc416 100644 +--- python-clean/configure.ac ++++ python-workdir/configure.ac +@@ -553,6 +553,9 @@ then + *-*-cygwin*) + ac_sys_system=Cygwin + ;; ++ *-*-aero*) ++ ac_sys_system=Aero ++ ;; + *-*-vxworks*) + ac_sys_system=VxWorks + ;; +@@ -619,6 +622,9 @@ if test "$cross_compiling" = yes; then + *-*-vxworks*) + _host_cpu=$host_cpu + ;; ++ *-*-aero*) ++ _host_cpu=$host_cpu ++ ;; + wasm32-*-* | wasm64-*-*) + _host_cpu=$host_cpu + ;; +@@ -3216,6 +3222,9 @@ then + CYGWIN*) + LDSHARED="gcc -shared -Wl,--enable-auto-image-base" + LDCXXSHARED="g++ -shared -Wl,--enable-auto-image-base";; ++ Aero*) ++ LDSHARED='$(CC) -shared' ++ LDCXXSHARED='$(CXX) - shared';; + *) LDSHARED="ld";; + esac + fi +@@ -3268,7 +3277,9 @@ then + else CCSHARED="-Kpic -belf" + fi;; + VxWorks*) +- CCSHARED="-fpic -D__SO_PICABILINUX__ -ftls-model=global-dynamic" ++ CCSHARED="-fpic -D__SO_PICABILINUX__ -ftls-model=global-dynamic";; ++ Aero*) ++ CCSHARED="-fPIC";; + esac + fi + AC_MSG_RESULT([$CCSHARED]) +@@ -3338,6 +3349,8 @@ then + LINKFORSHARED='-Wl,-E -N 2048K';; + VxWorks*) + LINKFORSHARED='-Wl,-export-dynamic';; ++ Aero*) ++ LINKFORSHARED='-export-dynamic';; + esac + fi + AC_MSG_RESULT([$LINKFORSHARED]) diff --git a/recipes/python b/recipes/python new file mode 100644 index 00000000000..e3dae6b0974 --- /dev/null +++ b/recipes/python @@ -0,0 +1,46 @@ +name=python +version=3.13.0 +tarball_url="https://www.python.org/ftp/python/${version}/Python-${version}a1.tar.xz" +tarball_blake2b="62612d22ce652f4b1d7ce93aa30bd5814dbf271dbe98e321b99d003d7da8f74798e55f556db75fc39b676295c1d1f7b31919c444fe3c667d2fbd2ea16799a211" +source_deps="autoconf-archive" +source_hostdeps="automake autoconf libtool pkg-config" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libexpat" + +regenerate() { + autotools_recursive_regen +} + +build() { + mkdir -p ./build + cd ./build + + # XXX make this a host dep + if ! [ -f built ]; then + ${source_dir}/configure + + make -j${parallelism} + touch built + fi + + cd - + + CONFIG_SITE=${base_dir}/build-support/python/python-config-site autotools_configure \ + --with-system-ffi \ + --with-system-expat \ + --disable-ipv6 \ + --without-ensurepip \ + --host=x86_64-aero \ + --build=x86_64-linux-gnu \ + --with-build-python="$(pwd -P)/build/python" \ + --with-pkg-config=yes + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + ln -sv python3 "${dest_dir}${prefix}/bin/python" + post_package_strip +} + diff --git a/src/aero_kernel/src/arch/x86_64/task.rs b/src/aero_kernel/src/arch/x86_64/task.rs index 6e269809608..6d4d6f5960d 100644 --- a/src/aero_kernel/src/arch/x86_64/task.rs +++ b/src/aero_kernel/src/arch/x86_64/task.rs @@ -33,17 +33,14 @@ use alloc::alloc::alloc_zeroed; use aero_syscall::{MMapFlags, MMapProt}; -use alloc::boxed::Box; use alloc::vec::Vec; use raw_cpuid::CpuId; use core::alloc::Layout; use core::ptr::Unique; -use crate::arch::controlregs::MxCsr; use crate::arch::interrupts::InterruptErrorStack; use crate::fs::cache::DirCacheItem; -use crate::mem::alloc_boxed_buffer; use crate::mem::paging::*; use crate::syscall::ExecArgs; use crate::userland::vm::Vm; diff --git a/src/aero_kernel/src/arch/x86_64/time.rs b/src/aero_kernel/src/arch/x86_64/time.rs index b783ec7c465..4c5e5e82baf 100644 --- a/src/aero_kernel/src/arch/x86_64/time.rs +++ b/src/aero_kernel/src/arch/x86_64/time.rs @@ -109,7 +109,7 @@ fn pit_irq_handler(_stack: &mut InterruptStack) { if value % PIT_FREQUENCY_HZ == 0 { UPTIME_SEC.fetch_add(1, Ordering::Relaxed); // Increment uptime seconds - crate::syscall::check_timers(); + crate::syscall::time::check_timers(); } } diff --git a/src/aero_kernel/src/drivers/mouse.rs b/src/aero_kernel/src/drivers/mouse.rs index bde3783c788..d761366881f 100644 --- a/src/aero_kernel/src/drivers/mouse.rs +++ b/src/aero_kernel/src/drivers/mouse.rs @@ -147,7 +147,7 @@ impl INodeInterface for Mouse { assert_eq!(buffer.len(), size); unsafe { - *(buffer.as_mut_ptr() as *mut Packet) = packet; + *(buffer.as_mut_ptr().cast::()) = packet; } Ok(size) diff --git a/src/aero_kernel/src/fs/devfs.rs b/src/aero_kernel/src/fs/devfs.rs index 819c17d212d..d59c6dd3581 100644 --- a/src/aero_kernel/src/fs/devfs.rs +++ b/src/aero_kernel/src/fs/devfs.rs @@ -310,7 +310,7 @@ impl INodeInterface for DevFb { count = buffer.len() - ((offset + buffer.len()) - fb.len()); } - let raw = buffer.as_ptr() as *const u32; + let raw = buffer.as_ptr().cast::(); let src = unsafe { core::slice::from_raw_parts(raw, count) }; fb[offset..offset + count].copy_from_slice(src); diff --git a/src/aero_kernel/src/fs/eventfd.rs b/src/aero_kernel/src/fs/eventfd.rs index d7b257bcafb..a919f6d5c6f 100644 --- a/src/aero_kernel/src/fs/eventfd.rs +++ b/src/aero_kernel/src/fs/eventfd.rs @@ -60,7 +60,7 @@ impl INodeInterface for EventFd { // SAFETY: We have above verified that it is safe to dereference // the value. - let value = unsafe { &mut *(buffer.as_mut_ptr() as *mut u64) }; + let value = unsafe { &mut *(buffer.as_mut_ptr().cast::()) }; let mut count = self.wq.block_on(&self.count, |e| **e != 0)?; *value = *count; @@ -75,7 +75,7 @@ impl INodeInterface for EventFd { assert!(buffer.len() >= chunk_size); // TODO: use bytemuck to remove the unsafe. - let target = unsafe { *(buffer.as_ptr() as *const u64) }; + let target = unsafe { *(buffer.as_ptr().cast::()) }; if target == u64::MAX { return Err(FileSystemError::NotSupported); diff --git a/src/aero_kernel/src/fs/ext2/mod.rs b/src/aero_kernel/src/fs/ext2/mod.rs index 78dbb06e434..4653ebfc6a2 100644 --- a/src/aero_kernel/src/fs/ext2/mod.rs +++ b/src/aero_kernel/src/fs/ext2/mod.rs @@ -40,6 +40,7 @@ use self::group_desc::GroupDescriptors; use super::block::{self, BlockDevice, CachedAccess}; use super::cache::{DirCacheItem, INodeCacheItem}; +use super::path::PathBuf; use super::{cache, FileSystemError}; use super::inode::{DirEntry, INodeInterface, Metadata, PollFlags, PollTable}; @@ -518,7 +519,7 @@ impl INodeInterface for INode { self.make_inode(name, FileType::Socket, Some(inode)) } - fn resolve_link(&self) -> super::Result { + fn resolve_link(&self) -> super::Result { if !self.metadata()?.is_symlink() { return Err(FileSystemError::NotSupported); } diff --git a/src/aero_kernel/src/fs/file_table.rs b/src/aero_kernel/src/fs/file_table.rs index 01448efa18f..c7e01b89e24 100644 --- a/src/aero_kernel/src/fs/file_table.rs +++ b/src/aero_kernel/src/fs/file_table.rs @@ -172,7 +172,7 @@ impl FileHandle { let file_type = entry.inode().metadata()?.file_type(); let file_type: aero_syscall::SysFileType = file_type.into(); - let sysd = unsafe { &mut *(buffer.as_mut_ptr() as *mut SysDirEntry) }; + let sysd = unsafe { &mut *(buffer.as_mut_ptr().cast::()) }; sysd.inode = entry.inode().metadata()?.id(); sysd.offset = reclen; diff --git a/src/aero_kernel/src/fs/inode.rs b/src/aero_kernel/src/fs/inode.rs index 4cf721ceb8d..98a0a86898b 100644 --- a/src/aero_kernel/src/fs/inode.rs +++ b/src/aero_kernel/src/fs/inode.rs @@ -36,6 +36,7 @@ use crate::utils::sync::{BMutex, Mutex, WaitQueue}; use super::cache::{Cacheable, CachedINode, DirCacheItem, INodeCacheItem}; use super::devfs::DevINode; use super::file_table::FileHandle; +use super::path::PathBuf; use super::{cache, FileSystem, FileSystemError, Result}; static DIR_CACHE_MARKER: AtomicUsize = AtomicUsize::new(0x00); @@ -120,7 +121,7 @@ pub trait INodeInterface: Send + Sync { /// ## Errors /// - `FileSystemError::NotSupported` - If the inode is not a symbolic link or the filesystem /// does not support symbolic links. - fn resolve_link(&self) -> Result { + fn resolve_link(&self) -> Result { Err(FileSystemError::NotSupported) } diff --git a/src/aero_kernel/src/fs/mod.rs b/src/aero_kernel/src/fs/mod.rs index c0e64579de8..4cb64f4c8c1 100644 --- a/src/aero_kernel/src/fs/mod.rs +++ b/src/aero_kernel/src/fs/mod.rs @@ -17,6 +17,11 @@ use core::mem; +pub mod path; + +// TODO: Do not re-export this. +pub use path::Path; + use aero_syscall::SyscallError; use alloc::collections::BTreeMap; use alloc::sync::Arc; @@ -80,8 +85,8 @@ impl MountManager { let current_data = directory.data.lock(); let mut root_data = root_dir.data.lock(); - root_data.name = current_data.name.clone(); - root_data.parent = current_data.parent.clone(); + root_data.name.clone_from(¤t_data.name); + root_data.parent.clone_from(¤t_data.parent); mem::drop(root_data); mem::drop(current_data); @@ -157,53 +162,6 @@ impl From for SyscallError { } } -/// A slice of a path (akin to [str]). -#[derive(Debug)] -pub struct Path(str); - -impl Path { - pub fn new(path: &str) -> &Self { - unsafe { &*(path as *const str as *const Path) } - } - - #[inline] - pub fn is_empty(&self) -> bool { - self.0.is_empty() - } - - /// Returns [`true`] if the path is absolute. - pub fn is_absolute(&self) -> bool { - self.0.starts_with('/') - } - - /// Returns an iterator over the components of the path. - pub fn components(&self) -> impl Iterator { - self.0.split('/').filter(|e| !e.is_empty() && *e != ".") - } - - pub fn as_str(&self) -> &str { - &self.0 - } - - /// Helper function that returns the parent path and the base name - /// of the path. - pub fn parent_and_basename(&self) -> (&Self, &str) { - if let Some(slash_index) = self.0.rfind('/') { - let parent_dir = if slash_index == 0 { - Path::new("/") - } else { - Path::new(&self.0[..slash_index]) - }; - - let basename = &self.0[(slash_index + 1)..]; - (parent_dir, basename) - } else { - // A relative path without any slashes. - (Path::new(""), &self.0) - } - } -} - #[derive(Debug, Copy, Clone, PartialEq)] pub enum LookupMode { None, @@ -215,7 +173,10 @@ pub fn lookup_path_with( mut cwd: DirCacheItem, path: &Path, mode: LookupMode, + resolve_last: bool, ) -> Result { + let components_len = path.components().count(); + // Iterate and resolve each component. For example `a`, `b`, and `c` in `a/b/c`. for (i, component) in path.components().enumerate() { match component { @@ -249,7 +210,7 @@ pub fn lookup_path_with( if err == FileSystemError::EntryNotFound && mode == LookupMode::Create => { - if i == path.components().count() - 1 { + if i == components_len - 1 { cwd = cwd.inode().touch(cwd.clone(), component)?; } else { // todo: fix this shit @@ -258,6 +219,7 @@ pub fn lookup_path_with( cwd.clone(), Path::new(component), LookupMode::None, + resolve_last, ) { Ok(x) => x, Err(e) => { @@ -275,16 +237,19 @@ pub fn lookup_path_with( let inode = cwd.inode(); let metadata = inode.metadata()?; - if metadata.is_symlink() { - let resolved_path_str = inode.resolve_link()?; - let resolved_path = Path::new(&resolved_path_str); - - if resolved_path.is_absolute() { - cwd = lookup_path(resolved_path)?; - continue; - } - - cwd = lookup_path_with(parent, resolved_path, LookupMode::None)?; + if metadata.is_symlink() && resolve_last { + let resolved_path = inode.resolve_link()?; + + cwd = lookup_path_with( + if resolved_path.is_absolute() { + root_dir().clone() + } else { + parent + }, + resolved_path.as_ref(), + LookupMode::None, + resolve_last, + )?; } else if metadata.is_directory() { if let Ok(mount_point) = MOUNT_MANAGER.find_mount(cwd.clone()) { cwd = mount_point.root_entry; @@ -299,12 +264,13 @@ pub fn lookup_path_with( pub fn lookup_path(path: &Path) -> Result { let cwd = if !path.is_absolute() { - scheduler::get_scheduler().current_task().cwd_dirent() + scheduler::current_thread().cwd_dirent() } else { root_dir().clone() }; - lookup_path_with(cwd, path, LookupMode::None) + // TODO:Keep `resolve_last` set to true as a default? + lookup_path_with(cwd, path, LookupMode::None, true) } pub fn root_dir() -> &'static DirCacheItem { diff --git a/src/aero_kernel/src/fs/path.rs b/src/aero_kernel/src/fs/path.rs new file mode 100644 index 00000000000..a553befb74b --- /dev/null +++ b/src/aero_kernel/src/fs/path.rs @@ -0,0 +1,162 @@ +use core::borrow::Borrow; +use core::fmt::Display; +use core::ops::Deref; + +use alloc::borrow::ToOwned; +use alloc::vec::Vec; + +/// A slice of a path (akin to [str]). +#[derive(Debug)] +pub struct Path(str); + +impl Path { + pub fn new(path: &str) -> &Self { + unsafe { &*(path as *const str as *const Path) } + } + + #[inline] + pub fn is_empty(&self) -> bool { + self.0.is_empty() + } + + /// Returns [`true`] if the path is absolute. + pub fn is_absolute(&self) -> bool { + self.0.starts_with('/') + } + + /// Returns an iterator over the components of the path. + pub fn components(&self) -> impl Iterator { + self.0.split('/').filter(|e| !e.is_empty() && *e != ".") + } + + pub fn as_str(&self) -> &str { + &self.0 + } + + /// Creates an owned [`PathBuf`] with `path` adjoined to `self`. + /// + /// If `path` is absolute, it replaces the current path. + /// + /// See [`PathBuf::push`] for more details on what it means to adjoin a path. + pub fn join>(&self, path: P) -> PathBuf { + let mut result = self.to_owned(); + result.push(path); + result + } + + /// Helper function that returns the parent path and the base name + /// of the path. + pub fn parent_and_basename(&self) -> (&Self, &str) { + if let Some(slash_index) = self.0.rfind('/') { + let parent_dir = if slash_index == 0 { + Path::new("/") + } else { + Path::new(&self.0[..slash_index]) + }; + + let basename = &self.0[(slash_index + 1)..]; + (parent_dir, basename) + } else { + // A relative path without any slashes. + (Path::new(""), &self.0) + } + } + + #[inline] + pub fn as_bytes(&self) -> &[u8] { + self.0.as_bytes() + } +} + +impl Borrow for PathBuf { + #[inline] + fn borrow(&self) -> &Path { + self.deref() + } +} + +impl ToOwned for Path { + type Owned = PathBuf; + + #[inline] + fn to_owned(&self) -> Self::Owned { + PathBuf(self.0.to_owned()) + } +} + +impl AsRef for Path { + #[inline] + fn as_ref(&self) -> &Path { + self + } +} + +/// An owned, mutable path (akin to [`String`]). +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct PathBuf(String); + +impl PathBuf { + #[inline] + fn as_mut_vec(&mut self) -> &mut Vec { + // TODO: safety? + unsafe { self.0.as_mut_vec() } + } + + /// Extends `self` with `path`. + /// + /// If `path` is absolute, it replaces the current path. + pub fn push>(&mut self, path: P) { + let path = path.as_ref(); + + // absolute `path` replaces `self` + if path.is_absolute() { + self.as_mut_vec().truncate(0); + } + + let need_sep = self.0.chars().last().map(|c| c != '/').unwrap_or(false); + + // TODO: verbatim pahts need . and .. removed + + if need_sep { + self.0.push('/'); + } + + self.0.push_str(path.as_str()); + } +} + +impl From for PathBuf { + #[inline] + fn from(path: String) -> Self { + Self(path) + } +} + +impl From<&str> for PathBuf { + fn from(value: &str) -> Self { + Self(value.to_owned()) + } +} + +impl Deref for PathBuf { + type Target = Path; + + #[inline] + fn deref(&self) -> &Self::Target { + Path::new(&self.0) + } +} + +impl AsRef for PathBuf { + #[inline] + fn as_ref(&self) -> &Path { + self + } +} + +impl Display for PathBuf { + #[inline] + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + self.0.fmt(f) + } +} diff --git a/src/aero_kernel/src/fs/procfs.rs b/src/aero_kernel/src/fs/procfs.rs index 48f4dc19790..57a12bae572 100644 --- a/src/aero_kernel/src/fs/procfs.rs +++ b/src/aero_kernel/src/fs/procfs.rs @@ -19,23 +19,23 @@ use core::sync::atomic::{AtomicUsize, Ordering}; use alloc::borrow::ToOwned; use alloc::collections::BTreeMap; -use alloc::string::{String, ToString}; +use alloc::string::ToString; use alloc::sync::{Arc, Weak}; use spin::{Once, RwLock}; +use crate::fs; use crate::fs::inode::FileType; use crate::arch::tls; +use crate::userland::scheduler; -use super::cache; use super::cache::*; +use super::{cache, FileSystem, Path, MOUNT_MANAGER}; +use super::inode::{DirEntry, INodeInterface, Metadata}; use super::FileSystemError; -use super::inode::*; -use super::*; - // TODO: put this mf in prelude use alloc::vec; @@ -151,7 +151,7 @@ impl LockedProcINode { name: &str, file_type: FileType, contents: FileContents, - ) -> Result { + ) -> fs::Result { let icache = cache::icache(); let mut this = self.0.write(); @@ -183,7 +183,7 @@ impl LockedProcINode { } impl INodeInterface for LockedProcINode { - fn read_at(&self, offset: usize, buffer: &mut [u8]) -> Result { + fn read_at(&self, offset: usize, buffer: &mut [u8]) -> fs::Result { let this = self.0.read(); let data = match &this.contents { @@ -216,7 +216,7 @@ impl INodeInterface for LockedProcINode { Ok(count) } - fn lookup(&self, dir: DirCacheItem, name: &str) -> Result { + fn lookup(&self, dir: DirCacheItem, name: &str) -> fs::Result { let this = self.0.read(); let child = this .children @@ -226,7 +226,7 @@ impl INodeInterface for LockedProcINode { Ok(DirEntry::new(dir, child.clone(), String::from(name))) } - fn metadata(&self) -> Result { + fn metadata(&self) -> fs::Result { let this = self.0.read(); Ok(Metadata { @@ -237,7 +237,7 @@ impl INodeInterface for LockedProcINode { }) } - fn dirent(&self, parent: DirCacheItem, index: usize) -> Result> { + fn dirent(&self, parent: DirCacheItem, index: usize) -> fs::Result> { let this = self.0.read(); if this.file_type != FileType::Directory { @@ -282,7 +282,7 @@ struct ProcFs { } impl ProcFs { - pub fn new() -> Result> { + pub fn new() -> fs::Result> { let icache = cache::icache(); let root_node = Arc::new(LockedProcINode::new(ProcINode::default())); @@ -345,7 +345,7 @@ impl FileSystem for ProcFs { static PROC_FS: Once> = Once::new(); -pub fn init() -> Result<()> { +pub fn init() -> fs::Result<()> { let fs = ProcFs::new()?; let fs = PROC_FS.call_once(|| fs); diff --git a/src/aero_kernel/src/fs/ramfs.rs b/src/aero_kernel/src/fs/ramfs.rs index 060fe214cb7..822b3531aba 100644 --- a/src/aero_kernel/src/fs/ramfs.rs +++ b/src/aero_kernel/src/fs/ramfs.rs @@ -19,7 +19,7 @@ use core::sync::atomic::{AtomicUsize, Ordering}; use aero_syscall::MMapFlags; use alloc::collections::BTreeMap; -use alloc::string::{String, ToString}; +use alloc::string::ToString; use alloc::sync::{Arc, Weak}; use alloc::vec::Vec; diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index 54a6d418e72..72d802f5e33 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -69,12 +69,12 @@ extern crate aero_proc; mod prelude { + #[allow(unused)] pub mod rust_2021 { // Since asm is used almost all over the kernel, its a better idea // to add it to the prelude. pub use core::arch::asm; pub use core::prelude::rust_2021::*; - pub use core::prelude::v1::*; pub use alloc::string::String; @@ -83,6 +83,7 @@ mod prelude { } } +#[allow(unused)] #[prelude_import] pub use prelude::rust_2021::*; diff --git a/src/aero_kernel/src/mem/paging/mod.rs b/src/aero_kernel/src/mem/paging/mod.rs index 7ed5a571793..7e523182dbd 100644 --- a/src/aero_kernel/src/mem/paging/mod.rs +++ b/src/aero_kernel/src/mem/paging/mod.rs @@ -27,8 +27,6 @@ pub use self::mapper::*; pub use self::page::*; pub use self::page_table::*; -pub use frame::LockedFrameAllocator; - use crate::PHYSICAL_MEMORY_OFFSET; pub static FRAME_ALLOCATOR: LockedFrameAllocator = LockedFrameAllocator::new_uninit(); diff --git a/src/aero_kernel/src/syscall/fs.rs b/src/aero_kernel/src/syscall/fs.rs index 2ba5633ca5c..d011dc7c37f 100644 --- a/src/aero_kernel/src/syscall/fs.rs +++ b/src/aero_kernel/src/syscall/fs.rs @@ -19,7 +19,8 @@ use core::fmt; use aero_syscall::prelude::*; use aero_syscall::signal::SigProcMask; -use aero_syscall::{AtFlags, OpenFlags, Stat, SyscallError, TimeSpec, AT_FDCWD}; +use aero_syscall::{AtFlags, OpenFlags, Stat, TimeSpec, AT_FDCWD}; +use alloc::borrow::ToOwned; use alloc::sync::Arc; use crate::fs::cache::{self, DirCacheImpl}; @@ -27,6 +28,7 @@ use crate::fs::epoll::EPoll; use crate::fs::eventfd::EventFd; use crate::fs::file_table::{DuplicateHint, FileHandle}; use crate::fs::inode::{DirEntry, PollTable}; +use crate::fs::path::PathBuf; use crate::fs::pipe::Pipe; use crate::fs::{self, lookup_path, LookupMode}; use crate::syscall::SysArg; @@ -129,7 +131,7 @@ pub fn open(fd: usize, path: &Path, mode: usize) -> Result lookup_mode = LookupMode::Create; } - let inode = fs::lookup_path_with(dir, path, lookup_mode)?; + let inode = fs::lookup_path_with(dir, path, lookup_mode, true)?; if flags.contains(OpenFlags::O_DIRECTORY) && !inode.inode().metadata()?.is_directory() { return Err(SyscallError::ENOTDIR); @@ -470,7 +472,7 @@ pub fn fstat(fd: usize, path: &Path, flags: usize, stat: &mut Stat) -> Result Result { #[syscall] pub fn read_link(path: &Path, buffer: &mut [u8]) -> Result { // XXX: lookup_path with automatically resolve the link. - let file = fs::lookup_path(path)?; - let resolved_path = file.absolute_path_str(); - let size = core::cmp::min(resolved_path.len(), buffer.len()); + let cwd = if !path.is_absolute() { + scheduler::current_thread().cwd_dirent() + } else { + fs::root_dir().clone() + }; + + let file = fs::lookup_path_with(cwd.clone(), path, LookupMode::None, false)?.inode(); + if !file.metadata()?.is_symlink() { + return Err(SyscallError::EINVAL); + } + + let resolved_path = file.resolve_link()?; + let resolved_path = if resolved_path.is_absolute() { + resolved_path + } else { + Path::new(&cwd.absolute_path_str()).join(resolved_path) + }; + + let size = core::cmp::min(resolved_path.as_str().len(), buffer.len()); + + log::warn!("Orig: {path:?} -> {resolved_path}"); buffer[..size].copy_from_slice(&resolved_path.as_bytes()[..size]); Ok(size) diff --git a/src/aero_kernel/src/syscall/mod.rs b/src/aero_kernel/src/syscall/mod.rs index b6275ec0949..70c76c10f33 100644 --- a/src/aero_kernel/src/syscall/mod.rs +++ b/src/aero_kernel/src/syscall/mod.rs @@ -24,19 +24,14 @@ use aero_syscall::prelude::*; mod fs; mod futex; -mod ipc; +pub mod ipc; mod net; mod process; -mod time; +pub mod time; use alloc::boxed::Box; use alloc::vec::Vec; -pub use fs::*; -pub use ipc::*; -pub use process::*; -pub use time::*; - use crate::utils::StackHelper; #[derive(Default)] diff --git a/src/aero_kernel/src/syscall/net.rs b/src/aero_kernel/src/syscall/net.rs index f54cf2bb3f9..d7375f73a40 100644 --- a/src/aero_kernel/src/syscall/net.rs +++ b/src/aero_kernel/src/syscall/net.rs @@ -35,9 +35,8 @@ use crate::socket::unix::*; use crate::socket::{SocketAddr, SocketAddrRef}; use crate::userland::scheduler; -use crate::userland::task::TaskId; -use super::FileDescriptor; +use crate::syscall::fs::FileDescriptor; /// Creates a [`SocketAddr`] from the provided userland socket structure address. This /// is done by looking at the family field present in every socket address structure. diff --git a/src/aero_kernel/src/userland/signals.rs b/src/aero_kernel/src/userland/signals.rs index a9a714863d0..0cf1cf56c96 100644 --- a/src/aero_kernel/src/userland/signals.rs +++ b/src/aero_kernel/src/userland/signals.rs @@ -360,7 +360,10 @@ impl Signals { handler: Option, old: Option<&mut SigAction>, ) { - assert!(signal < SIGNAL_COUNT); + if signal >= SIGNAL_COUNT { + log::warn!("signal index is out of bounds"); + return; + } if !can_override(signal) { return; diff --git a/src/aero_kernel/src/userland/task/mod.rs b/src/aero_kernel/src/userland/task/mod.rs index 86d60ba3723..43913010e04 100644 --- a/src/aero_kernel/src/userland/task/mod.rs +++ b/src/aero_kernel/src/userland/task/mod.rs @@ -33,7 +33,8 @@ use crate::mem::paging::*; use crate::arch::task::ArchTask; use crate::fs::file_table::FileTable; -use crate::syscall::{ExecArgs, MessageQueue}; +use crate::syscall::ipc::MessageQueue; +use crate::syscall::ExecArgs; use crate::utils::sync::{Mutex, WaitQueue}; use crate::userland::signals::Signals; From ec720d2197814933c5993fb63624c3d1fbe24d43 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 29 Mar 2024 15:38:18 +1100 Subject: [PATCH 041/112] fix(base-files): do not set `PYTHONHOME` Signed-off-by: Anhad Singh --- base-files/{.bashrc => etc/bash/bash.bashrc} | 2 - base-files/etc/profile | 49 ++++++++++++++++++++ src/aero_kernel/src/acpi/mod.rs | 2 +- 3 files changed, 50 insertions(+), 3 deletions(-) rename base-files/{.bashrc => etc/bash/bash.bashrc} (93%) create mode 100644 base-files/etc/profile diff --git a/base-files/.bashrc b/base-files/etc/bash/bash.bashrc similarity index 93% rename from base-files/.bashrc rename to base-files/etc/bash/bash.bashrc index 3c47db12580..a9b77a9c70b 100644 --- a/base-files/.bashrc +++ b/base-files/etc/bash/bash.bashrc @@ -9,8 +9,6 @@ export TERM=xterm-256color alias ls="ls --color=auto" alias clear='printf "\e[2J\e[H"' -export PYTHONHOME="/usr/lib" - # todo: https://github.com/sharkdp/bat/blob/master/src/bin/bat/directories.rs panics if not set? export BAT_CONFIG_DIR="/cfg/bat" export BAT_CACHE_PATH="/cache/bat" diff --git a/base-files/etc/profile b/base-files/etc/profile new file mode 100644 index 00000000000..dcb78173695 --- /dev/null +++ b/base-files/etc/profile @@ -0,0 +1,49 @@ +# /etc/profile + +# This file was copied from my host Arch Linux installation. Credits to them :) + +# Append "$1" to $PATH when not already in. +# This function API is accessible to scripts in /etc/profile.d +append_path () { + case ":$PATH:" in + *:"$1":*) + ;; + *) + PATH="${PATH:+$PATH:}$1" + esac +} + +# Append our default paths +append_path '/usr/local/sbin' +append_path '/usr/local/bin' +append_path '/usr/bin' + +# Force PATH to be environment +export PATH + +# Load profiles from /etc/profile.d +if test -d /etc/profile.d/; then + for profile in /etc/profile.d/*.sh; do + test -r "$profile" && . "$profile" + done + unset profile +fi + +# Unload our profile API functions +unset -f append_path + +# Source global bash config, when interactive but not posix or sh mode +if test "$BASH" &&\ + test "$PS1" &&\ + test -z "$POSIXLY_CORRECT" &&\ + test "${0#-}" != sh &&\ + test -r /etc/bash.bashrc +then + . /etc/bash.bashrc +fi + +# Termcap is outdated, old, and crusty, kill it. +unset TERMCAP + +# Man is much better than us at figuring this out +unset MANPATH diff --git a/src/aero_kernel/src/acpi/mod.rs b/src/aero_kernel/src/acpi/mod.rs index 5503c41f5ce..f7f59d19708 100644 --- a/src/aero_kernel/src/acpi/mod.rs +++ b/src/aero_kernel/src/acpi/mod.rs @@ -86,7 +86,7 @@ impl AcpiTable { } } -#[repr(packed)] +#[repr(C, packed)] #[derive(Clone, Copy, Debug)] pub struct GenericAddressStructure { pub address_space: u8, From e276b6e65712c69b571728c6040a67e0b9920469 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 29 Mar 2024 16:17:04 +1100 Subject: [PATCH 042/112] misc(absolute_path): rename and return a `PathBuf` * Rename `absolute_path_str` -> `absolute_path` * Make it return a `PathBuf` Signed-off-by: Anhad Singh --- src/aero_kernel/src/fs/cache.rs | 20 ++++++++------- src/aero_kernel/src/fs/file_table.rs | 13 +--------- src/aero_kernel/src/fs/mod.rs | 2 +- src/aero_kernel/src/fs/path.rs | 25 +++++++++++++++++++ src/aero_kernel/src/syscall/fs.rs | 6 ++--- src/aero_kernel/src/userland/scheduler/mod.rs | 7 +++++- src/aero_kernel/src/userland/task/mod.rs | 12 ++++----- src/aero_kernel/src/userland/vm.rs | 8 +++--- 8 files changed, 56 insertions(+), 37 deletions(-) diff --git a/src/aero_kernel/src/fs/cache.rs b/src/aero_kernel/src/fs/cache.rs index b18cbee1ad9..55c23e649db 100644 --- a/src/aero_kernel/src/fs/cache.rs +++ b/src/aero_kernel/src/fs/cache.rs @@ -38,6 +38,7 @@ use spin::Once; use crate::fs::inode::{DirEntry, INodeInterface}; use crate::utils::sync::BMutex; +use super::path::PathBuf; use super::FileSystem; pub static INODE_CACHE: Once> = Once::new(); @@ -317,7 +318,7 @@ pub type DirCacheItem = CacheArc>; impl Debug for DirCacheItem { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { f.debug_tuple("DirCacheItem") - .field(&self.absolute_path_str()) + .field(&self.absolute_path()) .finish() } } @@ -367,14 +368,14 @@ impl Cacheable for DirEntry { } pub trait DirCacheImpl { - fn absolute_path_str(&self) -> String; + fn absolute_path(&self) -> PathBuf; } impl DirCacheImpl for DirCacheItem { - fn absolute_path_str(&self) -> String { + fn absolute_path(&self) -> PathBuf { let mut current_entry = Some(self.clone()); let mut path_nodes = Vec::new(); - let mut result = String::new(); + let mut result = PathBuf::new(); // We need to collect all of the path nodes, reverse them and then join them // with the path separator. @@ -384,12 +385,13 @@ impl DirCacheImpl for DirCacheItem { } for node in path_nodes.iter().rev() { - result.push_str(node); + result.push(node.as_str()); + // result.push_str(node); - // If we are not at the root node, we need to add the path separator. - if node != "/" { - result.push('/'); - } + // // If we are not at the root node, we need to add the path separator. + // if node != "/" { + // result.push('/'); + // } } result diff --git a/src/aero_kernel/src/fs/file_table.rs b/src/aero_kernel/src/fs/file_table.rs index c7e01b89e24..c4428f50f62 100644 --- a/src/aero_kernel/src/fs/file_table.rs +++ b/src/aero_kernel/src/fs/file_table.rs @@ -68,17 +68,7 @@ impl FileHandle { let offset = self.offset.load(Ordering::SeqCst); let new_offset = self.inode.inode().read_at(offset, buffer)?; - if self.inode.absolute_path_str().contains("/tmp/ccAAAAAA.s") { - log::debug!( - "read {} bytes from {} ----- hi mom ----- {:?}", - new_offset, - self.inode.absolute_path_str(), - buffer - ); - } - self.offset.fetch_add(new_offset, Ordering::SeqCst); - Ok(new_offset) } @@ -87,7 +77,6 @@ impl FileHandle { let new_offset = self.inode.inode().write_at(offset, buffer)?; self.offset.fetch_add(new_offset, Ordering::SeqCst); - Ok(new_offset) } @@ -223,7 +212,7 @@ impl FileTable { log::debug!( "file handle: (fd={}, path=`{}`)", handle.fd, - handle.inode.absolute_path_str() + handle.inode.absolute_path() ) } } diff --git a/src/aero_kernel/src/fs/mod.rs b/src/aero_kernel/src/fs/mod.rs index 4cb64f4c8c1..37a17c50345 100644 --- a/src/aero_kernel/src/fs/mod.rs +++ b/src/aero_kernel/src/fs/mod.rs @@ -223,7 +223,7 @@ pub fn lookup_path_with( ) { Ok(x) => x, Err(e) => { - dbg!(component, cwd.absolute_path_str()); + dbg!(component, cwd.absolute_path()); return Err(dbg!(e)); } }; diff --git a/src/aero_kernel/src/fs/path.rs b/src/aero_kernel/src/fs/path.rs index a553befb74b..40905999c9e 100644 --- a/src/aero_kernel/src/fs/path.rs +++ b/src/aero_kernel/src/fs/path.rs @@ -66,6 +66,11 @@ impl Path { pub fn as_bytes(&self) -> &[u8] { self.0.as_bytes() } + + /// Returns the byte length of the path. + pub fn len(&self) -> usize { + self.0.len() + } } impl Borrow for PathBuf { @@ -91,11 +96,24 @@ impl AsRef for Path { } } +impl AsRef for &str { + #[inline] + fn as_ref(&self) -> &Path { + Path::new(self) + } +} + /// An owned, mutable path (akin to [`String`]). #[derive(Debug, Clone, PartialEq, Eq)] pub struct PathBuf(String); impl PathBuf { + /// Allocates an empty `PathBuf`. + #[inline] + pub fn new() -> Self { + Self(String::new()) + } + #[inline] fn as_mut_vec(&mut self) -> &mut Vec { // TODO: safety? @@ -154,6 +172,13 @@ impl AsRef for PathBuf { } } +impl Into for PathBuf { + #[inline] + fn into(self) -> String { + self.0 + } +} + impl Display for PathBuf { #[inline] fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { diff --git a/src/aero_kernel/src/syscall/fs.rs b/src/aero_kernel/src/syscall/fs.rs index d011dc7c37f..23d7d60a46a 100644 --- a/src/aero_kernel/src/syscall/fs.rs +++ b/src/aero_kernel/src/syscall/fs.rs @@ -55,7 +55,7 @@ impl FileDescriptor { impl fmt::Display for FileDescriptor { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if let Ok(file_handle) = self.handle() { - let path = file_handle.inode.absolute_path_str(); + let path = file_handle.inode.absolute_path(); write!(f, "{{ {} -> {} }}", self.0, path) } else { // invalid file descriptor @@ -470,7 +470,7 @@ pub fn fstat(fd: usize, path: &Path, flags: usize, stat: &mut Stat) -> Result Result let resolved_path = if resolved_path.is_absolute() { resolved_path } else { - Path::new(&cwd.absolute_path_str()).join(resolved_path) + cwd.absolute_path().join(resolved_path) }; let size = core::cmp::min(resolved_path.as_str().len(), buffer.len()); diff --git a/src/aero_kernel/src/userland/scheduler/mod.rs b/src/aero_kernel/src/userland/scheduler/mod.rs index 043e97d2dd7..8f5629bba49 100644 --- a/src/aero_kernel/src/userland/scheduler/mod.rs +++ b/src/aero_kernel/src/userland/scheduler/mod.rs @@ -131,9 +131,14 @@ impl Scheduler { pub fn log_ptable(&self) { self.tasks.0.lock().iter().for_each(|(pid, task)| { + let path: String = task + .path() + .map(|path| path.into()) + .unwrap_or("".into()); + log::info!( "task(pid={pid:?}, path={:?}, state={:?})", - task.path().unwrap_or(String::from("")), + path, task.state() ) }); diff --git a/src/aero_kernel/src/userland/task/mod.rs b/src/aero_kernel/src/userland/task/mod.rs index 43913010e04..c242e511759 100644 --- a/src/aero_kernel/src/userland/task/mod.rs +++ b/src/aero_kernel/src/userland/task/mod.rs @@ -28,6 +28,7 @@ use core::ops::Range; use core::sync::atomic::{AtomicBool, AtomicU8, AtomicUsize, Ordering}; use crate::fs::cache::{DirCacheImpl, DirCacheItem}; +use crate::fs::path::PathBuf; use crate::fs::{self, FileSystem}; use crate::mem::paging::*; @@ -510,11 +511,8 @@ impl Task { } } - pub fn path(&self) -> Option { - self.executable - .lock() - .as_ref() - .map(|e| e.absolute_path_str()) + pub fn path(&self) -> Option { + self.executable.lock().as_ref().map(|e| e.absolute_path()) } pub fn exec( @@ -648,8 +646,8 @@ impl Task { self.cwd.read().as_ref().unwrap().inode.clone() } - pub fn get_cwd(&self) -> String { - self.cwd.read().as_ref().unwrap().inode.absolute_path_str() + pub fn get_cwd(&self) -> PathBuf { + self.cwd.read().as_ref().unwrap().inode.absolute_path() } pub fn set_cwd(&self, cwd: DirCacheItem) { diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs index 32d4e8ca459..5bfef124bfd 100644 --- a/src/aero_kernel/src/userland/vm.rs +++ b/src/aero_kernel/src/userland/vm.rs @@ -872,7 +872,7 @@ impl VmProtected { protection, flags, offset, - z.map(|f| f.absolute_path_str()) + z.map(|f| f.absolute_path()) ); crate::unwind::unwind_stack_trace(); @@ -915,19 +915,19 @@ impl VmProtected { if let Some(shebang) = parse_shebang(bin.clone())? { log::debug!( "shebang: (interpreter={}, argument={})", - shebang.interpreter.absolute_path_str(), + shebang.interpreter.absolute_path(), shebang.argument ); let mut largv = ExecArgs::default(); - largv.push(shebang.interpreter.absolute_path_str().as_bytes()); + largv.push(shebang.interpreter.absolute_path().as_bytes()); if !shebang.argument.is_empty() { largv.push(shebang.argument.as_bytes()); } - largv.push(bin.absolute_path_str().as_bytes()); + largv.push(bin.absolute_path().as_bytes()); if let Some(argv) = argv { largv.extend(&argv.inner[1..]) From 7d054dba37c054c86ead1edd4c5ea3ecb3e18fe4 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 29 Mar 2024 20:23:13 +1100 Subject: [PATCH 043/112] misc(kernel): refactor and make clippy happier Signed-off-by: Anhad Singh --- .vscode/settings.json | 2 +- .../src/drivers/block/nvme/command.rs | 2 +- src/aero_kernel/src/drivers/block/nvme/queue.rs | 12 ++++++------ src/aero_kernel/src/drivers/drm/rawfb.rs | 5 +++-- src/aero_kernel/src/drivers/e1000.rs | 10 ++++++---- src/aero_kernel/src/fs/cache.rs | 2 +- src/aero_kernel/src/fs/ext2/disk.rs | 15 +++++++-------- src/aero_kernel/src/utils/dma.rs | 4 ++-- src/aero_kernel/src/utils/mod.rs | 17 +++++++++++++++++ 9 files changed, 44 insertions(+), 25 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 887a54e7cd9..f4cfcd3638f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ { "rust-analyzer.linkedProjects": [ "./src/Cargo.toml", - "./userland/Cargo.toml" + // "./userland/Cargo.toml" ], "rust-analyzer.checkOnSave.allTargets": false, // "rust-analyzer.checkOnSave.extraArgs": [ diff --git a/src/aero_kernel/src/drivers/block/nvme/command.rs b/src/aero_kernel/src/drivers/block/nvme/command.rs index c967885ebbc..120e6cce68a 100644 --- a/src/aero_kernel/src/drivers/block/nvme/command.rs +++ b/src/aero_kernel/src/drivers/block/nvme/command.rs @@ -351,7 +351,7 @@ pub struct CompletionEntry { #[repr(C)] pub union Command { - common: CommonCommand, + pub(super) common: CommonCommand, identify: IdentifyCommand, rw: ReadWriteCommand, create_sq: CreateSQCommand, diff --git a/src/aero_kernel/src/drivers/block/nvme/queue.rs b/src/aero_kernel/src/drivers/block/nvme/queue.rs index 4ed0b4221db..fa45e47aa0f 100644 --- a/src/aero_kernel/src/drivers/block/nvme/queue.rs +++ b/src/aero_kernel/src/drivers/block/nvme/queue.rs @@ -1,11 +1,13 @@ use core::cell::UnsafeCell; +use core::ptr; use core::sync::atomic::{AtomicU16, Ordering}; use crate::mem::paging::PhysAddr; use crate::utils::dma::Dma; +use crate::utils::VolatileCell; use super::command::{Command, CompletionEntry}; -use super::*; +use super::{Error, Registers}; const fn calculate_doorbell_offset(queue_id: u16, multiplier: usize, dstrd: usize) -> usize { 0x1000 + ((((queue_id as usize) * 2) + multiplier) * (4 << dstrd)) @@ -136,11 +138,9 @@ impl<'a> QueuePair<'a> { let mut command = command.into(); unsafe { - // SAFETY: Command Layout: - // - opcode: u8 - // - flags: u8 - // - command_id: u16 (offset=2 bytes)) - *(&mut command as *mut Command as *mut u16).offset(1) = self.cid; + // SAFETY: The offset of the `command_id` field is the same, regardless of the command + // type. + command.common.command_id = self.cid; } self.cid += 1; diff --git a/src/aero_kernel/src/drivers/drm/rawfb.rs b/src/aero_kernel/src/drivers/drm/rawfb.rs index 0b7f06064ac..1020539df8b 100644 --- a/src/aero_kernel/src/drivers/drm/rawfb.rs +++ b/src/aero_kernel/src/drivers/drm/rawfb.rs @@ -16,12 +16,13 @@ // along with Aero. If not, see . use alloc::sync::Arc; +use uapi::drm::DrmModeConStatus; use crate::fs::{devfs, FileSystem}; use crate::mem::paging::*; -use super::*; +use super::{make_dmt_modes, BufferObject, Connector, Crtc, Drm, DrmDevice, Encoder}; use crate::rendy; struct RawFramebuffer {} @@ -54,7 +55,7 @@ impl DrmDevice for RawFramebuffer { unsafe { core::ptr::copy_nonoverlapping( frame.as_slice_mut::().as_mut_ptr(), - (fb.as_mut_ptr() as *mut u8) + (fb.as_mut_ptr().cast::()) .offset(i as isize * Size4KiB::SIZE as isize), 4096, ) diff --git a/src/aero_kernel/src/drivers/e1000.rs b/src/aero_kernel/src/drivers/e1000.rs index fd9b6ff80be..3b8975cd599 100644 --- a/src/aero_kernel/src/drivers/e1000.rs +++ b/src/aero_kernel/src/drivers/e1000.rs @@ -15,6 +15,8 @@ // You should have received a copy of the GNU General Public License // along with Aero. If not, see . +use core::ptr; + use alloc::boxed::Box; use alloc::sync::Arc; use spin::Once; @@ -570,14 +572,14 @@ impl E1000 { unsafe fn write_raw(&self, register: u32, value: u32) { unsafe { - let register = self.base.as_mut_ptr::().add(register as usize); - core::ptr::write_volatile(register as *mut u32, value); + let register = self.base.as_mut_ptr::().byte_add(register as usize); + ptr::write_volatile(register, value); } } unsafe fn read_raw(&self, register: u32) -> u32 { - let register = self.base.as_ptr::().add(register as usize); - core::ptr::read_volatile(register as *const u32) + let register = self.base.as_ptr::().byte_add(register as usize); + ptr::read_volatile(register) } } diff --git a/src/aero_kernel/src/fs/cache.rs b/src/aero_kernel/src/fs/cache.rs index 55c23e649db..64fa5c84837 100644 --- a/src/aero_kernel/src/fs/cache.rs +++ b/src/aero_kernel/src/fs/cache.rs @@ -351,7 +351,7 @@ impl Cacheable for CachedINode { impl INodeCacheItem { pub fn make_key(fs: Weak, id: usize) -> INodeCacheKey { - (Weak::as_ptr(&fs) as *const () as usize, id) + (Weak::as_ptr(&fs).addr(), id) } } diff --git a/src/aero_kernel/src/fs/ext2/disk.rs b/src/aero_kernel/src/fs/ext2/disk.rs index 0dbe5c4f5b1..faf9af574b6 100644 --- a/src/aero_kernel/src/fs/ext2/disk.rs +++ b/src/aero_kernel/src/fs/ext2/disk.rs @@ -15,11 +15,12 @@ // You should have received a copy of the GNU General Public License // along with Aero. If not, see . +use core::ptr; + use bit_field::BitField; use crate::fs::inode; - -trait Revsion {} +use crate::utils::IncompleteArrayField; #[derive(Debug, PartialEq)] pub enum Revision { @@ -142,13 +143,14 @@ pub struct GroupDescriptor { const_assert_eq!(core::mem::size_of::(), 32); -#[derive(Debug, Copy, Clone)] -#[repr(C, packed)] +#[derive(Debug)] +#[repr(C)] pub struct DirEntry { pub inode: u32, pub entry_size: u16, pub name_size: u8, pub file_type: u8, + name: IncompleteArrayField, } impl DirEntry { @@ -157,10 +159,7 @@ impl DirEntry { self.name_size = name.len() as u8; - // SAFETY: Above we have verified that the name will fit in the entry. - let name_ptr = unsafe { (self as *mut _ as *mut u8).add(core::mem::size_of::()) }; - let name_bytes = unsafe { core::slice::from_raw_parts_mut(name_ptr, name.len()) }; - + let name_bytes = unsafe { self.name.as_mut_slice(name.len()) }; name_bytes.copy_from_slice(name.as_bytes()); } } diff --git a/src/aero_kernel/src/utils/dma.rs b/src/aero_kernel/src/utils/dma.rs index 861d8f089ab..c3c1a19a667 100644 --- a/src/aero_kernel/src/utils/dma.rs +++ b/src/aero_kernel/src/utils/dma.rs @@ -19,7 +19,7 @@ use alloc::boxed::Box; use core::alloc::{AllocError, Allocator, Layout}; use core::mem::MaybeUninit; -use core::ptr::NonNull; +use core::ptr::{self, NonNull}; use crate::mem::paging::*; @@ -114,7 +114,7 @@ impl core::fmt::Debug for Dma { impl Dma { pub fn addr(&self) -> PhysAddr { unsafe { - let phys = (&*self.0 as *const T as *const u8) as u64; + let phys = ptr::addr_of!(*self.0).addr() as u64; PhysAddr::new(phys - crate::PHYSICAL_MEMORY_OFFSET.as_u64()) } } diff --git a/src/aero_kernel/src/utils/mod.rs b/src/aero_kernel/src/utils/mod.rs index 7d143b05b7d..58918037f88 100644 --- a/src/aero_kernel/src/utils/mod.rs +++ b/src/aero_kernel/src/utils/mod.rs @@ -20,6 +20,7 @@ use alloc::sync::Arc; use core::alloc::Layout; use core::any::Any; use core::cell::UnsafeCell; +use core::marker::PhantomData; use core::mem; use core::ptr::Unique; @@ -235,3 +236,19 @@ macro_rules! extern_sym { unsafe { ::core::ptr::addr_of!($sym) } }}; } + +#[repr(C)] +#[derive(Debug, Default)] +pub struct IncompleteArrayField(PhantomData, [T; 0]); + +impl IncompleteArrayField { + #[inline] + pub unsafe fn as_mut_ptr(&mut self) -> *mut T { + self as *mut _ as *mut T + } + + #[inline] + pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { + core::slice::from_raw_parts_mut(self.as_mut_ptr(), len) + } +} From 4fc918bec99d0bd81f7721c80bc909a82f5e0261 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 29 Mar 2024 20:27:38 +1100 Subject: [PATCH 044/112] feat(kernel): add `symlink` systemcall Signed-off-by: Anhad Singh --- patches/mlibc/jinx-working-patch.patch | 39 ++++++++++++++++++-- src/aero_kernel/src/fs/ext2/mod.rs | 24 +++++++++++- src/aero_kernel/src/fs/inode.rs | 6 ++- src/aero_kernel/src/syscall/fs.rs | 30 +++++++++++++-- src/aero_kernel/src/syscall/mod.rs | 1 + src/aero_syscall/src/consts.rs | 1 + src/aero_syscall/src/lib.rs | 5 +++ userland/tests/utest.cc | 51 ++++++++++++++++++++++---- 8 files changed, 141 insertions(+), 16 deletions(-) diff --git a/patches/mlibc/jinx-working-patch.patch b/patches/mlibc/jinx-working-patch.patch index dbb0969d0bb..e948a5c0430 100644 --- a/patches/mlibc/jinx-working-patch.patch +++ b/patches/mlibc/jinx-working-patch.patch @@ -102,7 +102,7 @@ index 0000000..1b61d5a + ret +.section .note.GNU-stack,"",%progbits diff --git mlibc-clean/sysdeps/aero/generic/filesystem.cpp mlibc-workdir/sysdeps/aero/generic/filesystem.cpp -index 33a11f4..8795382 100644 +index 33a11f4..fe5773d 100644 --- mlibc-clean/sysdeps/aero/generic/filesystem.cpp +++ mlibc-workdir/sysdeps/aero/generic/filesystem.cpp @@ -102,31 +102,24 @@ int sys_access(const char *filename, int mode) { @@ -127,7 +127,7 @@ index 33a11f4..8795382 100644 + case fsfd_target::fd_path: break; - } -- + - default: { - mlibc::infoLogger() - << "mlibc warning: sys_stat: unsupported fsfd target" @@ -135,7 +135,7 @@ index 33a11f4..8795382 100644 - return EINVAL; - } - } - +- - if (result < 0) { - return -result; + default: @@ -149,6 +149,39 @@ index 33a11f4..8795382 100644 return 0; } +@@ -212,6 +205,17 @@ int sys_unlinkat(int fd, const char *path, int flags) { + return 0; + } + ++int sys_symlink(const char *target_path, const char *link_path) { ++ return sys_symlinkat(target_path, AT_FDCWD, link_path); ++} ++ ++int sys_symlinkat(const char *target_path, int dirfd, const char *link_path) { ++ auto ret = syscall(SYS_SYMLINK_AT, dirfd, target_path, strlen(target_path), link_path, strlen(link_path)); ++ if (int e = sc_error(ret); e) ++ return e; ++ return 0; ++} ++ + struct aero_dir_entry { + size_t inode; + size_t offset; +diff --git mlibc-clean/sysdeps/aero/include/aero/syscall.h mlibc-workdir/sysdeps/aero/include/aero/syscall.h +index 39c5b65..49533cc 100644 +--- mlibc-clean/sysdeps/aero/include/aero/syscall.h ++++ mlibc-workdir/sysdeps/aero/include/aero/syscall.h +@@ -82,6 +82,10 @@ + #define SYS_SOCK_SHUTDOWN 75 + #define SYS_GETPEERNAME 76 + #define SYS_GETSOCKNAME 77 ++#define SYS_DEBUG 78 ++#define SYS_SETSOCKOPT 79 ++#define SYS_GETSOCKOPT 80 ++#define SYS_SYMLINK_AT 81 + + // Invalid syscall used to trigger a log error in the kernel (as a hint) + // so, that we can implement the syscall in the kernel. diff --git mlibc-clean/sysdeps/aero/meson.build mlibc-workdir/sysdeps/aero/meson.build index 9d10701..3d2a883 100644 --- mlibc-clean/sysdeps/aero/meson.build diff --git a/src/aero_kernel/src/fs/ext2/mod.rs b/src/aero_kernel/src/fs/ext2/mod.rs index 4653ebfc6a2..92d4f390ff3 100644 --- a/src/aero_kernel/src/fs/ext2/mod.rs +++ b/src/aero_kernel/src/fs/ext2/mod.rs @@ -41,7 +41,7 @@ use super::block::{self, BlockDevice, CachedAccess}; use super::cache::{DirCacheItem, INodeCacheItem}; use super::path::PathBuf; -use super::{cache, FileSystemError}; +use super::{cache, FileSystemError, Path}; use super::inode::{DirEntry, INodeInterface, Metadata, PollFlags, PollTable}; use super::FileSystem; @@ -529,6 +529,8 @@ impl INodeInterface for INode { let path_len = inode.size(); let data_bytes: &[u8] = bytemuck::cast_slice(&inode.data_ptr); + // XXX: Symlinks under 60 bytes store data within the inode to avoid allocating a full + // block. if path_len <= data_bytes.len() { let path_bytes = &data_bytes[..path_len]; let path = core::str::from_utf8(path_bytes).or(Err(FileSystemError::InvalidPath))?; @@ -545,6 +547,26 @@ impl INodeInterface for INode { } } + fn symlink(&self, target: &Path) -> super::Result<()> { + let mut inode = self.inode.write(); + inode.set_file_type(FileType::Symlink); + + let target_len = target.len(); + let data_bytes: &mut [u8] = bytemuck::cast_slice_mut(&mut inode.data_ptr); + + // XXX: Symlinks under 60 bytes store data within the inode to avoid allocating a full + // block. + if target_len <= data_bytes.len() { + data_bytes[..target_len].copy_from_slice(target.as_bytes()); + inode.set_size(target_len); + } else { + drop(inode); + assert_eq!(self.write(0, target.as_bytes())?, target_len); + } + + Ok(()) + } + fn mmap(&self, offset: usize, size: usize, flags: MMapFlags) -> super::Result { assert!(self.proxy.is_none()); diff --git a/src/aero_kernel/src/fs/inode.rs b/src/aero_kernel/src/fs/inode.rs index 98a0a86898b..a3ae965c8b2 100644 --- a/src/aero_kernel/src/fs/inode.rs +++ b/src/aero_kernel/src/fs/inode.rs @@ -37,7 +37,7 @@ use super::cache::{Cacheable, CachedINode, DirCacheItem, INodeCacheItem}; use super::devfs::DevINode; use super::file_table::FileHandle; use super::path::PathBuf; -use super::{cache, FileSystem, FileSystemError, Result}; +use super::{cache, FileSystem, FileSystemError, Path, Result}; static DIR_CACHE_MARKER: AtomicUsize = AtomicUsize::new(0x00); @@ -279,6 +279,10 @@ pub trait INodeInterface: Send + Sync { fn link(&self, _name: &str, _src: DirCacheItem) -> Result<()> { Err(FileSystemError::NotSupported) } + + fn symlink(&self, _target: &Path) -> Result<()> { + Err(FileSystemError::NotSupported) + } } /// Structure representing the crucial, characteristics of an inode. The metadata diff --git a/src/aero_kernel/src/syscall/fs.rs b/src/aero_kernel/src/syscall/fs.rs index 23d7d60a46a..5b543914053 100644 --- a/src/aero_kernel/src/syscall/fs.rs +++ b/src/aero_kernel/src/syscall/fs.rs @@ -459,7 +459,7 @@ pub fn fstat(fd: usize, path: &Path, flags: usize, stat: &mut Stat) -> Result Result Result { }); Ok(0) } + +#[syscall] +pub fn symlink(link_dirfd: usize, target: &Path, linkpath: &Path) -> Result { + // TODO(andypython): the following code is reused in a couple of places. Isolate this inside the + // syscall parsing for FileDescriptor with an argument as a generic specifing the allowance + // of this value. + // + // If the pathname given in `linkpath` is relative, then it is interpreted relative to the + // directory referred to by the file descriptor `link_dirfd`. + let at = match link_dirfd as isize { + AT_FDCWD if !linkpath.is_absolute() => scheduler::current_thread().cwd_dirent(), + _ if !linkpath.is_absolute() => FileDescriptor::from_usize(link_dirfd) + .handle()? + .inode + .clone(), + _ => fs::root_dir().clone(), + }; + + let ent = fs::lookup_path_with(at, linkpath, LookupMode::Create, false)?; + ent.inode().symlink(target)?; + + Ok(0) +} diff --git a/src/aero_kernel/src/syscall/mod.rs b/src/aero_kernel/src/syscall/mod.rs index 70c76c10f33..54f7ab9c1b0 100644 --- a/src/aero_kernel/src/syscall/mod.rs +++ b/src/aero_kernel/src/syscall/mod.rs @@ -230,6 +230,7 @@ pub fn generic_do_syscall( SYS_LINK => fs::link(b, c, d, e), SYS_POLL => fs::poll(b, c, d, e), SYS_RENAME => fs::rename(b, c, d, e), + SYS_SYMLINK_AT => fs::symlink(b, c, d, e, f), // epoll calls: SYS_EPOLL_CREATE => fs::epoll_create(b), diff --git a/src/aero_syscall/src/consts.rs b/src/aero_syscall/src/consts.rs index fb800d38f6e..a08796a60b6 100644 --- a/src/aero_syscall/src/consts.rs +++ b/src/aero_syscall/src/consts.rs @@ -101,6 +101,7 @@ pub const SYS_GETSOCKNAME: usize = 77; pub const SYS_DEBUG: usize = 78; pub const SYS_SETSOCKOPT: usize = 79; pub const SYS_GETSOCKOPT: usize = 80; +pub const SYS_SYMLINK_AT: usize = 81; // constants for fcntl()'s command argument: pub const F_DUPFD: usize = 1; diff --git a/src/aero_syscall/src/lib.rs b/src/aero_syscall/src/lib.rs index 10ed83e6d37..15e3e4514f4 100644 --- a/src/aero_syscall/src/lib.rs +++ b/src/aero_syscall/src/lib.rs @@ -717,10 +717,15 @@ pub struct Stat { bitflags::bitflags! { #[repr(transparent)] pub struct AtFlags: usize { + /// Allow empty relative pathname. const EMPTY_PATH = 1; + /// Follow symbolic links. const SYMLINK_FOLLOW = 2; + /// Do not follow symbolic links. const SYMLINK_NOFOLLOW = 4; + /// Remove directory instead of unlinking file. const REMOVEDIR = 8; + /// Test access permitted for effective IDs, not real IDs. const EACCESS = 512; } } diff --git a/userland/tests/utest.cc b/userland/tests/utest.cc index 2fc71f96fcc..2abea8f9189 100644 --- a/userland/tests/utest.cc +++ b/userland/tests/utest.cc @@ -4,7 +4,10 @@ #include #include +#include #include +#include +#include #include #include #include @@ -199,7 +202,7 @@ DEFINE_TEST(epoll_mod_active, ([] { // Use mmap to change the protection flags instead of mprotect. DEFINE_TEST(mmap_partial_remap, ([] { - enable_systrace(); + //enable_systrace(); const int bytes = PAGE_SIZE * 2; @@ -610,6 +613,42 @@ DEFINE_TEST(mprotect_check_whether_three_way_split_mappings_are_handled_correctl }); })) +DEFINE_TEST(stat, ([] { + // SYM_B -> SYM_A -> /tmp/SYM_REAL + + // TODO: make mknod() + FILE *sym_real = fopen("/tmp/SYM_REAL", "w"); + + if (symlink("/tmp/SYM_REAL", "/tmp/SYM_A") == -1) + assert(!"(1) symlink() failed"); + + if (symlink("/tmp/SYM_A", "/tmp/SYM_B") == -1) + assert(!"(2) symlink() failed"); + + struct stat statbuf; + if (fstatat(AT_FDCWD, "/tmp/SYM_B", &statbuf, AT_SYMLINK_NOFOLLOW) == -1) + assert(!"fstatat() failed"); + + // Check that the symlink is not followed. + assert(S_ISLNK(statbuf.st_mode)); + + if (fstatat(AT_FDCWD, "/tmp/SYM_B", &statbuf, 0) == -1) + assert(!"fstatat() failed"); + + // Check that the symlink is followed. + assert(S_ISREG(statbuf.st_mode)); + + if (unlink("/tmp/SYM_A") == -1) + assert(!"unlink() failed"); + + if (unlink("/tmp/SYM_B") == -1) + assert(!"unlink() failed"); + + fclose(sym_real); + if (unlink("/tmp/SYM_REAL") == -1) + assert(!"unlink() failed"); +})) + static inline bool cpuid(uint32_t leaf, uint32_t subleaf, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { uint32_t cpuid_max; @@ -724,10 +763,8 @@ void abstract_test_case::register_case(abstract_test_case *tcp) { int main() { // Go through all tests and run them. - // for(abstract_test_case *tcp : test_case_ptrs()) { - // std::cout << "tests: Running " << tcp->name() << std::endl; - // tcp->run(); - // } - test_bad_sysenter.run(); - test_sysenter_system_call.run(); + for(abstract_test_case *tcp : test_case_ptrs()) { + std::cout << "tests: Running " << tcp->name() << std::endl; + tcp->run(); + } } From a1823a3ddc5f4ec5bbc7838b177f0d514ade5295 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 30 Mar 2024 12:52:10 +1100 Subject: [PATCH 045/112] fix(recipes): add `gcc` imagedep for python Signed-off-by: Anhad Singh --- recipes/python | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/python b/recipes/python index e3dae6b0974..5426ea68b76 100644 --- a/recipes/python +++ b/recipes/python @@ -2,6 +2,7 @@ name=python version=3.13.0 tarball_url="https://www.python.org/ftp/python/${version}/Python-${version}a1.tar.xz" tarball_blake2b="62612d22ce652f4b1d7ce93aa30bd5814dbf271dbe98e321b99d003d7da8f74798e55f556db75fc39b676295c1d1f7b31919c444fe3c667d2fbd2ea16799a211" +imagedeps="gcc" source_deps="autoconf-archive" source_hostdeps="automake autoconf libtool pkg-config" hostdeps="gcc autoconf automake libtool pkg-config" From 36028c7b0d4938f4659090920b7320dd51b37e39 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 30 Mar 2024 12:56:10 +1100 Subject: [PATCH 046/112] feat(ports): remove old xbstrap files and buildsys * Remove aero.py * Remove bootstrap/ and bootstrap.yml which were used in the past by xbstrap. Now since we have switched to Jinx, we do not need them. Signed-off-by: Anhad Singh --- Dockerfile | 53 - aero.py | 674 ---------- bootstrap.yml | 2647 -------------------------------------- bootstrap/app-misc.yml | 31 - bootstrap/db.yml | 38 - bootstrap/editors.yml | 60 - bootstrap/net.yml | 733 ----------- bootstrap/vcs.yml | 51 - bootstrap/x11-themes.yml | 49 - bootstrap/xorg.yml | 2635 ------------------------------------- 10 files changed, 6971 deletions(-) delete mode 100644 Dockerfile delete mode 100755 aero.py delete mode 100644 bootstrap.yml delete mode 100644 bootstrap/app-misc.yml delete mode 100644 bootstrap/db.yml delete mode 100644 bootstrap/editors.yml delete mode 100644 bootstrap/net.yml delete mode 100644 bootstrap/vcs.yml delete mode 100644 bootstrap/x11-themes.yml delete mode 100644 bootstrap/xorg.yml diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index a9d42f85791..00000000000 --- a/Dockerfile +++ /dev/null @@ -1,53 +0,0 @@ -FROM ubuntu:latest -WORKDIR /opt/workdir -# Cargo executables are installed here: -ENV PATH="$PATH:/home/workuser/.cargo/bin" -# Python executables are installed here: -ENV PATH="$PATH:/home/workuser/.local/bin" - -RUN apt-get update -RUN apt-get install -y \ - autopoint \ - bash \ - binutils \ - bison \ - cmake \ - coreutils \ - curl \ - expat \ - flex \ - gcc \ - gettext \ - git \ - gperf \ - groff \ - gzip \ - help2man \ - libgmp-dev \ - m4 \ - make \ - mercurial \ - meson \ - mtools \ - nasm \ - openssl \ - patch \ - perl \ - python3 \ - python3-mako \ - python3-pip \ - rsync \ - subversion \ - tar \ - texinfo \ - wget \ - xcb-proto \ - xorriso \ - xsltproc \ - xz-utils -RUN useradd -m workuser - -USER workuser -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -RUN python3 -m pip install requests xbstrap -ENTRYPOINT python3 aero.py --no-run \ No newline at end of file diff --git a/aero.py b/aero.py deleted file mode 100755 index a7123bee96f..00000000000 --- a/aero.py +++ /dev/null @@ -1,674 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright (C) 2021-2024 The Aero Project Developers. -# -# This file is part of The Aero Project. -# -# Aero is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Aero is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Aero. If not, see . - -import argparse -import json -import os -import platform -import shutil -import subprocess -import sys -import time - - -def log_info(msg): - """ - Logs a message with info log level. - """ - print(f"\033[1m\033[92minfo\033[0m: {msg}") - - -def log_error(msg): - """ - Logs a message with error log level. - """ - print(f"\033[1m\033[91merror\033[0m: {msg}") - - -# Make sure requests is installed -try: - import requests - import xbstrap -except ImportError: - log_error('Please install required libraries using the following command:') - log_error(' - python3 -m pip install requests xbstrap') - - sys.exit(0) - - -OVMF_URL = 'https://github.com/aero-os/ovmf-prebuilt' -LIMINE_URL = 'https://github.com/limine-bootloader/limine' - -BUILD_DIR = 'build' -BUNDLED_DIR = 'bundled' -SYSROOT_DIR = 'sysroot' -EXTRA_FILES = 'extra-files' -SYSROOT_CARGO_HOME = os.path.join(SYSROOT_DIR, 'cargo-home') -BASE_FILES_DIR = 'base-files' - -LIMINE_TEMPLATE = """ -TIMEOUT=0 -VERBOSE=yes - -:aero -PROTOCOL=limine -KASLR=no -KERNEL_PATH=boot:///aero.elf -CMDLINE=term-background=background theme-background=0x50000000 -#RESOLUTION=1920x1080 - -MODULE_PATH=boot:///term_background.bmp -MODULE_CMDLINE=background -""" - - -class BuildInfo: - args: argparse.Namespace - target_arch: str - - def __init__(self, target_arch: str, args: argparse.Namespace): - self.target_arch = target_arch - self.args = args - - -def get_userland_tool(): return os.path.join(SYSROOT_DIR, "tools") -def get_userland_package(): return os.path.join(SYSROOT_DIR, "packages") - - -def remove_prefix(string: str, prefix: str): - if string.startswith(prefix): - return string[len(prefix):] - else: - return string[:] - - -def parse_args(): - parser = argparse.ArgumentParser( - description="utility used to build aero kernel and userland") - - check_test = parser.add_mutually_exclusive_group() - - check_test.add_argument('--clean', - default=False, - action='store_true', - help='removes the build artifacts') - - check_test.add_argument('--check', - default=False, - action='store_true', - help='checks if aero builds correctly without packaging and running it') - - check_test.add_argument('--test', - default=False, - action='store_true', - help='runs the aero test suite') - - check_test.add_argument('--document', - default=False, - action='store_true', - help='generates the documentation for the aero kernel') - - parser.add_argument('--debug', - default=False, - action='store_true', - help='builds the kernel and userland in debug mode') - - parser.add_argument('--no-run', - default=False, - action='store_true', - help='doesn\'t run the built image in emulator when applicable') - - parser.add_argument('--only-run', - default=False, - action='store_true', - help='runs aero without rebuilding. ignores any build-related flags') - - parser.add_argument('--bios', - type=str, - default='legacy', - choices=['legacy', 'uefi'], - help='run aero using the selected BIOS') - - parser.add_argument('--features', - type=lambda x: x.split(','), - default=[], - help='additional features to build the kernel with') - - parser.add_argument('--target', - default='x86_64-aero_os', - help='override the target triple the kernel will be built for') - - parser.add_argument('--la57', - default=False, - action='store_true', - help='run emulator with 5 level paging support') - - parser.add_argument('--sysroot', - default=False, - action='store_true', - help='build the full userland sysroot. If disabled, then the sysroot will only contain the aero_shell and the init binaries') - - parser.add_argument('--disable-kvm', - default=False, - action='store_true', - help='disable KVM acceleration even if its available') - - parser.add_argument('remaining', - nargs=argparse.REMAINDER, - help='additional arguments to pass as the emulator') - - parser.add_argument('--memory', - default='9800M', - help='amount of memory to allocate to QEMU') - - parser.add_argument('--fmt', - default=False, - action='store_true', - help='format the source code') - - return parser.parse_args() - - -def run_command(args, **kwargs): - output = subprocess.run(args, **kwargs) - - return output.returncode, output.stdout, output.stderr - - -def download_bundled(): - if not os.path.exists(BUNDLED_DIR): - os.makedirs(BUNDLED_DIR) - - ovmf_path = os.path.join(BUNDLED_DIR, 'ovmf') - limine_path = os.path.join(BUNDLED_DIR, 'limine') - - if not os.path.exists(ovmf_path): - run_command(['git', 'clone', '--depth', '1', OVMF_URL, ovmf_path]) - - if not os.path.exists(limine_path): - run_command(['git', 'clone', '--branch', 'v4.x-branch-binary', - '--depth', '1', LIMINE_URL, limine_path]) - - if not os.path.exists(SYSROOT_DIR): - log_info("building minimal sysroot") - build_userland_sysroot(True) - - -def extract_artifacts(stdout): - result = [] - lines = stdout.splitlines() - - for line in lines: - info = json.loads(line) - executable = info['executable'] if 'executable' in info else None - - if executable: - result.append(info['executable']) - - return result - - -def build_cargo_workspace(cwd, command, args, cargo="cargo"): - code, _, _ = run_command([cargo, command, *args], cwd=cwd) - - if code != 0: - return None - - _, stdout, _ = run_command([cargo, command, *args, '--message-format=json'], - stdout=subprocess.PIPE, - stderr=subprocess.DEVNULL, - cwd=cwd) - - return extract_artifacts(stdout) - - -def build_kernel(args): - command = 'build' - cmd_args = ['--package', 'aero_kernel', - '--target', f'.cargo/{args.target}.json'] - - if not args.debug: - cmd_args += ['--release'] - - if args.test: - command = 'test' - cmd_args += ['--no-run'] - elif args.check: - command = 'check' - elif args.document: - command = 'doc' - - if args.features: - cmd_args += ['--features', ','.join(args.features)] - - return build_cargo_workspace('src', command, cmd_args) - - -# Helper function for symlink since os.symlink uses path -# relative to the destination directory. -def symlink_rel(src, dst): - rel_path_src = os.path.relpath(src, os.path.dirname(dst)) - os.symlink(rel_path_src, dst) - - -def build_userland_sysroot(minimal): - if not os.path.exists(SYSROOT_DIR): - os.mkdir(SYSROOT_DIR) - - # FIXME(xbstrap): xbstrap does not copy over the extra-files/rust/config.toml - # file into the cargo home directory. - if not os.path.exists(SYSROOT_CARGO_HOME): - os.mkdir(SYSROOT_CARGO_HOME) - - cargo_sys_cfg = os.path.join(SYSROOT_CARGO_HOME, 'config.toml') - if not os.path.exists(cargo_sys_cfg): - cargo_cfg_fd = open(os.path.join( - EXTRA_FILES, 'rust', 'config.toml'), 'r') - cargo_cfg = cargo_cfg_fd.read() - cargo_cfg_fd.close() - - cargo_cfg = cargo_cfg.replace("@SOURCE_ROOT@", os.getcwd()) - cargo_cfg = cargo_cfg.replace( - "@BUILD_ROOT@", os.path.join(os.getcwd(), SYSROOT_DIR)) - - cargo_cfg_fd = open(cargo_sys_cfg, "w+") - cargo_cfg_fd.write(cargo_cfg) - cargo_cfg_fd.close() - - blink = os.path.join(SYSROOT_DIR, 'bootstrap.link') - - if not os.path.islink(blink): - # symlink the bootstrap.yml file in the src root to sysroot/bootstrap.link - symlink_rel('bootstrap.yml', blink) - - def run_xbstrap(args): - try: - return run_command(['xbstrap', *args], cwd=SYSROOT_DIR) - except FileNotFoundError: - return run_command([f'{os.environ["HOME"]}/.local/bin/xbstrap', *args], cwd=SYSROOT_DIR) - - command = ['install', '-u', '--all'] - - if minimal: - command = ['install', '-u', 'bash', 'coreutils'] - - code, _, _ = run_xbstrap(command) - - if code != 0: - log_error( - f"`xbstrap {' '.join(command)}` exited with a non-zero status code") - exit(1) - - -def build_userland(args): - # We need to check if we have host-rust in-order for us to build - # our rust userland applications in `userland/`. - host_cargo = os.path.join(SYSROOT_DIR, "tools/host-rust") - - if not os.path.exists(host_cargo): - log_error( - "host-rust not built as a part of the sysroot, skipping compilation of `userland/`") - return [] - - HOST_RUST = "host-rust/bin/rustc" - HOST_GCC = "host-gcc/bin/x86_64-aero-gcc" - HOST_BINUTILS = "host-binutils/x86_64-aero/bin" - PACKAGE_MLIBC = "mlibc" - - tool_dir = get_userland_tool() - pkg_dir = get_userland_package() - - def get_rustc(): return os.path.join('..', tool_dir, HOST_RUST) - def get_gcc(): return os.path.join('..', tool_dir, HOST_GCC) - def get_binutils(): return os.path.join("..", tool_dir, HOST_BINUTILS) - def get_mlibc(): return os.path.join("..", pkg_dir, PACKAGE_MLIBC) - - command = 'build' - # TODO: handle the unbased architectures. - cmd_args = ["--target", "x86_64-unknown-aero", - - # cargo config - "--config", f"build.rustc = '{get_rustc()}'", - "--config", "build.target = 'x86_64-unknown-aero'", - "--config", f"build.rustflags = ['-C', 'link-args=-no-pie -B {get_binutils()} --sysroot {get_mlibc()}', '-lc']", - "--config", f"target.x86_64-unknown-aero.linker = '{get_gcc()}'", - - "-Z", "unstable-options"] - - if not args.debug: - cmd_args += ['--release'] - - if args.check: - command = 'check' - - if args.test: - return build_cargo_workspace('userland', 'build', ['--package', 'utest', *cmd_args]) - else: - return build_cargo_workspace('userland', command, cmd_args) - - # TODO: Userland check - # elif args.check: - # command = 'check' - - -def generate_docs(args): - doc_dir = os.path.join('src', 'target', args.target, 'doc') - out_dir = os.path.join(BUILD_DIR, 'web') - - if os.path.exists(out_dir): - shutil.rmtree(out_dir) - - shutil.copytree('web', out_dir, dirs_exist_ok=True) - shutil.copytree(doc_dir, out_dir, dirs_exist_ok=True) - - -def prepare_iso(args, kernel_bin, user_bins): - log_info("preparing ISO") - - if not os.path.exists(BUILD_DIR): - os.makedirs(BUILD_DIR) - - iso_path = os.path.join(BUILD_DIR, 'aero.iso') - iso_root = os.path.join(BUILD_DIR, 'iso_root') - limine_path = os.path.join(BUNDLED_DIR, 'limine') - - if os.path.exists(iso_root): - shutil.rmtree(iso_root) - - os.makedirs(iso_root) - - shutil.copy(kernel_bin, os.path.join(iso_root, 'aero.elf')) - shutil.copy(os.path.join('src', '.cargo', 'term_background.bmp'), iso_root) - shutil.copy(os.path.join(limine_path, 'limine.sys'), iso_root) - shutil.copy(os.path.join(limine_path, 'limine-cd.bin'), iso_root) - shutil.copy(os.path.join(limine_path, 'limine-cd-efi.bin'), iso_root) - - efi_boot = os.path.join(iso_root, "EFI", "BOOT") - os.makedirs(efi_boot) - - shutil.copy(os.path.join(limine_path, 'BOOTAA64.EFI'), efi_boot) - shutil.copy(os.path.join(limine_path, 'BOOTX64.EFI'), efi_boot) - - sysroot_dir = os.path.join(SYSROOT_DIR, 'system-root') - for file in user_bins: - bin_name = os.path.basename(file) - dest_dir = os.path.join(sysroot_dir, "usr", "bin") - os.makedirs(dest_dir, exist_ok=True) - shutil.copy(file, os.path.join(dest_dir, bin_name)) - - with open(os.path.join(iso_root, 'limine.cfg'), 'w') as limine_cfg: - limine_cfg.write(LIMINE_TEMPLATE) - - code, _, xorriso_stderr = run_command([ - 'xorriso', '-as', 'mkisofs', '-b', 'limine-cd.bin', '-no-emul-boot', '-boot-load-size', '4', - '-boot-info-table', '--efi-boot', 'limine-cd-efi.bin', '-efi-boot-part', - '--efi-boot-image', '--protective-msdos-label', iso_root, '-o', iso_path - ], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - - if code != 0: - log_error('failed to create the ISO image') - log_error(xorriso_stderr.decode('utf-8')) - - return None - - limine_deploy = os.path.join(limine_path, 'limine-deploy') - - if not os.path.exists(limine_deploy): - code, _, limine_build_stderr = run_command(['make', '-C', limine_path], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - if code != 0: - log_error('failed to build `limine-deploy`') - log_error(limine_build_stderr.decode('utf8')) - exit(1) - - code, _, limine_deploy_stderr = run_command([limine_deploy, iso_path], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - - if code != 0: - log_error('failed to install Limine') - log_error(limine_deploy_stderr) - - return None - - # create the disk image - disk_path = os.path.join(BUILD_DIR, 'disk.img') - - if not os.path.exists(disk_path): - log_info('creating disk image') - os.system('bash ./tools/mkimage.sh') - - return iso_path - - -def run_in_emulator(build_info: BuildInfo, iso_path): - is_kvm_available = is_kvm_supported() - args = build_info.args - - qemu_args = ['-cdrom', iso_path, - '-m', args.memory, - '-smp', '1', - '-serial', 'stdio', - '-drive', 'file=build/disk.img,if=none,id=NVME1,format=raw', '-device', 'nvme,drive=NVME1,serial=nvme', - # Specify the boot order (where `d` is the first CD-ROM drive) - '--boot', 'd', - '-s'] - - if args.bios == 'uefi': - qemu_args += ['-bios', - f'bundled/ovmf/ovmf-{build_info.target_arch}/OVMF.fd'] - - cmdline = args.remaining - - if '--' in cmdline: - cmdline.remove('--') - - if cmdline: - qemu_args += cmdline - - if is_kvm_available and not args.disable_kvm: - log_info("running with KVM acceleration enabled") - - if platform.system() == 'Darwin': - qemu_args += ['-accel', 'hvf', '-cpu', - 'qemu64,+la57' if args.la57 else 'qemu64'] - else: - qemu_args += ['-enable-kvm', '-cpu', - 'host,+la57' if args.la57 else 'host'] - else: - if build_info.target_arch == "aarch64": - qemu_args += ['-device', 'ramfb', - '-M', 'virt', '-cpu', 'cortex-a72'] - elif build_info.target_arch == "x86_64": - qemu_args += ["-cpu", "qemu64,+la57" if args.la57 else "max"] - else: - log_error("unknown target architecture") - exit(1) - - qemu_binary = os.getenv("QEMU_PATH") - if not qemu_binary: - qemu_binary = f'qemu-system-{build_info.target_arch}' - else: - qemu_binary = os.path.join( - qemu_binary, f'qemu-system-{build_info.target_arch}') - - log_info(f"{qemu_binary} {' '.join(qemu_args)}") - run_command([qemu_binary, *qemu_args]) - - -def get_sysctl(name: str) -> str: - """ - Shell out to sysctl(1) - - Returns the value as a string. - Non-leaf nodes will return the value for each sub-node separated by newline characters. - """ - status, stdout, stderr = run_command(["sysctl", "-n", name], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - if status != 0: - print("`sysctl` failed: ", end="") - print(stderr.decode()) - - return stdout.strip().decode() - - -def is_kvm_supported() -> bool: - """ - Returns True if KVM is supported on this machine - """ - - platform = sys.platform - - if platform == "darwin": - # Check for VMX support - cpu_features = get_sysctl("machdep.cpu.features") - vmx_support = "VMX" in cpu_features.split(' ') - - # Check for HVF support - hv_support = get_sysctl("kern.hv_support") == "1" - - return hv_support and vmx_support - - if platform == "linux": - kvm_path = "/dev/kvm" - - # Check if the `/dev/kvm` device exists. - if not os.path.exists(kvm_path): - return False - - # Read out the cpuinfo from `/proc/cpuinfo` - fd = open("/proc/cpuinfo") - cpuinfo = fd.read() - - # Parse the cpuinfo - cpuinfo_array = cpuinfo.split("\n\n") - processors_info = [] - - for cpu in cpuinfo_array: - ret = {} - for line in cpu.split("\n"): - try: - name, value = line.split(":") - - name = name.strip() - value = value.strip() - - ret[name] = value - except ValueError: - pass - - processors_info.append(ret) - - for processor in processors_info: - if processor["processor"] == "0": - # KVM acceleration can be used - if "vmx" in processor["flags"]: - return True - # KVM acceleration cannot be used - else: - return False - - fd.close() - - # KVM is not available on Windows - return False - - -def main(): - args = parse_args() - - if args.fmt: - run_command(['cargo', 'fmt'], cwd="src") - return - - if os.path.exists(BUILD_DIR): - system_root = os.path.join(SYSROOT_DIR, 'system-root') - sysroot_mod = max(os.path.getmtime(os.path.join(system_root, file)) - for file in os.listdir(system_root)) - build_mod = os.path.getmtime(BUILD_DIR) - if sysroot_mod > build_mod: - log_info("sysroot modified, rebuilding") - os.rmdir(BUILD_DIR) - - t0 = time.time() - # arch-aero_os - target_arch = args.target.split('-')[0] - build_info = BuildInfo(target_arch, args) - - if build_info.target_arch == "aarch64" and not args.bios == "uefi": - log_error("aarch64 requires UEFI (help: run again with `--bios=uefi`)") - return - - if not args.document: - download_bundled() - - if args.only_run: - iso_path = os.path.join(BUILD_DIR, 'aero.iso') - - if not os.path.exists(iso_path): - user_bins = build_userland(args) - kernel_bin = build_kernel(args) - - if not kernel_bin or args.check: - return - - kernel_bin = kernel_bin[0] - iso_path = prepare_iso(args, kernel_bin, user_bins) - run_in_emulator(build_info, iso_path) - elif args.clean: - src_target = os.path.join('src', 'target', args.target) - userland_target = os.path.join('userland', 'target') - - if os.path.exists(src_target): - shutil.rmtree(src_target) - - if os.path.exists(userland_target): - shutil.rmtree(userland_target) - elif args.sysroot: - build_userland_sysroot(False) - elif args.document: - build_kernel(args) - - generate_docs(args) - else: - user_bins = build_userland(args) - kernel_bin = build_kernel(args) - - if not kernel_bin or args.check: - return - - if not user_bins: - user_bins = [] - - kernel_bin = kernel_bin[0] - iso_path = prepare_iso(args, kernel_bin, user_bins) - - t1 = time.time() - log_info(f"build completed in {t1 - t0:.2f} seconds") - if not args.no_run: - run_in_emulator(build_info, iso_path) - - -if __name__ == '__main__': - try: - main() - except KeyboardInterrupt: - pass diff --git a/bootstrap.yml b/bootstrap.yml deleted file mode 100644 index 9b8c3f297d0..00000000000 --- a/bootstrap.yml +++ /dev/null @@ -1,2647 +0,0 @@ -imports: - - file: bootstrap/xorg.yml - - file: bootstrap/x11-themes.yml - - file: bootstrap/net.yml - - file: bootstrap/vcs.yml - - file: bootstrap/db.yml - - file: bootstrap/editors.yml - - file: bootstrap/app-misc.yml - -general: - cargo: - config_toml: 'extra-files/rust/config.toml' - -sources: - - name: binutils - subdir: 'bundled' - git: 'git://sourceware.org/git/binutils-gdb.git' - tag: 'binutils-2_37' - version: '2.37' - patch-path-strip: 1 - - - name: gcc - subdir: 'bundled' - git: 'git://gcc.gnu.org/git/gcc.git' - tag: 'releases/gcc-13.2.0' - patch-path-strip: 1 - version: '13.2.0' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - regenerate: - # download_prerequisites should probably move to some "post_checkout" step. - - args: ['./contrib/download_prerequisites'] - workdir: '@THIS_SOURCE_DIR@' - - args: ['autoconf'] - workdir: '@THIS_SOURCE_DIR@/gcc' - - args: ['autoconf'] - workdir: '@THIS_SOURCE_DIR@/libstdc++-v3' - - args: ['cp', - '@BUILD_ROOT@/tools/host-automake-v1.16/share/automake-1.16/config.sub', - '@THIS_SOURCE_DIR@/'] - - args: ['cp', - '@BUILD_ROOT@/tools/host-automake-v1.16/share/automake-1.16/config.sub', - '@THIS_SOURCE_DIR@/gmp-6.2.1/configfsf.sub'] - - args: ['cp', - '@BUILD_ROOT@/tools/host-automake-v1.16/share/automake-1.16/config.sub', - '@THIS_SOURCE_DIR@/isl-0.24/config.sub'] - - args: ['cp', '-f', - '@BUILD_ROOT@/tools/host-automake-v1.16/share/automake-1.16/config.sub', - '@THIS_SOURCE_DIR@/mpc-1.2.1/config.sub'] - - args: ['cp', - '@BUILD_ROOT@/tools/host-automake-v1.16/share/automake-1.16/config.sub', - '@THIS_SOURCE_DIR@/mpfr-4.1.0/config.sub'] - - - name: mlibc - subdir: 'bundled' - git: 'https://github.com/aero-os/mlibc' - branch: 'master' - - - name: tzcode - subdir: 'bundled' - url: 'https://data.iana.org/time-zones/releases/tzcode2022a.tar.gz' - format: 'tar.gz' - version: '2022a' - - - name: tzdata - subdir: 'bundled' - sources_required: ['tzcode'] - url: 'https://data.iana.org/time-zones/releases/tzdata2022a.tar.gz' - format: 'tar.gz' - version: '2022a' - regenerate: - - args: ['cp', '-r', '@THIS_SOURCE_DIR@/../tzcode/.', '@THIS_SOURCE_DIR@/'] - - - name: rust - subdir: 'bundled' - git: 'https://github.com/aero-os/rust.git' - branch: 'master' - commit: 'dee2030a44019048171c03d7ddcb134b945df8c5' - - - name: llvm - subdir: 'bundled' - git: 'https://github.com/llvm/llvm-project.git' - tag: 'llvmorg-17.0.3' - version: '17.0.3' - - - name: glib - subdir: 'bundled' - git: 'https://gitlab.gnome.org/GNOME/glib.git' - tag: '2.74.7' - version: '2.74.7' - - # --------------------------------------------------------------------------- - # Rust patched crates start - # --------------------------------------------------------------------------- - - name: rust-libc - subdir: 'bundled' - git: 'https://github.com/Andy-Python-Programmer/libc.git' - commit: 'fe4e9cda46b0be8421b0f56df0b63b8c4dcaf5e6' - branch: 'master' - - - name: rust-num-cpus - subdir: 'bundled' - git: 'https://github.com/seanmonstar/num_cpus.git' - tag: 'v1.15.0' - version: '1.15.0' - - - name: rust-users - subdir: 'bundled' - git: 'https://github.com/ogham/rust-users.git' - tag: 'v0.11.0' - version: '0.11.0' - - - name: rust-winit - subdir: 'bundled' - git: 'https://github.com/rust-windowing/winit.git' - tag: 'v0.26.1' - version: '0.26.1' - - - name: rust-mio-0.8 - subdir: 'bundled' - git: 'https://github.com/tokio-rs/mio.git' - tag: 'v0.8.3' - version: '0.8.3' - - - name: rust-nix - subdir: 'bundled' - git: 'https://github.com/nix-rust/nix.git' - tag: 'v0.22.3' - version: '0.22.3' - - - name: rust-mio-0.6 - subdir: 'bundled' - git: 'https://github.com/tokio-rs/mio.git' - tag: 'v0.6.23' - version: '0.6.23' - - - name: rust-glutin - subdir: 'bundled' - git: 'https://github.com/rust-windowing/glutin.git' - tag: 'v0.28.0' - version: '0.28.0' - - - name: rust-shared-library - subdir: 'bundled' - git: 'https://github.com/tomaka/shared_library.git' - commit: 'f09e038246a559650c8505b3b3831b820d1a5689' - branch: 'master' - version: '0.1.9' - - - name: rust-libloading - subdir: 'bundled' - git: 'https://github.com/nagisa/rust_libloading.git' - tag: '0.7.3' - version: '0.7.3' - - - name: rust-getrandom - subdir: 'bundled' - git: 'https://github.com/rust-random/getrandom.git' - tag: 'v0.2.9' - version: '0.2.9' - - - name: rust-rustix - subdir: 'bundled' - git: 'https://github.com/bytecodealliance/rustix' - branch: 'main' - # For some reason they do not have a release tag for the latest release. Bruh momento. - commit: '2eedbb2fa1e18a11f44df10fa41ef82a6756caf3' - - - name: rust-patched-libs - subdir: 'bundled' - sources_required: - - name: rust-libc - recursive: true - - name: rust-num-cpus - recursive: true - - name: rust-users - recursive: true - - name: rust-winit - recursive: true - - name: rust-shared-library - recursive: true - - name: rust-mio-0.8 - recursive: true - - name: rust-mio-0.6 - recursive: true - - name: rust-nix - recursive: true - - name: rust-glutin - recursive: true - - name: rust-libloading - recursive: true - - name: rust-getrandom - recursive: true - - name: rust-rustix - recursive: true - # --------------------------------------------------------------------------- - # Rust patched crates end - # --------------------------------------------------------------------------- - - - name: python - subdir: 'bundled' - patch-path-strip: 1 - git: 'https://github.com/python/cpython.git' - tag: 'v3.8.2' - version: '3.8.2' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - regenerate: - - args: ['autoreconf', '-f', '-i'] - - - name: 'pkg-config' - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/pkg-config/pkg-config.git' - tag: 'pkg-config-0.29.2' - version: '0.29.2' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - regenerate: - - args: ['./autogen.sh'] - environ: - 'NOCONFIGURE': 'yes' - - # - name: wayland - # subdir: 'bundled' - # git: 'https://github.com/wayland-project/wayland.git' - # tag: '1.20.0' - # version: '1.20.0' - - - name: libxtrans - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxtrans.git' - tag: 'xtrans-1.4.0' - version: '1.4.0' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - - - name: icu - subdir: 'bundled' - git: 'https://github.com/unicode-org/icu.git' - tag: 'release-73-2' - version: '73.2' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - regenerate: - - args: ['cp', - '@BUILD_ROOT@/tools/host-automake-v1.16/share/automake-1.16/config.sub', - '@THIS_SOURCE_DIR@/icu4c/source'] - -tools: - - name: host-glib - exports_aclocal: true - from_source: glib - configure: - - args: - - 'meson' - - '--prefix=@PREFIX@' - - '--libdir=lib' - - '@THIS_SOURCE_DIR@' - compile: - - args: ['ninja'] - install: - - args: ['ninja', 'install'] - - - name: host-cmake - source: - subdir: 'bundled' - git: 'https://gitlab.kitware.com/cmake/cmake.git' - tag: 'v3.24.2' - version: '3.24.2' - configure: - - args: - - '@THIS_SOURCE_DIR@/bootstrap' - - '--prefix=@PREFIX@' - - '--parallel=@PARALLELISM@' - compile: - - args: ['make', '-j@PARALLELISM@'] - install: - - args: ['make', 'install'] - - args: ['ln', '-sf', '@SOURCE_ROOT@/userland/aero.cmake', '@PREFIX@/share/cmake-3.24/Modules/Platform/'] - - # We could run an external pkg-config; however, we need the aclocal files. - # The easiest way to ensure that they are available is to just install pkg-config. - - name: host-pkg-config - exports_aclocal: true - from_source: pkg-config - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--prefix=@PREFIX@' - - '--with-internal-glib' - compile: - - args: ['make', '-j@PARALLELISM@'] - install: - - args: ['make', 'install'] - - - name: host-autoconf-v2.69 - source: - name: autoconf-v2.69 - subdir: 'bundled' - url: 'https://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.xz' - format: 'tar.xz' - extract_path: 'autoconf-2.69' - patch-path-strip: 3 - version: '2.69' - configure: - - args: ['@THIS_SOURCE_DIR@/configure', '--prefix=@PREFIX@'] - compile: - - args: ['make', '-j@PARALLELISM@'] - install: - - args: ['make', 'install'] - - - - name: host-autoconf-v2.13 - source: - name: autoconf-v2.13 - subdir: 'bundled' - url: 'https://ftp.gnu.org/gnu/autoconf/autoconf-2.13.tar.gz' - format: 'tar.gz' - extract_path: 'autoconf-2.13' - patch-path-strip: 3 - version: '2.13' - configure: - - args: ['@THIS_SOURCE_DIR@/configure', '--prefix=@PREFIX@'] - compile: - - args: ['make', '-j@PARALLELISM@'] - install: - - args: ['make', 'install'] - - - name: host-automake-v1.16 - source: - name: automake-v1.16 - subdir: 'bundled' - git: 'https://github.com/autotools-mirror/automake' - tag: 'v1.16.5' - version: '1.16.5' - tools_required: - - host-autoconf-v2.69 - regenerate: - - args: ['./bootstrap'] - tools_required: - - host-autoconf-v2.69 - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--prefix=@PREFIX@' - compile: - - args: | - set -e - export PATH="`pwd`/bin:$PATH" - make bin/aclocal-1.16 bin/automake-1.16 -j@PARALLELISM@ - make -j@PARALLELISM@ - install: - - args: ['make', 'install-strip'] - - args: ['ln', '-sf', '@PREFIX@/share/aclocal-1.16', '@PREFIX@/share/aclocal'] - - - name: host-autoconf-archive - exports_aclocal: true - source: - subdir: 'bundled' - git: 'https://github.com/autoconf-archive/autoconf-archive.git' - tag: 'v2019.01.06' - version: '2019.01.06' - install: - - args: ['mkdir', '-p', '@BUILD_ROOT@/tools/host-autoconf-archive/share/'] - - args: ['cp', '-r', '@THIS_SOURCE_DIR@/m4', '@BUILD_ROOT@/tools/host-autoconf-archive/share/aclocal'] - - - name: host-rust - from_source: rust - tools_required: - - host-llvm - sources_required: - - rust-patched-libs - compile: - - args: | - cat << EOF > config.toml - change-id = 115898 - - [llvm] - download-ci-llvm = false - targets = "X86" - - [build] - target = ["x86_64-unknown-aero", "x86_64-unknown-linux-gnu"] - build-dir = "@THIS_BUILD_DIR@" - docs = false - - [install] - prefix = "@PREFIX@" - sysconfdir = "@PREFIX@/etc" - - [rust] - codegen-tests = false - deny-warnings = false # work around rust-num-cpus warning - - [target.x86_64-unknown-linux-gnu] - llvm-config = "@BUILD_ROOT@/tools/host-llvm/bin/llvm-config" - - [target.x86_64-unknown-aero] - llvm-config = "@BUILD_ROOT@/tools/host-llvm/bin/llvm-config" - EOF - - args: ['python3', '@THIS_SOURCE_DIR@/x.py', 'build', '--stage', '2', '-j', '@PARALLELISM@'] - install: - - args: ['python3', '@THIS_SOURCE_DIR@/x.py', 'install', '-j', '@PARALLELISM@'] - - # - name: host-cargo - # source: - # subdir: 'bundled' - # git: 'https://github.com/rust-lang/cargo.git' - # tag: '0.61.0' - # version: '0.61.0' - # tools_required: - # - tool: host-rust - # recursive: true - # - tool: host-gcc # GCC is used for linking - # recursive: true - # sources_required: - # # This cargo runs on the host, so we don't actually need any patches here. We just - # # add the sources used by cargo so that the dependency resolver doesn't complain. - # - rust-patched-libs - # - host-bootstrap-cargo - # compile: - # - args: - # - 'cargo' - # - 'install' - # - '--target' - # - 'x86_64-unknown-linux-gnu' - # - '--target-dir' - # - '@THIS_BUILD_DIR@' - # - '--path' - # - '@THIS_SOURCE_DIR@' - # - '-j@PARALLELISM@' - # - '--root' - # - '@PREFIX@' - - - name: host-python - from_source: python - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--prefix=@PREFIX@' - compile: - - args: ['make', '-j@PARALLELISM@'] - install: - - args: ['make', 'install'] - - - name: host-icu - from_source: icu - configure: - - args: - - '@THIS_SOURCE_DIR@/icu4c/source/configure' - - '--prefix=@PREFIX@' - compile: - - args: ['make', '-j@PARALLELISM@'] - install: - - args: ['make', 'install'] - - - name: host-binutils - from_source: binutils - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--prefix=@PREFIX@' - - '--target=x86_64-aero' - - '--with-sysroot=@SYSROOT_DIR@' - # On recent compilers, binutils 2.26 causes implicit-fallthrough warnings, among others. - - '--disable-werror' - - '--enable-targets=x86_64-elf,x86_64-pe' - # -g blows up the binary size. - - 'CFLAGS=-pipe' - compile: - - args: ['make', '-j@PARALLELISM@'] - install: - - args: ['make', 'install'] - - - name: host-gcc - from_source: gcc - tools_required: - - tool: host-binutils - recursive: true - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--prefix=@PREFIX@' - - '--target=x86_64-aero' - - '--with-sysroot=@SYSROOT_DIR@' - - '--enable-languages=c,c++' - - '--disable-multilib' - - '--enable-initfini-array' - # -g blows up GCC's binary size. - - 'CFLAGS=-O2 -pipe' - - 'CXXFLAGS=-O2 -pipe' - stages: - - name: compiler - pkgs_required: - - mlibc-headers - compile: - - args: ['make', '-j@PARALLELISM@', 'all-gcc'] - install: - - args: ['make', 'install-gcc'] - # GCC does *not* look for target-prefixed LD/AS. - # Instead, it searches a list of prefix directories. Link AS/LD to make it happy. - - args: ['mkdir', '-p', '@PREFIX@/x86_64-aero/bin'] - - args: ['ln', '-sf', '../../../host-binutils/x86_64-aero/bin/as', - '@PREFIX@/x86_64-aero/bin/as'] - - args: ['ln', '-sf', '../../../host-binutils/x86_64-aero/bin/ld', - '@PREFIX@/x86_64-aero/bin/ld'] - - name: libgcc - tools_required: - - tool: host-gcc - stage_dependencies: [compiler] - pkgs_required: - - mlibc - compile: - - args: ['make', '-j@PARALLELISM@', 'all-target-libgcc'] - install: - - args: ['make', 'install-strip-target-libgcc'] - - - name: libstdc++ - tools_required: - - tool: host-gcc - stage_dependencies: [libgcc] - compile: - - args: ['make', '-j@PARALLELISM@', 'all-target-libstdc++-v3'] - install: - - args: ['make', 'install-strip-target-libstdc++-v3'] - - - name: bootstrap-host-gcc - from_source: gcc - tools_required: - - tool: host-binutils - recursive: true - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--prefix=@PREFIX@' - - '--target=x86_64-aero' - - '--with-sysroot=@SYSROOT_DIR@' - - '--enable-languages=c,c++' - - '--disable-multilib' - - '--disable-shared' - - '--enable-initfini-array' - # -g blows up GCC's binary size. - - 'CFLAGS=-O2' - - 'CXXFLAGS=-O2' - stages: - - name: compiler - pkgs_required: - - mlibc-headers - compile: - # GCC complains if the include directory is non-existant. - - args: ['mkdir', '-p', '@SYSROOT_DIR@/usr/include'] - - args: ['make', '-j@PARALLELISM@', 'inhibit_libc=true', 'all-gcc'] - install: - - args: ['make', 'install-gcc'] - # GCC does *not* look for target-prefixed LD/AS. - # Instead, it searches a list of prefix directories. Link AS/LD to make it happy. - - args: ['mkdir', '-p', '@PREFIX@/x86_64-aero/bin'] - - args: ['ln', '-sf', '../../../cross-binutils/x86_64-aero/bin/as', - '@PREFIX@/x86_64-aero/bin/as'] - - args: ['ln', '-sf', '../../../cross-binutils/x86_64-aero/bin/ld', - '@PREFIX@/x86_64-aero/bin/ld'] - - - name: libgcc - tools_required: - - tool: bootstrap-host-gcc - stage_dependencies: [compiler] - compile: - - args: ['make', '-j@PARALLELISM@', 'inhibit_libc=true', 'all-target-libgcc'] - install: - - args: ['make', 'install-target-libgcc'] - - - name: host-llvm - from_source: llvm - sources_required: - - binutils - configure: - - args: - - 'cmake' - - '-GNinja' - - '-DCMAKE_INSTALL_PREFIX=@PREFIX@' - # LLVM configuration options. - # We really have to build LLVM in Release mode. - # Building it in debug mode produces tens of GiB of debugging info. - - '-DCMAKE_BUILD_TYPE=Release' - - '-DLLVM_TARGETS_TO_BUILD=X86' - - '-DLLVM_ENABLE_PROJECTS=llvm;clang;clang-tools-extra' - - '-DLLVM_ENABLE_Z3_SOLVER=OFF' - # clang configuration options. - - '-DDEFAULT_SYSROOT=@SYSROOT_DIR@' - # Gold linker configuration options. - - '-DLLVM_BINUTILS_INCDIR=@SOURCE_ROOT@/bundled/binutils/include' - - '@THIS_SOURCE_DIR@/llvm' - compile: - - args: ['ninja', '-j@PARALLELISM@'] - # Build on a single CPU to prevent OOM on smaller systems. - #- args: ['ninja', '-j1'] - install: - - args: ['ninja', 'install', '-j@PARALLELISM@'] - # quiet: true - - - name: host-libtool - exports_aclocal: true - source: - name: libtool - subdir: 'bundled' - git: 'https://git.savannah.gnu.org/git/libtool.git' - tag: 'v2.4.6' - version: '2.4.6' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - regenerate: - # libtool's ./bootstrap does a shallow clone with insufficient depth. - - args: ['git', 'submodule', 'update', '--init'] - - args: ['./bootstrap'] - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--prefix=@PREFIX@' - compile: - - args: ['make', '-j@PARALLELISM@'] - install: - - args: ['make', 'install'] - - # - name: wayland-scanner - # from_source: wayland - # tools_required: - # - virtual: pkgconfig-for-host - # program_name: host-pkg-config - # configure: - # - args: - # - 'meson' - # - '--native-file' - # - '@SOURCE_ROOT@/userland/native-file.ini' - # - '--prefix=@PREFIX@' - # - '-Ddtd_validation=false' - # - '-Ddocumentation=false' - # - '-Dscanner=true' - # - '-Dlibraries=false' - # - '@THIS_SOURCE_DIR@' - # compile: - # - args: ['ninja'] - # install: - # - args: ['ninja', 'install'] - -packages: - - name: llvm - from_source: llvm - tools_required: - - host-cmake - - host-gcc - pkgs_required: - - mlibc - - zlib - configure: - - args: - - 'cmake' - - '-GNinja' - - '-DCMAKE_TOOLCHAIN_FILE=@SOURCE_ROOT@/userland/CMakeToolchain-x86_64.cmake' - - '-DCMAKE_INSTALL_PREFIX=/usr' - # We really have to build LLVM in Release mode. - # Building it in debug mode produces tens of GiB of debugging info. - - '-DCMAKE_BUILD_TYPE=Release' - - '-DLLVM_LINK_LLVM_DYLIB=ON' - # RTTI affects the ABI. Hence, we enable it. - - '-DLLVM_ENABLE_RTTI=ON' - - '-DLLVM_TARGETS_TO_BUILD=X86' - - '-DLLVM_TARGET_ARCH=X86_64' - - '-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-aero' - - '-DLLVM_HOST_TRIPLE=x86_64-aero' - # Disable linking against ncurses, which we do not build with -fPIC. - - '-DLLVM_ENABLE_TERMINFO=OFF' - # Suppress developer warnings - - '-Wno-dev' - - '@THIS_SOURCE_DIR@/llvm' - build: - - args: ['ninja', '-j@PARALLELISM@'] - - args: ['ninja', 'install/strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: alacritty - source: - subdir: 'bundled' - git: 'https://github.com/alacritty/alacritty' - tag: 'v0.10.1' - version: '0.10.1' - tools_required: - - host-rust - - host-gcc - sources_required: - - rust-patched-libs - pkgs_required: - - mlibc - - fontconfig - - freetype - - libx11 - configure: - - args: ['python3', '@SOURCE_ROOT@/tools/cargo-inject-patches.py', '@THIS_SOURCE_DIR@/Cargo.toml'] - build: - - args: ['install', '-D', '@THIS_SOURCE_DIR@/alacritty.yml', '@THIS_COLLECT_DIR@/root/.alacritty.yml'] - - args: - - 'cargo' - - 'install' - - '--no-default-features' - - '--features' - - 'x11' - - '--locked' - - '--target-dir' - - '@THIS_BUILD_DIR@' - - '--path' - - '@THIS_SOURCE_DIR@/alacritty' - - '--root' - - '@THIS_COLLECT_DIR@/usr' - - '-j@PARALLELISM@' - environ: - RUSTFLAGS: '-Cforce-frame-pointers=yes -Clink-args=-no-pie' - - - name: neofetch - source: - subdir: bundled - git: 'https://github.com/Andy-Python-Programmer/neofetch' - branch: 'master' - configure: - - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] - build: - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # - name: ripgrep - # source: - # subdir: bundled - # git: 'https://github.com/BurntSushi/ripgrep.git' - # tag: '12.1.1' - # version: '12.1.1' - # tools_required: - # - host-cargo - # sources_required: - # - rust-patched-libs - # pkgs_required: - # - mlibc - # configure: - # - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] - # # cc: https://github.com/rust-lang/cargo/issues/10283 - # # - args: ['python3', '@SOURCE_ROOT@/tools/cargo-inject-patches.py', '@THIS_SOURCE_DIR@/Cargo.toml'] - # build: - # - args: ['python3', '@SOURCE_ROOT@/tools/cargo-inject-patches.py', './Cargo.toml'] - # - args: - # - 'cargo' - # - 'install' - # - '--locked' - # - '--path' - # - '.' - # - '--root' - # - '@THIS_COLLECT_DIR@/usr' - # - '-j@PARALLELISM@' - - # - name: hex - # source: - # subdir: bundled - # git: 'https://github.com/sitkevij/hex' - # tag: 'v0.4.2' - # version: '0.4.2' - # tools_required: - # - host-cargo - # sources_required: - # - rust-patched-libs - # pkgs_required: - # - mlibc - # configure: - # # cc: https://github.com/rust-lang/cargo/issues/10283 - # # - args: ['python3', '@SOURCE_ROOT@/tools/cargo-inject-patches.py', '@THIS_SOURCE_DIR@/Cargo.toml'] - # - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] - # build: - # - args: ['python3', '@SOURCE_ROOT@/tools/cargo-inject-patches.py', './Cargo.toml'] - # - args: - # - 'cargo' - # - 'install' - # - '--locked' - # - '--path' - # - '.' - # - '--root' - # - '@THIS_COLLECT_DIR@/usr' - # - '-j@PARALLELISM@' - - # - name: bat - # source: - # subdir: 'bundled' - # git: 'https://github.com/sharkdp/bat' - # tag: 'v0.23.0' - # version: '0.23.0' - # tools_required: - # - host-rust - # - host-gcc - # sources_required: - # - rust-patched-libs - # pkgs_required: - # - mlibc - # configure: - # - args: ['python3', '@SOURCE_ROOT@/tools/cargo-inject-patches.py', '@THIS_SOURCE_DIR@/Cargo.toml'] - # build: - # - args: - # - 'cargo' - # - 'install' - # - '--locked' - # - '--root' - # - '@THIS_COLLECT_DIR@/usr' - # - '-j@PARALLELISM@' - # - '--target-dir' - # - '@THIS_BUILD_DIR@' - # - '--path' - # - '@THIS_SOURCE_DIR@' - - - name: quickjs - source: - subdir: bundled - git: 'https://github.com/bellard/quickjs' - branch: master - commit: 'b5e62895c619d4ffc75c9d822c8d85f1ece77e5b' - tools_required: - - host-gcc - configure: - - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] - build: - - args: ['make', '-j@PARALLELISM@', 'CROSS_PREFIX=x86_64-aero-'] - - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/usr/bin'] - - args: ['cp', '@THIS_BUILD_DIR@/qjs', '@THIS_COLLECT_DIR@/usr/bin/qjs'] - - # - name: sd - # source: - # subdir: bundled - # git: 'https://github.com/chmln/sd' - # tag: 'v0.7.6' - # version: '0.7.6' - # tools_required: - # - host-cargo - # sources_required: - # - rust-patched-libs - # pkgs_required: - # - mlibc - # configure: - # - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] - # # cc: https://github.com/rust-lang/cargo/issues/10283 - # # - args: ['python3', '@SOURCE_ROOT@/tools/cargo-inject-patches.py', '@THIS_SOURCE_DIR@/Cargo.toml'] - # build: - # - args: ['python3', '@SOURCE_ROOT@/tools/cargo-inject-patches.py', './Cargo.toml'] - # - args: - # - 'cargo' - # - 'install' - # - '--locked' - # - '--path' - # - '.' - # - '--root' - # - '@THIS_COLLECT_DIR@/usr' - # - '-j@PARALLELISM@' - - # - name: llvm - # from_source: llvm - # tools_required: - # - host-gcc - # - host-cmake - # pkgs_required: - # - mlibc - # - zlib - # revision: 3 - # configure: - # - args: - # - 'cmake' - # - '-GNinja' - # - '-DCMAKE_TOOLCHAIN_FILE=@SOURCE_ROOT@/userland/CMakeToolchain-x86_64.txt' - # - '-DCMAKE_INSTALL_PREFIX=/usr' - # # We really have to build LLVM in Release mode. - # # Building it in debug mode produces tens of GiB of debugging info. - # - '-DCMAKE_BUILD_TYPE=Release' - # - '-DLLVM_LINK_LLVM_DYLIB=ON' - # # RTTI affects the ABI. Hence, we enable it. - # - '-DLLVM_ENABLE_RTTI=ON' - # - '-DLLVM_TARGETS_TO_BUILD=X86' - # - '-DLLVM_TARGET_ARCH=X86_64' - # - '-DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-aero' - # - '-DLLVM_HOST_TRIPLE=x86_64-aero' - # # Disable linking against ncurses, which we do not build with -fPIC. - # - '-DLLVM_ENABLE_TERMINFO=OFF' - # # Suppress developer warnings - # - '-Wno-dev' - # - '@THIS_SOURCE_DIR@/llvm' - # build: - # - args: ['ninja'] - # - args: ['ninja', 'install'] - # environ: - # DESTDIR: '@THIS_COLLECT_DIR@' - - - name: linux-headers - source: - subdir: 'bundled' - url: 'https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.1.8.tar.xz' - checksum: 'blake2b:1eeab95bf09757131031ebeaa3fb66f01626ecfe3b72d0044176613d027ac6643c688a0bb8f4493ae6faa3d3bf0c89fcdff3c28d7b8375e59ed6e8bd6d856e44' - extract_path: 'linux-6.1.8' - format: 'tar.xz' - version: '6.1.8' - implict_package: true - configure: - - args: ['cp', '-Tr', '@THIS_SOURCE_DIR@', '.'] - build: - - args: ['make', 'ARCH=x86_64', 'headers_install'] - - args: ['find', 'usr/include', '-type', 'f', '!', '-name', '*.h', '-delete'] - - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/usr'] - # remove this file, as mlibc will override this file with one suited to mlibc - - args: ['rm', 'usr/include/linux/libc-compat.h'] - - args: ['cp', '-r', 'usr/include', '@THIS_COLLECT_DIR@/usr'] - - - name: mlibc-headers - from_source: mlibc - implict_package: true - pkgs_required: - - linux-headers - configure: - - args: - - 'meson' - - 'setup' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '-Dheaders_only=true' - - '-Ddisable_iconv_option=true' - - '--buildtype=release' - - '-Dlinux_kernel_headers=@BUILD_ROOT@/packages/linux-headers/usr/include' - - '-Ddisable_intl_option=true' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: mlibc - from_source: mlibc - tools_required: - - bootstrap-host-gcc - implict_package: true - pkgs_required: - - mlibc-headers - - linux-headers - configure: - - args: - - 'meson' - - 'setup' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '--libdir=lib' - - '-Dmlibc_no_headers=true' - - '-Ddisable_iconv_option=true' - - '--buildtype=debug' - - '-Dlinux_kernel_headers=@BUILD_ROOT@/packages/linux-headers/usr/include' - - '-Ddisable_intl_option=true' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: libdrm - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/mesa/drm' - tag: 'libdrm-2.4.110' - version: '2.4.110' - tools_required: - - host-gcc - pkgs_required: - - mlibc - configure: - - args: - - 'meson' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '--libdir=lib' - - '--buildtype=debugoptimized' - - '-Dintel=false' - - '-Dvmwgfx=false' - - '-Dradeon=false' - - '-Damdgpu=false' - - '-Dnouveau=false' - - '-Dman-pages=false' - # We might want to build cairo with OpenGL support. - # Doing so would introduce a circular dependency here. - - '-Dcairo-tests=false' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: drm_test - source: - subdir: 'bundled' - # copied from https://github.com/dvdhrm/docs/tree/master/drm-howto - # - # changes: compile to the aero target instead of the linux one. - git: 'https://github.com/aero-os/drm_test' - branch: 'master' - tools_required: - - host-gcc - pkgs_required: - - libdrm - - mlibc - configure: - - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] - build: - - args: ['make'] - - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/usr/bin'] - - args: ['mv', 'drm', '@THIS_COLLECT_DIR@/usr/bin'] - - - name: nyancat - source: - subdir: 'bundled' - git: 'https://github.com/klange/nyancat.git' - tag: '1.5.2' - version: '1.5.2' - tools_required: - - host-gcc - pkgs_required: - - mlibc - configure: - - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] - build: - - args: ['make', '-j@PARALLELISM@'] - environ: - CC: "x86_64-aero-gcc" - - args: ['mkdir', '-pv', '@THIS_COLLECT_DIR@/usr/bin'] - - args: ['mkdir', '-pv', '@THIS_COLLECT_DIR@/usr/share/man/man1'] - - args: ['cp', '-v', '@THIS_BUILD_DIR@/src/nyancat', '@THIS_COLLECT_DIR@/usr/bin'] - - args: ['cp', '-v', '@THIS_BUILD_DIR@/nyancat.1', '@THIS_COLLECT_DIR@/usr/share/man/man1'] - - - name: coreutils - source: - subdir: 'bundled' - url: 'https://ftp.gnu.org/gnu/coreutils/coreutils-8.32.tar.xz' - format: 'tar.xz' - extract_path: 'coreutils-8.32' - patch-path-strip: 3 - tools_required: - - host-gcc - configure: - # Huge hack: coreutils does not compile the build-machine binary make-prime-list - # using the build-machine compiler. Hence, build and invoke the binary manually here. - - args: - - '@THIS_SOURCE_DIR@/configure' - - args: ['make', 'src/make-prime-list'] - - args: | - ./src/make-prime-list 5000 > @THIS_SOURCE_DIR@/src/primes.h - - args: ['make', 'clean'] - # No compile coreutils for the correct target. - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - 'CFLAGS=-DSLOW_BUT_NO_HACKS -Wno-error' - - '--enable-install-program=hostname' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: tzdata - from_source: tzdata - tools_required: - - host-gcc - pkgs_required: - - mlibc - configure: - - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@/'] - build: - # Build and install support programs - - args: ['make', 'CC=x86_64-aero-gcc', 'AR=x86_64-aero-ar'] - - args: ['make', 'install', 'DESTDIR=@THIS_COLLECT_DIR@', 'ZIC=zic'] - # Create the required directories - - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/etc'] - - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/usr/share/zoneinfo/posix'] - - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/usr/share/zoneinfo/right'] - # Create the time zone files without leap seconds, convention puts these in both zoneinfo and zoneinfo/posix. - # After that. create time time zone files with leap seconds - - args: | - set -e - zic -L /dev/null -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo "@THIS_BUILD_DIR@"/etcetera - zic -L /dev/null -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo/posix "@THIS_BUILD_DIR@"/etcetera - zic -L "@THIS_SOURCE_DIR@"/leapseconds -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo/right "@THIS_BUILD_DIR@"/etcetera - zic -L /dev/null -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo "@THIS_BUILD_DIR@"/southamerica - zic -L /dev/null -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo/posix "@THIS_BUILD_DIR@"/southamerica - zic -L "@THIS_SOURCE_DIR@"/leapseconds -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo/right "@THIS_BUILD_DIR@"/southamerica - zic -L /dev/null -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo "@THIS_BUILD_DIR@"/northamerica - zic -L /dev/null -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo/posix "@THIS_BUILD_DIR@"/northamerica - zic -L "@THIS_SOURCE_DIR@"/leapseconds -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo/right "@THIS_BUILD_DIR@"/northamerica - zic -L /dev/null -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo "@THIS_BUILD_DIR@"/europe - zic -L /dev/null -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo/posix "@THIS_BUILD_DIR@"/europe - zic -L "@THIS_SOURCE_DIR@"/leapseconds -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo/right "@THIS_BUILD_DIR@"/europe - zic -L /dev/null -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo "@THIS_BUILD_DIR@"/africa - zic -L /dev/null -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo/posix "@THIS_BUILD_DIR@"/africa - zic -L "@THIS_SOURCE_DIR@"/leapseconds -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo/right "@THIS_BUILD_DIR@"/africa - zic -L /dev/null -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo "@THIS_BUILD_DIR@"/antarctica - zic -L /dev/null -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo/posix "@THIS_BUILD_DIR@"/antarctica - zic -L "@THIS_SOURCE_DIR@"/leapseconds -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo/right "@THIS_BUILD_DIR@"/antarctica - zic -L /dev/null -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo "@THIS_BUILD_DIR@"/asia - zic -L /dev/null -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo/posix "@THIS_BUILD_DIR@"/asia - zic -L "@THIS_SOURCE_DIR@"/leapseconds -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo/right "@THIS_BUILD_DIR@"/asia - zic -L /dev/null -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo "@THIS_BUILD_DIR@"/australasia - zic -L /dev/null -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo/posix "@THIS_BUILD_DIR@"/australasia - zic -L "@THIS_SOURCE_DIR@"/leapseconds -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo/right "@THIS_BUILD_DIR@"/australasia - zic -L /dev/null -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo "@THIS_BUILD_DIR@"/backward - zic -L /dev/null -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo/posix "@THIS_BUILD_DIR@"/backward - zic -L "@THIS_SOURCE_DIR@"/leapseconds -d "@THIS_COLLECT_DIR@"/usr/share/zoneinfo/right "@THIS_BUILD_DIR@"/backward - # Create the posixrules file, POSIX requires daylight saving rules to be in accordance with US rules, thus use New York - - args: ['zic', '-d', '@THIS_COLLECT_DIR@/usr/share/zoneinfo', '-p', 'America/New_York'] - # Default to UTC for localtime, this should be fixed, but that is pending xbstrap support. - - args: ['ln', '-sf', '/usr/share/zoneinfo/UTC', '@THIS_COLLECT_DIR@/etc/localtime'] - - - name: ncurses - source: - subdir: 'bundled' - git: 'https://github.com/ThomasDickey/ncurses-snapshots.git' - tag: 'v6_2' - version: '6.2' - tools_required: - - host-gcc - - host-pkg-config - pkgs_required: - - mlibc - revision: 4 - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--without-ada' - - '--enable-pc-files' - - '--with-shared' - - '--without-normal' - - '--with-manpage-format=normal' - - '--with-pkg-config-libdir=/usr/lib/pkgconfig' - - '--with-termlib' - - '--enable-widec' - - '--disable-stripping' - environ: - cf_cv_func_nanosleep: 'yes' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'DESTDIR=@THIS_COLLECT_DIR@', 'install'] - # As we build ncurses with wide character support, make some compatibility links - - args: | - for lib in ncurses form panel menu tinfo ; do - rm -vf @THIS_COLLECT_DIR@/usr/lib/lib${lib}.so - echo "INPUT(-l${lib}w)" > @THIS_COLLECT_DIR@/usr/lib/lib${lib}.so - ln -sfv ${lib}w.pc @THIS_COLLECT_DIR@/usr/lib/pkgconfig/${lib}.pc - done - rm -vf @THIS_COLLECT_DIR@/usr/lib/libcursesw.so - echo "INPUT(-lncursesw)" > @THIS_COLLECT_DIR@/usr/lib/libcursesw.so - ln -sfv libncurses.so @THIS_COLLECT_DIR@/usr/lib/libcurses.so - - - name: gcc - from_source: gcc - revision: 2 - tools_required: - - host-gcc - pkgs_required: - - mlibc - - binutils - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--target=x86_64-aero' - - '--with-sysroot=/' - - '--with-build-sysroot=@SYSROOT_DIR@' - - '--enable-languages=c,c++' - - '--enable-initfini-array' - - '--disable-multilib' - - '--disable-nls' - # -g blows up GCC's binary size. - - 'CFLAGS=-O2 -pipe' - - 'CXXFLAGS=-O2 -pipe' - build: - - args: ['make', '-j@PARALLELISM@', 'all-gcc', 'all-target-libgcc'] - - args: ['make', 'install-strip-gcc', 'install-strip-target-libgcc'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - args: ['sh', '-c', 'cp -rv @BUILD_ROOT@/tools/host-gcc/x86_64-aero/lib/* @THIS_COLLECT_DIR@/usr/lib/'] - - args: ['sh', '-c', 'cp -rv @BUILD_ROOT@/tools/host-gcc/x86_64-aero/include/* @THIS_COLLECT_DIR@/usr/include/'] - - args: ['ln', '-s', '/usr/bin/gcc', '@THIS_COLLECT_DIR@/usr/bin/cc'] - - - name: binutils - from_source: binutils - tools_required: - - host-gcc - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--target=x86_64-aero' - - '--with-sysroot=/' - - '--disable-nls' - # On recent compilers, binutils 2.26 causes implicit-fallthrough warnings, among others. - - '--disable-werror' - - '--disable-gdb' - # -g blows up the binary size. - - 'CFLAGS=-pipe' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: bash - source: - git: 'https://github.com/bminor/bash' - # Checkout bash 5.1 - branch: 'master' - commit: '9439ce094c9aa7557a9d53ac7b412a23aa66e36b' - version: '5.1.16' - subdir: 'bundled' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - pkgs_required: - - mlibc - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--without-bash-malloc' - - '--disable-nls' - environ: - ac_cv_func_wcswidth: 'no' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'DESTDIR=@THIS_COLLECT_DIR@', 'install'] - - args: ['ln', '-sf', '/usr/bin/bash', '@THIS_COLLECT_DIR@/usr/bin/sh'] - - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/bin'] - - args: ['ln', '-sf', '/usr/bin/bash', '@THIS_COLLECT_DIR@/bin/sh'] - - - name: tcc - source: - subdir: 'bundled' - git: 'https://github.com/aero-os/tcc' - branch: master - patch-path-strip: 3 - tools_required: - - host-gcc - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--tccdir=/usr/lib/tcc' - - '--elfinterp=/usr/lib/ld.so' - - '--libpaths=/usr/lib' - - '--sysincludepaths=/usr/lib/tcc/include:/usr/include' - - '--cross-prefix=x86_64-aero-' - - '--cc=gcc' - - '--ar=ar' - - '--with-selinux' - - '--strip-binaries' - - '--prefix=/usr' - build: - - args: ['make'] - - args: ['make', 'DESTDIR=@THIS_COLLECT_DIR@', 'install-strip'] - - - name: nasm - source: - subdir: 'bundled' - url: 'http://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.xz' - format: 'tar.xz' - extract_path: 'nasm-2.14.02' - version: '2.14.02' - tools_required: - - host-gcc - pkgs_required: - - mlibc - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - 'CFLAGS=-g -O0' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: python - from_source: python - tools_required: - - host-gcc - - host-python - pkgs_required: - - mlibc - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--build=x86_64-linux-gnu' - - '--prefix=/usr' - - '--enable-shared' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - - '--with-system-ffi' - - '--with-system-expat' - - '--disable-ipv6' - - '--without-ensurepip' - environ: - CONFIG_SITE: '@SOURCE_ROOT@/extra-files/python/python-config-site' - PKG_CONFIG_SYSROOT_DIR: '@BUILD_ROOT@/system-root' - PKG_CONFIG_LIBDIR: '@BUILD_ROOT@/system-root/usr/lib/pkgconfig:@BUILD_ROOT@/system-root/usr/share/pkgconfig' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: doomgeneric - source: - subdir: 'bundled' - git: 'https://github.com/ozkl/doomgeneric.git' - branch: 'master' - commit: '2d9b24f07c78c36becf41d89db30fa99863463e5' - tools_required: - - host-gcc - pkgs_required: - - mlibc - build: - - args: ['make', '-C', '@THIS_SOURCE_DIR@/doomgeneric', '-f', 'Makefile', '-j@PARALLELISM@', 'CC=x86_64-aero-gcc'] - - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/usr/bin'] - - args: ['cp', '@THIS_SOURCE_DIR@/doomgeneric/doomgeneric', '@THIS_COLLECT_DIR@/usr/bin/doomgeneric'] - - - name: lua - source: - subdir: bundled - url: 'https://www.lua.org/ftp/lua-5.3.5.tar.gz' - format: 'tar.gz' - extract_path: 'lua-5.3.5' - version: '5.3.5' - tools_required: - - host-gcc - pkgs_required: - - mlibc - configure: - - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] - - args: - - 'sed' - - '-i' - - 's|^#define LUA_ROOT "/usr/local/"$|#define LUA_ROOT "/usr/"|' - - 'src/luaconf.h' - build: - - args: - - 'make' - - 'generic' - - 'CC=x86_64-aero-gcc' - - 'AR=x86_64-aero-ar rcu' - - 'RANLIB=x86_64-aero-ranlib' - - '-j@PARALLELISM@' - - args: ['make', 'install', 'INSTALL_TOP=@THIS_COLLECT_DIR@/usr'] - - # -------------------- wayland -------------------- - # - name: wayland-protocols - # source: - # subdir: 'bundled' - # git: 'https://github.com/wayland-project/wayland-protocols.git' - # tag: '1.24' - # version: '1.24' - # tools_required: - # - host-gcc - # - wayland-scanner - # configure: - # - args: - # - 'meson' - # - '--cross-file' - # - '@SOURCE_ROOT@/userland/cross-file.ini' - # - '--prefix=/usr' - # - '--buildtype=release' - # - '-Dtests=false' - # - '@THIS_SOURCE_DIR@' - # build: - # - args: ['ninja'] - # - args: ['ninja', 'install'] - # environ: - # DESTDIR: '@THIS_COLLECT_DIR@' - # quiet: true - - - name: libexpat - source: - subdir: 'bundled' - git: 'https://github.com/libexpat/libexpat.git' - tag: 'R_2_4_1' - version: '2.4.1' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - regenerate: - - args: ['./buildconf.sh'] - workdir: '@THIS_SOURCE_DIR@/expat' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-gcc - pkgs_required: - - mlibc - configure: - - args: - - '@THIS_SOURCE_DIR@/expat/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - # We disable xmlwf to avoid building its documentation. - - '--without-xmlwf' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - quiet: true - - - name: libffi - source: - subdir: 'bundled' - git: 'https://github.com/libffi/libffi.git' - tag: 'v3.4.2' - version: '3.4.2' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - regenerate: - - args: ['./autogen.sh'] - - args: ['cp', - '@BUILD_ROOT@/tools/host-automake-v1.16/share/automake-1.16/config.sub', - '@THIS_SOURCE_DIR@/'] - tools_required: - - host-gcc - pkgs_required: - - mlibc - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # - name: wayland - # from_source: wayland - # tools_required: - # - host-pkg-config - # - host-gcc - # - wayland-scanner - # - host-libtool - # - virtual: pkgconfig-for-target - # triple: "x86_64-aero" - # - virtual: pkgconfig-for-host - # program_name: host-pkg-config - # pkgs_required: - # - mlibc - # - libexpat - # - libffi - # configure: - # - args: - # - 'meson' - # - '--native-file' - # - '@SOURCE_ROOT@/userland/native-file.ini' - # - '--cross-file' - # - '@SOURCE_ROOT@/userland/cross-file.ini' - # - '--prefix=/usr' - # - '--buildtype=debugoptimized' - # - '-Ddtd_validation=false' - # - '-Ddocumentation=false' - # - '-Dscanner=false' - # - '@THIS_SOURCE_DIR@' - # environ: - # PKG_CONFIG_SYSROOT_DIR: '@BUILD_ROOT@/system-root' - # build: - # - args: ['ninja'] - # - args: ['ninja', 'install'] - # environ: - # DESTDIR: '@THIS_COLLECT_DIR@' - - - name: zlib - source: - subdir: 'bundled' - git: 'https://github.com/madler/zlib.git' - tag: 'v1.2.12' - version: '1.2.12' - tools_required: - - host-gcc - pkgs_required: - - mlibc - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - environ: - CHOST: 'x86_64-aero' - prefix: '/usr' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # zstd fast compression library - # - # This package provides the programs to interact with Zstandard compressed files. - - name: zstd - source: - subdir: bundled - git: 'https://github.com/facebook/zstd.git' - tag: 'v1.5.2' - version: '1.5.2' - tools_required: - - host-gcc - pkgs_required: - - mlibc - - zlib - - xz-utils - revision: 2 - configure: - - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] - build: - - args: ['make', '-j@PARALLELISM@'] - environ: - CC: 'x86_64-aero-gcc' - CXX: 'x86_64-aero-g++' - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - PREFIX: '/usr' - - # Utilities for managing LZMA compressed files - # - # This package provides the programs to compress and decompress lzma and - # xz compressed files. - - name: xz-utils - source: - subdir: 'bundled' - git: 'https://git.tukaani.org/xz.git' - tag: 'v5.2.5' - version: '5.2.5' - disable_shallow_fetch: true - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - regenerate: - - args: ['./autogen.sh', '--no-po4a'] - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-gcc - pkgs_required: - - mlibc - - zlib - revision: 4 - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--disable-static' - - '--disable-nls' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: openssl - source: - subdir: 'bundled' - git: 'https://github.com/openssl/openssl.git' - tag: 'OpenSSL_1_1_1o' - version: '1.1.1o' - tools_required: - - host-gcc - pkgs_required: - - mlibc - - zlib - configure: - - args: - - '@THIS_SOURCE_DIR@/Configure' - - '--prefix=/usr' - - '--openssldir=/etc/ssl' - - '--libdir=lib' - - 'x86_64-aero' - - 'shared' - - 'zlib-dynamic' - - 'no-afalgeng' - environ: - CC: 'x86_64-aero-gcc' - CXX: 'x86_64-aero-g++' - build: - - args: ['make', '-j@PARALLELISM@'] - # Disable installing static libraries - - args: ['sed', '-i', '/INSTALL_LIBS/s/libcrypto.a libssl.a//', '@THIS_BUILD_DIR@/Makefile'] - # Suffix all man pages with ssl - - args: ['make', 'DESTDIR=@THIS_COLLECT_DIR@', 'MANSUFFIX=ssl', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - # Move the doc dir to a versioned directory - - args: ['mv', '@THIS_COLLECT_DIR@/usr/share/doc/openssl', '@THIS_COLLECT_DIR@/usr/share/doc/openssl-1.1.1o'] - - - name: libpng - source: - subdir: 'bundled' - git: 'https://git.code.sf.net/p/libpng/code' - tag: 'v1.6.37' - version: '1.6.37' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - regenerate: - - args: ['git', 'clean', '-xf', '-e', '*.xbstrap'] - - args: ['autoreconf', '-fvi'] - tools_required: - - host-gcc - pkgs_required: - - mlibc - - zlib - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: freetype - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/freetype/freetype.git' - tag: 'VER-2-13-0' - version: '2.13.0' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: '1' - - args: ['cp', - '@BUILD_ROOT@/tools/host-automake-v1.16/share/automake-1.16/config.sub', - '@THIS_SOURCE_DIR@/builds/unix/'] - tools_required: - - host-gcc - pkgs_required: - - mlibc - - libpng - - zlib - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--disable-static' - - '--with-harfbuzz=no' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: fontconfig - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/fontconfig/fontconfig.git' - tag: '2.14.0' - version: '2.14.0' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - # Make sure we regenerate this file - - args: ['rm', '-f', 'src/fcobjshash.h'] - pkgs_required: - - mlibc - - freetype - - libxml - - libiconv - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-gcc - - host-libtool - - host-pkg-config - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-docs' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - - '--enable-libxml2' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: libxml - source: - subdir: 'bundled' - git: 'https://gitlab.gnome.org/GNOME/libxml2.git' - tag: 'v2.9.14' - version: '2.9.14' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - pkgs_required: - - mlibc - - zlib - - python - - libiconv - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--with-python=@SYSROOT_DIR@/usr/bin/python3.8' - - '--disable-static' - - '--with-threads' - - '--disable-ipv6' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: libiconv - source: - subdir: 'bundled' - git: 'https://git.savannah.gnu.org/git/libiconv.git' - # Last release tag is broken for us, use current master (07-12-2020) - branch: 'master' - commit: '0eb1068ceb77ba383c3ce2fc391ab40ef686c491' - version: '1.16' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - regenerate: - - args: ['./gitsub.sh', 'pull'] - # Gnulib broke on commit e3174b6d1fdbe6ea2297bf8c8333f65f9d9d9588, so check out the one before that. - - args: ['git', 'checkout', '766ec17a90f67e8cda78394e58a7fffb00f5a4b7'] - workdir: '@THIS_SOURCE_DIR@/gnulib' - - args: ['./autogen.sh'] - environ: - 'NOCONFIGURE': 'yes' - - args: ['cp', - '@BUILD_ROOT@/tools/host-automake-v1.16/share/automake-1.16/config.sub', - '@THIS_SOURCE_DIR@/build-aux/'] - - args: ['cp', - '@BUILD_ROOT@/tools/host-automake-v1.16/share/automake-1.16/config.sub', - '@THIS_SOURCE_DIR@/libcharset/build-aux/'] - - args: ['cp', - '@BUILD_ROOT@/tools/host-libtool/share/aclocal/libtool.m4', - '@THIS_SOURCE_DIR@/m4/'] - - args: ['cp', - '@BUILD_ROOT@/tools/host-libtool/share/aclocal/libtool.m4', - '@THIS_SOURCE_DIR@/libcharset/m4/'] - - args: ['cp', - '@BUILD_ROOT@/tools/host-libtool/share/libtool/build-aux/ltmain.sh', - '@THIS_SOURCE_DIR@/libcharset/build-aux/'] - - args: ['cp', - '@BUILD_ROOT@/tools/host-libtool/share/libtool/build-aux/ltmain.sh', - '@THIS_SOURCE_DIR@/build-aux/'] - - args: ['cp', - '@BUILD_ROOT@/tools/host-libtool/share/aclocal/ltversion.m4', - '@THIS_SOURCE_DIR@/m4/'] - - args: ['cp', - '@BUILD_ROOT@/tools/host-libtool/share/aclocal/ltversion.m4', - '@THIS_SOURCE_DIR@/libcharset/m4/'] - - args: ['autoreconf', '-fvi', '-I@THIS_SOURCE_DIR@/m4', '-I@THIS_SOURCE_DIR@/srcm4'] - tools_required: - - host-gcc - - host-libtool - pkgs_required: - - mlibc - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - - '--disable-nls' - - '--enable-shared' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # Library for manipulating Unicode and C strings according to Unicode standard - # - # This package provides a library containing functions for manipulating Unicode - # strings and for manipulating C strings according to the Unicode standard. - - name: libunistring - source: - subdir: 'bundled' - url: 'https://ftp.gnu.org/gnu/libunistring/libunistring-1.0.tar.xz' - format: 'tar.xz' - checksum: blake2b:8208fe33d4ac2f015b0efb56b0c7dd87afc4bb1c6ca4eb3ded86d7e2101d7b7f68bfd8991af4b6dd408282ec73f134ee0b884e761ff6d52e8a1e398326aec420 - extract_path: 'libunistring-1.0' - version: '1.0' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - regenerate: - - args: ['autoreconf', '-fvi'] - tools_required: - - host-gcc - pkgs_required: - - mlibc - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - - '--disable-static' - - '--docdir=/usr/share/doc/libunistring-1.0' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # GTK+ & GNOME Accessibility Toolkit - # - # This package provides a set of accessibility interfaces used extensively througout GTK and GNOME. - - name: atk - source: - subdir: 'bundled' - git: 'https://gitlab.gnome.org/GNOME/atk.git' - tag: '2.38.0' - version: '2.38.0' - tools_required: - - host-gcc - - host-pkg-config - - virtual: pkgconfig-for-target - triple: "x86_64-aero" - pkgs_required: - - mlibc - - glib - configure: - - args: - - 'meson' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '--libdir=lib' - - '--buildtype=debugoptimized' - - '-Dintrospection=false' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: cairo - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/cairo/cairo.git' - tag: '1.17.6' - version: '1.17.6' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - regenerate: - - args: ['./autogen.sh'] - environ: - 'NOCONFIGURE': 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - pkgs_required: - - mlibc - - freetype - - fontconfig - - libpng - - pixman - - libxcb - - libx11 - - libxext - - mesa - - libxrender - - glib - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - - '--enable-xlib-xcb' - - '--enable-xml' - - '--enable-tee' - - '--enable-gl' - environ: - # freetype-config does not support cross-compilation. - FREETYPE_CONFIG: 'no' - PKG_CONFIG_SYSROOT_DIR: '@BUILD_ROOT@/system-root' - PKG_CONFIG_LIBDIR: '@BUILD_ROOT@/system-root/usr/lib/pkgconfig:@BUILD_ROOT@/system-root/usr/share/pkgconfig' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: at-spi2-atk - source: - subdir: 'bundled' - git: 'https://gitlab.gnome.org/GNOME/at-spi2-atk.git' - tag: 'AT_SPI2_ATK_2_38_0' - version: '2.38.0' - tools_required: - - host-pkg-config - - host-gcc - - virtual: pkgconfig-for-target - triple: 'x86_64-aero' - pkgs_required: - - mlibc - - at-spi2-core - - atk - - dbus - - glib - - libxml - configure: - - args: - - 'meson' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: at-spi2-core - source: - subdir: 'bundled' - git: 'https://gitlab.gnome.org/GNOME/at-spi2-core.git' - tag: 'AT_SPI2_CORE_2_38_0' - version: '2.38.0' - tools_required: - - host-pkg-config - - host-gcc - - virtual: pkgconfig-for-target - triple: 'x86_64-aero' - pkgs_required: - - mlibc - - dbus - - glib - - libxtst - configure: - - args: - - 'meson' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '-Dsystemd_user_dir=/tmp' - - '-Dintrospection=no' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: pcre - source: - subdir: 'bundled' - # Use a git mirror as pcre retired their svn repositories - git: 'https://github.com/vinix-os/pcre' - tag: '1767' - # Seems to be 8.45? - version: '8.45' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-autoconf-archive - regenerate: - - args: ['./autogen.sh'] - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - pkgs_required: - - mlibc - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - - '--enable-unicode-properties' - - '--enable-pcre8' - - '--enable-pcre16' - - '--enable-pcre32' - - '--disable-static' - environ: - PKG_CONFIG_SYSROOT_DIR: '@BUILD_ROOT@/system-root' - PKG_CONFIG_LIBDIR: '@BUILD_ROOT@/system-root/usr/lib/pkgconfig:@BUILD_ROOT@/system-root/usr/share/pkgconfig' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'DESTDIR=@THIS_COLLECT_DIR@', 'install'] - - - name: dbus - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/dbus/dbus.git' - tag: 'dbus-1.12.20' - version: '1.12.20' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-autoconf-archive - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - - host-python - - virtual: pkgconfig-for-target - triple: 'x86_64-aero' - pkgs_required: - - mlibc - - glib - - libexpat - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-doxygen-docs' - - '--disable-xml-docs' - - '--disable-static' - - '--enable-shared' - - '--enable-verbose-mode' - - '--with-systemdsystemunitdir=no' - - '--with-systemduserunitdir=no' - - '--docdir=/usr/share/doc/dbus-1.12.20' - - '--with-console-auth-dir=/run/console' - - '--with-system-pid-file=/run/dbus/pid' - - '--with-system-socket=/run/dbus/system_bus_socket' - - '--disable-selinux' - - '--disable-apparmor' - - '--disable-libaudit' - - '--disable-kqueue' - - '--disable-launchd' - - '--disable-systemd' - - '--disable-tests' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: gettext - from_source: gettext - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - pkgs_required: - - mlibc - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--docdir=/usr/share/doc/gettext-0.22.3' - - '--enable-static=no' - - '--enable-shared=yes' - - '--disable-java' - - '--disable-nls' - - '--disable-acl' - - '--without-emacs' - - '--without-git' - - '--without-bzip2' - - '--without-xz' - - '--disable-curses' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: libintl - source: - subdir: 'bundled' - url: 'https://ftp.gnu.org/gnu/gettext/gettext-0.22.tar.xz' - format: 'tar.xz' - extract_path: 'gettext-0.22' - version: '0.22' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - regenerate: - - args: ['autoreconf', '-fvi'] - tools_required: - - host-gcc - pkgs_required: - - mlibc - - libiconv - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--without-emacs' - - '--without-lispdir' - # Normally this controls nls behavior in general, but the libintl - # subdir is skipped unless this is explicitly set. - - '--enable-nls' - # This magic flag enables libintl. - - '--with-included-gettext' - - '--disable-c++' - - '--disable-libasprintf' - - '--disable-java' - - '--enable-shared' - - '--disable-static' - - '--enable-threads=posix' - - '--disable-curses' - - '--without-git' - - '--without-cvs' - - '--without-bzip2' - - '--without-xz' - build: - - args: ['make', '-C', 'gettext-runtime/intl', '-j@PARALLELISM@'] - - args: ['make', '-C', 'gettext-runtime/intl', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: glib - from_source: glib - tools_required: - - host-gcc - - host-libtool - - host-pkg-config - - virtual: pkgconfig-for-target - triple: "x86_64-aero" - pkgs_required: - - mlibc - - pcre - - libffi - - zlib - - libiconv - - libintl - configure: - - args: - - 'meson' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '--libdir=lib' - - '--buildtype=debugoptimized' - - '-Dxattr=false' - - '@THIS_SOURCE_DIR@' - environ: - # The warning is false positive and the more recent versions of GCC. Workaround and disable the warning. - # - # Bug 1744: https://gitlab.gnome.org/GNOME/glib/-/issues/1744 - CFLAGS: '-Wno-error=format-nonliteral' - PKG_CONFIG_SYSROOT_DIR: '@BUILD_ROOT@/system-root' - PKG_CONFIG_LIBDIR: '@BUILD_ROOT@/system-root/usr/lib/pkgconfig:@BUILD_ROOT@/system-root/usr/share/pkgconfig' - build: - - args: ['ninja'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - scripts: - post_install: - - args: ['glib-compile-schemas /usr/share/glib-2.0/schemas'] - - args: ['gio-querymodules /usr/lib/gio/modules'] - - - name: libjpeg-turbo - source: - subdir: 'bundled' - git: 'https://github.com/libjpeg-turbo/libjpeg-turbo.git' - tag: '2.1.4' - version: '2.1.4' - tools_required: - - host-pkg-config - - host-gcc - - host-cmake - - virtual: pkgconfig-for-target - triple: "x86_64-aero" - pkgs_required: - - mlibc - configure: - - args: - - 'cmake' - - '-DCMAKE_TOOLCHAIN_FILE=@SOURCE_ROOT@/userland/CMakeToolchain-x86_64.cmake' - - '-DCMAKE_INSTALL_PREFIX=/usr' - - '-DCMAKE_BUILD_TYPE=RELEASE' - - '-DENABLE_STATIC=FALSE' - - '-DCMAKE_INSTALL_DOCDIR=/usr/share/doc/libjpeg-turbo-2.1.4' - - '-DCMAKE_INSTALL_DEFAULT_LIBDIR=lib' - - '-DWITH_JPEG8=ON' - - '-DCMAKE_SYSTEM_PROCESSOR=x86_64' - - '@THIS_SOURCE_DIR@/' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # A free implementation of the unicode bidirectional algorithm - # - # This package provides a library with an implementation of the Unicode - # Bidirectional Algorithm (BIDI). This is used for supporting Arabic and - # Hebrew alphabets in other packages. - - name: fribidi - source: - subdir: 'bundled' - git: 'https://github.com/fribidi/fribidi.git' - tag: 'v1.0.12' - version: '1.0.12' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - regenerate: - - args: ['./autogen.sh'] - environ: - 'NOCONFIGURE': 'yes' - - args: 'sed -i s/"SUBDIRS = gen.tab lib bin doc test"/"SUBDIRS = gen.tab lib bin test"/ @THIS_SOURCE_DIR@/Makefile.am' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - pkgs_required: - - mlibc - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # Translation tool for XML documents that uses gettext files and ITS rules - # - # This package contains a program for translating XML with PO files using W3C - # Internationalization Tag Set rules. - - name: itstool - source: - subdir: 'bundled' - git: 'https://github.com/itstool/itstool.git' - tag: '2.0.7' - version: '2.0.7' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - regenerate: - - args: ['./autogen.sh'] - environ: - 'NOCONFIGURE': 'yes' - tools_required: - - host-gcc - - host-python - pkgs_required: - - mlibc - - libxml - - python - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - environ: - 'PYTHON': '/usr/bin/python3' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: readline - source: - subdir: 'bundled' - git: 'https://git.savannah.gnu.org/git/readline.git' - tag: 'readline-8.1' - version: '8.1' - tools_required: - - host-gcc - pkgs_required: - - mlibc - - ncurses - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--disable-static' - - '--enable-multibyte' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'DESTDIR=@THIS_COLLECT_DIR@', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # General purpose crypto library based on the code used in GnuPG - # - # This package contains a general purpose crypto library based on the code used - # in GnuPG. The library provides a high level interface to cryptographic building - # blocks using an extendable and flexible API. - - name: libgcrypt - source: - subdir: 'bundled' - git: 'https://dev.gnupg.org/source/libgcrypt.git' - tag: 'libgcrypt-1.10.1' - version: '1.10.1' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - regenerate: - - args: ['./autogen.sh'] - - args: ['autoreconf', '-fvi'] - tools_required: - - host-gcc - pkgs_required: - - mlibc - - libgpg-error - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--enable-shared' - - '--disable-static' - - '--prefix=/usr' - - '--disable-nls' - - '--disable-doc' - - '--disable-dev-random' - - '--with-libgpg-error-prefix=@SYSROOT_DIR@/usr' - - '--disable-asm' - environ: - LIBS: '-lgpg-error' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # A lossy image compression format - # - # This package contains a library and support programs to encode and decode images in WebP format. - - name: libwebp - source: - subdir: 'bundled' - git: 'https://github.com/webmproject/libwebp.git' - tag: 'v1.3.0' - version: '1.3.0' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - regenerate: - - args: ['./autogen.sh'] - tools_required: - - host-gcc - pkgs_required: - - mlibc - - libjpeg-turbo - - libpng - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--enable-libwebpmux' - - '--enable-libwebpdemux' - - '--enable-libwebpdecoder' - - '--enable-libwebpextras' - - '--enable-swap-16bit-csp' - - '--disable-static' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: libtasn - source: - subdir: 'bundled' - git: 'https://gitlab.com/gnutls/libtasn1.git' - tag: 'v4.18.0' - version: '4.18.0' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - - host-libtool - regenerate: - - args: ['./bootstrap'] - - args: ['cp', - '@BUILD_ROOT@/tools/host-automake-v1.16/share/automake-1.16/config.sub', - '@THIS_SOURCE_DIR@/build-aux/'] - tools_required: - - host-gcc - pkgs_required: - - mlibc - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--disable-static' - - '--disable-doc' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # Contains error handling functions used by GnuPG software - # - # This package contains a library that defines common error values for - # all GnuPG components. - - name: libgpg-error - source: - subdir: 'bundled' - git: 'https://dev.gnupg.org/source/libgpg-error.git' - tag: 'libgpg-error-1.45' - version: '1.45' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - regenerate: - - args: ['./autogen.sh'] - - args: ['autoreconf', '-f', '-v', '-i'] - tools_required: - - host-gcc - pkgs_required: - - mlibc - configure: - # libgpg-error does not know about managarm, teach it - - args: ['cp', '-v', '@THIS_SOURCE_DIR@/src/syscfg/lock-obj-pub.x86_64-unknown-linux-gnu.h', - '@THIS_SOURCE_DIR@/src/syscfg/lock-obj-pub.aero.h'] - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--disable-nls' - - '--disable-doc' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: icu - from_source: icu - tools_required: - - host-gcc - - host-icu - pkgs_required: - - mlibc - configure: - - args: ['cp', - '@THIS_SOURCE_DIR@/icu4c/source/config/mh-linux', - '@THIS_SOURCE_DIR@/icu4c/source/config/mh-unknown'] - - args: - - '@THIS_SOURCE_DIR@/icu4c/source/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--with-cross-build=@BUILD_ROOT@/tool-builds/host-icu' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: graphite2 - source: - subdir: 'bundled' - git: 'https://github.com/silnrsi/graphite.git' - tag: '1.3.14' - version: '1.3.14' - tools_required: - - host-gcc - - host-python - - host-cmake - pkgs_required: - - mlibc - - gcc # Actually requires libstdc++.so in the system root, otherwise it links against the host libstdc++.so.6 - configure: - - args: - - 'cmake' - - '-DCMAKE_TOOLCHAIN_FILE=@SOURCE_ROOT@/userland/CMakeToolchain-x86_64.cmake' - - '-DCMAKE_INSTALL_PREFIX=/usr' - - '@THIS_SOURCE_DIR@' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: harfbuzz - source: - subdir: 'bundled' - git: 'https://github.com/harfbuzz/harfbuzz.git' - tag: '3.1.2' - version: '3.1.2' - tools_required: - - host-gcc - - host-pkg-config - - virtual: pkgconfig-for-target - triple: "x86_64-aero" - pkgs_required: - - mlibc - - graphite2 - - glib - - zlib - - freetype - - cairo - - icu - configure: - - args: - - 'meson' - - '--native-file' - - '@SOURCE_ROOT@/userland/native-file.ini' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '--libdir=lib' - - '--buildtype=debugoptimized' - - '-Dgraphite2=enabled' - - '-Dglib=enabled' - - '-Dgobject=disabled' - - '-Dicu=enabled' - - '-Dfreetype=enabled' - - '-Dcairo=enabled' - - '-Dintrospection=disabled' - - '-Ddocs=disabled' - - '-Dtests=disabled' # Disabled due to a linking error - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - -tasks: - - name: sysroot - pkgs_required: - - binutils - - coreutils - - nyancat - - gcc - - tcc - args: - - '@SOURCE_ROOT@/make-iso.sh' - - '@BUILD_ROOT@' - - '@SOURCE_ROOT@' - - '@SYSROOT_DIR@' - workdir: '@BUILD_ROOT@' diff --git a/bootstrap/app-misc.yml b/bootstrap/app-misc.yml deleted file mode 100644 index f8ca618882a..00000000000 --- a/bootstrap/app-misc.yml +++ /dev/null @@ -1,31 +0,0 @@ -packages: - # A lightweight and flexible command-line JSON processor - - name: jq - source: - url: 'https://github.com/jqlang/jq/releases/download/jq-1.7/jq-1.7.tar.gz' - format: 'tar.gz' - version: '1.7' - subdir: 'bundled' - patch-path-strip: 0 - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-gcc - pkgs_required: - - mlibc - configure: - - args: - - '@THIS_SOURCE_DIR@/jq-1.7/configure' - - '--disable-docs' - - '--disable-valgrind' - - '--disable-maintainer-mode' - - '--with-oniguruma=builtin' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' diff --git a/bootstrap/db.yml b/bootstrap/db.yml deleted file mode 100644 index b4a932c05c6..00000000000 --- a/bootstrap/db.yml +++ /dev/null @@ -1,38 +0,0 @@ -packages: - - name: sqlite - source: - subdir: 'bundled' - url: 'https://sqlite.org/2021/sqlite-autoconf-3370000.tar.gz' - format: 'tar.gz' - checksum: blake2b:35e72700f20c35701d26f7b66da126242ea1d253f710f299a9b6f180f0a53d417114af022161a6cd9ebf20b791f0645f7a30290210fac197d5fda3a647067fd0 - extract_path: 'sqlite-autoconf-3370000' - version: '3.37.0' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - regenerate: - - args: ['autoreconf', '-fvi'] - tools_required: - - host-gcc - - host-libtool - - host-autoconf-v2.69 - - host-automake-v1.16 - pkgs_required: - - mlibc - - readline - - zlib - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--disable-static' - - '--enable-readline' - - '--enable-fts5' - - 'CFLAGS=-g -O2 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_UNLOCK_NOTIFY=1 -DSQLITE_ENABLE_DBSTAT_VTAB=1 -DSQLITE_SECURE_DELETE=1 -DSQLITE_ENABLE_FTS3_TOKENIZER=1' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' diff --git a/bootstrap/editors.yml b/bootstrap/editors.yml deleted file mode 100644 index 5842bc33825..00000000000 --- a/bootstrap/editors.yml +++ /dev/null @@ -1,60 +0,0 @@ -packages: - - name: vim - source: - subdir: 'bundled' - git: 'https://github.com/vim/vim.git' - tag: 'v8.2.3704' - version: '8.2.3704' - tools_required: - - host-gcc - - host-pkg-config - - host-automake-v1.16 - pkgs_required: - - mlibc - - ncurses - - libiconv - revision: 4 - configure: - # vim does not seem to support out-of-tree builds, so we just copy - # the source tree into the build directory instead - - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] - - args: - - './configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--disable-gtktest' - - '--disable-icon-cache-update' - - '--disable-desktop-database-update' - - '--disable-canberra' - - '--disable-selinux' - - '--disable-xsmp' - - '--disable-channel' - - '--disable-netbeans' - - '--enable-multibyte' - - '--disable-acl' - - '--disable-gpm' - - '--disable-sysmouse' - - '--disable-nls' - - '--with-tlib=tinfo' - - '--enable-gui=no' - - '--without-x' - environ: - ac_cv_small_wchar_t: 'no' - ac_cv_func_sigsetjmp: 'no' - vim_cv_toupper_broken: 'no' - vim_cv_terminfo: 'yes' - vim_cv_tgetent: 'zero' - vim_cv_tty_group: '' - vim_cv_tty_mode: '0620' - vim_cv_getcwd_broken: 'no' - vim_cv_stat_ignores_slash: 'no' - vim_cv_memmove_handles_overlap: 'yes' - vim_cv_bcopy_handles_overlap: 'yes' - vim_cv_memcpy_handles_overlap: 'yes' - STRIP: 'x86_64-aero-strip' - workdir: '@THIS_BUILD_DIR@/src/' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' diff --git a/bootstrap/net.yml b/bootstrap/net.yml deleted file mode 100644 index 118868d86f5..00000000000 --- a/bootstrap/net.yml +++ /dev/null @@ -1,733 +0,0 @@ -sources: - - name: nss - subdir: 'bundled' - git: 'https://github.com/nss-dev/nss.git' - tag: 'NSS_3_94_RTM' - version: '3.94.RTM' - -packages: - - name: dhcpd - source: - subdir: 'bundled' - git: 'https://github.com/Andy-Python-Programmer/dhcpd' - branch: 'main' - tools_required: - - host-rust - - host-gcc - sources_required: - - rust-patched-libs - pkgs_required: - - mlibc - configure: - - args: ['python3', '@SOURCE_ROOT@/tools/cargo-inject-patches.py', '@THIS_SOURCE_DIR@/Cargo.toml'] - build: - - args: - - 'cargo' - - 'install' - - '--locked' - - '--target-dir' - - '@THIS_BUILD_DIR@' - - '--path' - - '@THIS_SOURCE_DIR@' - - '--root' - - '@THIS_COLLECT_DIR@/usr' - - '-j@PARALLELISM@' - environ: - RUSTFLAGS: '-Cforce-frame-pointers=yes -Clink-args=-no-pie' - - # C library for the Public Suffix List - # - # This package provides a library for accessing and resolving information from the Public - # Suffix List (PSL). The PSL is a set of domain names beyond the standard suffixes, such - # as .com. - - name: libpsl - source: - subdir: 'bundled' - git: 'https://github.com/rockdaboot/libpsl.git' - tag: '0.21.1' - version: '0.21.1' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - regenerate: - - args: ['./autogen.sh'] - tools_required: - - host-gcc - pkgs_required: - - mlibc - - libidn2 - - libunistring - - libiconv - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--disable-static' - - '--enable-builtin=libidn2' - - '--enable-runtime=libidn2' - # Gentoo disables asan, cfi and ubsan - - '--disable-asan' - - '--disable-cfi' - - '--disable-ubsan' - - '--disable-man' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: libidn2 - source: - subdir: 'bundled' - git: 'https://gitlab.com/libidn/libidn2.git' - tag: 'v2.3.2' - version: '2.3.2' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - regenerate: - - args: ['./bootstrap'] - - args: ['autoreconf', '-fvi'] - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - pkgs_required: - - mlibc - - libunistring - - libiconv - configure: - # Remove some files from the source directory if they exist. - - args: | - if [ -f @THIS_SOURCE_DIR@/lib/gendata ]; then - rm -rv @THIS_SOURCE_DIR@/lib/gendata - fi - - args: | - if [ -f @THIS_SOURCE_DIR@/lib/gentr46map ]; then - rm -rv @THIS_SOURCE_DIR@/lib/gentr46map - fi - # Configure for the host, we need some files to be generated - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--disable-doc' - - '--disable-nls' - # Broken out of tree build, but also broken in tree for some reason, work around it - - args: ['cp', '-v', '@THIS_SOURCE_DIR@/lib/idna-tables-properties.csv', '@THIS_BUILD_DIR@/lib/'] - - args: ['cp', '-v', '@THIS_BUILD_DIR@/lib/idn2.h', '@THIS_SOURCE_DIR@/lib/'] - # Build it so we get our files - - args: ['make', '-j@PARALLELISM@'] - # Copy the files to the source dir, where libidn2 wants them - - args: ['cp', '-v', '@THIS_BUILD_DIR@/lib/gendata', '@THIS_SOURCE_DIR@/lib/gendata'] - - args: ['cp', '-v', '@THIS_BUILD_DIR@/lib/gentr46map', '@THIS_SOURCE_DIR@/lib/gentr46map'] - # Finally, configure for managarm - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - - '--disable-static' - - '--disable-doc' - - '--disable-nls' - # Again, copy the header, it might've changed due to configure. - - args: ['cp', '-v', '@THIS_BUILD_DIR@/lib/idn2.h', '@THIS_SOURCE_DIR@/lib/'] - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: curl - source: - subdir: 'bundled' - git: 'https://github.com/curl/curl.git' - tag: 'curl-7_84_0' - version: '7.84.0' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-autoconf-archive - regenerate: - - args: ['autoreconf', '-fiv'] - tools_required: - - host-pkg-config - - host-gcc - - virtual: pkgconfig-for-target - triple: "x86_64-aero" - pkgs_required: - - mlibc - - libidn2 - - libpsl - - openssl - - zlib - - zstd - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--disable-static' - - '--with-ca-path=/etc/ssl/certs' - - '--enable-threaded-resolver' - - '--with-openssl' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: links - source: - subdir: 'bundled' - url: 'http://links.twibright.com/download/links-2.28.tar.gz' - format: 'tar.gz' - checksum: blake2b:5695cfa26fac30f021ef415e75edb9456ad0360b0edeefa02d2862b149f757a1f1f4d5e5a1e6f3f198696bf35129c93f0f46bdf06ab1b0eb6c91f22e08fffb07 - extract_path: 'links-2.28' - version: '2.28' - tools_required: - - host-pkg-config - - host-gcc - - virtual: pkgconfig-for-target - triple: x86_64-aero - pkgs_required: - - mlibc - - zlib - - openssl - - libpng - - zstd - - libxext - - freetype - - fontconfig - - xz-utils - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--mandir=/usr/share/man' - - '--enable-graphics' - - '--without-directfb' - - '--without-librsvg' - - '--with-bzip2' - - '--with-X' - - '--x-includes=@SYSROOT_DIR@/usr/include' - - '--x-libraries=@SYSROOT_DIR@/usr/lib' - - '--with-zlib' - - '--with-zstd' - - '--with-openssl' - - '--with-libjpeg' - - '--without-libtiff' - - '--without-openmp' - - '--with-lzma' - - '--with-freetype' - - '--without-ipv6' - environ: - # Configure doesn't set CC correctly and assumes gcc unless manually overridden. - CC: 'x86_64-aero-gcc' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'DESTDIR=@THIS_COLLECT_DIR@', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # Network-related giomodules for glib - # - # This package contains network related gio modules for GLib. - - name: glib-networking - source: - subdir: 'bundled' - git: 'https://gitlab.gnome.org/GNOME/glib-networking.git' - tag: '2.72.2' - version: '2.72.2' - tools_required: - - host-gcc - - host-pkg-config - - virtual: pkgconfig-for-target - triple: "x86_64-aero" - pkgs_required: - - mlibc - - glib - # - gnutls - configure: - - args: - - 'meson' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '--buildtype=debugoptimized' - - '-Dgnutls=disabled' - - '-Dopenssl=enabled' - - '-Dinstalled_tests=false' - - '-Dstatic_modules=false' - - '-Dlibproxy=disabled' - - '-Dgnome_proxy=disabled' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - scripts: - post_install: - - args: ['gio-querymodules', '/usr/lib/gio/modules'] - - # This package is a HTTP client/server library for GNOME. It uses GObject and the GLib main - # loop to integrate with GNOME applications and it also has an asynchronous API for use in - # threaded applications. - - name: libsoup - source: - subdir: 'bundled' - git: 'https://gitlab.gnome.org/GNOME/libsoup.git' - tag: '2.74.2' - version: '2.74.2' - tools_required: - - host-gcc - - host-pkg-config - - virtual: pkgconfig-for-target - triple: "x86_64-aero" - pkgs_required: - - mlibc - - glib - - glib-networking - - zlib - - libxml - - libpsl - - sqlite - configure: - - args: - - 'meson' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '--buildtype=debugoptimized' - - '-Dintrospection=disabled' - - '-Dinstalled_tests=false' - - '-Dsysprof=disabled' - - '-Dgtk_doc=false' - - '-Dvapi=disabled' - - '-Dgnome=false' - - '-Dtls_check=false' - - '-Dbrotli=disabled' - - '-Dntlm=disabled' - - '-Dgssapi=disabled' - - '-Dtests=false' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: alsa-lib - source: - subdir: 'bundled' - git: 'https://github.com/alsa-project/alsa-lib.git' - tag: 'v1.2.9' - version: '1.2.9' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - virtual: pkgconfig-for-target - triple: "x86_64-aero" - regenerate: - - args: ['autoreconf', '-fvi'] - tools_required: - - host-gcc - pkgs_required: - - mlibc - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: nspr - source: - subdir: 'bundled' - hg: 'https://hg.mozilla.org/projects/nspr/' - tag: 'NSPR_4_35_RTM' - version: '4.35.1' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - regenerate: - - args: ['autoreconf', '-fvi'] - - args: ['cp', - '@BUILD_ROOT@/tools/host-automake-v1.16/share/automake-1.16/config.sub', - '@THIS_SOURCE_DIR@/build/autoconf/'] - tools_required: - - host-gcc - pkgs_required: - - mlibc - configure: - # Disable installing two unneeded scripts. - - args: ['sed', '-ri', '/^RELEASE/s/^/#/', '@THIS_SOURCE_DIR@/pr/src/misc/Makefile.in'] - # Disable installing static libraries. - - args: ['sed', '-i', 's#$(LIBRARY) ##', '@THIS_SOURCE_DIR@/config/rules.mk'] - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-linux' - - '--build=x86_64-linux' - - '--prefix=/usr' - - '--with-mozilla' - - '--with-pthreads' - - '--enable-64bit' - environ: - CROSS_COMPILE: '1' - ac_cv_func_syscall: 'no' - build: - # We first build a native nsinstall that the build can use later on. - - args: ['make', 'CC=gcc', 'CXX=g++', '-C', '@THIS_BUILD_DIR@/config/'] - - args: ['mv', '-v', '@THIS_BUILD_DIR@/config/nsinstall', '@THIS_BUILD_DIR@/config/native-nsinstall'] - - args: ['sed', '-s', 's#/nsinstall$#/native-nsinstall#', '-i', '@THIS_BUILD_DIR@/config/autoconf.mk'] - - args: ['rm', '-v', '@THIS_BUILD_DIR@/config/nsinstall.o'] - # Then build the real deal - - args: ['make', 'CC=x86_64-aero-gcc', 'CXX=x86_64-aero-g++', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - quiet: true - - - name: nss - from_source: nss - tools_required: - - host-gcc - pkgs_required: - - mlibc - - nspr - - sqlite - - zlib - configure: - - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] - build: - # First, build a host version of nsinstall. - - args: ['make', '-C', '@THIS_BUILD_DIR@/coreconf/'] - environ: - CC: 'gcc' - BUILD_OPT: '1' - NSPR_INCLUDE_DIR: '/usr/include/nspr' - USE_SYSTEM_ZLIB: '1' - ZLIB_LIBS: '-lz' - NSS_ENABLE_WERROR: '0' - USE_64: '1' - NSS_USE_SYSTEM_SQLITE: '1' - NS_USE_GCC: '1' - CC_IS_GCC: '1' - NSDISTMODE: 'copy' - # Then, build some configuration items courtesy of BLFS (see the patches). - - args: | - make V=1 -C @THIS_BUILD_DIR@/config NSINSTALL=@THIS_BUILD_DIR@/$(find -type f -name nsinstall) -j1 - environ: - # Optimized builds. - BUILD_OPT: '1' - # NSPR is here. - NSPR_INCLUDE_DIR: '@SYSROOT_DIR@/usr/include/nspr' - # Use our zlib. - USE_SYSTEM_ZLIB: '1' - # Freestanding freebl yes please. - FREEBL_NO_DEPEND: '1' - FREEBL_LOWHASH: '1' - NSS_SEED_ONLY_DEV_URANDOM: '1' - # Link with zlib. - ZLIB_LIBS: '-lz' - # Do not enable Werror. - NSS_ENABLE_WERROR: '0' - # We are 64 bit. - USE_64: '1' - # Use system sqlite. - NSS_USE_SYSTEM_SQLITE: '1' - # We're using gcc. - NS_USE_GCC: '1' - CC_IS_GCC: '1' - # We're cross compiling. - CROSS_COMPILE: '1' - # Don't symlink files, copy them. - NSDISTMODE: 'copy' - # Do not build the tests. - NSS_DISABLE_GTESTS: '1' - # Put the libs and binaries here. - SOURCE_PREFIX: '@THIS_BUILD_DIR@/dist' - # Specify the compiler. - CC: 'x86_64-aero-gcc' - CXX: 'x86_64-aero-g++' - # Then build the main libraries and binaries. - - args: | - make V=1 -C @THIS_BUILD_DIR@/. NSINSTALL=@THIS_BUILD_DIR@/$(find -type f -name nsinstall) -j1 - environ: - BUILD_OPT: '1' - NSPR_INCLUDE_DIR: '@SYSROOT_DIR@/usr/include/nspr' - USE_SYSTEM_ZLIB: '1' - FREEBL_NO_DEPEND: '1' - FREEBL_LOWHASH: '1' - NSS_SEED_ONLY_DEV_URANDOM: '1' - ZLIB_LIBS: '-lz' - NSS_ENABLE_WERROR: '0' - USE_64: '1' - NSS_USE_SYSTEM_SQLITE: '1' - NS_USE_GCC: '1' - CC_IS_GCC: '1' - CROSS_COMPILE: '1' - NSDISTMODE: 'copy' - NSS_DISABLE_GTESTS: '1' - SOURCE_PREFIX: '@THIS_BUILD_DIR@/dist' - CC: 'x86_64-aero-gcc' - CXX: 'x86_64-aero-g++' - # Create some directories to install into. - - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/usr/lib/pkgconfig'] - - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/usr/bin'] - - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/usr/include'] - # And install everything, this _will_ break on a non Linux box, but unfortunately NSS hardcodes kernel names and versions. - # If someone wants to patch NSS to not do that, greatly appreciated. - # These install instructions are adapted from BLFS, and not Gentoo as I usually do. - - args: | - cd dist - install -v -m755 Linux*/lib/*.so @THIS_COLLECT_DIR@/usr/lib - install -v -m644 Linux*/lib/{*.chk,libcrmf.a} @THIS_COLLECT_DIR@/usr/lib - install -v -m755 -d @THIS_COLLECT_DIR@/usr/include/nss - cp -v -RL {public,private}/nss/* @THIS_COLLECT_DIR@/usr/include/nss - chmod -v 644 @THIS_COLLECT_DIR@/usr/include/nss/* - install -v -m755 Linux*/bin/{certutil,nss-config,pk12util} @THIS_COLLECT_DIR@/usr/bin - install -v -m644 Linux*/lib/pkgconfig/nss.pc @THIS_COLLECT_DIR@/usr/lib/pkgconfig - - - name: libevent - source: - subdir: bundled - git: 'https://github.com/libevent/libevent.git' - tag: 'release-2.1.12-stable' - version: '2.1.12' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - regenerate: - - args: ['./autogen.sh'] - # Fix an issue that prevents event_rpcgen.py from working. - - args: ['sed', '-i', 's/python/&3/', '@THIS_SOURCE_DIR@/event_rpcgen.py'] - tools_required: - - host-gcc - pkgs_required: - - mlibc - - openssl - - zlib - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: libvpx - source: - subdir: 'bundled' - git: 'https://chromium.googlesource.com/webm/libvpx.git' - tag: 'v1.11.0' - version: '1.11.0' - tools_required: - - host-gcc - pkgs_required: - - mlibc - configure: - # Fix ownership and permission of installed files. - - args: ['sed', '-i', 's/cp -p/cp/', '@THIS_SOURCE_DIR@/build/make/Makefile'] - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--prefix=/usr' - - '--disable-static' - - '--enable-shared' - # Generic GNU target to disable optimizations - - '--force-target=generic-gnu' - - '--enable-pic' - - '--enable-vp8' - - '--enable-vp9' - - '--enable-multithread' - - '--enable-vp9-highbitdepth' - - '--disable-examples' - - '--disable-install-docs' - - '--disable-docs' - build: - - args: ['make', 'HAVE_GNU_STRIP=no', 'CC=x86_64-aero-gcc', 'LD=x86_64-aero-gcc', 'CXX=x86_64-aero-g++', 'AR=x86_64-aero-ar', 'NM=x86_64-aero-nm', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # - name: firefox - # source: - # subdir: 'bundled' - # git: 'https://github.com/mozilla/gecko-dev' - # commit: 7baa783763c946ff667c3faea292e91d3de1e459 - # branch: master - # configure: - # - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] - # - args: ['cp', '@SOURCE_ROOT@/extra-files/firefox/mozconfig', '@THIS_BUILD_DIR@/mozconfig'] - # tools_required: - # - host-gcc - # - host-rust - # - host-pkg-config - # # - virtual: pkgconfig-for-target - # # triple: "x86_64-aero" - # pkgs_required: - # - mlibc - # - alsa-lib - # - glib - # - gtk+-3 - # - gtk+-2 - # - icu - # - gcc - # - nspr - # - nss - # - libvpx - # - libevent - # sources_required: - # - rust-patched-libs - # build: - # - args: ['./mach', 'build'] - # environ: - # HOST_CC: 'gcc' - # HOST_CXX: 'g++' - # CC: 'x86_64-aero-gcc' - # CXX: 'x86_64-aero-g++' - # CARGOFLAGS: '--verbose' - # MOZ_RUST_TIER: '1' - # BINDGEN_EXTRA_CLANG_ARGS: '-isystem@SYSROOT_DIR/usr/include' - # # CROSS_SYSROOT: '@SYSROOT_DIR@'./system-root/usr/include/c++/11.2.0/memory - - # cargo install cbindgen - # - # pacman -S autoconf2.13 - # - name: firefox-esr - # source: - # subdir: 'bundled' - # git: 'https://github.com/mozilla/gecko-dev' - # branch: 'FIREFOX_ESR_68_0_X_RELBRANCH' - # configure: - # - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] - # - args: ['cp', '@SOURCE_ROOT@/extra-files/firefox/mozconfig', '@THIS_BUILD_DIR@/mozconfig'] - # tools_required: - # - host-gcc - # - host-rust - # - host-pkg-config - # # - virtual: pkgconfig-for-target - # # triple: "x86_64-aero" - # pkgs_required: - # - mlibc - # - alsa-lib - # - glib - # - gtk+-3 - # - gtk+-2 - # - gcc - # build: - # # python ~/work/aero/tools/cargo-inject-patches.py ./Cargo.toml - # - args: ['./mach', 'build'] - # environ: - # HOST_CC: 'clang' - # CC: 'x86_64-aero-gcc' - # CARGOFLAGS: '--verbose' - # # - args: ['./mach', 'install'] - # # environ: - # # DESTDIR: '@THIS_COLLECT_DIR@' - - # /home/andy/work/aero/bundled/webkitgtk/Source/ThirdParty/ANGLE/src/common/system_utils_posix.cpp:313:14: error: ‘mkstemps’ was not declared in this scope; did you mean ‘mkstemp’? - # 313 | int fd = mkstemps(&tempFileTemplate[0], static_cast(extension.size())); - # | ^~~~~~~~ - # | mkstemp - - name: webkitgtk - source: - subdir: bundled - git: 'https://github.com/WebKit/WebKit.git' - # I think? Apple is weird with naming - tag: 'Safari-612.1.27.0.24' - version: '2.33.3' - tools_required: - - host-gcc - - host-cmake - pkgs_required: - - mlibc - - cairo - - fontconfig - - freetype - - libgcrypt - - glib - - harfbuzz - - icu - - libjpeg-turbo - - zlib - - sqlite - - libpng - - libxml - - atk - - libwebp - - gtk+-3 - - libsoup - - libxslt - - at-spi2-core - - libtasn - - libx11 - - libxcomposite - - libxdamage - - libxrender - - libxt - - mesa - configure: - - args: - - 'cmake' - - '-GNinja' - - '-DCMAKE_TOOLCHAIN_FILE=@SOURCE_ROOT@/userland/CMakeToolchain-x86_64.cmake' - - '-DCMAKE_INSTALL_PREFIX=/usr' - - '-DCMAKE_SYSTEM_PROCESSOR=x86_64' - - '-DCMAKE_BUILD_TYPE=Release' - - '-DCMAKE_SKIP_RPATH=ON' - - '-DPORT=GTK' - - '-DLIB_INSTALL_DIR=/usr/lib' - - '-DUSE_LIBHYPHEN=OFF' - - '-DENABLE_GAMEPAD=OFF' - - '-DENABLE_MINIBROWSER=ON' - - '-DUSE_WOFF2=OFF' - - '-DUSE_SYSTEMD=OFF' - - '-DENABLE_BUBBLEWRAP_SANDBOX=OFF' - - '-Wno-dev -G Ninja' - - '-DUSE_LIBNOTIFY=OFF' - - '-DUSE_SYSTEM_MALLOC=ON' - - '-DENABLE_GEOLOCATION=OFF' - - '-DENABLE_VIDEO=OFF' - - '-DENABLE_WEB_AUDIO=OFF' - - '-DENABLE_INTROSPECTION=OFF' - - '-DUSE_LIBSECRET=OFF' - - '-DUSE_OPENJPEG=OFF' - - '-DENABLE_SPELLCHECK=OFF' - - '-DENABLE_WAYLAND_TARGET=OFF' - - '-DENABLE_X11_TARGET=ON' - - '-DENABLE_WEBGL=ON' - - '-DUSE_WPE_RENDERER=OFF' - - '-DENABLE_WEBGL2=OFF' - - '-DUSE_SOUP2=ON' - - '-DUSE_LCMS=OFF' - - '@THIS_SOURCE_DIR@' - environ: - CXXFLAGS: '-DLOG_DISABLED=0' - build: - - args: ['ninja', '-j6'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' diff --git a/bootstrap/vcs.yml b/bootstrap/vcs.yml deleted file mode 100644 index 31b040ad96d..00000000000 --- a/bootstrap/vcs.yml +++ /dev/null @@ -1,51 +0,0 @@ -packages: - # The Git version control system - # - # Git is one of the most used version control systems designed to - # handle large projects efficiently. - # - name: git - # source: - # subdir: 'bundled' - # git: 'https://github.com/git/git.git' - # tag: 'v2.32.0' - # version: '2.32.0' - # tools_required: - # - host-autoconf-v2.69 - # - host-automake-v1.16 - # - host-libtool - # regenerate: - # - args: ['autoreconf'] - # tools_required: - # - host-pkg-config - # - host-gcc - # - virtual: pkgconfig-for-target - # triple: "x86_64-aero" - # pkgs_required: - # - mlibc - # - python - # - libexpat - # - zlib - # - openssl - # - curl - # - libiconv - # - pcre - # configure: - # - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] - # - args: - # - './configure' - # - '--host=x86_64-aero' - # - '--prefix=/usr' - # - '--with-python=python3' - # - '--with-gitconfig=/etc/gitconfig' - # - '--with-curl=@SYSROOT_DIR@/usr' - # - '--without-iconv' - # - '--with-libpcre' - # - 'ac_cv_fread_reads_directories=1' - # - 'ac_cv_snprintf_returns_bogus=1' - # environ: - # CURL_CONFIG: '@SYSROOT_DIR@/usr/bin/curl-config' - # build: - # - args: ['make', 'NO_GETTEXT=YesPlease', '-j@PARALLELISM@'] - # - args: ['make', 'NO_GETTEXT=YesPlease', 'install'] - # environ: - # DESTDIR: '@THIS_COLLECT_DIR@' diff --git a/bootstrap/x11-themes.yml b/bootstrap/x11-themes.yml deleted file mode 100644 index 09506dfd667..00000000000 --- a/bootstrap/x11-themes.yml +++ /dev/null @@ -1,49 +0,0 @@ -packages: - # This package contains a default fallback theme for implementations of the icon theme specification. - - name: hicolor-icon-theme - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xdg/default-icon-theme.git' - tag: '0.17' - version: '0.17' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - regenerate: - - args: ['./autogen.sh', '--no-configure'] - tools_required: - - host-gcc - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: adwaita-icon-theme - source: - subdir: 'bundled' - git: 'https://gitlab.gnome.org/GNOME/adwaita-icon-theme.git' - tag: '45.0' - version: '45.0' - tools_required: - - host-gcc - pkgs_required: - - hicolor-icon-theme - configure: - - args: - - 'meson' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' diff --git a/bootstrap/xorg.yml b/bootstrap/xorg.yml deleted file mode 100644 index 3ce977b6aaf..00000000000 --- a/bootstrap/xorg.yml +++ /dev/null @@ -1,2635 +0,0 @@ -sources: - - name: xorg-util-macros - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/util/macros.git' - tag: 'util-macros-1.19.3' - version: '1.19.3' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - - - name: xorg-font-util - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/font/util.git' - tag: 'font-util-1.3.2' - version: '1.3.2' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - - - name: gettext - subdir: 'bundled' - url: 'https://ftp.gnu.org/pub/gnu/gettext/gettext-0.22.3.tar.gz' - checksum: blake2b:aebe85a82cb94c37ed81e9801acf1e89d150f5992fb9be42d53b3f2734c5c95804f0051fabc26b8d0892dfaf89d18df16d4bca6bcb2e9b95eef5d4ae93a64379 - extract_path: 'gettext-0.22.3' - format: 'tar.gz' - version: '0.22.3' - - - name: gobject-introspection - subdir: 'bundled' - git: 'https://gitlab.gnome.org/GNOME/gobject-introspection.git' - tag: '1.76.1' - version: '1.76.1' - -tools: - - name: host-gobject-introspection - exports_aclocal: true - from_source: gobject-introspection - tools_required: - - host-python - - host-glib - - host-pkg-config - - virtual: pkgconfig-for-host - program_name: host-pkg-config - configure: - - args: - - 'meson' - - '--prefix=@PREFIX@' - - '--native-file' - - '@SOURCE_ROOT@/userland/native-file.ini' - - '-Dbuild_introspection_data=false' - - '@THIS_SOURCE_DIR@' - compile: - - args: ['ninja'] - install: - - args: ['ninja', 'install'] - - - name: host-xorg-macros - exports_aclocal: true - from_source: xorg-util-macros - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--prefix=@PREFIX@' - compile: - - args: ['make', '-j@PARALLELISM@'] - install: - - args: ['make', 'install-strip'] - - - name: host-xtrans - exports_aclocal: true - from_source: libxtrans - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--prefix=@PREFIX@' - compile: - - args: ['make', '-j@PARALLELISM@'] - install: - - args: ['make', 'install-strip'] - - - name: host-xorg-font-util - exports_aclocal: true - from_source: xorg-font-util - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--prefix=@PREFIX@' - compile: - - args: ['make', '-j@PARALLELISM@'] - install: - - args: ['make', 'install-strip'] - -packages: - # `xorg-util-macros` is a set of autoconf macros used by the configure.ac scripts in - # other Xorg modular packages, and is needed to generate new versions - # of their configure scripts with autoconf. - - name: xorg-util-macros - from_source: xorg-util-macros - tools_required: - - host-gcc - - host-xorg-macros - pkgs_required: - - mlibc - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `xorg-proto` provides the headers and specification documents defining the core protocol - # and extensions for the X Window System. - - name: xorg-proto - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/proto/xorgproto.git' - tag: 'xorgproto-2022.1' - version: '2022.1' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - pkgs_required: - - mlibc - - xorg-util-macros - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `xcb-proto` provides the XML-XCB protocol descriptions that libxcb uses to - # generate the majority of its code and API. - - name: xcb-proto - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/proto/xcbproto.git' - tag: 'xcb-proto-1.15' - version: '1.15' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-python - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libxau - - libxdmcp - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - environ: - PYTHON: '@BUILD_ROOT@/tools/host-python/bin/python3.8' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: libxcb-image - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxcb-image' - tag: 'xcb-util-image-0.4.1' - version: '0.4.1' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['git', 'submodule', 'update', '--init'] - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libxcb-util - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: libxcb-util - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxcb-util' - tag: 'xcb-util-0.4.1' - version: '0.4.1' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['git', 'submodule', 'update', '--init'] - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-python - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `libxdmcp` is X Display Manager Control Protocol library. - - name: libxdmcp - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxdmcp.git' - tag: 'libXdmcp-1.1.3' - version: '1.1.3' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libxau - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `xtrans` is a library of code that is shared among various X packages to - # handle network protocol transport in a modular fashion. - - name: libxtrans - from_source: libxtrans - tools_required: - - host-gcc - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libxcb - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `libxau` is a sample authorization protocol for X - - name: libxau - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxau.git' - tag: 'libXau-1.0.9' - version: '1.0.9' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `libxcb` provides an interface to the X Window System protocol, which - # replaces the traditional Xlib interface. - - name: libxcb - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxcb.git' - tag: 'libxcb-1.15' - version: '1.15' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - - host-python - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libxau - - libxdmcp - - xcb-proto - configure: - - args: ['sed', '-i', "s/pthread-stubs//", '@THIS_SOURCE_DIR@/configure'] - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - - '--without-doxygen' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - environ: - PYTHON: '@BUILD_ROOT@/tools/host-python/bin/python3.8' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `libx11` is core X11 protocol client library. - - name: libx11 - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libx11.git' - tag: 'libX11-1.8' - version: '1.8' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - - host-xtrans - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libxcb - - libxtrans - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - - '--disable-ipv6' - - '--disable-malloc0returnsnull' - - '--with-keysymdefdir=@SYSROOT_DIR@/usr/include/X11' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: libxcursor - source: - subdir: bundled - git: 'https://gitlab.freedesktop.org/xorg/lib/libxcursor.git' - tag: 'libXcursor-1.2.1' - version: '1.2.1' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - 'NOCONFIGURE': 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxfixes - - libxrender - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: glu - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/mesa/glu.git' - tag: 'glu-9.0.2' - version: '9.0.2' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: '1' - tools_required: - - host-gcc - pkgs_required: - - mlibc - - gcc # Actually requires libstdc++.so in the system root, otherwise it links against the host libstdc++.so.6 - - mesa - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # - name: mesa-demos - # source: - # subdir: 'bundled' - # git: 'https://gitlab.freedesktop.org/mesa/demos.git/' - # branch: 'master' - # tools_required: - # - host-autoconf-v2.69 - # - host-automake-v1.16 - # - host-libtool - # - host-pkg-config - # - host-xorg-macros - # regenerate: - # - args: ['./autogen.sh'] - # environ: - # 'NOCONFIGURE': 'yes' - # tools_required: - # - host-gcc - # pkgs_required: - # - mlibc - # - mesa - # configure: - # - args: - # - '@THIS_SOURCE_DIR@/configure' - # - '--host=x86_64-aero' - # - '--prefix=/usr' - # - '--sysconfdir=/etc' - # - '--localstatedir=/var' - # - '--disable-static' - # - '--disable-gles1' # Requires some linux header that we don't have - # - '--disable-vg' - # - '--disable-osmesa' - # - '--disable-rbug' - # - '--with-system-data-files' - # build: - # - args: ['make', '-j@PARALLELISM@'] - # - args: ['make', 'install'] - # environ: - # DESTDIR: '@THIS_COLLECT_DIR@' - - - name: mesa - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/mesa/mesa.git' - tag: 'mesa-21.3.5' - version: '21.3.5' - tools_required: - - host-pkg-config - tools_required: - - host-pkg-config - - host-gcc - - virtual: pkgconfig-for-target - triple: "x86_64-aero" - - virtual: pkgconfig-for-host - program_name: host-pkg-config - pkgs_required: - - mlibc - - libdrm - - zlib - - libxrandr - - libxfixes - - libx11 - - libxext - - libxcb - - llvm - configure: - - args: ['cp', '@SOURCE_ROOT@/userland/cross-file.ini', 'meson.cross-file'] - - args: - - 'sed' - - '-i' - - "/^# sed adds binaries here.$/a llvm-config = '@SOURCE_ROOT@/userland/cross-llvm-config'" - - 'meson.cross-file' - - args: - - 'meson' - - 'setup' - - '--native-file' - - '@SOURCE_ROOT@/userland/native-file.ini' - - '--cross-file' - - 'meson.cross-file' - - '--prefix=/usr' - - '--libdir=lib' - # The debug build type enables some additional output from Mesa. - - '--buildtype=release' - #- '--buildtype=debug' - - '-Dglx=gallium-xlib' - - '-Dplatforms=x11' - # The Gallium swrast driver seems to be preferred over dri-swrast. - - '-Ddri-drivers=' - - '-Dgallium-drivers=swrast' - - '-Dvulkan-drivers=' - # Force Mesa to build with LLVM. - - '-Dllvm=enabled' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja', '-j@PARALLELISM@'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `libxkbfile` is used by the X servers and utilities to parse the XKB - # configuration data files. - - name: libxkbfile - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxkbfile.git' - tag: 'libxkbfile-1.1.0' - version: '1.1.0' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: xorg-font-util - from_source: xorg-font-util - tools_required: - - host-gcc - pkgs_required: - - mlibc - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `libfontenc` is a font encoding library. - - name: libfontenc - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libfontenc.git' - tag: 'libfontenc-1.1.4' - version: '1.1.4' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - - host-xorg-font-util - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxtrans - - xorg-font-util - - zlib - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: xf86-input-mouse - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/driver/xf86-input-mouse.git' - tag: 'xf86-input-mouse-1.9.4' - version: '1.9.4' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - pkgs_required: - - mlibc - - xorg-server - - xorg-util-macros - - libx11 - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `libxfont` provides the core of the legacy X11 font system, handling the index - # files - - name: libxfont2 - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxfont.git' - tag: 'libXfont2-2.0.5' - version: '2.0.5' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - - host-xtrans - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - - host-xtrans - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxtrans - - freetype - - libfontenc - - fontconfig - - zlib - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - - '--disable-devel-docs' - # strcasecmp is implicitly declared, probably an missing include somewhere, so disable -Werror for that - - '--disable-selective-werror' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `pixman` is a library that provides low-level pixel manipulation - # features such as image compositing and trapezoid rasterization. - - name: pixman - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/pixman/pixman.git' - tag: 'pixman-0.42.2' - version: '0.42.2' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - regenerate: - - args: ['./autogen.sh'] - environ: - 'NOCONFIGURE': 'yes' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-gcc - pkgs_required: - - mlibc - - libpng - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: libepoxy - source: - subdir: 'bundled' - git: 'https://github.com/anholt/libepoxy.git' - tag: '1.5.10' - version: '1.5.10' - tools_required: - - host-pkg-config - - host-gcc - - virtual: pkgconfig-for-target - triple: "@OPTION:x86_64-aero" - pkgs_required: - - mlibc - - mesa - - xorg-proto - - libx11 - configure: - - args: - - 'meson' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '-Degl=no' - - '-Dtests=false' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: xorg-xinit - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/app/xinit' - tag: 'xinit-1.3.4' - version: '1.3.4' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - - host-xorg-font-util - - host-xtrans - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-gcc - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - xorg-server - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - args: ['cp', '@SOURCE_ROOT@/extra-files/xorg/xinitrc', '@THIS_COLLECT_DIR@/etc/X11/xinit/xinitrc'] - - # X.Org xcvt library and cvt program - # - # VESA CVT standard timing modeline generation library & utility. - - name: libxcvt - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxcvt.git' - tag: 'libxcvt-0.1.2' - version: '0.1.2' - tools_required: - - host-gcc - - host-pkg-config - pkgs_required: - - mlibc - configure: - - args: - - 'meson' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja', '-j@PARALLELISM@'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # The X server accepts requests from client applications to create windows, - # which are (normally rectangular) "virtual screens" that the client program - # can draw into. - - name: xorg-server - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/xserver.git' - tag: 'xorg-server-1.20.14' - version: '1.20.14' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - - host-xorg-font-util - - host-xtrans - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - openssl - - libepoxy - - libxkbfile - - libxfont2 - - libxcvt - - pixman - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - - '--with-xkb-output=/var/lib/xkb' - - '--enable-xorg' - - '--enable-xv' - - '--enable-xvfb' - - '--disable-xephyr' - - '--disable-xwayland' - - '--disable-xnest' - - '--disable-dmx' - - '--disable-suid-wrapper' - - '--disable-pciaccess' - - '--disable-dpms' - - '--disable-screensaver' - - '--disable-xres' - - '--disable-xinerama' - - '--disable-xvmc' - - '--disable-systemd-logind' - - '--disable-secure-rpc' - - '--disable-config-udev' - - '--disable-dri' - - '--disable-dri2' - - '--disable-dri3' - - '--disable-vbe' - - '--disable-int10-module' - - '--disable-vgahw' - - '--disable-libdrm' - - '--disable-glamor' - - '--disable-glx' - environ: - CFLAGS: '-Wno-error=array-bounds -pipe' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/etc/X11'] - - args: ['cp', '@SOURCE_ROOT@/extra-files/xorg/xorg.conf', '@THIS_COLLECT_DIR@/etc/X11/'] - - # `libxext` is the historical libX11-based catchall library for the X11 - # extensions without their own libraries. - - name: libxext - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxext.git' - tag: 'libXext-1.3.4' - version: '1.3.4' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxtrans - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - - '--disable-malloc0returnsnull' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `libsm` is a X session management library. - - name: libsm - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libsm.git' - tag: 'libSM-1.2.3' - version: '1.2.3' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - - host-xtrans - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-gcc - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxtrans - - libice - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: libxt - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxt.git' - tag: 'libXt-1.2.1' - version: '1.2.1' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - - host-gcc - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxtrans - - libsm - - libice - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - - '--disable-malloc0returnsnull' - - '--with-appdefaultdir=/etc/X11/app-defaults' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `libxmu` contains miscellaneous utilities and is not part of the Xlib - # standard - - name: libxmu - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxmu.git' - tag: 'libXmu-1.1.3' - version: '1.1.3' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - - host-xtrans - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - - host-gcc - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxext - - libxtrans - - libxt - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `libice` is a inter-client exchange library. - - name: libice - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libice.git' - tag: 'libICE-1.0.10' - version: '1.0.10' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - - host-xtrans - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - - host-gcc - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxtrans - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `libxaw` is the X athena widget set. - - name: libxaw - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxaw.git' - tag: 'libXaw-1.0.14' - version: '1.0.14' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - - host-gcc - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxext - - libxt - - libxmu - - libxpm - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `libxpm` is X Pixmap (XPM) image file format library. - - name: libxpm - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxpm.git' - tag: 'libXpm-3.5.13' - version: '3.5.13' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - - host-gcc - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxext - - libxt - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `libxrender` is a library for the Render Extension to the X11 protocol - - name: libxrender - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxrender.git' - tag: 'libXrender-0.9.10' - version: '0.9.10' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxtrans - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - - '--disable-malloc0returnsnull' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `libxft` is X FreeType library. - - name: libxft - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxft.git' - tag: 'libXft-2.3.4' - version: '2.3.4' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - - host-gcc - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxrender - - freetype - - fontconfig - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `libxi` is library for the X input extension. - - name: libxi - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxi.git' - tag: 'libXi-1.8' - version: '1.8' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxtrans - - libxext - - libxfixes - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - - '--disable-malloc0returnsnull' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `libxfixes` is xfixes extension library. - - name: libxfixes - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxfixes.git' - tag: 'libXfixes-6.0.0' - version: '6.0.0' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxtrans - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # `xeyes` is a follow the mouse X demo, using the X shape extension. - - name: xeyes - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/app/xeyes.git' - tag: 'xeyes-1.2.0' - version: '1.2.0' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - - host-gcc - pkgs_required: - - mlibc - - libx11 - - libxmu - - libxaw - - libxrender - - libxft - - libxt - - libxkbfile - - libiconv - - libxi - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-selective-werror' # strncasecmp - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: limine-term - source: - subdir: 'bundled' - git: 'https://github.com/Andy-Python-Programmer/limine-term-emu' - branch: 'master' - regenerate: - - args: ['git', 'submodule', 'update', '--init'] - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - virtual: pkgconfig-for-target - triple: "x86_64-aero" - - virtual: pkgconfig-for-host - program_name: host-pkg-config - - host-gcc - pkgs_required: - - mlibc - - libx11 - - libxmu - - libxaw - - libxrender - - libxft - - libxt - - libxkbfile - - libiconv - - libxi - configure: - - args: - - 'meson' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja', '-j@PARALLELISM@'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: dwm - source: - subdir: 'bundled' - git: 'https://git.suckless.org/dwm/' - branch: master - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - - host-gcc - pkgs_required: - - mlibc - - libx11 - - libxmu - - libxaw - - libxrender - - libxft - - libxt - - libxkbfile - - libiconv - - libxi - - dejavu - configure: - - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] - build: - - args: ['make', 'CC=x86_64-aero-gcc', 'CXX=x86_64-aero-g++'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: xwallpaper - source: - subdir: 'bundled' - git: 'https://github.com/stoeckmann/xwallpaper' - branch: 'master' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxcb-image - - libxcb-util - - libpng - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: dmenu - source: - subdir: 'bundled' - git: 'https://git.suckless.org/dmenu/' - branch: master - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - - host-gcc - pkgs_required: - - mlibc - - libx11 - - libxmu - - libxaw - - libxrender - - libxft - - libxt - - libxkbfile - - libiconv - - libxi - - dejavu - configure: - - args: ['cp', '-r', '@THIS_SOURCE_DIR@/.', '@THIS_BUILD_DIR@'] - build: - - args: ['make', 'CC=x86_64-aero-gcc', 'CXX=x86_64-aero-g++'] - - args: ['make', 'install'] - environ: - PREFIX: '/usr' - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: dejavu - source: - subdir: bundled - url: 'https://sourceforge.net/projects/dejavu/files/dejavu/2.37/dejavu-fonts-ttf-2.37.tar.bz2' - format: 'tar.bz2' - checksum: blake2b:d8614907887f20967fc7c75cb33b636a0eb5c682a076ccc7aef09f4ac243507afc005ef90d0b2aeee6a4a6a1ff3d5ce4fac0d1722a382525b3883ef53cdec26a - extract_path: 'dejavu-fonts-ttf-2.37' - version: '2.37' - pkgs_required: - - freetype - - fontconfig - revision: 3 - configure: - - args: ['cp', '-r', '@THIS_SOURCE_DIR@/ttf', '@THIS_SOURCE_DIR@/dejavu'] - - args: ['cp', '-r', '@THIS_SOURCE_DIR@/', '@THIS_BUILD_DIR@'] - build: - - args: ['mkdir', '-p', '@THIS_COLLECT_DIR@/usr/share/fonts/truetype/'] - - args: ['cp', '-r', '@THIS_BUILD_DIR@/dejavu/dejavu', '@THIS_COLLECT_DIR@/usr/share/fonts/truetype/'] - scripts: - post_install: - - args: 'echo "Running fc-cache; this may take a few seconds..."' - - args: ['fc-cache'] - - - name: libxv - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxv.git' - tag: 'libXv-1.0.11' - version: '1.0.11' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxext - - libxfixes - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - - '--disable-malloc0returnsnull' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: libxrandr - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxrandr.git' - tag: 'libXrandr-1.5.2' - version: '1.5.2' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxtrans - - libxrender - - libxext - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - - '--disable-malloc0returnsnull' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: xkbcomp - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/app/xkbcomp.git' - tag: 'xkbcomp-1.4.5' - version: '1.4.5' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - libx11 - - libxkbfile - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: libxkbcommon - source: - subdir: 'bundled' - git: 'https://github.com/xkbcommon/libxkbcommon.git' - tag: 'xkbcommon-1.4.0' - version: '1.4.0' - tools_required: - - host-pkg-config - - host-gcc - - virtual: pkgconfig-for-host - program_name: host-pkg-config - - virtual: pkgconfig-for-target - triple: "x86_64-aero" - pkgs_required: - - mlibc - - libxcb - - libxml - - xkeyboard-config - configure: - - args: - - 'meson' - - '--native-file' - - '@SOURCE_ROOT@/userland/native-file.ini' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '--libdir=lib' - - '--buildtype=release' - - '-Denable-docs=false' - - '-Denable-x11=true' - - '-Denable-wayland=false' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - args: ['mkdir', '-p', "@THIS_COLLECT_DIR@/usr/share/X11/xkb"] - - - name: xkbutils - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/app/xkbutils.git' - tag: 'xkbutils-1.0.4' - version: '1.0.4' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['autoreconf', '-vfi'] - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-gcc - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxt - - libxaw - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: xkeyboard-config - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config.git' - tag: 'xkeyboard-config-2.34' - version: '2.34' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - - host-gcc - pkgs_required: - - mlibc - - libx11 - - xorg-proto - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--with-xkb-rules-symlink=xorg' - - '--disable-nls' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: xf86-input-keyboard - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/driver/xf86-input-keyboard.git' - tag: 'xf86-input-keyboard-1.9.0' - version: '1.9.0' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - pkgs_required: - - mlibc - - xorg-server - - xorg-util-macros - - libx11 - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: xf86-video-fbdev - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/driver/xf86-video-fbdev.git' - tag: 'xf86-video-fbdev-0.5.0' - version: '0.5.0' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - regenerate: - - args: ['./autogen.sh'] - environ: - NOCONFIGURE: 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - pkgs_required: - - mlibc - - xorg-server - - xorg-util-macros - - libx11 - - libxrandr - - libxrender - - libxv - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - - '--disable-pciaccess' - environ: - SYSROOT: '@SYSROOT_DIR@' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install-strip'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: libxtst - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxtst.git' - tag: 'libXtst-1.2.4' - version: '1.2.4' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - - host-autoconf-archive - regenerate: - - args: ['./autogen.sh'] - environ: - 'NOCONFIGURE': 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxtrans - - libxext - - libxi - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - # X Damage Extension library - - name: libxdamage - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxdamage.git' - tag: 'libXdamage-1.1.5' - version: '1.1.5' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - - host-autoconf-archive - regenerate: - - args: ['./autogen.sh'] - environ: - 'NOCONFIGURE': 'yes' - tools_required: - - host-gcc - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-pkg-config - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxtrans - - libxfixes - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: pango - source: - subdir: 'bundled' - git: 'https://gitlab.gnome.org/GNOME/pango.git' - tag: '1.50.14' - version: '1.50.14' - tools_required: - - host-pkg-config - - host-gcc - - host-glib - - virtual: pkgconfig-for-target - triple: "x86_64-aero" - pkgs_required: - - mlibc - - glib - - fontconfig - - freetype - - fribidi - - cairo - - xorg-proto - - libx11 - - libxtrans - - libxext - - harfbuzz - - libxft - revision: 3 - configure: - # False positive with GCC 13 and -O3, see bug #903259 - # - # https://gitlab.gnome.org/GNOME/pango/-/issues/740 - - args: ['sed', '-i', '-e', '/\-Werror=array-bounds/d', '@THIS_SOURCE_DIR@/meson.build'] - - args: - - 'meson' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '--buildtype=release' - - '-Dintrospection=disabled' - - '--wrap-mode=nofallback' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: gdk-pixbuf - source: - subdir: 'bundled' - git: 'https://gitlab.gnome.org/GNOME/gdk-pixbuf.git' - tag: '2.40.0' - version: '2.40.0' - tools_required: - - host-gcc - - host-libtool - - host-pkg-config - - virtual: pkgconfig-for-target - triple: "x86_64-aero" - pkgs_required: - - mlibc - - glib - - libjpeg-turbo - - libpng - - shared-mime-info - - libx11 - configure: - - args: - - 'meson' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '-Dgir=false' - - '-Dman=false' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - scripts: - post_install: - - args: ['gdk-pixbuf-query-loaders', '--update-cache'] - - - name: shared-mime-info - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xdg/shared-mime-info.git' - tag: 'Release-1-15' - version: '1.15' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - regenerate: - - args: ['./autogen.sh'] - environ: - 'NOCONFIGURE': 'yes' - tools_required: - - host-gcc - - host-python - pkgs_required: - - mlibc - - glib - - libxml - - itstool - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--disable-update-mimedb' - environ: - 'ITSTOOL': '/usr/bin/itstool' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - scripts: - post_install: - - args: 'echo "Running update-mime-database; this may take a minute or 2..."' - - args: '/usr/bin/update-mime-database /usr/share/mime/' - - # Collection of GSettings schemas for GNOME desktop - # - # This package contains a collection of GSettings schemas for - # settings shared by various components of a GNOME Desktop. - #- name: gsettings-desktop-schemas - # source: - # subdir: 'bundled' - # git: 'https://gitlab.gnome.org/GNOME/gsettings-desktop-schemas.git' - # tag: '42.0' - # version: '42.0' - # tools_required: - # - host-gcc - # - host-gobject-introspection - # - host-libtool - # - host-pkg-config - # - virtual: pkgconfig-for-target - # triple: "x86_64-aero" - # pkgs_required: - # - mlibc - # - glib - # configure: - # - args: | - # sed -i -r 's:"(/system):"/org/gnome\1:g' @THIS_SOURCE_DIR@/schemas/*.in - # - args: - # - 'meson' - # - '--cross-file' - # - '@SOURCE_ROOT@/userland/cross-file.ini' - # - '--prefix=/usr' - # - '-Dintrospection=false' - # - '@THIS_SOURCE_DIR@' - # build: - # - args: ['ninja'] - # - args: ['ninja', 'install'] - # environ: - # DESTDIR: '@THIS_COLLECT_DIR@' - # scripts: - # post_install: - # - args: 'glib-compile-schemas /usr/share/glib-2.0/schemas' - - # Deprecated, please don't depend on this anymore. Only here for gtklife and hexchat. - - name: gtk+-2 - source: - subdir: 'bundled' - url: 'https://download.gnome.org/sources/gtk+/2.24/gtk+-2.24.32.tar.xz' - format: 'tar.xz' - checksum: blake2b:03f4c0a8be98473f62bc8c86859937969c4169960a5f93d37ff6dcde00413215fa6c7125b15781bf50d67b40aa0056cb71b83fb50acb2c3467b5deb3c8d938f0 - extract_path: 'gtk+-2.24.32' - patch-path-strip: 1 - version: '2.24.32' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - - host-glib - regenerate: - - args: ['autoreconf', '-fvi'] - tools_required: - - host-gcc - - virtual: pkgconfig-for-target - triple: "x86_64-aero" - pkgs_required: - - mlibc - - atk - - cairo - - glib - - gdk-pixbuf - - libx11 - - libxext - - libxcb - - pango - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - - '--disable-gtk-doc-html' - - '--disable-cups' - - '--disable-papi' - - '--disable-introspection' - - '--disable-glibtest' - - '--disable-test-print-backend' - - '--enable-xkb' - environ: - ac_cv_func_getresuid: 'no' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - quiet: true - # Rename a file to avoid conflicts, we will use gtk3 as default, so rename this one. - - args: ['mv', '-v', '@THIS_COLLECT_DIR@/usr/bin/gtk-update-icon-cache', '@THIS_COLLECT_DIR@/usr/bin/gtk2-update-icon-cache'] - scripts: - post_install: - - args: ['gtk-query-immodules-2.0', '--update-cache'] - - args: ['glib-compile-schemas', '/usr/share/glib-2.0/schemas'] - - # Collection of GSettings schemas for GNOME desktop - - name: gsettings-desktop-schemas - source: - subdir: 'bundled' - git: 'https://gitlab.gnome.org/GNOME/gsettings-desktop-schemas.git' - tag: '42.0' - version: '42.0' - tools_required: - - host-gcc - - host-gobject-introspection - - host-libtool - - host-pkg-config - - virtual: pkgconfig-for-target - triple: "x86_64-aero" - pkgs_required: - - mlibc - - glib - configure: - - args: | - sed -i -r 's:"(/system):"/org/gnome\1:g' @THIS_SOURCE_DIR@/schemas/*.in - - args: - - 'meson' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '-Dintrospection=false' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - scripts: - post_install: - - args: 'glib-compile-schemas /usr/share/glib-2.0/schemas' - - - name: gtk+-3 - source: - subdir: 'bundled' - git: 'https://gitlab.gnome.org/GNOME/gtk.git' - tag: '3.24.28' - version: '3.24.28' - tools_required: - - host-gcc - - virtual: pkgconfig-for-target - triple: "x86_64-aero" - - host-glib - pkgs_required: - - mlibc - - atk - - at-spi2-atk - - cairo - - glib - - gdk-pixbuf - - libx11 - - libxext - - libxcb - - libxrender - - libxrandr - - libxfixes - - libxdamage - - pango - - fribidi - - libepoxy - - libxkbcommon - - fontconfig - - freetype - - libxi - - harfbuzz - - libxcursor - - gsettings-desktop-schemas - - dbus - configure: - - args: - - 'meson' - - '--native-file' - - '@SOURCE_ROOT@/userland/native-file.ini' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '--libdir=lib' - - '--buildtype=debugoptimized' - - '-Dprint_backends=file' - - '-Dintrospection=false' - - '-Dx11_backend=true' - - '-Dwayland_backend=false' - - '-Dbroadway_backend=true' - - '-Dgtk_doc=false' - - '-Dcolord=no' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - scripts: - post_install: - - args: ['gtk-query-immodules-3.0', '--update-cache'] - - args: ['glib-compile-schemas', '/usr/share/glib-2.0/schemas'] - - # X.Org Xcomposite library - - name: libxcomposite - source: - subdir: 'bundled' - git: 'https://gitlab.freedesktop.org/xorg/lib/libxcomposite.git' - tag: 'libXcomposite-0.4.5' - version: '0.4.5' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - - host-xorg-macros - - host-autoconf-archive - regenerate: - - args: ['./autogen.sh'] - environ: - 'NOCONFIGURE': 'yes' - tools_required: - - host-gcc - pkgs_required: - - mlibc - - xorg-util-macros - - xorg-proto - - libx11 - - libxfixes - configure: - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--sysconfdir=/etc' - - '--localstatedir=/var' - - '--disable-static' - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: libxslt - source: - subdir: 'bundled' - git: 'https://gitlab.gnome.org/GNOME/libxslt.git' - tag: 'v1.1.34' - version: '1.1.34' - tools_required: - - host-autoconf-v2.69 - - host-automake-v1.16 - - host-libtool - - host-pkg-config - regenerate: - - args: ['./autogen.sh'] - environ: - 'NOCONFIGURE': 'yes' - tools_required: - - host-gcc - pkgs_required: - - mlibc - - libxml - configure: - # BLFS increases the recursion limit, apparently some packages need that to build their documentation. - - args: ['sed', '-i', 's/3000/5000/', '@THIS_SOURCE_DIR@/libxslt/transform.c'] - - args: ['sed', '-i', 's/3000/5000/', '@THIS_SOURCE_DIR@/doc/xsltproc.1'] - - args: ['sed', '-i', 's/3000/5000/', '@THIS_SOURCE_DIR@/doc/xsltproc.xml'] - - args: - - '@THIS_SOURCE_DIR@/configure' - - '--host=x86_64-aero' - - '--prefix=/usr' - - '--disable-static' - - '--without-crypto' - - '--without-debug' - - '--without-debugger' - - '--without-profiler' - - '--without-python' - - '--with-sysroot=@SYSROOT_DIR@' # Set libtool's lt_sysroot. - build: - - args: ['make', '-j@PARALLELISM@'] - - args: ['make', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - - - name: gdk-pixbuf-xlib - source: - subdir: 'bundled' - url: 'https://download.gnome.org/sources/gdk-pixbuf-xlib/2.40/gdk-pixbuf-xlib-2.40.2.tar.xz' - format: 'tar.xz' - checksum: blake2b:a515e86bc69f59910f61fe9c275ab89c0732f0aa2cfb614ac94e597de420d25708a11b9b21313c7cfe3763434f45a8318412ae5889c24c8ed57dac68e09c0227 - extract_path: 'gdk-pixbuf-xlib-2.40.2' - patch-path-strip: 1 - version: '2.40.2' - tools_required: - - host-gcc - - host-libtool - - host-pkg-config - - virtual: pkgconfig-for-target - triple: "x86_64-aero" - pkgs_required: - - mlibc - - gdk-pixbuf - - libx11 - configure: - - args: - - 'meson' - - '--cross-file' - - '@SOURCE_ROOT@/userland/cross-file.ini' - - '--prefix=/usr' - - '@THIS_SOURCE_DIR@' - build: - - args: ['ninja'] - - args: ['ninja', 'install'] - environ: - DESTDIR: '@THIS_COLLECT_DIR@' - scripts: - post_install: - - args: ['gdk-pixbuf-query-loaders', '--update-cache'] From ea9e66bedf906dfb2695ed2f71af5f41cdde06b8 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 30 Mar 2024 14:39:59 +1100 Subject: [PATCH 047/112] misc(kernel): make clippy happier! Signed-off-by: Anhad Singh --- src/Cargo.lock | 46 ++++---- src/aero_kernel/src/acpi/madt.rs | 8 +- .../src/arch/x86_64/controlregs.rs | 9 +- src/aero_kernel/src/arch/x86_64/gdt.rs | 1 + src/aero_kernel/src/arch/x86_64/task.rs | 2 +- src/aero_kernel/src/drivers/block/nvme/mod.rs | 100 ++++++++++-------- .../src/drivers/block/nvme/queue.rs | 1 - src/aero_kernel/src/drivers/e1000.rs | 2 +- src/aero_kernel/src/drivers/pty.rs | 6 +- src/aero_kernel/src/drivers/tty/vtty.rs | 4 +- src/aero_kernel/src/fs/block/mod.rs | 16 +-- src/aero_kernel/src/fs/ext2/disk.rs | 2 - src/aero_kernel/src/fs/ext2/group_desc.rs | 10 +- src/aero_kernel/src/fs/ext2/mod.rs | 12 +-- src/aero_kernel/src/fs/file_table.rs | 5 +- src/aero_kernel/src/fs/inode.rs | 18 ++-- src/aero_kernel/src/fs/mod.rs | 8 +- src/aero_kernel/src/fs/path.rs | 20 +++- src/aero_kernel/src/main.rs | 1 + src/aero_kernel/src/syscall/fs.rs | 17 ++- src/aero_kernel/src/syscall/futex.rs | 2 +- src/aero_kernel/src/syscall/process.rs | 6 +- src/aero_kernel/src/userland/mod.rs | 4 +- src/aero_kernel/src/userland/scheduler/mod.rs | 12 +-- src/aero_kernel/src/userland/task/mod.rs | 7 +- src/aero_kernel/src/userland/task/sessions.rs | 32 +++--- src/aero_kernel/src/userland/terminal.rs | 2 +- src/aero_kernel/src/userland/vm.rs | 32 +++--- src/aero_kernel/src/utils/sync.rs | 6 +- src/aero_syscall/src/lib.rs | 4 +- 30 files changed, 216 insertions(+), 179 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index 4c373e1600e..1e136f7b711 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -9,7 +9,7 @@ dependencies = [ "aero_proc", "aero_syscall", "bit_field", - "bitflags 2.4.2", + "bitflags 2.5.0", "byte_endian", "bytemuck", "cpio_reader", @@ -81,9 +81,9 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" [[package]] name = "bit_field" @@ -99,9 +99,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.2" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "byte_endian" @@ -137,10 +137,10 @@ dependencies = [ [[package]] name = "crabnet" version = "0.1.0" -source = "git+https://github.com/aero-os/crabnet#3e5d0a2041e0776bb637c294c8cb552e54b3a2e2" +source = "git+https://github.com/aero-os/crabnet#58a74ea76fb9586ac1c33fd0adbda497ebdaac43" dependencies = [ "bit_field", - "bitflags 2.4.2", + "bitflags 2.5.0", "byte_endian", "static_assertions", ] @@ -148,7 +148,7 @@ dependencies = [ [[package]] name = "crabnet_tcp" version = "0.1.0" -source = "git+https://github.com/aero-os/crabnet#3e5d0a2041e0776bb637c294c8cb552e54b3a2e2" +source = "git+https://github.com/aero-os/crabnet#58a74ea76fb9586ac1c33fd0adbda497ebdaac43" dependencies = [ "crabnet", "log", @@ -212,9 +212,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.10" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "lai" @@ -240,7 +240,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "846c87e24d089e8717a61098cba72b378e3525c46a87cf75b71352dcf668e68c" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", ] [[package]] @@ -260,9 +260,9 @@ dependencies = [ [[package]] name = "memoffset" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] @@ -350,14 +350,14 @@ version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d86a7c4638d42c44551f4791a20e687dbb4c3de1f33c43dd71e355cd429def1" dependencies = [ - "bitflags 2.4.2", + "bitflags 2.5.0", ] [[package]] name = "rayon" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4963ed1bc86e4f3ee217022bd855b297cef07fb9eac5dfa1f788b220b49b3bd" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" dependencies = [ "either", "rayon-core", @@ -402,14 +402,14 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.115" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" dependencies = [ "itoa", "ryu", @@ -447,9 +447,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" dependencies = [ "proc-macro2", "quote", @@ -485,7 +485,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40eb22ae96f050e0c0d6f7ce43feeae26c348fc4dea56928ca81537cfaa6188b" dependencies = [ "arrayvec", - "bitflags 2.4.2", + "bitflags 2.5.0", "cursor-icon", "log", "utf8parse", @@ -534,5 +534,5 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.52", + "syn 2.0.55", ] diff --git a/src/aero_kernel/src/acpi/madt.rs b/src/aero_kernel/src/acpi/madt.rs index e75dc324850..6ced67daed6 100644 --- a/src/aero_kernel/src/acpi/madt.rs +++ b/src/aero_kernel/src/acpi/madt.rs @@ -106,14 +106,14 @@ impl Iterator for MadtIterator { while self.current < self.limit { unsafe { let entry_pointer = self.current; - let header = *(self.current as *const EntryHeader); + let header = *self.current.cast::(); self.current = self.current.offset(header.length as isize); let item = match header.entry_type { - 0 => MadtEntry::LocalApic(&*(entry_pointer as *const MadtLocalApic)), - 1 => MadtEntry::IoApic(&*(entry_pointer as *const IoApicHeader)), - 2 => MadtEntry::IntSrcOverride(&*(entry_pointer as *const MadtIntSrcOverride)), + 0 => MadtEntry::LocalApic(&*entry_pointer.cast::()), + 1 => MadtEntry::IoApic(&*entry_pointer.cast::()), + 2 => MadtEntry::IntSrcOverride(&*entry_pointer.cast::()), 0x10..=0x7f => continue, 0x80..=0xff => continue, diff --git a/src/aero_kernel/src/arch/x86_64/controlregs.rs b/src/aero_kernel/src/arch/x86_64/controlregs.rs index 13edf5a06ed..601a192bae5 100644 --- a/src/aero_kernel/src/arch/x86_64/controlregs.rs +++ b/src/aero_kernel/src/arch/x86_64/controlregs.rs @@ -19,6 +19,8 @@ use crate::mem::paging::{PhysAddr, PhysFrame, VirtAddr}; bitflags::bitflags! { /// Controls cache settings for the level 4 page table. + #[derive(Debug, Copy, Clone)] + #[repr(transparent)] pub struct Cr3Flags: u64 { /// Use a writethrough cache policy for the P4 table (else a writeback policy is used). const PAGE_LEVEL_WRITETHROUGH = 1 << 3; @@ -29,6 +31,8 @@ bitflags::bitflags! { bitflags::bitflags! { /// Controls cache settings for the level 4 page table. + #[derive(Debug, Copy, Clone)] + #[repr(transparent)] pub struct Cr4Flags: u64 { /// Enables hardware-supported performance enhancements for software running in /// virtual-8086 mode. @@ -86,6 +90,8 @@ bitflags::bitflags! { bitflags::bitflags! { /// Configuration flags of the [`Cr0`] register. + #[derive(Debug, Copy, Clone)] + #[repr(transparent)] pub struct Cr0Flags: u64 { /// Enables protected mode. const PROTECTED_MODE_ENABLE = 1; @@ -184,7 +190,7 @@ bitflags::bitflags! { } bitflags::bitflags! { - #[derive(Debug)] + #[derive(Debug, Copy, Clone)] pub struct MxCsr: u32 { const INVALID_OPERATION = 1 << 0; const DENORMAL = 1 << 1; @@ -212,6 +218,7 @@ bitflags::bitflags! { /// For MPX, [`BNDREG`](XCr0Flags::BNDREG) and [`BNDCSR`](XCr0Flags::BNDCSR) must be set/unset simultaneously. /// For AVX-512, [`OPMASK`](XCr0Flags::OPMASK), [`ZMM_HI256`](XCr0Flags::ZMM_HI256), and [`HI16_ZMM`](XCr0Flags::HI16_ZMM) /// must be set/unset simultaneously. + #[derive(Debug, Copy, Clone)] #[repr(transparent)] pub struct XCr0Flags: u64 { /// Enables using the x87 FPU state diff --git a/src/aero_kernel/src/arch/x86_64/gdt.rs b/src/aero_kernel/src/arch/x86_64/gdt.rs index 35e10f37e9e..7e8df0e6707 100644 --- a/src/aero_kernel/src/arch/x86_64/gdt.rs +++ b/src/aero_kernel/src/arch/x86_64/gdt.rs @@ -31,6 +31,7 @@ use core::ptr::addr_of; use alloc::alloc::alloc_zeroed; bitflags::bitflags! { + #[derive(Debug, Copy, Clone)] struct GdtEntryFlags: u8 { const PROTECTED_MODE = 1 << 6; const LONG_MODE = 1 << 5; diff --git a/src/aero_kernel/src/arch/x86_64/task.rs b/src/aero_kernel/src/arch/x86_64/task.rs index 6d4d6f5960d..a903d0fcdd8 100644 --- a/src/aero_kernel/src/arch/x86_64/task.rs +++ b/src/aero_kernel/src/arch/x86_64/task.rs @@ -367,7 +367,7 @@ impl ArchTask { pub fn exec( &mut self, vm: &Vm, - executable: DirCacheItem, + executable: &DirCacheItem, argv: Option, envv: Option, diff --git a/src/aero_kernel/src/drivers/block/nvme/mod.rs b/src/aero_kernel/src/drivers/block/nvme/mod.rs index 01959e339d7..cebdb406be4 100644 --- a/src/aero_kernel/src/drivers/block/nvme/mod.rs +++ b/src/aero_kernel/src/drivers/block/nvme/mod.rs @@ -233,12 +233,13 @@ impl<'a> Namespace<'a> { assert!(size_bytes != 0); let blocks = size_bytes.div_ceil(self.block_size); - let mut read_cmd = ReadWriteCommand::default(); - - read_cmd.opcode = opcode as u8; - read_cmd.nsid = self.nsid; - read_cmd.start_lba = sector as u64; - read_cmd.length = (blocks - 1) as u16; + let mut read_cmd = ReadWriteCommand { + opcode: opcode as u8, + nsid: self.nsid, + start_lba: sector as u64, + length: (blocks - 1) as u16, + ..Default::default() + }; if size_bytes > Size4KiB::SIZE as usize { // The data cannot fit in 8KiB frames, so we need to use @@ -338,13 +339,18 @@ impl<'a> Controller<'a> { registers.set_enable(true)?; let identity = Dma::::zeroed(); - let mut identify_command = IdentifyCommand::default(); - identify_command.opcode = AdminOpcode::Identify as u8; - identify_command.cns = IdentifyCns::Controller as u8; - identify_command.data_ptr.prp1 = identity.addr().as_u64(); - - admin.submit_command(identify_command); + // TODO(andypython): builder pattern for building a command? We also shouldn't be required + // to manually fill in the `opcode` field. + admin.submit_command(IdentifyCommand { + opcode: AdminOpcode::Identify as u8, + cns: IdentifyCns::Controller as u8, + data_ptr: DataPointer { + prp1: identity.addr().as_u64(), + ..Default::default() + }, + ..Default::default() + }); log::trace!( "nvme: identifed controller (vendor={}, subsystem_vendor={})", @@ -355,27 +361,25 @@ impl<'a> Controller<'a> { // Create and initialize the I/O queues. let io_queue = QueuePair::new(registers, queue_size)?; - let mut io_cq_cmd = CreateCQCommand::default(); - - io_cq_cmd.opcode = AdminOpcode::CreateCq as u8; - io_cq_cmd.prp1 = io_queue.completion_addr().as_u64(); - io_cq_cmd.cqid = io_queue.id(); - io_cq_cmd.q_size = (io_queue.len() - 1) as u16; - io_cq_cmd.irq_vector = 0; - io_cq_cmd.cq_flags = CommandFlags::QUEUE_PHYS_CONTIG.bits(); - - admin.submit_command(io_cq_cmd); - - let mut io_sq_cmd = CreateSQCommand::default(); - - io_sq_cmd.opcode = AdminOpcode::CreateSq as u8; - io_sq_cmd.prp1 = io_queue.submission_addr().as_u64(); - io_sq_cmd.cqid = io_queue.id(); - io_sq_cmd.sqid = io_queue.id(); - io_sq_cmd.q_size = (io_queue.len() - 1) as u16; - io_sq_cmd.sq_flags = CommandFlags::QUEUE_PHYS_CONTIG.bits(); + admin.submit_command(CreateCQCommand { + opcode: AdminOpcode::CreateCq as u8, + prp1: io_queue.completion_addr().as_u64(), + cqid: io_queue.id(), + q_size: (io_queue.len() - 1) as u16, + irq_vector: 0, + cq_flags: CommandFlags::QUEUE_PHYS_CONTIG.bits(), + ..Default::default() + }); - admin.submit_command(io_sq_cmd); + admin.submit_command(CreateSQCommand { + opcode: AdminOpcode::CreateSq as u8, + prp1: io_queue.submission_addr().as_u64(), + cqid: io_queue.id(), + sqid: io_queue.id(), + q_size: (io_queue.len() - 1) as u16, + sq_flags: CommandFlags::QUEUE_PHYS_CONTIG.bits(), + ..Default::default() + }); let shift = 12 + registers.capability.mpsmin() as usize; let max_transfer_shift = if identity.mdts != 0 { @@ -395,13 +399,16 @@ impl<'a> Controller<'a> { // Discover and initialize the namespaces. let nsids = { let nsid_list = Dma::::new_uninit_slice(this.identity.nn as usize); - let mut nsid_command = IdentifyCommand::default(); - nsid_command.opcode = AdminOpcode::Identify as u8; - nsid_command.cns = IdentifyCns::ActivateList as u8; - nsid_command.data_ptr.prp1 = nsid_list.addr().as_u64(); - - this.admin.lock().submit_command(nsid_command); + this.admin.lock().submit_command(IdentifyCommand { + opcode: AdminOpcode::Identify as u8, + cns: IdentifyCns::ActivateList as u8, + data_ptr: DataPointer { + prp1: nsid_list.addr().as_u64(), + ..Default::default() + }, + ..Default::default() + }); // SAFETY: The list is initialized above. unsafe { nsid_list.assume_init() } @@ -416,14 +423,17 @@ impl<'a> Controller<'a> { } let identity = Dma::::zeroed(); - let mut identify_command = IdentifyCommand::default(); - - identify_command.opcode = AdminOpcode::Identify as u8; - identify_command.cns = IdentifyCns::Namespace as u8; - identify_command.nsid = nsid; - identify_command.data_ptr.prp1 = identity.addr().as_u64(); - this.admin.lock().submit_command(identify_command); + this.admin.lock().submit_command(IdentifyCommand { + opcode: AdminOpcode::Identify as u8, + cns: IdentifyCns::Namespace as u8, + nsid, + data_ptr: DataPointer { + prp1: identity.addr().as_u64(), + ..Default::default() + }, + ..Default::default() + }); let blocks = identity.nsze as usize; let block_size = 1 << identity.lbaf[(identity.flbas & 0b11111) as usize].ds; diff --git a/src/aero_kernel/src/drivers/block/nvme/queue.rs b/src/aero_kernel/src/drivers/block/nvme/queue.rs index fa45e47aa0f..6763564bb4c 100644 --- a/src/aero_kernel/src/drivers/block/nvme/queue.rs +++ b/src/aero_kernel/src/drivers/block/nvme/queue.rs @@ -1,5 +1,4 @@ use core::cell::UnsafeCell; -use core::ptr; use core::sync::atomic::{AtomicU16, Ordering}; use crate::mem::paging::PhysAddr; diff --git a/src/aero_kernel/src/drivers/e1000.rs b/src/aero_kernel/src/drivers/e1000.rs index 3b8975cd599..27cca5d9700 100644 --- a/src/aero_kernel/src/drivers/e1000.rs +++ b/src/aero_kernel/src/drivers/e1000.rs @@ -613,7 +613,7 @@ impl NetworkDriver for Device { loop { let mut e1000 = self.e1000.lock_irq(); if let Some(data) = e1000.recv() { - self.wq.remove(task); + self.wq.remove(&task); return data; } else { drop(e1000); diff --git a/src/aero_kernel/src/drivers/pty.rs b/src/aero_kernel/src/drivers/pty.rs index 931b8db71be..711d9bfaa48 100644 --- a/src/aero_kernel/src/drivers/pty.rs +++ b/src/aero_kernel/src/drivers/pty.rs @@ -187,7 +187,7 @@ impl INodeInterface for Master { impl TerminalDevice for Slave { fn attach(&self, task: Arc) { assert!(task.is_session_leader()); - self.master.discipline.set_foreground(task); + self.master.discipline.set_foreground(&task); } fn detach(&self, task: Arc) { @@ -246,11 +246,11 @@ impl INodeInterface for Slave { TermiosCmd::GetWinSize(mut size) => *size = self.master.get_window_size(), TermiosCmd::SetWinSize(size) => self.master.set_window_size(*size), TermiosCmd::TcGets(mut termios) => *termios = self.master.discipline.termios(), - TermiosCmd::TcSetsf(termios) => self.master.discipline.set_termios(*termios), + TermiosCmd::TcSetsf(termios) => self.master.discipline.set_termios(termios.clone()), TermiosCmd::TcSetsw(termios) => { // TODO: Allow the output buffer to drain and then set the current serial port // settings. - self.master.discipline.set_termios(*termios) + self.master.discipline.set_termios(termios.clone()) } TermiosCmd::SetCtrlTerm => { diff --git a/src/aero_kernel/src/drivers/tty/vtty.rs b/src/aero_kernel/src/drivers/tty/vtty.rs index 11b8a16b68a..4174cc2ace9 100644 --- a/src/aero_kernel/src/drivers/tty/vtty.rs +++ b/src/aero_kernel/src/drivers/tty/vtty.rs @@ -320,7 +320,7 @@ impl INodeInterface for Tty { let lock = TERMIOS.lock_irq(); let this = &*lock; - *termios = *this; + *termios = this.clone(); Ok(0x00) } @@ -337,7 +337,7 @@ impl INodeInterface for Tty { let mut lock = TERMIOS.lock_irq(); let this = &mut *lock; - *this = *termios; + *this = termios.clone(); Ok(0x00) } diff --git a/src/aero_kernel/src/fs/block/mod.rs b/src/aero_kernel/src/fs/block/mod.rs index d74ad267fb9..870d3837d5f 100644 --- a/src/aero_kernel/src/fs/block/mod.rs +++ b/src/aero_kernel/src/fs/block/mod.rs @@ -76,8 +76,8 @@ impl CachedPage { self.page.start_address() } - fn make_key(device: Weak, offset: usize) -> PageCacheKey { - (device.as_ptr() as *const u8 as usize, offset) + fn make_key(device: &Weak, offset: usize) -> PageCacheKey { + (device.as_ptr().addr(), offset) } /// Returns whether the page has been marked dirty. @@ -116,7 +116,7 @@ impl Drop for CachedPage { impl Cacheable for CachedPage { fn cache_key(&self) -> PageCacheKey { - Self::make_key(self.device.clone(), self.offset) + Self::make_key(&self.device, self.offset) } } @@ -133,9 +133,9 @@ impl Cache { /// * `device` - The device to get the page from. /// * `offset` - The offset in bytes to the data. This will be rounded down to the nearest page /// boundary. - pub fn get_page(&self, device: Weak, offset: usize) -> PageCacheItem { + pub fn get_page(&self, device: &Weak, offset: usize) -> PageCacheItem { let cache_offset = offset / Size4KiB::SIZE as usize; - let cache_key = CachedPage::make_key(device.clone(), cache_offset); + let cache_key = CachedPage::make_key(device, cache_offset); if let Some(page) = PAGE_CACHE.get(cache_key) { return page; @@ -161,7 +161,7 @@ pub struct DirtyRef { } impl DirtyRef { - pub fn new(device: Weak, offset: usize) -> Self { + pub fn new(device: &Weak, offset: usize) -> Self { let cache = PAGE_CACHE.get_page(device, offset); let ptr_offset = offset % Size4KiB::SIZE as usize; @@ -209,7 +209,7 @@ pub trait CachedAccess: BlockDeviceInterface { let mut loc = 0; while loc < dest.len() { - let page = PAGE_CACHE.get_page(self.sref(), offset); + let page = PAGE_CACHE.get_page(&self.sref(), offset); let page_offset = offset % Size4KiB::SIZE as usize; let size = core::cmp::min(Size4KiB::SIZE as usize - page_offset, dest.len() - loc); @@ -236,7 +236,7 @@ pub trait CachedAccess: BlockDeviceInterface { let mut loc = 0; while loc < buffer.len() { - let page = PAGE_CACHE.get_page(self.sref(), offset); + let page = PAGE_CACHE.get_page(&self.sref(), offset); let page_offset = offset % Size4KiB::SIZE as usize; let size = core::cmp::min(Size4KiB::SIZE as usize - page_offset, buffer.len() - loc); diff --git a/src/aero_kernel/src/fs/ext2/disk.rs b/src/aero_kernel/src/fs/ext2/disk.rs index faf9af574b6..4f38aca74b4 100644 --- a/src/aero_kernel/src/fs/ext2/disk.rs +++ b/src/aero_kernel/src/fs/ext2/disk.rs @@ -15,8 +15,6 @@ // You should have received a copy of the GNU General Public License // along with Aero. If not, see . -use core::ptr; - use bit_field::BitField; use crate::fs::inode; diff --git a/src/aero_kernel/src/fs/ext2/group_desc.rs b/src/aero_kernel/src/fs/ext2/group_desc.rs index beaca675e44..97c5ff113c8 100644 --- a/src/aero_kernel/src/fs/ext2/group_desc.rs +++ b/src/aero_kernel/src/fs/ext2/group_desc.rs @@ -47,7 +47,7 @@ impl GroupDescriptors { /// * `device` - Block device to read the group descriptors from. pub fn new( ext2: Weak, - device: Arc, + device: &BlockDevice, superblock: &disk::SuperBlock, ) -> Option { let bgdt_len = superblock.bgdt_len(); @@ -134,7 +134,7 @@ impl GroupDescriptors { let mut descriptors = self.descriptors.write(); let block_group = &mut descriptors[block_group_idx]; - let mut bitmap = Bitmap::new(fs, block_group.block_bitmap as usize)?; + let mut bitmap = Bitmap::new(&fs, block_group.block_bitmap as usize)?; let block_id = block_group_idx * blocks_per_group + bitmap.alloc()?; block_group.free_blocks_count -= 1; @@ -156,7 +156,7 @@ impl GroupDescriptors { let mut descriptors = self.descriptors.write(); let block_group = &mut descriptors[block_group_idx]; - let mut bitmap = Bitmap::new(fs, block_group.inode_bitmap as usize)?; + let mut bitmap = Bitmap::new(&fs, block_group.inode_bitmap as usize)?; // Since inode numbers start from 1 rather than 0, the first bit in the first block // group's inode bitmap represent inode number 1. Thus, we add 1 to the allocated // inode number. @@ -184,7 +184,7 @@ impl Bitmap { /// /// **Note**: Any changes to the bitmap will be written back to the disk when the /// bitmap has been dropped. - fn new(fs: Arc, block: usize) -> Option { + fn new(fs: &Arc, block: usize) -> Option { let block_size = fs.superblock.block_size(); let offset = block * block_size; @@ -198,7 +198,7 @@ impl Bitmap { Some(Self { bitmap, offset, - fs: Arc::downgrade(&fs), + fs: Arc::downgrade(fs), }) } diff --git a/src/aero_kernel/src/fs/ext2/mod.rs b/src/aero_kernel/src/fs/ext2/mod.rs index 92d4f390ff3..18036123913 100644 --- a/src/aero_kernel/src/fs/ext2/mod.rs +++ b/src/aero_kernel/src/fs/ext2/mod.rs @@ -105,7 +105,7 @@ impl INode { let block_index = self.get_block(block).unwrap() as usize; - block::DirtyRef::new(filesystem.block.sref(), (block_index * block_size) + loc) + block::DirtyRef::new(&filesystem.block.sref(), (block_index * block_size) + loc) } pub fn read(&self, offset: usize, buffer: &mut [MaybeUninit]) -> super::Result { @@ -290,14 +290,14 @@ impl INode { } } - pub fn make_disk_dirent(&self, inode: Arc, file_type: u8, name: &str) { + pub fn make_disk_dirent(&self, inode: &INode, file_type: u8, name: &str) { // TODO: scan for unused directory entries and check if this can be // inserted into the existing block. let block = self.append_block().unwrap(); let fs = self.fs.upgrade().expect("ext2: filesystem was dropped"); let block_size = fs.superblock.block_size(); - let mut entry = DirtyRef::::new(fs.block.sref(), block * block_size); + let mut entry = DirtyRef::::new(&fs.block.sref(), block * block_size); entry.entry_size = block_size as _; entry.inode = inode.id as _; entry.file_type = file_type; @@ -338,7 +338,7 @@ impl INode { } // FIXME: Fix the filetype! - self.make_disk_dirent(ext2_inode, 2, name); + self.make_disk_dirent(&ext2_inode, 2, name); Ok(inode) } @@ -458,7 +458,7 @@ impl INodeInterface for INode { if let Some(_parent) = old.parent() { // FIXME: Remove the directory entry from the parent - self.make_disk_dirent(old.inode().downcast_arc().unwrap(), 2, dest); + self.make_disk_dirent(&old.inode().downcast_arc().unwrap(), 2, dest); return Ok(()); } @@ -719,7 +719,7 @@ impl Ext2 { ); Some(Arc::new_cyclic(|sref| Self { - bgdt: GroupDescriptors::new(sref.clone(), block.clone(), &superblock) + bgdt: GroupDescriptors::new(sref.clone(), &block, &superblock) .expect("ext2: failed to read group descriptors"), superblock, block, diff --git a/src/aero_kernel/src/fs/file_table.rs b/src/aero_kernel/src/fs/file_table.rs index c4428f50f62..ca86a505f58 100644 --- a/src/aero_kernel/src/fs/file_table.rs +++ b/src/aero_kernel/src/fs/file_table.rs @@ -30,6 +30,7 @@ use super::cache::{DirCacheItem, INodeCacheItem}; use super::inode::FileType; use super::FileSystemError; +#[derive(Debug, Copy, Clone)] pub enum DuplicateHint { Exact(usize), Any, @@ -270,7 +271,7 @@ impl FileTable { // Ensure the file descriptor is available. if files[new_fd].is_none() { files[new_fd] = Some(handle.duplicate(new_fd, flags)?); - Ok(0x00) + Ok(0) } else { // If the file descriptor is not available, then we close the // old one and set its handle to the new duplicate handle. @@ -280,7 +281,7 @@ impl FileTable { old.inode.inode().close(*old.flags.read()); files[new_fd] = Some(handle); - Ok(0x00) + Ok(0) } } diff --git a/src/aero_kernel/src/fs/inode.rs b/src/aero_kernel/src/fs/inode.rs index a3ae965c8b2..5b8d3c0261c 100644 --- a/src/aero_kernel/src/fs/inode.rs +++ b/src/aero_kernel/src/fs/inode.rs @@ -57,7 +57,7 @@ impl Drop for PollTable { fn drop(&mut self) { let ctask = scheduler::get_scheduler().current_task(); for queue in self.queues.iter() { - queue.remove(ctask.clone()); + queue.remove(&ctask); } } } @@ -419,10 +419,16 @@ impl DirEntry { // ".." (ie. we do not want to re-cache the current directory's, parent directory). let cache_me = ![".", ".."].contains(&name.as_str()); + let filesystem = if let Some(fs) = inode.weak_filesystem() { + Once::initialized(fs) + } else { + Once::new() + }; + let entry = Self { data: BMutex::new(DirProtectedData { parent: Some(parent), - inode: inode.clone(), + inode, name, }), @@ -432,11 +438,7 @@ impl DirEntry { 0x00 }, - filesystem: if let Some(filesystem) = inode.weak_filesystem() { - Once::initialized(filesystem) - } else { - Once::new() - }, + filesystem, }; if cache_me { @@ -540,7 +542,7 @@ impl DirEntry { /// Fetches a cached directory entry item from the directory cache. Returns if /// the provided entry exists in the given parent directory cache. -pub fn fetch_dir_entry(parent: DirCacheItem, name: String) -> Option { +pub fn fetch_dir_entry(parent: &DirCacheItem, name: String) -> Option { let dcache = cache::dcache(); let cache_key = (parent.cache_marker, name); diff --git a/src/aero_kernel/src/fs/mod.rs b/src/aero_kernel/src/fs/mod.rs index 37a17c50345..570dbfa5ec5 100644 --- a/src/aero_kernel/src/fs/mod.rs +++ b/src/aero_kernel/src/fs/mod.rs @@ -103,9 +103,9 @@ impl MountManager { Ok(()) } - fn find_mount(&self, directory: DirCacheItem) -> Result { + fn find_mount(&self, dir: &DirCacheItem) -> Result { let this = self.0.lock(); - let cache_key = directory.cache_key(); + let cache_key = dir.cache_key(); if let Some(mount_point) = this.get(&cache_key) { Ok(mount_point.clone()) @@ -197,7 +197,7 @@ pub fn lookup_path_with( _ => { // After we have resolved all of the special cases that might occur in a path, now // we have to resolve the directory entry itself. For example `a` in `./a/`. - let cache_entry = inode::fetch_dir_entry(cwd.clone(), String::from(component)); + let cache_entry = inode::fetch_dir_entry(&cwd, String::from(component)); let parent = cwd.clone(); if let Some(entry) = cache_entry { @@ -251,7 +251,7 @@ pub fn lookup_path_with( resolve_last, )?; } else if metadata.is_directory() { - if let Ok(mount_point) = MOUNT_MANAGER.find_mount(cwd.clone()) { + if let Ok(mount_point) = MOUNT_MANAGER.find_mount(&cwd) { cwd = mount_point.root_entry; } } diff --git a/src/aero_kernel/src/fs/path.rs b/src/aero_kernel/src/fs/path.rs index 40905999c9e..388b497d687 100644 --- a/src/aero_kernel/src/fs/path.rs +++ b/src/aero_kernel/src/fs/path.rs @@ -103,6 +103,13 @@ impl AsRef for &str { } } +impl AsRef for String { + #[inline] + fn as_ref(&self) -> &Path { + Path::new(self) + } +} + /// An owned, mutable path (akin to [`String`]). #[derive(Debug, Clone, PartialEq, Eq)] pub struct PathBuf(String); @@ -143,6 +150,13 @@ impl PathBuf { } } +impl Default for PathBuf { + #[inline] + fn default() -> Self { + PathBuf::new() + } +} + impl From for PathBuf { #[inline] fn from(path: String) -> Self { @@ -172,10 +186,10 @@ impl AsRef for PathBuf { } } -impl Into for PathBuf { +impl From for String { #[inline] - fn into(self) -> String { - self.0 + fn from(val: PathBuf) -> Self { + val.0 } } diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index 72d802f5e33..d3a3e707252 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -63,6 +63,7 @@ #![no_std] #![no_main] #![reexport_test_harness_main = "test_main"] +#![warn(clippy::needless_pass_by_value)] #![deny(clippy::ptr_as_ptr)] #[macro_use] diff --git a/src/aero_kernel/src/syscall/fs.rs b/src/aero_kernel/src/syscall/fs.rs index 5b543914053..f9b93a801be 100644 --- a/src/aero_kernel/src/syscall/fs.rs +++ b/src/aero_kernel/src/syscall/fs.rs @@ -20,15 +20,13 @@ use core::fmt; use aero_syscall::prelude::*; use aero_syscall::signal::SigProcMask; use aero_syscall::{AtFlags, OpenFlags, Stat, TimeSpec, AT_FDCWD}; -use alloc::borrow::ToOwned; -use alloc::sync::Arc; +use alloc::sync::{Arc, Weak}; use crate::fs::cache::{self, DirCacheImpl}; use crate::fs::epoll::EPoll; use crate::fs::eventfd::EventFd; use crate::fs::file_table::{DuplicateHint, FileHandle}; use crate::fs::inode::{DirEntry, PollTable}; -use crate::fs::path::PathBuf; use crate::fs::pipe::Pipe; use crate::fs::{self, lookup_path, LookupMode}; use crate::syscall::SysArg; @@ -70,9 +68,9 @@ impl super::SysArg for FileDescriptor { } } -impl Into for FileDescriptor { - fn into(self) -> usize { - self.0 +impl From for usize { + fn from(val: FileDescriptor) -> Self { + val.0 } } @@ -623,9 +621,10 @@ pub fn link(src_path: &Path, dest_path: &Path) -> Result { // strong references to it. // // TODO: Should this be moved to the inode impl? - if dest_dir.weak_filesystem().unwrap().as_ptr() - != src.inode().weak_filesystem().unwrap().as_ptr() - { + if !Weak::ptr_eq( + &dest_dir.weak_filesystem().unwrap(), + &src.inode().weak_filesystem().unwrap(), + ) { return Err(SyscallError::EINVAL); } diff --git a/src/aero_kernel/src/syscall/futex.rs b/src/aero_kernel/src/syscall/futex.rs index e0782114906..c7d6ec0a390 100644 --- a/src/aero_kernel/src/syscall/futex.rs +++ b/src/aero_kernel/src/syscall/futex.rs @@ -97,7 +97,7 @@ impl FutexContainer { futex.insert(current_task.clone()); scheduler.inner.await_io()?; - futex.remove(current_task); + futex.remove(¤t_task); if futex.is_empty() { self.futexes.lock().remove(&key); diff --git a/src/aero_kernel/src/syscall/process.rs b/src/aero_kernel/src/syscall/process.rs index df60b8e6c43..9682a54d834 100644 --- a/src/aero_kernel/src/syscall/process.rs +++ b/src/aero_kernel/src/syscall/process.rs @@ -140,7 +140,7 @@ pub fn exec(path: &Path, args: usize, argc: usize, envs: usize, envc: usize) -> scheduler::get_scheduler() .current_task() - .exec(executable, argv, envv) + .exec(&executable, argv, envv) .expect("task: failed to exec task"); unreachable!() @@ -378,7 +378,7 @@ fn find_task_by_pid(pid: usize) -> Result> { #[syscall] pub fn getpgid(pid: usize) -> Result { let task = find_task_by_pid(pid)?; - let group = SESSIONS.find_group(task).unwrap(); + let group = SESSIONS.find_group(&task).unwrap(); Ok(group.id()) } @@ -416,6 +416,6 @@ pub fn setsid() -> Result { return Err(SyscallError::EPERM); } - SESSIONS.isolate(current_task); + SESSIONS.isolate(¤t_task); Ok(0) } diff --git a/src/aero_kernel/src/userland/mod.rs b/src/aero_kernel/src/userland/mod.rs index 2954470514b..7b7853de708 100644 --- a/src/aero_kernel/src/userland/mod.rs +++ b/src/aero_kernel/src/userland/mod.rs @@ -28,7 +28,7 @@ pub fn run() -> fs::Result<()> { let init_path = Path::new("/usr/bin/init"); let init_inode = fs::lookup_path(init_path)?; - scheduler::get_scheduler().exec(init_inode, None, None); + scheduler::get_scheduler().exec(&init_inode, None, None); Ok(()) } @@ -37,6 +37,6 @@ pub fn run_tests() -> fs::Result<()> { let utest_path = Path::new("/usr/bin/utest"); let utest_inode = fs::lookup_path(utest_path)?; - scheduler::get_scheduler().exec(utest_inode, None, None); + scheduler::get_scheduler().exec(&utest_inode, None, None); Ok(()) } diff --git a/src/aero_kernel/src/userland/scheduler/mod.rs b/src/aero_kernel/src/userland/scheduler/mod.rs index 8f5629bba49..692bf81a06e 100644 --- a/src/aero_kernel/src/userland/scheduler/mod.rs +++ b/src/aero_kernel/src/userland/scheduler/mod.rs @@ -70,7 +70,7 @@ impl TaskContainer { self.0.lock().insert(task_id, task); } - fn remove_task(&self, task: Arc) { + fn remove_task(&self, task: &Task) { self.0.lock().remove(&task.pid()); } } @@ -104,12 +104,12 @@ impl Scheduler { /// Registers the provided task in the schedulers queue. pub fn register_task(&self, task: Arc) { self.tasks.register_task(task.pid(), task.clone()); - self.inner.register_task(task.clone()); - SESSIONS.register_task(task); + SESSIONS.register_task(task.clone()); + self.inner.register_task(task); } #[inline] - pub fn exec(&self, executable: DirCacheItem, argv: Option, envv: Option) { + pub fn exec(&self, executable: &DirCacheItem, argv: Option, envv: Option) { self.inner .current_task() .exec(executable, argv, envv) @@ -124,8 +124,8 @@ impl Scheduler { pub fn exit(&self, status: ExitStatus) -> ! { let current_task = self.inner.current_task(); - SESSIONS.remove_task(current_task.clone()); - self.tasks.remove_task(current_task); + SESSIONS.remove_task(¤t_task); + self.tasks.remove_task(¤t_task); self.inner.exit(status) } diff --git a/src/aero_kernel/src/userland/task/mod.rs b/src/aero_kernel/src/userland/task/mod.rs index c242e511759..f14abd89d8c 100644 --- a/src/aero_kernel/src/userland/task/mod.rs +++ b/src/aero_kernel/src/userland/task/mod.rs @@ -517,7 +517,7 @@ impl Task { pub fn exec( &self, - executable: DirCacheItem, + executable: &DirCacheItem, argv: Option, envv: Option, @@ -598,6 +598,11 @@ impl Task { // TODO: is_process_leader() && children.len() == 0 and then // assert!(self.file_table.strong_count() == 1); dbg!(Arc::strong_count(&self.file_table)); + log::warn!( + "HI MOM HI MOM HI MOM HI MOM: I HAVE {} STRONG AND {} WEAK REFERENCES", + Weak::strong_count(&self.sref), + Weak::weak_count(&self.sref) + ); if Arc::strong_count(&self.file_table) == 1 { self.file_table.0.read().iter().for_each(|file| { if let Some(handle) = file { diff --git a/src/aero_kernel/src/userland/task/sessions.rs b/src/aero_kernel/src/userland/task/sessions.rs index c0502680ddd..e6a8a003036 100644 --- a/src/aero_kernel/src/userland/task/sessions.rs +++ b/src/aero_kernel/src/userland/task/sessions.rs @@ -36,13 +36,15 @@ pub struct Group { impl Group { /// Creates a new process group. pub fn new(leader: Arc) -> Arc { - let mut tasks = HashMap::new(); - tasks.insert(leader.pid(), leader.clone()); - leader.set_group_id(leader.pid().as_usize()); + let id = leader.pid().as_usize(); + + let mut tasks = HashMap::new(); + tasks.insert(leader.pid(), leader); + Arc::new(Self { - id: leader.pid().as_usize(), + id, tasks: Mutex::new(tasks), }) } @@ -55,7 +57,7 @@ impl Group { assert!(self.tasks.lock_irq().insert(task.pid(), task).is_none()); } - pub fn remove_task(&self, task: Arc) { + pub fn remove_task(&self, task: &Arc) { assert!(self.tasks.lock_irq().remove(&task.pid()).is_some()); } @@ -80,17 +82,17 @@ pub struct Session { impl Session { /// Creates a new process session. pub fn new(leader: Arc) -> Arc { - let mut groups = HashMap::new(); - groups.insert(leader.pid().as_usize(), Group::new(leader.clone())); - leader.set_session_id(leader.pid().as_usize()); + let mut groups = HashMap::new(); + groups.insert(leader.pid().as_usize(), Group::new(leader)); + Arc::new(Self { groups: Mutex::new(groups), }) } - pub fn find(&self, target: Arc) -> Option> { + pub fn find(&self, target: &Arc) -> Option> { self.groups.lock_irq().get(&target.group_id()).cloned() } @@ -107,13 +109,13 @@ impl Session { } } - pub fn remove_task(&self, task: Arc) { + pub fn remove_task(&self, task: &Arc) { let mut groups = self.groups.lock(); let group = groups .get(&task.group_id()) .expect("Session::remove_task: ESRCH"); - group.remove_task(task.clone()); + group.remove_task(task); if group.is_empty() { assert!(task.is_group_leader()); @@ -136,7 +138,7 @@ impl SessionList { .insert(leader.pid().as_usize(), Session::new(leader)); } - pub fn find_group(&self, target: Arc) -> Option> { + pub fn find_group(&self, target: &Arc) -> Option> { self.0.lock_irq().get(&target.session_id())?.find(target) } @@ -153,13 +155,13 @@ impl SessionList { } } - pub fn remove_task(&self, task: Arc) { + pub fn remove_task(&self, task: &Arc) { let mut sessions = self.0.lock_irq(); let session = sessions .get(&task.session_id()) .expect("SessionList::remove_task: ESRCH"); - session.remove_task(task.clone()); + session.remove_task(task); if session.is_empty() { assert!(task.is_session_leader()); @@ -167,7 +169,7 @@ impl SessionList { } } - pub fn isolate(&self, task: Arc) { + pub fn isolate(&self, task: &Arc) { assert!(!task.is_group_leader() && !task.is_session_leader()); let leader = task.process_leader(); diff --git a/src/aero_kernel/src/userland/terminal.rs b/src/aero_kernel/src/userland/terminal.rs index d7fc67fc888..5d1313f3a81 100644 --- a/src/aero_kernel/src/userland/terminal.rs +++ b/src/aero_kernel/src/userland/terminal.rs @@ -170,7 +170,7 @@ impl LineDiscipline { self.foreground.read().upgrade() } - pub fn set_foreground(&self, task: Arc) { + pub fn set_foreground(&self, task: &Arc) { *self.foreground.write() = Arc::downgrade(&SESSIONS.find_group(task).unwrap()); } diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs index 5bfef124bfd..4f552704010 100644 --- a/src/aero_kernel/src/userland/vm.rs +++ b/src/aero_kernel/src/userland/vm.rs @@ -57,7 +57,7 @@ pub enum ElfLoadError { MemoryMapError, } -fn parse_elf_header<'header>(file: DirCacheItem) -> Result, ElfLoadError> { +fn parse_elf_header<'header>(file: &DirCacheItem) -> Result, ElfLoadError> { // 1. Read the ELF PT1 header: let pt1_hdr_slice = Box::leak(mem::alloc_boxed_buffer::(ELF_PT1_SIZE)); @@ -103,7 +103,7 @@ fn parse_elf_header<'header>(file: DirCacheItem) -> Result, ElfL } fn parse_program_header<'pheader>( - file: DirCacheItem, + file: &DirCacheItem, header: Header<'pheader>, index: u16, ) -> Result, ElfLoadError> { @@ -151,9 +151,8 @@ struct Shebang { } impl Shebang { - fn new(path: String, argument: String) -> Result { - let path = Path::new(&path); - let interpreter = fs::lookup_path(path).map_err(ElfLoadError::IOError)?; + fn new>(path: P, argument: String) -> Result { + let interpreter = fs::lookup_path(path.as_ref()).map_err(ElfLoadError::IOError)?; Ok(Self { interpreter, @@ -164,7 +163,7 @@ impl Shebang { /// Returns [`true`] if the provided executable (`bin`) contains a shebang /// at the start. -fn contains_shebang(bin: DirCacheItem) -> Result { +fn contains_shebang(bin: &DirCacheItem) -> Result { let shebang = &mut [0u8; 2]; bin.inode() @@ -174,8 +173,8 @@ fn contains_shebang(bin: DirCacheItem) -> Result { Ok(shebang[0] == b'#' && shebang[1] == b'!') } -fn parse_shebang(bin: DirCacheItem) -> Result, ElfLoadError> { - if !contains_shebang(bin.clone())? { +fn parse_shebang(bin: &DirCacheItem) -> Result, ElfLoadError> { + if !contains_shebang(bin)? { return Ok(None); } @@ -238,7 +237,7 @@ pub struct Elf<'this> { impl<'this> Elf<'this> { fn new(file: DirCacheItem) -> Result { - let header = parse_elf_header(file.clone())?; + let header = parse_elf_header(&file)?; Ok(Self { header, file }) } @@ -276,8 +275,7 @@ impl<'this> Iterator for ProgramHeaderIter<'this> { } // Parse and return the program header. - let result = - parse_program_header(self.file.clone(), self.header, self.next_index as u16).ok(); + let result = parse_program_header(&self.file, self.header, self.next_index as u16).ok(); // Increment the next index. self.next_index += 1; @@ -907,12 +905,12 @@ impl VmProtected { fn load_bin<'header>( &mut self, - bin: DirCacheItem, + bin: &DirCacheItem, argv: Option, envv: Option, ) -> Result, ElfLoadError> { // check for a shebang before proceeding. - if let Some(shebang) = parse_shebang(bin.clone())? { + if let Some(shebang) = parse_shebang(bin)? { log::debug!( "shebang: (interpreter={}, argument={})", shebang.interpreter.absolute_path(), @@ -933,7 +931,7 @@ impl VmProtected { largv.extend(&argv.inner[1..]) } - return self.load_bin(shebang.interpreter, Some(largv), envv); + return self.load_bin(&shebang.interpreter, Some(largv), envv); } let elf = Elf::new(bin.clone())?; @@ -1049,7 +1047,7 @@ impl VmProtected { } else if header_type == xmas_elf::program::Type::Interp { let ld = fs::lookup_path(fs::Path::new("/usr/lib/ld.so")).unwrap(); - let res = self.load_bin(ld, None, None)?; + let res = self.load_bin(&ld, None, None)?; entry_point = res.entry_point; } } @@ -1168,7 +1166,7 @@ impl VmProtected { let data = parent.inner.lock(); // Copy over all of the mappings from the parent into the child. - self.mappings = data.mappings.clone(); + self.mappings.clone_from(&data.mappings); } } @@ -1213,7 +1211,7 @@ impl Vm { /// Mapping the provided `bin` file into the VM. pub fn load_bin( &self, - bin: DirCacheItem, + bin: &DirCacheItem, argv: Option, envv: Option, ) -> Result { diff --git a/src/aero_kernel/src/utils/sync.rs b/src/aero_kernel/src/utils/sync.rs index 7dbe1f53f9c..c171ec7617d 100644 --- a/src/aero_kernel/src/utils/sync.rs +++ b/src/aero_kernel/src/utils/sync.rs @@ -64,7 +64,7 @@ impl WaitQueue { lock = mutex.lock_irq(); } - self.remove(task); + self.remove(&task); Ok(lock) } @@ -72,7 +72,7 @@ impl WaitQueue { self.queue.lock_irq().push(task); } - pub fn remove(&self, task: Arc) { + pub fn remove(&self, task: &Task) { let mut tasks = self.queue.lock_irq(); tasks @@ -163,7 +163,7 @@ impl BMutex { loop { if let Some(guard) = self.spin.inner.try_lock() { - self.wq.remove(task); + self.wq.remove(&task); return BMutexGuard { guard, mutex: self }; } diff --git a/src/aero_syscall/src/lib.rs b/src/aero_syscall/src/lib.rs index 15e3e4514f4..437fca0fdd6 100644 --- a/src/aero_syscall/src/lib.rs +++ b/src/aero_syscall/src/lib.rs @@ -273,7 +273,7 @@ pub struct TimeSpec { } #[repr(usize)] -#[derive(Debug)] +#[derive(Debug, Copy, Clone)] pub enum SeekWhence { SeekCur = 1, SeekEnd = 2, @@ -422,7 +422,7 @@ bitflags::bitflags! { } } -#[derive(Debug, Default, Copy, Clone)] +#[derive(Debug, Default, Clone)] #[repr(C)] pub struct Termios { pub c_iflag: TermiosIFlag, From 694e57fd2ad285a9ecb420b9a38f903833dc8482 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 30 Mar 2024 23:06:34 +1100 Subject: [PATCH 048/112] fix(nvme): map bar Signed-off-by: Anhad Singh --- src/aero_kernel/src/drivers/block/nvme/mod.rs | 8 +-- src/aero_kernel/src/drivers/pci.rs | 49 +++++++++++++++++-- src/aero_kernel/src/mem/paging/page.rs | 6 +++ 3 files changed, 56 insertions(+), 7 deletions(-) diff --git a/src/aero_kernel/src/drivers/block/nvme/mod.rs b/src/aero_kernel/src/drivers/block/nvme/mod.rs index cebdb406be4..6e87f6c9e82 100644 --- a/src/aero_kernel/src/drivers/block/nvme/mod.rs +++ b/src/aero_kernel/src/drivers/block/nvme/mod.rs @@ -29,7 +29,7 @@ use alloc::vec::Vec; use bit_field::BitField; use crate::arch::interrupts::{self, InterruptStack}; -use crate::drivers::pci::*; +use crate::drivers::pci::{self, *}; use crate::fs::block::{install_block_device, BlockDevice, BlockDeviceInterface}; use crate::mem::paging::*; @@ -281,11 +281,13 @@ impl<'a> Controller<'a> { let bar0 = header.get_bar(0).ok_or(Error::UnknownBar)?; // All NVMe registers are accessible via BAR0. - let registers_addr = match bar0 { - Bar::Memory64 { address, .. } => PhysAddr::new(address), + let (registers_addr, bar_size) = match bar0 { + Bar::Memory64 { address, size, .. } => (PhysAddr::new(address), size), _ => return Err(Error::UnknownBar), }; + pci::map_bar(&bar0); + let registers = registers_addr .as_hhdm_virt() .read_mut::() diff --git a/src/aero_kernel/src/drivers/pci.rs b/src/aero_kernel/src/drivers/pci.rs index 1b652d50623..dc95c07fb95 100644 --- a/src/aero_kernel/src/drivers/pci.rs +++ b/src/aero_kernel/src/drivers/pci.rs @@ -23,7 +23,7 @@ use crate::utils::bitmap::Bitmap; use crate::utils::sync::Mutex; use crate::acpi::mcfg; -use crate::mem::paging::OffsetPageTable; +use crate::mem::paging::{OffsetPageTable, PhysAddr}; use crate::utils::VolatileCell; use crate::arch::{apic, io}; @@ -116,16 +116,18 @@ impl<'a> Msix<'a> { .get_bar(bar_index) .expect("msix: table bar not present"); + map_bar(&bar); + let bar_address = match bar { - Bar::Memory64 { address, .. } => address, - Bar::Memory32 { address, .. } => address as u64, + Bar::Memory64 { address, .. } => PhysAddr::new(address), + Bar::Memory32 { address, .. } => PhysAddr::new(address as u64), _ => unreachable!(), }; // SAFETY: We have exclusive access to the BAR and the slice is in bounds. let messages = unsafe { core::slice::from_raw_parts_mut( - (bar_address + bar_offset as u64) as *mut Message, + (bar_address.as_hhdm_virt() + bar_offset as u64).as_mut_ptr::(), table_length as usize, ) }; @@ -788,6 +790,45 @@ impl PciTable { } } +pub fn map_bar(bar: &Bar) { + use crate::mem::paging::{Mapper, Page, PageTableFlags, PhysFrame, Size4KiB, UnmapError}; + + use crate::mem::AddressSpace; + + let mut address_space = AddressSpace::this(); + let mut offset_table = address_space.offset_page_table(); + + let (addr, size) = match bar { + Bar::Memory64 { address, size, .. } => (PhysAddr::new(*address), *size), + _ => unreachable!(), + }; + + for frame in PhysFrame::range( + PhysFrame::::from_start_address(addr).unwrap(), + PhysFrame::containing_address(addr + size), + ) { + let virt = frame.start_address().as_hhdm_virt(); + let page = Page::containing_address(virt); + + // Map will fail if the bar was partially mapped. + match offset_table.unmap(page) { + Ok((_, m)) => m.ignore(), + Err(UnmapError::PageNotMapped) => {} + Err(e) => unreachable!("{:?}", e), + } + + unsafe { + offset_table.map_to( + page, + frame, + PageTableFlags::PRESENT | PageTableFlags::WRITABLE | PageTableFlags::NO_EXECUTE, + ) + } + .unwrap() + .flush(); + } +} + pub fn register_device_driver(handle: Arc) { PCI_TABLE.lock().inner.push(PciDevice { handle }) } diff --git a/src/aero_kernel/src/mem/paging/page.rs b/src/aero_kernel/src/mem/paging/page.rs index 56e212786d4..84894fea5b5 100644 --- a/src/aero_kernel/src/mem/paging/page.rs +++ b/src/aero_kernel/src/mem/paging/page.rs @@ -249,6 +249,12 @@ impl PhysFrame { Ok(PhysFrame::containing_address(address)) } + /// Returns a range of pages, exclusive `end`. + #[inline] + pub const fn range(start: Self, end: Self) -> PhysFrameRange { + PhysFrameRange { start, end } + } + /// Returns the frame that contains the given physical address. #[inline] pub fn containing_address(address: PhysAddr) -> Self { From cc40294cf48323e2a295cd13b2788016436a4cca Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 30 Mar 2024 23:13:29 +1100 Subject: [PATCH 049/112] fix(makefile): unset `QEMU_PATH` workaround Signed-off-by: Anhad Singh --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index f31c027278c..aeea0b245b1 100644 --- a/Makefile +++ b/Makefile @@ -40,10 +40,16 @@ iso: $(KERNEL_TARGET) distro-image: distro ./build-support/mkimage.sh +QEMU_PATH ?= $(shell dirname $(shell which qemu-system-x86_64)) + .PHONY: qemu qemu: $(KERNEL_TARGET) $(USERLAND_TARGET) ${QEMU_PATH}/qemu-system-x86_64 -cdrom target/aero.iso -m 8G -serial stdio --boot d -s -enable-kvm -cpu host,+vmx -drive file=target/disk.img,if=none,id=NVME1,format=raw -device nvme,drive=NVME1,serial=nvme +# .PHONY: qemu_perf +# qemu_perf: +# ${QEMU_PATH}/qemu-system-x86_64 -cdrom target/aero.iso -m 8G -serial stdio --boot d -s -cpu host,+vmx -drive file=target/disk.img,if=none,id=NVME1,format=raw -device nvme,drive=NVME1,serial=nvme -plugin './target/kern-profile.so,out=raw-data,delay=1' + .PHONY: doc doc: cd src && cargo doc --package aero_kernel --release --target-dir=../target/doc/ From eaaf127e25b58cef45b759c11bbe9971c80d6311 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sun, 31 Mar 2024 13:10:50 +1100 Subject: [PATCH 050/112] ports(xz): CVE-2024-3094 workaround Changes copied from Lyre. Signed-off-by: Anhad Singh --- recipes/xz | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/xz b/recipes/xz index 861cea5478e..5cfdcce1766 100644 --- a/recipes/xz +++ b/recipes/xz @@ -1,8 +1,8 @@ name=xz -version=5.4.6 +version=5.4.5 revision=1 -tarball_url="https://github.com/tukaani-project/xz/releases/download/v${version}/xz-${version}.tar.gz" -tarball_blake2b="f0bbd33ea7cd64d475c3501f6e76080c8c0080e377f23462f5f76459935f4e621538ddaa8452d2feaed278d62a596e38ed2aca18ed9e76512c4ec77fa2f4cc5f" +tarball_url="http://deb.debian.org/debian/pool/main/x/xz-utils/xz-utils_5.6.1+really5.4.5.orig.tar.xz" +tarball_blake2b="08d9afebd927ea5d155515a4c9eedda4d1a249f2b1ab6ada11f50e5b7a3c90b389b32378ab1c0872c7f4627de8dff37149d85e49f7f4d30614add37320ec4f3e" source_hostdeps="automake autoconf libtool pkg-config" hostdeps="gcc autoconf automake libtool pkg-config" deps="core-libs" From d6c5a666919d2d7e70aa3cb70146775d02191c1b Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Mon, 1 Apr 2024 20:39:10 +1100 Subject: [PATCH 051/112] perf(kernel): do not wrap allocator in `Once` Not required. Signed-off-by: Anhad Singh --- Makefile | 10 ++- src/aero_kernel/src/mem/paging/frame.rs | 83 +++++++++++--------- src/aero_kernel/src/mem/paging/page_table.rs | 1 + src/aero_kernel/src/utils/bitmap.rs | 2 +- 4 files changed, 54 insertions(+), 42 deletions(-) diff --git a/Makefile b/Makefile index aeea0b245b1..1317c92661b 100644 --- a/Makefile +++ b/Makefile @@ -46,9 +46,13 @@ QEMU_PATH ?= $(shell dirname $(shell which qemu-system-x86_64)) qemu: $(KERNEL_TARGET) $(USERLAND_TARGET) ${QEMU_PATH}/qemu-system-x86_64 -cdrom target/aero.iso -m 8G -serial stdio --boot d -s -enable-kvm -cpu host,+vmx -drive file=target/disk.img,if=none,id=NVME1,format=raw -device nvme,drive=NVME1,serial=nvme -# .PHONY: qemu_perf -# qemu_perf: -# ${QEMU_PATH}/qemu-system-x86_64 -cdrom target/aero.iso -m 8G -serial stdio --boot d -s -cpu host,+vmx -drive file=target/disk.img,if=none,id=NVME1,format=raw -device nvme,drive=NVME1,serial=nvme -plugin './target/kern-profile.so,out=raw-data,delay=1' +.PHONY: qemu_perf +qemu_perf: $(KERNEL_TARGET) $(USERLAND_TARGET) + ${QEMU_PATH}/qemu-system-x86_64 -cdrom target/aero.iso -m 8G -serial stdio --boot d -s -drive file=target/disk.img,if=none,id=NVME1,format=raw -device nvme,drive=NVME1,serial=nvme -plugin './target/kern-profile.so,out=raw-data,delay=30' -d plugin -cpu max + +.PHONY: qemu_p +qemu_p: + ${QEMU_PATH}/qemu-system-x86_64 -cdrom target/aero.iso -m 8G -serial stdio --boot d -s -drive file=target/disk.img,if=none,id=NVME1,format=raw -device nvme,drive=NVME1,serial=nvme -d plugin -cpu max -qmp unix:/tmp/qmp.sock,server,nowait .PHONY: doc doc: diff --git a/src/aero_kernel/src/mem/paging/frame.rs b/src/aero_kernel/src/mem/paging/frame.rs index 8cf3d583cbf..f2372a2995d 100644 --- a/src/aero_kernel/src/mem/paging/frame.rs +++ b/src/aero_kernel/src/mem/paging/frame.rs @@ -63,32 +63,52 @@ const fn order_from_size(size: u64) -> usize { unreachable!() } -pub struct LockedFrameAllocator(Once>); +pub struct LockedFrameAllocator(Mutex); impl LockedFrameAllocator { /// Constructs a new uninitialized and locked version of the global frame /// allocator. pub(super) const fn new_uninit() -> Self { - Self(Once::new()) + let bstrap_ref = BootAllocRef { + inner: core::ptr::null(), + }; + + Self(Mutex::new(GlobalFrameAllocator { + buddies: [ + Bitmap::empty(bstrap_ref), + Bitmap::empty(bstrap_ref), + Bitmap::empty(bstrap_ref), + Bitmap::empty(bstrap_ref), + Bitmap::empty(bstrap_ref), + Bitmap::empty(bstrap_ref), + Bitmap::empty(bstrap_ref), + Bitmap::empty(bstrap_ref), + Bitmap::empty(bstrap_ref), + Bitmap::empty(bstrap_ref), + ], + free: [0; 10], + + base: PhysAddr::zero(), + end: PhysAddr::zero(), + })) } /// Initializes the inner locked global frame allocator. pub(super) fn init(&self, memory_map: &mut limine::response::MemoryMapResponse) { - self.0 - .call_once(|| Mutex::new(GlobalFrameAllocator::new(memory_map))); + *self.0.lock_irq() = GlobalFrameAllocator::new(memory_map); } pub fn dealloc(&self, addr: PhysAddr, size_bytes: usize) { let order = order_from_size(size_bytes as u64); - let mut allocator = self.0.get().unwrap().lock_irq(); + let mut allocator = self.0.lock_irq(); allocator.deallocate_frame_inner(addr, order); } pub fn alloc(&self, size_bytes: usize) -> Option { let order = order_from_size(size_bytes as u64); - let mut allocator = self.0.get()?.lock_irq(); + let mut allocator = self.0.lock_irq(); allocator.allocate_frame_inner(order) } @@ -108,12 +128,8 @@ unsafe impl FrameAllocator for LockedFrameAllocator { fn deallocate_frame(&self, frame: PhysFrame) { self.0 - .get() - .map(|m| { - m.lock_irq() - .deallocate_frame_inner(frame.start_address(), order_from_size(Size4KiB::SIZE)) - }) - .unwrap() + .lock_irq() + .deallocate_frame_inner(frame.start_address(), order_from_size(Size4KiB::SIZE)) } } @@ -125,12 +141,8 @@ unsafe impl FrameAllocator for LockedFrameAllocator { fn deallocate_frame(&self, frame: PhysFrame) { self.0 - .get() - .map(|m| { - m.lock_irq() - .deallocate_frame_inner(frame.start_address(), order_from_size(Size2MiB::SIZE)) - }) - .unwrap() + .lock_irq() + .deallocate_frame_inner(frame.start_address(), order_from_size(Size2MiB::SIZE)) } } @@ -188,7 +200,7 @@ pub fn pmm_alloc(order: BuddyOrdering) -> PhysAddr { debug_assert!(order <= BUDDY_SIZE.len()); super::FRAME_ALLOCATOR - .alloc_zeroed(BUDDY_SIZE[order] as _) + .alloc(BUDDY_SIZE[order] as _) .unwrap() } @@ -232,13 +244,13 @@ impl BootAlloc { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy)] struct BootAllocRef { inner: *const BootAlloc, } impl BootAllocRef { - fn new(inner: &BootAlloc) -> Self { + const fn new(inner: &BootAlloc) -> Self { Self { inner: inner as *const _, } @@ -357,16 +369,16 @@ impl GlobalFrameAllocator { end, buddies: [ - Bitmap::empty(bref.clone()), - Bitmap::empty(bref.clone()), - Bitmap::empty(bref.clone()), - Bitmap::empty(bref.clone()), - Bitmap::empty(bref.clone()), - Bitmap::empty(bref.clone()), - Bitmap::empty(bref.clone()), - Bitmap::empty(bref.clone()), - Bitmap::empty(bref.clone()), - Bitmap::empty(bref.clone()), + Bitmap::empty(bref), + Bitmap::empty(bref), + Bitmap::empty(bref), + Bitmap::empty(bref), + Bitmap::empty(bref), + Bitmap::empty(bref), + Bitmap::empty(bref), + Bitmap::empty(bref), + Bitmap::empty(bref), + Bitmap::empty(bref), ], free: [0; 10], }; @@ -376,7 +388,7 @@ impl GlobalFrameAllocator { // Allocate the buddies using prealloc: for (i, bsize) in BUDDY_SIZE.iter().enumerate() { let chunk = size / bsize; - this.buddies[i] = Bitmap::new_in(bref.clone(), chunk as usize); + this.buddies[i] = Bitmap::new_in(bref, chunk as usize); } for region in bref.get_inner().memory_ranges.lock().iter() { @@ -545,12 +557,7 @@ impl GlobalFrameAllocator { pub fn init_vm_frames() { VM_FRAMES.call_once(|| { - let frame_count = super::FRAME_ALLOCATOR - .0 - .get() - .unwrap() - .lock_irq() - .frame_count(); + let frame_count = super::FRAME_ALLOCATOR.0.lock_irq().frame_count(); let mut frames = Vec::::new(); frames.resize_with(frame_count, VmFrame::new); diff --git a/src/aero_kernel/src/mem/paging/page_table.rs b/src/aero_kernel/src/mem/paging/page_table.rs index 90a3af6de88..4550d946bfc 100644 --- a/src/aero_kernel/src/mem/paging/page_table.rs +++ b/src/aero_kernel/src/mem/paging/page_table.rs @@ -57,6 +57,7 @@ impl PageTableEntry { } /// Returns whether this entry is zero. + #[inline] pub const fn is_unused(&self) -> bool { self.entry == 0 } diff --git a/src/aero_kernel/src/utils/bitmap.rs b/src/aero_kernel/src/utils/bitmap.rs index 246646af959..747112639f4 100644 --- a/src/aero_kernel/src/utils/bitmap.rs +++ b/src/aero_kernel/src/utils/bitmap.rs @@ -60,7 +60,7 @@ impl Bitmap { /// ```rust /// let bitmap = Bitmap::new(); /// ``` - pub fn empty(alloc: A) -> Self { + pub const fn empty(alloc: A) -> Self { Self { bitmap: Vec::new_in(alloc), } From fc41560a5a1464ddb7643ba942f4ee19a09d31e8 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Mon, 1 Apr 2024 20:50:12 +1100 Subject: [PATCH 052/112] perf(kernel::rendy): do not over-allocate Regresssion. In future, the `alloc_boxed_buffer` must be fully removed. The zeroing is also not required. Signed-off-by: Anhad Singh --- .gitignore | 1 + Makefile | 2 +- src/aero_kernel/src/rendy.rs | 15 ++++----------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index dd4aec68aa7..d4638961943 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ host-pkgs/ host-builds/ pkgs/ builds/ +raw-data diff --git a/Makefile b/Makefile index 1317c92661b..85771d08d14 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ qemu: $(KERNEL_TARGET) $(USERLAND_TARGET) .PHONY: qemu_perf qemu_perf: $(KERNEL_TARGET) $(USERLAND_TARGET) - ${QEMU_PATH}/qemu-system-x86_64 -cdrom target/aero.iso -m 8G -serial stdio --boot d -s -drive file=target/disk.img,if=none,id=NVME1,format=raw -device nvme,drive=NVME1,serial=nvme -plugin './target/kern-profile.so,out=raw-data,delay=30' -d plugin -cpu max + ${QEMU_PATH}/qemu-system-x86_64 -cdrom target/aero.iso -m 8G -serial stdio --boot d -s -drive file=target/disk.img,if=none,id=NVME1,format=raw -device nvme,drive=NVME1,serial=nvme -plugin './target/kern-profile.so,out=raw-data,delay=25' -d plugin -cpu max .PHONY: qemu_p qemu_p: diff --git a/src/aero_kernel/src/rendy.rs b/src/aero_kernel/src/rendy.rs index 659dec79dda..986f3706ed2 100644 --- a/src/aero_kernel/src/rendy.rs +++ b/src/aero_kernel/src/rendy.rs @@ -738,17 +738,10 @@ impl<'this> DebugRendy<'this> { let cols = (width - DEFAULT_MARGIN * 2) / FONT_WIDTH; let rows = (height - DEFAULT_MARGIN * 2) / FONT_HEIGHT; - let grid_size = rows * cols * core::mem::size_of::(); - let grid = mem::alloc_boxed_buffer::(grid_size); - - let queue_size = rows * cols * core::mem::size_of::(); - let queue = mem::alloc_boxed_buffer::(queue_size); - - let map_size = rows * cols * core::mem::size_of::>(); - let map = mem::alloc_boxed_buffer::>(map_size); - - let bg_canvas_size = width * height * core::mem::size_of::(); - let bg_canvas = mem::alloc_boxed_buffer::(bg_canvas_size); + let grid = mem::alloc_boxed_buffer::(rows * cols); + let queue = mem::alloc_boxed_buffer::(rows * cols); + let map = mem::alloc_boxed_buffer::>(rows * cols); + let bg_canvas = mem::alloc_boxed_buffer::(width * height); let mut this = Self { inner: Inner { From a758ca8600251871ebc7ab7a95de8fd0e86c0fe1 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Mon, 1 Apr 2024 21:15:12 +1100 Subject: [PATCH 053/112] misc(rendy): wrap queue character ptr in `NonNull` Signed-off-by: Anhad Singh --- src/aero_kernel/src/rendy.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/aero_kernel/src/rendy.rs b/src/aero_kernel/src/rendy.rs index 986f3706ed2..a88662088ae 100644 --- a/src/aero_kernel/src/rendy.rs +++ b/src/aero_kernel/src/rendy.rs @@ -18,6 +18,7 @@ use core::fmt::Write; use core::ops::{Index, IndexMut}; +use core::ptr::NonNull; use core::time::Duration; use core::{fmt, u8}; @@ -294,7 +295,7 @@ pub struct Inner<'this> { queue: Box<[QueueCharacter]>, grid: Box<[Character]>, - map: Box<[Option<*mut QueueCharacter>]>, + map: Box<[Option>]>, bg_canvas: Box<[u32]>, queue_cursor: usize, @@ -496,13 +497,13 @@ impl<'a> Inner<'a> { queue.x = x; queue.y = y; - self.map[i] = Some(queue as *mut _); + self.map[i] = Some(NonNull::from(queue)); } let item = self.map[i]; unsafe { - (*item.unwrap()).char = *char; + item.unwrap().as_mut().char = *char; } } @@ -529,7 +530,7 @@ impl<'a> Inner<'a> { if self.map[i].is_some() { unsafe { - char = (*self.map[i].unwrap()).char; + char = self.map[i].unwrap().as_ref().char; } } else { char = self.grid[i]; @@ -541,7 +542,7 @@ impl<'a> Inner<'a> { if self.map[i].is_some() { unsafe { - self.grid[i] = (*self.map[i].unwrap()).char; + self.grid[i] = self.map[i].unwrap().as_ref().char; } self.map[i] = None; @@ -686,7 +687,7 @@ impl<'a> Inner<'a> { if let Some(char) = queue { unsafe { - res = (*char).char; + res = char.as_ref().char; } } else { res = self.grid[i]; @@ -740,7 +741,7 @@ impl<'this> DebugRendy<'this> { let grid = mem::alloc_boxed_buffer::(rows * cols); let queue = mem::alloc_boxed_buffer::(rows * cols); - let map = mem::alloc_boxed_buffer::>(rows * cols); + let map = mem::alloc_boxed_buffer::>>(rows * cols); let bg_canvas = mem::alloc_boxed_buffer::(width * height); let mut this = Self { From e2ae63952fca163bac2e6e2b5721a8e915746470 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Mon, 1 Apr 2024 21:58:15 +1100 Subject: [PATCH 054/112] feat(ext2): fill in the timestamp fields for stat Signed-off-by: Anhad Singh --- src/aero_kernel/src/arch/x86_64/apic.rs | 2 +- src/aero_kernel/src/fs/ext2/disk.rs | 23 ++++++++++++++++++++--- src/aero_kernel/src/fs/ext2/mod.rs | 6 +++++- src/aero_syscall/src/lib.rs | 12 ++++++++++++ 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/aero_kernel/src/arch/x86_64/apic.rs b/src/aero_kernel/src/arch/x86_64/apic.rs index 464f5116c93..31f126e3a67 100644 --- a/src/aero_kernel/src/arch/x86_64/apic.rs +++ b/src/aero_kernel/src/arch/x86_64/apic.rs @@ -450,7 +450,7 @@ pub fn init() -> ApicType { log::debug!("apic: detected APIC (addr={address_phys:?}, type={apic_type:?})"); - let address_virt = unsafe { PHYSICAL_MEMORY_OFFSET } + address_phys.as_u64(); + let address_virt = address_phys.as_hhdm_virt(); let mut local_apic = LocalApic::new(address_virt, apic_type); local_apic.init(); diff --git a/src/aero_kernel/src/fs/ext2/disk.rs b/src/aero_kernel/src/fs/ext2/disk.rs index 4f38aca74b4..341a2c057fb 100644 --- a/src/aero_kernel/src/fs/ext2/disk.rs +++ b/src/aero_kernel/src/fs/ext2/disk.rs @@ -15,6 +15,8 @@ // You should have received a copy of the GNU General Public License // along with Aero. If not, see . +use core::time::Duration; + use bit_field::BitField; use crate::fs::inode; @@ -199,10 +201,10 @@ impl From for inode::FileType { pub struct INode { type_and_perm: u16, pub user_id: u16, - pub size_lower: u32, - pub last_access: u32, + size_lower: u32, + last_access: u32, pub creation_time: u32, - pub last_modification: u32, + last_modification: u32, pub deletion_time: u32, pub group_id: u16, pub hl_count: u16, @@ -253,6 +255,21 @@ impl INode { _ => FileType::Unknown, } } + + #[inline] + pub fn last_access(&self) -> Duration { + Duration::from_secs(self.last_access as u64) + } + + #[inline] + pub fn last_modification(&self) -> Duration { + Duration::from_secs(self.last_modification as u64) + } + + #[inline] + pub fn creation_time(&self) -> Duration { + Duration::from_secs(self.creation_time as u64) + } } const_assert_eq!(core::mem::size_of::(), 128); diff --git a/src/aero_kernel/src/fs/ext2/mod.rs b/src/aero_kernel/src/fs/ext2/mod.rs index 18036123913..66fcb0918f8 100644 --- a/src/aero_kernel/src/fs/ext2/mod.rs +++ b/src/aero_kernel/src/fs/ext2/mod.rs @@ -380,7 +380,7 @@ impl INodeInterface for INode { let inode = self.inode.read(); let filesystem = self.fs.upgrade().unwrap(); - let filetype = self.metadata()?.file_type(); + let filetype = inode.file_type().into(); let mut mode = Mode::empty(); @@ -401,6 +401,10 @@ impl INodeInterface for INode { st_size: inode.size() as _, st_mode: mode, + st_atim: inode.last_access().into(), + st_mtim: inode.last_modification().into(), + st_ctim: inode.creation_time().into(), + ..Default::default() }) } diff --git a/src/aero_syscall/src/lib.rs b/src/aero_syscall/src/lib.rs index 437fca0fdd6..d2ecd44102d 100644 --- a/src/aero_syscall/src/lib.rs +++ b/src/aero_syscall/src/lib.rs @@ -32,6 +32,8 @@ pub mod time; pub type Result = core::result::Result; +use core::time::Duration; + use byte_endian::BigEndian; pub use crate::syscall::*; @@ -272,6 +274,16 @@ pub struct TimeSpec { pub tv_nsec: isize, } +impl From for TimeSpec { + #[inline] + fn from(value: Duration) -> Self { + TimeSpec { + tv_sec: value.as_secs() as isize, + tv_nsec: value.subsec_nanos() as isize, + } + } +} + #[repr(usize)] #[derive(Debug, Copy, Clone)] pub enum SeekWhence { From d7f9d43a73a14f870720d4029ff7e8fae4086575 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 3 Apr 2024 18:10:50 +1100 Subject: [PATCH 055/112] feat(makefile): add option to select build profile Signed-off-by: Anhad Singh --- Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 85771d08d14..9f77125313d 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,11 @@ +profile ?= release + +ifneq ($(filter $(profile), dev debug), ) + KERNEL_TARGET := src/target/x86_64-unknown-none/debug/aero_kernel +else + KERNEL_TARGET := src/target/x86_64-unknown-none/release/aero_kernel +endif + jinx: if [ ! -f "target/jinx" ]; then \ curl -Lo target/jinx https://github.com/mintsuki/jinx/raw/30e7d5487bff67a66dfba332113157a08a324820/jinx; \ @@ -15,7 +23,6 @@ distro: jinx SOURCE_DIR := src USERLAND_DIR := userland USERLAND_TARGET := builds/userland/target/init -KERNEL_TARGET := src/target/x86_64-unknown-none/release/aero_kernel .PHONY: clean clean: @@ -26,7 +33,7 @@ check: cd src && cargo check $(KERNEL_TARGET): $(shell find $(SOURCE_DIR) -type f -not -path '$(SOURCE_DIR)/target/*') - cd src && cargo build --package aero_kernel --release + cd src && cargo build --package aero_kernel --profile $(profile) ./build-support/mkiso.sh $(USERLAND_TARGET): $(shell find $(USERLAND_DIR) -type f -not -path '$(USERLAND_DIR)/target/*') From 0476db68a99170a59775db5a9177270dcd3c46f3 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 3 Apr 2024 18:47:20 +1100 Subject: [PATCH 056/112] misc(kernel): cleanup Signed-off-by: Anhad Singh --- src/aero_kernel/src/arch/x86_64/apic.rs | 1 - src/aero_kernel/src/drivers/block/nvme/mod.rs | 10 +++++----- src/aero_kernel/src/drivers/pci.rs | 6 +++--- src/aero_kernel/src/drivers/pty.rs | 8 +++----- src/aero_kernel/src/drivers/uart_16550.rs | 4 ++-- src/aero_kernel/src/fs/block/gpt.rs | 2 +- src/aero_kernel/src/fs/inode.rs | 4 ++-- src/aero_kernel/src/fs/path.rs | 2 +- src/aero_kernel/src/mem/mod.rs | 4 +--- src/aero_kernel/src/mem/paging/addr.rs | 18 ++++++------------ src/aero_kernel/src/mem/paging/frame.rs | 4 ++-- src/aero_kernel/src/mem/paging/page_table.rs | 2 +- src/aero_kernel/src/modules.rs | 2 +- src/aero_kernel/src/net/arp.rs | 4 +--- src/aero_kernel/src/net/loopback.rs | 4 ++-- src/aero_kernel/src/net/mod.rs | 1 - src/aero_kernel/src/socket/netlink.rs | 19 ++++++++----------- src/aero_kernel/src/socket/tcp.rs | 11 +++-------- src/aero_kernel/src/socket/unix.rs | 6 +++--- src/aero_kernel/src/userland/vm.rs | 12 ++++++------ src/aero_kernel/src/utils/buffer.rs | 2 +- src/aero_kernel/src/utils/sync.rs | 4 ++-- 22 files changed, 54 insertions(+), 76 deletions(-) diff --git a/src/aero_kernel/src/arch/x86_64/apic.rs b/src/aero_kernel/src/arch/x86_64/apic.rs index 31f126e3a67..5330a9930b1 100644 --- a/src/aero_kernel/src/arch/x86_64/apic.rs +++ b/src/aero_kernel/src/arch/x86_64/apic.rs @@ -29,7 +29,6 @@ use crate::utils::sync::{Mutex, MutexGuard}; use super::{io, time}; use crate::acpi::madt; -use crate::PHYSICAL_MEMORY_OFFSET; const APIC_SPURIOUS_VECTOR: u32 = 0xFF; diff --git a/src/aero_kernel/src/drivers/block/nvme/mod.rs b/src/aero_kernel/src/drivers/block/nvme/mod.rs index 6e87f6c9e82..2462eedcbf9 100644 --- a/src/aero_kernel/src/drivers/block/nvme/mod.rs +++ b/src/aero_kernel/src/drivers/block/nvme/mod.rs @@ -21,7 +21,7 @@ mod queue; use core::mem::MaybeUninit; use command::*; -use queue::*; +use queue::QueuePair; use alloc::sync::Arc; use alloc::vec::Vec; @@ -281,8 +281,8 @@ impl<'a> Controller<'a> { let bar0 = header.get_bar(0).ok_or(Error::UnknownBar)?; // All NVMe registers are accessible via BAR0. - let (registers_addr, bar_size) = match bar0 { - Bar::Memory64 { address, size, .. } => (PhysAddr::new(address), size), + let registers_addr = match bar0 { + Bar::Memory64 { address, .. } => PhysAddr::new(address), _ => return Err(Error::UnknownBar), }; @@ -538,7 +538,7 @@ impl PciDeviceHandle for Handler<'static> { for device_name in devices { let device = BlockDevice::new(device_name, controller.clone()); - install_block_device(device).expect("nvme: failed to install the block device") + install_block_device(device).expect("nvme: failed to install the block device"); } self.controllers.lock().push(controller); @@ -551,7 +551,7 @@ fn irq_handler(_stack: &mut InterruptStack) { fn nvme_init() { // Register the NVMe device handler. - register_device_driver(Handler::new()) + register_device_driver(Handler::new()); } crate::module_init!(nvme_init, ModuleType::Block); diff --git a/src/aero_kernel/src/drivers/pci.rs b/src/aero_kernel/src/drivers/pci.rs index dc95c07fb95..c44dc4ee6f3 100644 --- a/src/aero_kernel/src/drivers/pci.rs +++ b/src/aero_kernel/src/drivers/pci.rs @@ -679,7 +679,9 @@ impl PciHeader { // bit 0:true - the BAR is in memory // bit 0:false - the BAR is in I/O - if !bar.get_bit(0) { + if bar.get_bit(0) { + Some(Bar::IO(bar.get_bits(2..32))) + } else { let prefetchable = bar.get_bit(3); let address = bar.get_bits(4..32) << 4; @@ -727,8 +729,6 @@ impl PciHeader { _ => None, } - } else { - Some(Bar::IO(bar.get_bits(2..32))) } } diff --git a/src/aero_kernel/src/drivers/pty.rs b/src/aero_kernel/src/drivers/pty.rs index 711d9bfaa48..d75dd81d7b1 100644 --- a/src/aero_kernel/src/drivers/pty.rs +++ b/src/aero_kernel/src/drivers/pty.rs @@ -26,7 +26,7 @@ use alloc::sync::{Arc, Weak}; use alloc::vec::Vec; use spin::{Once, RwLock}; -use uapi::pty::*; +use uapi::pty::TIOCGPTN; use crate::arch::user_copy::UserRef; use crate::fs::cache::*; @@ -107,8 +107,6 @@ struct Master { impl Master { pub fn new() -> Self { - use aero_syscall::*; - Self { id: PTY_ID.fetch_add(1, Ordering::SeqCst), wq: WaitQueue::new(), @@ -191,8 +189,8 @@ impl TerminalDevice for Slave { } fn detach(&self, task: Arc) { - use aero_syscall::signal::*; - use aero_syscall::*; + use aero_syscall::signal::SIGINT; + use aero_syscall::VINTR; if !self.master.discipline.termios.lock().is_cooked() { return; diff --git a/src/aero_kernel/src/drivers/uart_16550.rs b/src/aero_kernel/src/drivers/uart_16550.rs index d644a7a1aa6..328adaa134b 100644 --- a/src/aero_kernel/src/drivers/uart_16550.rs +++ b/src/aero_kernel/src/drivers/uart_16550.rs @@ -47,7 +47,7 @@ bitflags::bitflags! { pub struct SerialPort(u16); impl SerialPort { - #[inline(always)] + #[inline] pub const fn new(port: u16) -> Self { Self(port) } @@ -90,7 +90,7 @@ impl SerialPort { fn wait_for_line_status(&self, line_status: LineStatus) { while !self.line_status().contains(line_status) { - core::hint::spin_loop() + core::hint::spin_loop(); } } diff --git a/src/aero_kernel/src/fs/block/gpt.rs b/src/aero_kernel/src/fs/block/gpt.rs index b52473b7dd6..113a361ee26 100644 --- a/src/aero_kernel/src/fs/block/gpt.rs +++ b/src/aero_kernel/src/fs/block/gpt.rs @@ -23,7 +23,7 @@ use core::mem::MaybeUninit; use alloc::boxed::Box; use alloc::sync::Arc; -const GPT_TABLE_SIGNATURE: u64 = 0x5452415020494645; +const GPT_TABLE_SIGNATURE: u64 = 0x5452_4150_2049_4645; #[repr(C)] pub struct GptTableHeader { diff --git a/src/aero_kernel/src/fs/inode.rs b/src/aero_kernel/src/fs/inode.rs index 5b8d3c0261c..01c621c00ec 100644 --- a/src/aero_kernel/src/fs/inode.rs +++ b/src/aero_kernel/src/fs/inode.rs @@ -286,7 +286,7 @@ pub trait INodeInterface: Send + Sync { } /// Structure representing the crucial, characteristics of an inode. The metadata -/// of an inode can be retrieved by invoking the [INodeInterface::metadata] function. +/// of an inode can be retrieved by invoking the [`INodeInterface::metadata`] function. #[derive(Debug, Copy, Clone)] pub struct Metadata { pub id: usize, @@ -345,7 +345,7 @@ pub enum FileContents { /// and is backed by a static byte buffer StaticContent(&'static [u8]), - /// If the file type of the inode is [FileType::Device], in that case this variant + /// If the file type of the inode is [`FileType::Device`], in that case this variant /// is used. Device(Arc), diff --git a/src/aero_kernel/src/fs/path.rs b/src/aero_kernel/src/fs/path.rs index 388b497d687..c7df40ffc18 100644 --- a/src/aero_kernel/src/fs/path.rs +++ b/src/aero_kernel/src/fs/path.rs @@ -138,7 +138,7 @@ impl PathBuf { self.as_mut_vec().truncate(0); } - let need_sep = self.0.chars().last().map(|c| c != '/').unwrap_or(false); + let need_sep = self.0.chars().last().is_some_and(|c| c != '/'); // TODO: verbatim pahts need . and .. removed diff --git a/src/aero_kernel/src/mem/mod.rs b/src/aero_kernel/src/mem/mod.rs index a6d5adc3654..f7eb4792567 100644 --- a/src/aero_kernel/src/mem/mod.rs +++ b/src/aero_kernel/src/mem/mod.rs @@ -23,9 +23,7 @@ mod vmalloc; use ::alloc::boxed::Box; -use crate::mem::paging::*; - -use self::paging::{active_level_4_table, FRAME_ALLOCATOR}; +use paging::*; /// Structure representing a *virtual* address space. The address space /// contains a reference of the page table allocated for this address space. diff --git a/src/aero_kernel/src/mem/paging/addr.rs b/src/aero_kernel/src/mem/paging/addr.rs index 75abdca7a08..2d97f2592aa 100644 --- a/src/aero_kernel/src/mem/paging/addr.rs +++ b/src/aero_kernel/src/mem/paging/addr.rs @@ -97,19 +97,19 @@ impl VirtAddr { /// Converts the address to a raw pointer. #[cfg(target_pointer_width = "64")] #[inline] - pub fn as_ptr(self) -> *const T { + pub const fn as_ptr(self) -> *const T { self.as_u64() as *const T } /// Converts the address to a mutable raw pointer. #[cfg(target_pointer_width = "64")] #[inline] - pub fn as_mut_ptr(self) -> *mut T { - self.as_ptr::() as *mut T + pub const fn as_mut_ptr(self) -> *mut T { + self.as_ptr::().cast_mut() } #[inline] - pub fn is_zero(self) -> bool { + pub const fn is_zero(self) -> bool { self.0 == 0 } @@ -360,12 +360,6 @@ impl Step for VirtAddr { } } -/// A passed `u64` was not a valid physical address. -/// -/// This means that bits 52 to 64 were not all null. -#[derive(Debug)] -pub struct PhysAddrNotValid(u64); - impl PhysAddr { /// Creates a new physical address. /// @@ -570,7 +564,7 @@ pub fn align_down(addr: u64, align: u64) -> u64 { /// Panics if the alignment is not a power of two. Without the `const_fn` /// feature, the panic message will be "index out of bounds". #[inline] -pub fn align_up(addr: u64, align: u64) -> u64 { +pub const fn align_up(addr: u64, align: u64) -> u64 { let align_mask = align - 1; if addr & align_mask == 0 { @@ -581,7 +575,7 @@ pub fn align_up(addr: u64, align: u64) -> u64 { } #[inline] -pub fn is_aligned(addr: u64, align: u64) -> bool { +pub const fn is_aligned(addr: u64, align: u64) -> bool { align_up(addr, align) == addr } diff --git a/src/aero_kernel/src/mem/paging/frame.rs b/src/aero_kernel/src/mem/paging/frame.rs index f2372a2995d..b12b81d9d46 100644 --- a/src/aero_kernel/src/mem/paging/frame.rs +++ b/src/aero_kernel/src/mem/paging/frame.rs @@ -418,9 +418,9 @@ impl GlobalFrameAllocator { if mask & address.as_u64() != 0 { continue; - } else { - return order; } + + return order; } 0 diff --git a/src/aero_kernel/src/mem/paging/page_table.rs b/src/aero_kernel/src/mem/paging/page_table.rs index 4550d946bfc..bf20f8aa598 100644 --- a/src/aero_kernel/src/mem/paging/page_table.rs +++ b/src/aero_kernel/src/mem/paging/page_table.rs @@ -49,7 +49,7 @@ impl PageTableEntry { // page table entry counter. const COUNTER_MASK: u64 = 0x7ff0_0000_0000_0000; const COUNTER_SHIFT: u64 = 52; - const FLAGS_MASK: u64 = 0x80000000000001ff; + const FLAGS_MASK: u64 = 0x8000_0000_0000_01ff; /// Creates an unused page table entry. pub const fn new() -> Self { diff --git a/src/aero_kernel/src/modules.rs b/src/aero_kernel/src/modules.rs index 8f809a01021..133a8cc13ba 100644 --- a/src/aero_kernel/src/modules.rs +++ b/src/aero_kernel/src/modules.rs @@ -33,7 +33,7 @@ use core::mem::size_of; use crate::{drivers, extern_sym, fs}; -/// Inner helper function to make sure the function provided to the [module_init] macro +/// Inner helper function to make sure the function provided to the [`module_init`] macro /// has a valid function signature. This function returns the passed module init function as /// a const void pointer. diff --git a/src/aero_kernel/src/net/arp.rs b/src/aero_kernel/src/net/arp.rs index 879dc5c34a6..bed1a21598c 100644 --- a/src/aero_kernel/src/net/arp.rs +++ b/src/aero_kernel/src/net/arp.rs @@ -76,9 +76,7 @@ impl Cache { } fn request(&mut self, ip: Ipv4Addr, packet: RawPacket) { - if ip == Ipv4Addr::LOOPBACK { - panic!() - } + assert!(ip != Ipv4Addr::LOOPBACK); if self.0.get_mut(&ip).is_some() { todo!() diff --git a/src/aero_kernel/src/net/loopback.rs b/src/aero_kernel/src/net/loopback.rs index f6bd8a036f2..ff0aebc684e 100644 --- a/src/aero_kernel/src/net/loopback.rs +++ b/src/aero_kernel/src/net/loopback.rs @@ -49,12 +49,12 @@ impl NetworkDriver for Loopback { } lazy_static::lazy_static! { - pub static ref LOOPBACK: Arc = (|| { + pub static ref LOOPBACK: Arc = { let device = Arc::new(NetworkDevice::new(Arc::new(Loopback))); device.set_ip(Ipv4Addr::LOOPBACK); device.set_subnet_mask(Ipv4Addr::new(255, 0, 0, 0)); device - })(); + }; } diff --git a/src/aero_kernel/src/net/mod.rs b/src/aero_kernel/src/net/mod.rs index bd0bd163405..6425ca0917a 100644 --- a/src/aero_kernel/src/net/mod.rs +++ b/src/aero_kernel/src/net/mod.rs @@ -67,7 +67,6 @@ impl NetworkDevice { // What should the default be? Also this should really be handled inside dhcpd. default_gateway: Ipv4Addr::new(10, 0, 2, 2), subnet_mask: Ipv4Addr::new(255, 255, 255, 0), - ..Default::default() }; Self { diff --git a/src/aero_kernel/src/socket/netlink.rs b/src/aero_kernel/src/socket/netlink.rs index bc3588a3169..e91d5c3c7ff 100644 --- a/src/aero_kernel/src/socket/netlink.rs +++ b/src/aero_kernel/src/socket/netlink.rs @@ -33,7 +33,6 @@ use alloc::vec::Vec; use crabnet::network::Ipv4Addr; use crate::fs; -use crate::fs::cache::DirCacheImpl; use crate::fs::inode::{FileType, INodeInterface, Metadata, PollFlags, PollTable}; use crate::utils::sync::{Mutex, WaitQueue}; @@ -61,7 +60,7 @@ impl NetlinkBuilder { Self { buffer: Vec::new() } } - fn header(&mut self, header: netlink::nlmsghdr) { + fn header(&mut self, header: &netlink::nlmsghdr) { self.buffer.extend_from_slice(unsafe { core::slice::from_raw_parts( &header as *const _ as *const u8, @@ -72,7 +71,7 @@ impl NetlinkBuilder { self.buffer_align(); } - fn message(&mut self, message: netlink::rtmsg) { + fn message(&mut self, message: &netlink::rtmsg) { self.buffer.extend_from_slice(unsafe { core::slice::from_raw_parts( &message as *const _ as *const u8, @@ -154,7 +153,7 @@ impl NetLinkSocket { fn send_route_packet(&self, header: &netlink::nlmsghdr) { let mut builder = NetlinkBuilder::new(); - builder.header(netlink::nlmsghdr { + builder.header(&netlink::nlmsghdr { nlmsg_type: MessageType::RtmNewRoute, nlmsg_flags: MessageFlags::MULTI, nlmsg_seq: header.nlmsg_seq, @@ -162,7 +161,7 @@ impl NetLinkSocket { nlmsg_len: 0, }); - builder.message(netlink::rtmsg { + builder.message(&netlink::rtmsg { rtm_family: AF_INET as u8, rtm_dst_len: 0, // FIXME rtm_src_len: 0, @@ -259,13 +258,11 @@ impl INodeInterface for NetLinkSocket { bytes_copied += copy; iovecs.remove(index); + } else if flags.contains(socket::MessageFlags::TRUNC) && bytes_copied == 0 { + message_hdr.flags = socket::MessageFlags::TRUNC.bits() as i32; + return Ok(data.len()); } else { - if flags.contains(socket::MessageFlags::TRUNC) && bytes_copied == 0 { - message_hdr.flags = socket::MessageFlags::TRUNC.bits() as i32; - return Ok(data.len()); - } else { - unimplemented!() - } + unimplemented!() } } diff --git a/src/aero_kernel/src/socket/tcp.rs b/src/aero_kernel/src/socket/tcp.rs index 1cb4c559dff..1af0ec3b2a3 100644 --- a/src/aero_kernel/src/socket/tcp.rs +++ b/src/aero_kernel/src/socket/tcp.rs @@ -78,10 +78,7 @@ impl TcpSocket { pub fn on_packet(&self, tcp: &Tcp, options: TcpOptions, payload: &[u8]) { if let Some(socket) = self.tcp.lock_irq().as_mut() { // Ignore any invalid TCP options. - let options = options - .iter() - .filter_map(|option| option.ok()) - .collect::>(); + let options = options.iter().filter_map(Result::ok).collect::>(); socket.on_packet(tcp, &options, payload); self.wq.notify_all(); @@ -96,8 +93,7 @@ impl TcpSocket { pub fn non_blocking(&self) -> bool { self.handle .get() - .map(|handle| handle.flags().contains(OpenFlags::O_NONBLOCK)) - .unwrap_or_default() + .is_some_and(|handle| handle.flags().contains(OpenFlags::O_NONBLOCK)) } pub fn do_recv(&self, buf: &mut [u8]) -> Result { @@ -113,8 +109,7 @@ impl TcpSocket { let mut socket = self.wq.block_on(&self.tcp, |tcp| { tcp.as_ref() - .map(|socket| !socket.recv_queue.is_empty()) - .unwrap_or(true) + .map_or(true, |socket| !socket.recv_queue.is_empty()) })?; if let Some(socket) = socket.as_mut() { diff --git a/src/aero_kernel/src/socket/unix.rs b/src/aero_kernel/src/socket/unix.rs index 81067917b86..bed1da1ae52 100644 --- a/src/aero_kernel/src/socket/unix.rs +++ b/src/aero_kernel/src/socket/unix.rs @@ -28,7 +28,7 @@ use crate::arch::user_copy::UserRef; use crate::fs; use crate::fs::cache::DirCacheItem; use crate::fs::file_table::FileHandle; -use crate::fs::inode::*; +use crate::fs::inode::{DirEntry, FileType, INodeInterface, Metadata, PollFlags, PollTable}; use crate::fs::{FileSystemError, Path}; @@ -342,7 +342,7 @@ impl INodeInterface for UnixSocket { fn accept(&self, address: Option<(VirtAddr, &mut u32)>) -> fs::Result> { let mut inner = self.wq.block_on(&self.inner, |e| { - e.state.queue().map(|x| !x.is_empty()).unwrap_or(false) + e.state.queue().is_some_and(|x| !x.is_empty()) })?; let queue = inner @@ -352,7 +352,7 @@ impl INodeInterface for UnixSocket { let peer = queue.pop().expect("UnixSocket::accept(): backlog is empty"); let sock = Self::new(); - sock.inner.lock_irq().address = inner.address.clone(); + sock.inner.lock_irq().address.clone_from(&inner.address); { let mut sock_inner = sock.inner.lock_irq(); diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs index 4f552704010..cd0d21fa2fd 100644 --- a/src/aero_kernel/src/userland/vm.rs +++ b/src/aero_kernel/src/userland/vm.rs @@ -327,7 +327,7 @@ pub struct MMapFile { impl MMapFile { #[inline] fn new(file: DirCacheItem, offset: usize, size: usize) -> Self { - Self { file, offset, size } + Self { offset, file, size } } } @@ -689,7 +689,7 @@ impl VmProtected { map.handle_pf_private_anon(&mut offset_table, reason, accessed_address) } - (true, false) | (false, false) => { + (true | false, false) => { map.handle_pf_file(&mut offset_table, reason, accessed_address) } @@ -751,10 +751,10 @@ impl VmProtected { if hole as usize >= size { return Some((start, cursor)); - } else { - // The hole is too small - cursor.move_next(); } + + // The hole is too small + cursor.move_next(); } else { let hole = map_start.as_u64() - address.as_u64(); @@ -939,7 +939,7 @@ impl VmProtected { let load_offset = VirtAddr::new( if header.pt2.type_().as_type() == header::Type::SharedObject { - 0x40000000u64 + 0x4000_0000_u64 } else { 0u64 }, diff --git a/src/aero_kernel/src/utils/buffer.rs b/src/aero_kernel/src/utils/buffer.rs index 2cb0358b419..01bb8b87b1a 100644 --- a/src/aero_kernel/src/utils/buffer.rs +++ b/src/aero_kernel/src/utils/buffer.rs @@ -122,7 +122,7 @@ impl + AsMut<[u8]>> RingBuffer { /// Appends the provided byte to the ring buffer. pub fn append_byte(&mut self, byte: u8) { self.storage.as_mut()[self.position] = byte; - self.position = (self.position + 1) % self.storage.as_mut().len() + self.position = (self.position + 1) % self.storage.as_mut().len(); } } diff --git a/src/aero_kernel/src/utils/sync.rs b/src/aero_kernel/src/utils/sync.rs index c171ec7617d..67ef642bd37 100644 --- a/src/aero_kernel/src/utils/sync.rs +++ b/src/aero_kernel/src/utils/sync.rs @@ -266,14 +266,14 @@ impl<'a, T: ?Sized> core::ops::Deref for MutexGuard<'a, T> { #[inline] fn deref(&self) -> &T { - self.guard.deref() + &self.guard } } impl<'a, T: ?Sized> core::ops::DerefMut for MutexGuard<'a, T> { #[inline] fn deref_mut(&mut self) -> &mut T { - self.guard.deref_mut() + &mut self.guard } } From e23b1da7305fe5441dcde95a34b5c0536e8f26b8 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 3 Apr 2024 20:55:51 +1100 Subject: [PATCH 057/112] fix(rsdp): unaligned pointer deref * Use `read_unaligned` instead. Signed-off-by: Anhad Singh --- src/aero_kernel/src/acpi/rsdp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aero_kernel/src/acpi/rsdp.rs b/src/aero_kernel/src/acpi/rsdp.rs index 0ddd290fafc..008282bc90b 100644 --- a/src/aero_kernel/src/acpi/rsdp.rs +++ b/src/aero_kernel/src/acpi/rsdp.rs @@ -114,7 +114,7 @@ impl Rsdt { for i in 0..self.entries_count() { let item_addr_virt = unsafe { let ptr = header_data_address.add(i); - PhysAddr::new(*ptr as u64).as_hhdm_virt() + PhysAddr::new(ptr.read_unaligned() as u64).as_hhdm_virt() }; let item = unsafe { Sdt::from_address(item_addr_virt) }; From 43aac1421d3742440f7ae3c750dd8b037fce6473 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 3 Apr 2024 20:56:26 +1100 Subject: [PATCH 058/112] fix(rendy): unaligned pointer deref Signed-off-by: Anhad Singh --- src/aero_kernel/src/rendy.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/aero_kernel/src/rendy.rs b/src/aero_kernel/src/rendy.rs index a88662088ae..9181e71417c 100644 --- a/src/aero_kernel/src/rendy.rs +++ b/src/aero_kernel/src/rendy.rs @@ -371,13 +371,9 @@ impl<'a> Inner<'a> { let mut img_x = ratio * xstart; for x in xstart..xend { - let img_pixel = unsafe { - (image.image.as_ptr()) - .add(fixedp6_to_int(img_x) * col_size + off) - .cast::() - }; - - let i = blender(x, y, unsafe { *img_pixel }); + let offset = fixedp6_to_int(img_x) * col_size + off; + let img_pixel: [u8; 4] = unsafe { *image.image.as_ptr().add(offset).cast() }; + let i = blender(x, y, u32::from_le_bytes(img_pixel)); unsafe { *self.buffer.as_mut_ptr().add(fb_off + x) = i as u32; From ada93a20d0cdcad92d0f89fa2ec284b2ee475299 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 3 Apr 2024 20:56:53 +1100 Subject: [PATCH 059/112] misc(kernel): remove feature `pointer_is_aligned` * Remove the feature request for `pointer_is_aligned`, as it has now been stabilized. Signed-off-by: Anhad Singh --- src/aero_kernel/src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index d3a3e707252..d89e2e40737 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -41,7 +41,6 @@ maybe_uninit_write_slice, // https://github.com/rust-lang/rust/issues/79995 slice_ptr_get, // https://github.com/rust-lang/rust/issues/74265 maybe_uninit_as_bytes, // https://github.com/rust-lang/rust/issues/93092 - pointer_is_aligned, // https://github.com/rust-lang/rust/issues/96284 const_trait_impl, // https://github.com/rust-lang/rust/issues/67792 int_roundings, // https://github.com/rust-lang/rust/issues/88581 const_ptr_is_null, // https://github.com/rust-lang/rust/issues/74939 From b69e91bb07249af32bf8f04aff0b66a07cba4a90 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 3 Apr 2024 20:58:14 +1100 Subject: [PATCH 060/112] misc(makefile): cleanup Signed-off-by: Anhad Singh --- Makefile | 14 +++++++++----- build-support/mkiso.sh | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 9f77125313d..1c5cd422d43 100644 --- a/Makefile +++ b/Makefile @@ -26,15 +26,15 @@ USERLAND_TARGET := builds/userland/target/init .PHONY: clean clean: - rm -rf src/target + rm -rf $(SOURCE_DIR)/target .PHONY: check check: - cd src && cargo check + cd $(SOURCE_DIR) && cargo check $(KERNEL_TARGET): $(shell find $(SOURCE_DIR) -type f -not -path '$(SOURCE_DIR)/target/*') - cd src && cargo build --package aero_kernel --profile $(profile) - ./build-support/mkiso.sh + cd $(SOURCE_DIR) && cargo build --package aero_kernel --profile $(profile) + ./build-support/mkiso.sh $(KERNEL_TARGET) $(USERLAND_TARGET): $(shell find $(USERLAND_DIR) -type f -not -path '$(USERLAND_DIR)/target/*') ./target/jinx rebuild userland @@ -53,9 +53,13 @@ QEMU_PATH ?= $(shell dirname $(shell which qemu-system-x86_64)) qemu: $(KERNEL_TARGET) $(USERLAND_TARGET) ${QEMU_PATH}/qemu-system-x86_64 -cdrom target/aero.iso -m 8G -serial stdio --boot d -s -enable-kvm -cpu host,+vmx -drive file=target/disk.img,if=none,id=NVME1,format=raw -device nvme,drive=NVME1,serial=nvme +# "qemu_perf" options: +# delay (default: 30) - the amount of microseconds between each sample. +delay ?= 30 + .PHONY: qemu_perf qemu_perf: $(KERNEL_TARGET) $(USERLAND_TARGET) - ${QEMU_PATH}/qemu-system-x86_64 -cdrom target/aero.iso -m 8G -serial stdio --boot d -s -drive file=target/disk.img,if=none,id=NVME1,format=raw -device nvme,drive=NVME1,serial=nvme -plugin './target/kern-profile.so,out=raw-data,delay=25' -d plugin -cpu max + ${QEMU_PATH}/qemu-system-x86_64 -cdrom target/aero.iso -m 8G -serial stdio --boot d -s -drive file=target/disk.img,if=none,id=NVME1,format=raw -device nvme,drive=NVME1,serial=nvme -plugin './target/kern-profile.so,out=raw-data,delay=$(delay)' -d plugin -cpu max .PHONY: qemu_p qemu_p: diff --git a/build-support/mkiso.sh b/build-support/mkiso.sh index 7e0a6ebecf9..4a0d021d9a9 100755 --- a/build-support/mkiso.sh +++ b/build-support/mkiso.sh @@ -5,7 +5,7 @@ set -ex rm -rf target/iso_root mkdir -pv target/iso_root/boot -cp src/target/x86_64-unknown-none/release/aero_kernel target/iso_root/aero +cp $1 target/iso_root/aero cp build-support/limine.cfg src/.cargo/term_background.bmp target/iso_root/ # Install the limine binaries From c1455ba113c13e5df601fb816e6be953f7471326 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 3 Apr 2024 21:27:32 +1100 Subject: [PATCH 061/112] misc(kernel): cleanup Signed-off-by: Anhad Singh --- src/aero_kernel/src/fs/block/gpt.rs | 3 +-- src/aero_kernel/src/fs/block/mod.rs | 2 +- src/aero_kernel/src/net/mod.rs | 2 +- src/aero_kernel/src/net/tcp.rs | 2 +- src/aero_kernel/src/socket/tcp.rs | 2 +- src/aero_kernel/src/socket/unix.rs | 2 +- src/aero_kernel/src/syscall/net.rs | 2 +- 7 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/aero_kernel/src/fs/block/gpt.rs b/src/aero_kernel/src/fs/block/gpt.rs index 113a361ee26..ee94ad652be 100644 --- a/src/aero_kernel/src/fs/block/gpt.rs +++ b/src/aero_kernel/src/fs/block/gpt.rs @@ -21,7 +21,6 @@ use super::BlockDevice; use core::mem::MaybeUninit; use alloc::boxed::Box; -use alloc::sync::Arc; const GPT_TABLE_SIGNATURE: u64 = 0x5452_4150_2049_4645; @@ -121,7 +120,7 @@ pub struct Gpt { } impl Gpt { - pub fn new(controller: Arc) -> Option { + pub fn new(controller: &BlockDevice) -> Option { // Get the GPT header. let mut header = Box::::new_uninit(); diff --git a/src/aero_kernel/src/fs/block/mod.rs b/src/aero_kernel/src/fs/block/mod.rs index 870d3837d5f..7c5b3f4beb0 100644 --- a/src/aero_kernel/src/fs/block/mod.rs +++ b/src/aero_kernel/src/fs/block/mod.rs @@ -398,7 +398,7 @@ pub fn launch() -> Result<()> { } for block in blocks_copy { - if let Some(gpt) = Gpt::new(block.clone()) { + if let Some(gpt) = Gpt::new(&block) { log::info!("block: found GPT on {}!", block.name()); for (i, entry) in gpt diff --git a/src/aero_kernel/src/net/mod.rs b/src/aero_kernel/src/net/mod.rs index 6425ca0917a..756b7fc9c85 100644 --- a/src/aero_kernel/src/net/mod.rs +++ b/src/aero_kernel/src/net/mod.rs @@ -153,7 +153,7 @@ fn packet_processor_thread() { let options = parser.next::(); let payload = &parser.payload()[..size]; - tcp::on_packet(tcp, options, payload) + tcp::on_packet(tcp, &options, payload) } } } diff --git a/src/aero_kernel/src/net/tcp.rs b/src/aero_kernel/src/net/tcp.rs index b6337dee38e..2889545cf1a 100644 --- a/src/aero_kernel/src/net/tcp.rs +++ b/src/aero_kernel/src/net/tcp.rs @@ -25,7 +25,7 @@ use crate::socket::tcp::TcpSocket; static HANDLERS: RwLock>> = RwLock::new(BTreeMap::new()); -pub fn on_packet(tcp: &Tcp, options: TcpOptions, payload: &[u8]) { +pub fn on_packet(tcp: &Tcp, options: &TcpOptions, payload: &[u8]) { let handlers = HANDLERS.read(); if let Some(handler) = handlers.get(&tcp.dest_port()) { diff --git a/src/aero_kernel/src/socket/tcp.rs b/src/aero_kernel/src/socket/tcp.rs index 1af0ec3b2a3..6b79aa10976 100644 --- a/src/aero_kernel/src/socket/tcp.rs +++ b/src/aero_kernel/src/socket/tcp.rs @@ -75,7 +75,7 @@ impl TcpSocket { }) } - pub fn on_packet(&self, tcp: &Tcp, options: TcpOptions, payload: &[u8]) { + pub fn on_packet(&self, tcp: &Tcp, options: &TcpOptions, payload: &[u8]) { if let Some(socket) = self.tcp.lock_irq().as_mut() { // Ignore any invalid TCP options. let options = options.iter().filter_map(Result::ok).collect::>(); diff --git a/src/aero_kernel/src/socket/unix.rs b/src/aero_kernel/src/socket/unix.rs index bed1da1ae52..bc243f4f0dc 100644 --- a/src/aero_kernel/src/socket/unix.rs +++ b/src/aero_kernel/src/socket/unix.rs @@ -209,7 +209,7 @@ impl UnixSocket { }) } - pub fn connect_pair(a: DirCacheItem, b: DirCacheItem) -> fs::Result<()> { + pub fn connect_pair(a: &DirCacheItem, b: &DirCacheItem) -> fs::Result<()> { let a = a .inode() .downcast_arc::() diff --git a/src/aero_kernel/src/syscall/net.rs b/src/aero_kernel/src/syscall/net.rs index d7375f73a40..aecdd5af984 100644 --- a/src/aero_kernel/src/syscall/net.rs +++ b/src/aero_kernel/src/syscall/net.rs @@ -337,7 +337,7 @@ pub fn socket_pair( let a = create_socket(domain, type_and_flags, protocol)?; let b = create_socket(domain, type_and_flags, protocol)?; - UnixSocket::connect_pair(a.clone(), b.clone())?; + UnixSocket::connect_pair(&a, &b)?; fds[0] = current_task.file_table.open_file(a, sockfd_flags)? as i32; fds[1] = current_task.file_table.open_file(b, sockfd_flags)? as i32; From a1e09a5e6ef5d016e2bbcb1c9bd171384794bc6b Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 3 Apr 2024 22:48:12 +1100 Subject: [PATCH 062/112] feat(ext2): optimize `DirEntryIter` * Read a block at a time since a directory entry cannot span between multiple data blocks. * Only allocate once, ie, on the creation of the iterator. * Reuse the same allocated chunk for the rest of the items. * Return a mutable reference instead of an owned allocated item (expensive). Signed-off-by: Anhad Singh --- src/aero_kernel/src/fs/ext2/disk.rs | 10 ++++ src/aero_kernel/src/fs/ext2/mod.rs | 81 ++++++++++++++++++----------- src/aero_kernel/src/utils/mod.rs | 14 ++++- 3 files changed, 73 insertions(+), 32 deletions(-) diff --git a/src/aero_kernel/src/fs/ext2/disk.rs b/src/aero_kernel/src/fs/ext2/disk.rs index 341a2c057fb..615a985ed18 100644 --- a/src/aero_kernel/src/fs/ext2/disk.rs +++ b/src/aero_kernel/src/fs/ext2/disk.rs @@ -162,6 +162,16 @@ impl DirEntry { let name_bytes = unsafe { self.name.as_mut_slice(name.len()) }; name_bytes.copy_from_slice(name.as_bytes()); } + + pub fn name(&self) -> &str { + unsafe { core::str::from_utf8_unchecked(self.name.as_slice(self.name_size as usize)) } + } + + #[inline] + pub fn is_used(&self) -> bool { + // value of 0 indicates that the entry is not used + self.inode != 0 + } } #[repr(u8)] diff --git a/src/aero_kernel/src/fs/ext2/mod.rs b/src/aero_kernel/src/fs/ext2/mod.rs index 66fcb0918f8..74d70ccc821 100644 --- a/src/aero_kernel/src/fs/ext2/mod.rs +++ b/src/aero_kernel/src/fs/ext2/mod.rs @@ -43,7 +43,7 @@ use super::cache::{DirCacheItem, INodeCacheItem}; use super::path::PathBuf; use super::{cache, FileSystemError, Path}; -use super::inode::{DirEntry, INodeInterface, Metadata, PollFlags, PollTable}; +use super::inode::{self, INodeInterface, Metadata, PollFlags, PollTable}; use super::FileSystem; pub struct INode { @@ -301,6 +301,7 @@ impl INode { entry.entry_size = block_size as _; entry.inode = inode.id as _; entry.file_type = file_type; + // JSDJFKDSJFHJK CHECK THIS this is ub entry.set_name(name); } @@ -314,7 +315,7 @@ impl INode { return Err(FileSystemError::NotDirectory); } - if DirEntryIter::new(self.sref()).any(|(e, _)| e == name) { + if DirEntryIter::new(self.sref()).any(|entry| entry.name() == name) { return Err(FileSystemError::EntryExists); } @@ -349,7 +350,7 @@ impl INode { entry: &disk::DirEntry, ) -> Option { let inode = self.fs.upgrade()?.find_inode(entry.inode as usize, None)?; - Some(DirEntry::new(parent, inode, name.to_string())) + Some(inode::DirEntry::new(parent, inode, name.to_string())) } pub fn sref(&self) -> Arc { @@ -410,19 +411,19 @@ impl INodeInterface for INode { } fn dirent(&self, parent: DirCacheItem, index: usize) -> super::Result> { - if let Some((name, entry)) = DirEntryIter::new(self.sref()).nth(index) { - Ok(self.make_dirent(parent, &name, &entry)) + if let Some(entry) = DirEntryIter::new(self.sref()).nth(index) { + Ok(self.make_dirent(parent, entry.name(), entry)) } else { Ok(None) } } fn lookup(&self, parent: DirCacheItem, name: &str) -> super::Result { - let (name, entry) = DirEntryIter::new(self.sref()) - .find(|(ename, _)| ename == name) + let entry = DirEntryIter::new(self.sref()) + .find(|entry| entry.name() == name) .ok_or(FileSystemError::EntryNotFound)?; - Ok(self.make_dirent(parent, &name, &entry).unwrap()) + Ok(self.make_dirent(parent, entry.name(), entry).unwrap()) } fn read_at(&self, offset: usize, usr_buffer: &mut [u8]) -> super::Result { @@ -456,7 +457,7 @@ impl INodeInterface for INode { fn rename(&self, old: DirCacheItem, dest: &str) -> super::Result<()> { assert!(self.metadata()?.is_directory()); - if DirEntryIter::new(self.sref()).any(|(name, _)| name == dest) { + if DirEntryIter::new(self.sref()).any(|entry| entry.name() == dest) { return Err(FileSystemError::EntryExists); } @@ -504,7 +505,7 @@ impl INodeInterface for INode { } let inode = self.make_inode(name, FileType::File, None)?; - Ok(DirEntry::new(parent, inode, name.to_string())) + Ok(inode::DirEntry::new(parent, inode, name.to_string())) } fn mkdir(&self, name: &str) -> super::Result { @@ -645,46 +646,66 @@ impl INodeInterface for INode { } } -pub struct DirEntryIter { +pub struct DirEntryIter<'a> { inode: Arc, offset: usize, + + current_block: Box<[MaybeUninit]>, + block_size: usize, + _phantom: core::marker::PhantomData<&'a disk::DirEntry>, } -impl DirEntryIter { +impl<'a> DirEntryIter<'a> { pub fn new(inode: Arc) -> Self { - Self { inode, offset: 0 } + let block_size = inode.fs.upgrade().unwrap().superblock.block_size(); + let buf = Box::<[u8]>::new_uninit_slice(block_size); + + Self { + inode, + offset: 0, + current_block: buf, + block_size, + + _phantom: core::marker::PhantomData, + } } } -impl Iterator for DirEntryIter { - type Item = (String, block::DirtyRef); +impl<'a> Iterator for DirEntryIter<'a> { + type Item = &'a mut disk::DirEntry; fn next(&mut self) -> Option { + // Read 1 block at a time. + // + // XXX: A directory entry cannot span between multiple data blocks. let file_size = self.inode.inode.read().size(); if self.offset + core::mem::size_of::() > file_size { return None; } - let entry = unsafe { self.inode.read_mut::(self.offset) }; - if entry.inode == 0 { - return None; + let block_offset = self.offset % self.block_size; + if block_offset == 0 { + self.inode + .read(self.offset, &mut self.current_block) + .unwrap(); } - let mut name = Box::<[u8]>::new_uninit_slice(entry.name_size as usize); - self.inode - .read( - self.offset + core::mem::size_of::(), - MaybeUninit::slice_as_bytes_mut(&mut name), - ) - .ok()?; + // SAFETY: We have initialized the current block above. + let entry = unsafe { + &mut *self + .current_block + .as_mut_ptr() + .add(block_offset) + .cast::() + }; - // SAFETY: We have initialized the name above. - let name = unsafe { name.assume_init() }; - let name = unsafe { core::str::from_utf8_unchecked(&name) }; + if !entry.is_used() { + return None; + } self.offset += entry.entry_size as usize; - Some((name.to_string(), entry)) + Some(entry) } } @@ -747,6 +768,6 @@ impl FileSystem for Ext2 { .find_inode(Ext2::ROOT_INODE_ID, None) .expect("ext2: invalid filesystem (root inode not found)"); - DirEntry::new_root(inode, String::from("/")) + inode::DirEntry::new_root(inode, String::from("/")) } } diff --git a/src/aero_kernel/src/utils/mod.rs b/src/aero_kernel/src/utils/mod.rs index 58918037f88..e2ce5a60da5 100644 --- a/src/aero_kernel/src/utils/mod.rs +++ b/src/aero_kernel/src/utils/mod.rs @@ -21,8 +21,8 @@ use core::alloc::Layout; use core::any::Any; use core::cell::UnsafeCell; use core::marker::PhantomData; -use core::mem; use core::ptr::Unique; +use core::{mem, ptr}; use crate::mem::paging::{align_down, ReadErr, VirtAddr}; @@ -244,11 +244,21 @@ pub struct IncompleteArrayField(PhantomData, [T; 0]); impl IncompleteArrayField { #[inline] pub unsafe fn as_mut_ptr(&mut self) -> *mut T { - self as *mut _ as *mut T + ptr::from_mut(self).cast::() + } + + #[inline] + pub unsafe fn as_ptr(&self) -> *const T { + ptr::from_ref(self).cast::() } #[inline] pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { core::slice::from_raw_parts_mut(self.as_mut_ptr(), len) } + + #[inline] + pub unsafe fn as_slice(&self, len: usize) -> &[T] { + core::slice::from_raw_parts(self.as_ptr(), len) + } } From 37fdd4e196ec6dc127d5b7835226593c631bd1ca Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 4 Apr 2024 22:19:01 +1100 Subject: [PATCH 063/112] cleanup(base-files): reorganize Signed-off-by: Anhad Singh --- Makefile | 11 ++++++++++- base-files/etc/bash.bashrc | 13 +++++++++++++ base-files/etc/bash/bash.bashrc | 15 --------------- base-files/etc/hostname | 1 + base-files/hello.asm | 20 -------------------- base-files/{ => home/aero}/a | 0 base-files/home/aero/test.c | 6 ++++++ base-files/test.c | 6 ------ userland/init/init.c | 4 +++- 9 files changed, 33 insertions(+), 43 deletions(-) create mode 100644 base-files/etc/bash.bashrc delete mode 100644 base-files/etc/bash/bash.bashrc create mode 100644 base-files/etc/hostname delete mode 100644 base-files/hello.asm rename base-files/{ => home/aero}/a (100%) create mode 100644 base-files/home/aero/test.c delete mode 100644 base-files/test.c diff --git a/Makefile b/Makefile index 1c5cd422d43..87fdabf1684 100644 --- a/Makefile +++ b/Makefile @@ -51,7 +51,16 @@ QEMU_PATH ?= $(shell dirname $(shell which qemu-system-x86_64)) .PHONY: qemu qemu: $(KERNEL_TARGET) $(USERLAND_TARGET) - ${QEMU_PATH}/qemu-system-x86_64 -cdrom target/aero.iso -m 8G -serial stdio --boot d -s -enable-kvm -cpu host,+vmx -drive file=target/disk.img,if=none,id=NVME1,format=raw -device nvme,drive=NVME1,serial=nvme + ${QEMU_PATH}/qemu-system-x86_64 \ + -cdrom target/aero.iso \ + -m 8G \ + -serial stdio \ + --boot d -s \ + -enable-kvm \ + -cpu host,+vmx \ + -drive file=target/disk.img,if=none,id=NVME1,format=raw \ + -device nvme,drive=NVME1,serial=nvme \ + ${QEMU_FLAGS} # "qemu_perf" options: # delay (default: 30) - the amount of microseconds between each sample. diff --git a/base-files/etc/bash.bashrc b/base-files/etc/bash.bashrc new file mode 100644 index 00000000000..a738e73f468 --- /dev/null +++ b/base-files/etc/bash.bashrc @@ -0,0 +1,13 @@ +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +alias ls='ls --color=auto' +alias grep='grep --color=auto' + +PS1='\[\033[01;32m\]root@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$ ' + +HISTCONTROL=ignoredups +HISTSIZE=-1 +HISTFILESIZE=-1 + +export DISPLAY=:0 diff --git a/base-files/etc/bash/bash.bashrc b/base-files/etc/bash/bash.bashrc deleted file mode 100644 index a9b77a9c70b..00000000000 --- a/base-files/etc/bash/bash.bashrc +++ /dev/null @@ -1,15 +0,0 @@ -PS1='\[\033[01;32m\]root@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$ ' - -HISTCONTROL=ignoredups -HISTSIZE=-1 -HISTFILESIZE=-1 - -export TERM=xterm-256color - -alias ls="ls --color=auto" -alias clear='printf "\e[2J\e[H"' - -# todo: https://github.com/sharkdp/bat/blob/master/src/bin/bat/directories.rs panics if not set? -export BAT_CONFIG_DIR="/cfg/bat" -export BAT_CACHE_PATH="/cache/bat" -export DISPLAY=:0 diff --git a/base-files/etc/hostname b/base-files/etc/hostname new file mode 100644 index 00000000000..b6e4a236707 --- /dev/null +++ b/base-files/etc/hostname @@ -0,0 +1 @@ +aero \ No newline at end of file diff --git a/base-files/hello.asm b/base-files/hello.asm deleted file mode 100644 index e29fca7d979..00000000000 --- a/base-files/hello.asm +++ /dev/null @@ -1,20 +0,0 @@ -global _start - -section .text -_start: - mov rdx, len - mov rcx, msg - mov rbx, 1 - mov rax, 1 ; SYS_WRITE - - syscall - - mov rbx, 0 - mov rax, 5 ; SYS_EXIT - syscall - - ud2 ; unreachable - -section .data -msg db "Hello, world!", 0xa -len equ $ - msg \ No newline at end of file diff --git a/base-files/a b/base-files/home/aero/a similarity index 100% rename from base-files/a rename to base-files/home/aero/a diff --git a/base-files/home/aero/test.c b/base-files/home/aero/test.c new file mode 100644 index 00000000000..a99e713a844 --- /dev/null +++ b/base-files/home/aero/test.c @@ -0,0 +1,6 @@ +#include + +int main() { + printf("Hello World, from Aero!\n"); + return 0; +} diff --git a/base-files/test.c b/base-files/test.c deleted file mode 100644 index f0f734d22fe..00000000000 --- a/base-files/test.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -int main() { - printf("Hello World, from Aero!\n"); - return 0; -} \ No newline at end of file diff --git a/userland/init/init.c b/userland/init/init.c index 2f7a6e78e70..aaee4abff9d 100644 --- a/userland/init/init.c +++ b/userland/init/init.c @@ -15,11 +15,13 @@ int main() { setenv("TERM", "linux", 1); setenv("USER", "root", 1); setenv("PATH", "/usr/local/bin:/usr/bin", 1); + setenv("HOME", "/home/aero", 1); int pid = fork(); if (!pid) { - char *args[] = {"/usr/bin/bash", "-l", NULL}; + char *args[] = {"/usr/bin/bash", "--login", NULL}; + chdir(getenv("HOME")); execvp("/usr/bin/bash", args); } else { int status; From 46bf24c5846c57a4f68d66b7a337cd3e19cf54dc Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 4 Apr 2024 22:19:28 +1100 Subject: [PATCH 064/112] ports(mlibc): implement `faccessat` Signed-off-by: Anhad Singh --- patches/mlibc/jinx-working-patch.patch | 29 ++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/patches/mlibc/jinx-working-patch.patch b/patches/mlibc/jinx-working-patch.patch index e948a5c0430..f9c3c43ac5b 100644 --- a/patches/mlibc/jinx-working-patch.patch +++ b/patches/mlibc/jinx-working-patch.patch @@ -102,11 +102,32 @@ index 0000000..1b61d5a + ret +.section .note.GNU-stack,"",%progbits diff --git mlibc-clean/sysdeps/aero/generic/filesystem.cpp mlibc-workdir/sysdeps/aero/generic/filesystem.cpp -index 33a11f4..fe5773d 100644 +index 33a11f4..987dc8e 100644 --- mlibc-clean/sysdeps/aero/generic/filesystem.cpp +++ mlibc-workdir/sysdeps/aero/generic/filesystem.cpp -@@ -102,31 +102,24 @@ int sys_access(const char *filename, int mode) { +@@ -89,44 +89,38 @@ int sys_close(int fd) { + return 0; + } + +-int sys_access(const char *filename, int mode) { +- auto result = +- syscall(SYS_ACCESS, AT_FDCWD, filename, strlen(filename), mode, 0); +- +- if (result < 0) { +- return -result; +- } +- ++int sys_faccessat(int dirfd, const char *pathname, int mode, int flags) { ++ auto ret = syscall(SYS_ACCESS, dirfd, pathname, strlen(pathname), mode, flags); ++ if(int e = sc_error(ret); e) ++ return e; + return 0; + } ++int sys_access(const char *filename, int mode) { ++ return sys_faccessat(AT_FDCWD, filename, mode, 0); ++} ++ int sys_stat(fsfd_target fsfdt, int fd, const char *path, int flags, struct stat *statbuf) { - auto result = 0; @@ -118,7 +139,7 @@ index 33a11f4..fe5773d 100644 + fd = AT_FDCWD; break; - } -- + - case fsfd_target::fd: { - result = syscall(SYS_FSTAT, fd, statbuf); + case fsfd_target::fd: @@ -149,7 +170,7 @@ index 33a11f4..fe5773d 100644 return 0; } -@@ -212,6 +205,17 @@ int sys_unlinkat(int fd, const char *path, int flags) { +@@ -212,6 +206,17 @@ int sys_unlinkat(int fd, const char *path, int flags) { return 0; } From 8bd3110912dbb6bcc1902bf4b1b80d7af880d797 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 4 Apr 2024 22:19:55 +1100 Subject: [PATCH 065/112] fix(gethostname): null terminate the resulting str Signed-off-by: Anhad Singh --- src/aero_kernel/src/syscall/process.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/aero_kernel/src/syscall/process.rs b/src/aero_kernel/src/syscall/process.rs index 9682a54d834..72e44389356 100644 --- a/src/aero_kernel/src/syscall/process.rs +++ b/src/aero_kernel/src/syscall/process.rs @@ -267,6 +267,7 @@ pub fn gethostname(buffer: &mut [u8]) -> Result { Err(SyscallError::ENAMETOOLONG) } else { buffer[0..bytes.len()].copy_from_slice(bytes); + buffer[bytes.len()] = b'\0'; Ok(bytes.len()) } From 4601c2fb0366d03285d9221a92f11111c41af220 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 4 Apr 2024 22:21:17 +1100 Subject: [PATCH 066/112] fix(nvme): zero the queue Signed-off-by: Anhad Singh --- src/aero_kernel/src/drivers/block/nvme/queue.rs | 5 +++-- src/aero_kernel/src/utils/dma.rs | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/aero_kernel/src/drivers/block/nvme/queue.rs b/src/aero_kernel/src/drivers/block/nvme/queue.rs index 6763564bb4c..8ad65684161 100644 --- a/src/aero_kernel/src/drivers/block/nvme/queue.rs +++ b/src/aero_kernel/src/drivers/block/nvme/queue.rs @@ -1,4 +1,5 @@ use core::cell::UnsafeCell; +use core::ptr; use core::sync::atomic::{AtomicU16, Ordering}; use crate::mem::paging::PhysAddr; @@ -56,7 +57,7 @@ impl<'bell, T: QueueType> Queue<'bell, T> { Ok(Self { doorbell, - queue: unsafe { Dma::new_uninit_slice(size).assume_init() }, + queue: unsafe { Dma::new_zeroed_slice(size).assume_init() }, index: 0, phase: true, }) @@ -139,7 +140,7 @@ impl<'a> QueuePair<'a> { unsafe { // SAFETY: The offset of the `command_id` field is the same, regardless of the command // type. - command.common.command_id = self.cid; + *ptr::addr_of_mut!(command).cast::().add(1) = self.cid; } self.cid += 1; diff --git a/src/aero_kernel/src/utils/dma.rs b/src/aero_kernel/src/utils/dma.rs index c3c1a19a667..15a26587bd1 100644 --- a/src/aero_kernel/src/utils/dma.rs +++ b/src/aero_kernel/src/utils/dma.rs @@ -32,7 +32,7 @@ unsafe impl Allocator for DmaAllocator { fn allocate(&self, layout: Layout) -> Result, AllocError> { let size_bytes = layout.size(); - let phys = FRAME_ALLOCATOR.alloc_zeroed(size_bytes).ok_or(AllocError)?; + let phys = FRAME_ALLOCATOR.alloc(size_bytes).ok_or(AllocError)?; let virt = phys.as_hhdm_virt(); // SAFETY: The frame is aligned and non-null. @@ -78,6 +78,10 @@ impl Dma { pub fn new_uninit_slice(len: usize) -> Dma<[MaybeUninit]> { Dma(DmaBuffer::new_uninit_slice_in(len, DmaAllocator)) } + + pub fn new_zeroed_slice(len: usize) -> Dma<[MaybeUninit]> { + Dma(DmaBuffer::new_zeroed_slice_in(len, DmaAllocator)) + } } impl Dma<[MaybeUninit]> { From f37046fdbf5931d7f904a89db34b3cefac6b9084 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 4 Apr 2024 22:21:36 +1100 Subject: [PATCH 067/112] feat(access): more complete * Check the flags + check the FD Signed-off-by: Anhad Singh --- src/aero_kernel/src/syscall/fs.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/aero_kernel/src/syscall/fs.rs b/src/aero_kernel/src/syscall/fs.rs index f9b93a801be..f333d3527a0 100644 --- a/src/aero_kernel/src/syscall/fs.rs +++ b/src/aero_kernel/src/syscall/fs.rs @@ -28,7 +28,7 @@ use crate::fs::eventfd::EventFd; use crate::fs::file_table::{DuplicateHint, FileHandle}; use crate::fs::inode::{DirEntry, PollTable}; use crate::fs::pipe::Pipe; -use crate::fs::{self, lookup_path, LookupMode}; +use crate::fs::{self, LookupMode}; use crate::syscall::SysArg; use crate::userland::scheduler; @@ -353,14 +353,19 @@ pub fn unlink(_fd: usize, _path: &Path, _flags: usize) -> Result Result { - if fd as isize == aero_syscall::AT_FDCWD { - lookup_path(path)?; - Ok(0x00) - } else { - // TODO: Implement atfd access - unimplemented!() - } +pub fn access(fd: usize, path: &Path, _mode: usize, flags: usize) -> Result { + let at = match fd as isize { + AT_FDCWD if !path.is_absolute() => scheduler::current_thread().cwd_dirent(), + _ if !path.is_absolute() => FileDescriptor::from_usize(fd).handle()?.inode.clone(), + _ => fs::root_dir().clone(), + }; + + let flags = AtFlags::from_bits(flags).ok_or(SyscallError::EINVAL)?; + + let resolve_last = !flags.contains(AtFlags::SYMLINK_NOFOLLOW); + let _ = fs::lookup_path_with(at, path, LookupMode::None, resolve_last)?; + + Ok(0) } const SETFL_MASK: OpenFlags = OpenFlags::from_bits_truncate( From c5339bee9980f956dea5f87d854cfcaa0aeb7f58 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sun, 7 Apr 2024 17:45:50 +1000 Subject: [PATCH 068/112] ports(coreutils): strip the binaries Signed-off-by: Anhad Singh --- recipes/coreutils | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/coreutils b/recipes/coreutils index 0e228af75ef..9fd78fd6c79 100644 --- a/recipes/coreutils +++ b/recipes/coreutils @@ -37,4 +37,5 @@ build() { package() { DESTDIR="${dest_dir}" make install-strip + post_package_strip } From 6af5f914f715a3ad652462ef0596020d2bd38272 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sun, 7 Apr 2024 17:46:25 +1000 Subject: [PATCH 069/112] ports(mesa): define `GNU_SOURCE` to fix compilation Signed-off-by: Anhad Singh --- patches/mesa/jinx-working-patch.patch | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/patches/mesa/jinx-working-patch.patch b/patches/mesa/jinx-working-patch.patch index 3fdc866bcfa..20d43de4e12 100644 --- a/patches/mesa/jinx-working-patch.patch +++ b/patches/mesa/jinx-working-patch.patch @@ -11,6 +11,19 @@ index 0254024..c2ffd35 100644 #include typedef int8_t __s8; typedef uint8_t __u8; +diff --git mesa-clean/meson.build mesa-workdir/meson.build +index 2902c10..1da7605 100644 +--- mesa-clean/meson.build ++++ mesa-workdir/meson.build +@@ -959,7 +959,7 @@ if cc.has_function('fmemopen') + endif + + # TODO: this is very incomplete +-if ['linux', 'cygwin', 'gnu', 'freebsd', 'gnu/kfreebsd', 'haiku', 'android'].contains(host_machine.system()) ++if ['linux', 'cygwin', 'gnu', 'freebsd', 'gnu/kfreebsd', 'haiku', 'android', 'aero'].contains(host_machine.system()) + pre_args += '-D_GNU_SOURCE' + elif host_machine.system() == 'sunos' + pre_args += '-D__EXTENSIONS__' diff --git mesa-clean/src/compiler/spirv/spirv_to_nir.c mesa-workdir/src/compiler/spirv/spirv_to_nir.c index 5f36118..a501802 100644 --- mesa-clean/src/compiler/spirv/spirv_to_nir.c From 0001dae0b7d6026cf3dceda0eb64d5c1ca7f6514 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sun, 7 Apr 2024 17:46:51 +1000 Subject: [PATCH 070/112] ports(llvm): fix patch Signed-off-by: Anhad Singh --- patches/llvm/jinx-working-patch.patch | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/patches/llvm/jinx-working-patch.patch b/patches/llvm/jinx-working-patch.patch index 24d4135b66b..2ac261e9954 100644 --- a/patches/llvm/jinx-working-patch.patch +++ b/patches/llvm/jinx-working-patch.patch @@ -631,7 +631,7 @@ index 79ccd64..ae3bfb0 100644 Solaris, UEFI, diff --git llvm-clean/llvm/lib/Support/Unix/Path.inc llvm-workdir/llvm/lib/Support/Unix/Path.inc -index e2aece4..72a6259 100644 +index e2aece4..54741ac 100644 --- llvm-clean/llvm/lib/Support/Unix/Path.inc +++ llvm-workdir/llvm/lib/Support/Unix/Path.inc @@ -74,7 +74,8 @@ extern char **environ; @@ -653,7 +653,26 @@ index e2aece4..72a6259 100644 #if defined(HAVE_LINUX_MAGIC_H) #include #else -@@ -472,7 +473,7 @@ std::error_code remove(const Twine &path, bool IgnoreNonExisting) { +@@ -129,7 +130,7 @@ const file_t kInvalidFile = -1; + #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ + defined(__minix) || defined(__FreeBSD_kernel__) || defined(__linux__) || \ + defined(__CYGWIN__) || defined(__DragonFly__) || defined(_AIX) || \ +- defined(__GNU__) || (defined(__sun__) && defined(__svr4__)) ++ defined(__GNU__) || (defined(__sun__) && defined(__svr4__)) || defined(__aero__) + static int test_dir(char ret[PATH_MAX], const char *dir, const char *bin) { + struct stat sb; + char fullpath[PATH_MAX]; +@@ -250,7 +251,8 @@ std::string getMainExecutable(const char *argv0, void *MainAddr) { + // If we don't have procfs mounted, fall back to argv[0] + if (getprogpath(exe_path, argv0) != NULL) + return exe_path; +-#elif defined(__linux__) || defined(__CYGWIN__) || defined(__gnu_hurd__) ++#elif defined(__linux__) || defined(__CYGWIN__) || defined(__gnu_hurd__) || \ ++ defined(__aero__) + char exe_path[PATH_MAX]; + const char *aPath = "/proc/self/exe"; + if (sys::fs::exists(aPath)) { +@@ -472,7 +474,7 @@ std::error_code remove(const Twine &path, bool IgnoreNonExisting) { } static bool is_local_impl(struct STATVFS &Vfs) { From cc0b4484b04523f1003179d1a6bc701cb3c9ad9e Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sun, 7 Apr 2024 17:47:08 +1000 Subject: [PATCH 071/112] ports(xorg-proto): fix patch Signed-off-by: Anhad Singh --- patches/xorg-proto/jinx-working-patch.patch | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/patches/xorg-proto/jinx-working-patch.patch b/patches/xorg-proto/jinx-working-patch.patch index 9c44f9bb503..ddea30d9e82 100644 --- a/patches/xorg-proto/jinx-working-patch.patch +++ b/patches/xorg-proto/jinx-working-patch.patch @@ -1,5 +1,18 @@ +diff --git xorg-proto-clean/include/X11/Xfuncs.h xorg-proto-workdir/include/X11/Xfuncs.h +index b23c283..89dbbb5 100644 +--- xorg-proto-clean/include/X11/Xfuncs.h ++++ xorg-proto-workdir/include/X11/Xfuncs.h +@@ -44,7 +44,7 @@ void bcopy(); + # define bcmp(b1,b2,len) memcmp(b1, b2, len) + # else + # include +-# if defined(__SCO__) || defined(__sun) || defined(__UNIXWARE__) || defined(__CYGWIN__) || defined(_AIX) || defined(__APPLE__) ++# if defined(__SCO__) || defined(__sun) || defined(__UNIXWARE__) || defined(__CYGWIN__) || defined(_AIX) || defined(__APPLE__) || defined(__aero__) + # include + # endif + # define _XFUNCS_H_INCLUDED_STRING_H diff --git xorg-proto-clean/include/X11/Xos.h xorg-proto-workdir/include/X11/Xos.h -index 75cc5b7..9adf88d 100644 +index 75cc5b7..6c46e33 100644 --- xorg-proto-clean/include/X11/Xos.h +++ xorg-proto-workdir/include/X11/Xos.h @@ -60,7 +60,7 @@ in this Software without prior written authorization from The Open Group. @@ -12,7 +25,7 @@ index 75cc5b7..9adf88d 100644 # else # ifndef index diff --git xorg-proto-clean/include/X11/Xos_r.h xorg-proto-workdir/include/X11/Xos_r.h -index f963b64..5ade17b 100644 +index f963b64..542c19d 100644 --- xorg-proto-clean/include/X11/Xos_r.h +++ xorg-proto-workdir/include/X11/Xos_r.h @@ -318,7 +318,7 @@ static __inline__ void _Xpw_copyPasswd(_Xgetpwparams p) From 343106db14859831b3ec16d90029587fbd6d2707 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sun, 7 Apr 2024 17:47:24 +1000 Subject: [PATCH 072/112] ports(llvm): build clang and clang-tools Signed-off-by: Anhad Singh --- recipes/llvm | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/llvm b/recipes/llvm index 8800987df7d..c1f425d614e 100644 --- a/recipes/llvm +++ b/recipes/llvm @@ -20,6 +20,7 @@ build() { -DLLVM_DEFAULT_TARGET_TRIPLE=${OS_TRIPLET} \ -DLLVM_HOST_TRIPLE=${OS_TRIPLET} \ -DLLVM_ENABLE_TERMINFO=OFF \ + -DLLVM_ENABLE_PROJECTS="llvm;clang;clang-tools-extra" \ -Wno-dev \ ${source_dir}/llvm From d2dc8c09836386f26f4fd001eb8a57ad33f9f24c Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sun, 7 Apr 2024 18:00:05 +1000 Subject: [PATCH 073/112] ports(frigg): bump Signed-off-by: Anhad Singh --- recipes/frigg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/frigg b/recipes/frigg index 84df948df6d..4a303d3524b 100644 --- a/recipes/frigg +++ b/recipes/frigg @@ -1,8 +1,8 @@ name=frigg -version=a24e99eeb3125e7f48f657ff8afca26a9ac4aaae +version=dd9d1eab062e8168edafe8d6249524e4e2b157fe revision=1 tarball_url="https://github.com/managarm/frigg/archive/${version}.tar.gz" -tarball_blake2b="bb47eb23f4a0d6cc31d8d2345d424d713f4c0f7b02c28a5a17d937023e778961a9a3a553facfdd60ce58d45da2479e6018ecbb9b39f9bf87c30995bb19698666" +tarball_blake2b="7d77f563f604a590713733b2f0030d0465dd4abbc304c6e183895146ba57bc3cc73993edee898a7a43eadb97d731297b0fb76d3cfc7e5b2ec61d3ec360cc540d" imagedeps="gcc meson ninja" hostdeps="pkg-config" From 1f13576acbd0bb3d6c3eb5b596183d9c86aab611 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sun, 7 Apr 2024 18:01:21 +1000 Subject: [PATCH 074/112] 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 --- Makefile | 4 + patches/mlibc/jinx-working-patch.patch | 248 +++++------------------- recipes/mlibc | 6 +- src/aero_kernel/src/syscall/process.rs | 2 +- src/aero_kernel/src/userland/signals.rs | 2 +- src/aero_syscall/src/consts.rs | 46 +++-- src/aero_syscall/src/lib.rs | 85 ++++---- src/aero_syscall/src/signal.rs | 8 +- 8 files changed, 147 insertions(+), 254 deletions(-) diff --git a/Makefile b/Makefile index 87fdabf1684..547837bb7e3 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,10 @@ USERLAND_TARGET := builds/userland/target/init clean: rm -rf $(SOURCE_DIR)/target +.PHONY: deep-clean +deep-clean: clean + rm -rf target sysroot sources pkgs host-pkgs host-builds builds + .PHONY: check check: cd $(SOURCE_DIR) && cargo check diff --git a/patches/mlibc/jinx-working-patch.patch b/patches/mlibc/jinx-working-patch.patch index f9c3c43ac5b..f646dc2e747 100644 --- a/patches/mlibc/jinx-working-patch.patch +++ b/patches/mlibc/jinx-working-patch.patch @@ -1,111 +1,25 @@ -diff --git mlibc-clean/options/ansi/generic/time-stubs.cpp mlibc-workdir/options/ansi/generic/time-stubs.cpp -index 887a7d3..7fd46bc 100644 ---- mlibc-clean/options/ansi/generic/time-stubs.cpp -+++ mlibc-workdir/options/ansi/generic/time-stubs.cpp -@@ -242,6 +242,7 @@ size_t strftime(char *__restrict dest, size_t max_size, - c++; - break; - } -+ case 'l': - case 'I': { - int hour = tm->tm_hour; - if(!hour) -diff --git mlibc-clean/options/posix/generic/posix_stdlib.cpp mlibc-workdir/options/posix/generic/posix_stdlib.cpp -index 7128e16..14e1dd7 100644 ---- mlibc-clean/options/posix/generic/posix_stdlib.cpp -+++ mlibc-workdir/options/posix/generic/posix_stdlib.cpp -@@ -139,23 +139,34 @@ char *setstate(char *state) { - // ---------------------------------------------------------------------------- +diff --git mlibc-clean/options/glibc/generic/execinfo.cpp mlibc-workdir/options/glibc/generic/execinfo.cpp +index 3474615..d06f130 100644 +--- mlibc-clean/options/glibc/generic/execinfo.cpp ++++ mlibc-workdir/options/glibc/generic/execinfo.cpp +@@ -1,9 +1,10 @@ + #include + #include ++#include - int mkostemp(char *pattern, int flags) { -+ return mkostemps(pattern, 0, flags); -+} -+ -+int mkstemp(char *path) { -+ return mkostemp(path, 0); -+} -+ -+int mkostemps(char *pattern, int suffixlen, int flags) { - flags &= ~O_WRONLY; - auto n = strlen(pattern); - __ensure(n >= 6); -- if(n < 6) { -+ -+ if(n < 6 || suffixlen > (n - 6)) { - errno = EINVAL; - return -1; - } -- for(size_t i = 0; i < 6; i++) { -- if(pattern[n - 6 + i] == 'X') -- continue; -+ -+ if (memcmp(pattern + (n - suffixlen - 6), "XXXXXX", 6)) { - errno = EINVAL; - return -1; - } - - // TODO: Do an exponential search. - for(size_t i = 0; i < 999999; i++) { -- __ensure(sprintf(pattern + (n - 6), "%06zu", i) == 6); -+ int x = i; -+ for (int j = 0; j < 6; j++, x >>= 5) { -+ pattern[(n - suffixlen - 6) + j] = 'A' + (x & 15) + (x & 16) * 2; -+ } - // mlibc::infoLogger() << "mlibc: mkstemp candidate is " - // << (const char *)pattern << frg::endlog; - -@@ -172,16 +183,6 @@ int mkostemp(char *pattern, int flags) { - return -1; + int backtrace(void **, int) { +- __ensure(!"Not implemented"); +- __builtin_unreachable(); ++ mlibc::infoLogger() << "backtrace: Not implemented" << frg::endlog; ++ return 0; } --int mkstemp(char *path) { -- return mkostemp(path, 0); --} -- --int mkostemps(char *pattern, int suffixlen, int flags) { -- (void)suffixlen; -- mlibc::infoLogger() << "mlibc: mkostemps ignores suffixlen!" << frg::endlog; -- return mkostemp(pattern, flags); --} -- - int mkstemps(char *pattern, int suffixlen) { - return mkostemps(pattern, suffixlen, 0); - } -diff --git mlibc-workdir/sysdeps/aero/crt-x86_64/crti.S mlibc-workdir/sysdeps/aero/crt-x86_64/crti.S -new file mode 100644 -index 0000000..f04679c ---- /dev/null -+++ mlibc-workdir/sysdeps/aero/crt-x86_64/crti.S -@@ -0,0 +1,10 @@ -+.section .init -+.global _init -+_init: -+ push %rax -+ -+.section .fini -+.global _fini -+_fini: -+ push %rax -+.section .note.GNU-stack,"",%progbits -diff --git mlibc-workdir/sysdeps/aero/crt-x86_64/crtn.S mlibc-workdir/sysdeps/aero/crt-x86_64/crtn.S -new file mode 100644 -index 0000000..1b61d5a ---- /dev/null -+++ mlibc-workdir/sysdeps/aero/crt-x86_64/crtn.S -@@ -0,0 +1,8 @@ -+.section .init -+ pop %rax -+ ret -+ -+.section .fini -+ pop %rax -+ ret -+.section .note.GNU-stack,"",%progbits + char **backtrace_symbols(void *const *, int) { diff --git mlibc-clean/sysdeps/aero/generic/filesystem.cpp mlibc-workdir/sysdeps/aero/generic/filesystem.cpp -index 33a11f4..987dc8e 100644 +index b9a812b..95c49b9 100644 --- mlibc-clean/sysdeps/aero/generic/filesystem.cpp +++ mlibc-workdir/sysdeps/aero/generic/filesystem.cpp -@@ -89,44 +89,38 @@ int sys_close(int fd) { +@@ -89,23 +89,24 @@ int sys_close(int fd) { return 0; } @@ -130,105 +44,49 @@ index 33a11f4..987dc8e 100644 + int sys_stat(fsfd_target fsfdt, int fd, const char *path, int flags, struct stat *statbuf) { -- auto result = 0; -- switch (fsfdt) { -- case fsfd_target::path: { -- result = syscall(SYS_STAT, path, strlen(path), statbuf); -+ case fsfd_target::path: -+ fd = AT_FDCWD; - break; -- } - -- case fsfd_target::fd: { -- result = syscall(SYS_FSTAT, fd, statbuf); -+ case fsfd_target::fd: -+ flags |= AT_EMPTY_PATH; -+ -+ case fsfd_target::fd_path: + case fsfd_target::path: + fd = AT_FDCWD; break; -- } - -- default: { -- mlibc::infoLogger() -- << "mlibc warning: sys_stat: unsupported fsfd target" -- << frg::endlog; -- return EINVAL; -- } -- } -- -- if (result < 0) { -- return -result; -+ default: -+ __ensure(!"Invalid fsfd_target"); -+ __builtin_unreachable(); - } - -+ auto ret = syscall(SYS_FSTAT, fd, path, strlen(path), flags, statbuf); -+ if(int e = sc_error(ret); e) -+ return e; - return 0; - } - -@@ -212,6 +206,17 @@ int sys_unlinkat(int fd, const char *path, int flags) { - return 0; ++ + case fsfd_target::fd: + flags |= AT_EMPTY_PATH; + +@@ -199,14 +200,14 @@ int sys_rmdir(const char *path) { } -+int sys_symlink(const char *target_path, const char *link_path) { -+ return sys_symlinkat(target_path, AT_FDCWD, link_path); -+} -+ -+int sys_symlinkat(const char *target_path, int dirfd, const char *link_path) { -+ auto ret = syscall(SYS_SYMLINK_AT, dirfd, target_path, strlen(target_path), link_path, strlen(link_path)); + int sys_unlinkat(int fd, const char *path, int flags) { +- auto ret = syscall(SYS_UNLINK, fd, path, strlen(path), flags); +- if (int e = sc_error(ret); e) +- return e; +- return 0; ++ auto ret = syscall(SYS_UNLINK, fd, path, strlen(path), flags); + if (int e = sc_error(ret); e) + return e; + return 0; -+} -+ - struct aero_dir_entry { - size_t inode; - size_t offset; -diff --git mlibc-clean/sysdeps/aero/include/aero/syscall.h mlibc-workdir/sysdeps/aero/include/aero/syscall.h -index 39c5b65..49533cc 100644 ---- mlibc-clean/sysdeps/aero/include/aero/syscall.h -+++ mlibc-workdir/sysdeps/aero/include/aero/syscall.h -@@ -82,6 +82,10 @@ - #define SYS_SOCK_SHUTDOWN 75 - #define SYS_GETPEERNAME 76 - #define SYS_GETSOCKNAME 77 -+#define SYS_DEBUG 78 -+#define SYS_SETSOCKOPT 79 -+#define SYS_GETSOCKOPT 80 -+#define SYS_SYMLINK_AT 81 + } - // Invalid syscall used to trigger a log error in the kernel (as a hint) - // so, that we can implement the syscall in the kernel. -diff --git mlibc-clean/sysdeps/aero/meson.build mlibc-workdir/sysdeps/aero/meson.build -index 9d10701..3d2a883 100644 ---- mlibc-clean/sysdeps/aero/meson.build -+++ mlibc-workdir/sysdeps/aero/meson.build -@@ -75,6 +75,24 @@ if not headers_only - install: true, - install_dir: get_option('libdir') - ) -+ -+ custom_target('crti', -+ build_by_default: true, -+ command: c_compiler.cmd_array() + ['-c', '-o', '@OUTPUT@', '@INPUT@'], -+ input: 'crt-x86_64/crti.S', -+ output: 'crti.o', -+ install: true, -+ install_dir: get_option('libdir') -+ ) -+ -+ custom_target('crtn', -+ build_by_default: true, -+ command: c_compiler.cmd_array() + ['-c', '-o', '@OUTPUT@', '@INPUT@'], -+ input: 'crt-x86_64/crtn.S', -+ output: 'crtn.o', -+ install: true, -+ install_dir: get_option('libdir') -+ ) - endif + int sys_symlink(const char *target_path, const char *link_path) { +- return sys_symlinkat(target_path, AT_FDCWD, link_path); ++ return sys_symlinkat(target_path, AT_FDCWD, link_path); + } - if host_machine.cpu_family() == 'x86_64' + int sys_symlinkat(const char *target_path, int dirfd, const char *link_path) { +diff --git mlibc-clean/sysdeps/aero/include/abi-bits/fcntl.h mlibc-workdir/sysdeps/aero/include/abi-bits/fcntl.h +index ea5323a..463e2c9 120000 +--- mlibc-clean/sysdeps/aero/include/abi-bits/fcntl.h ++++ mlibc-workdir/sysdeps/aero/include/abi-bits/fcntl.h +@@ -1 +1 @@ +-../../../../abis/mlibc/fcntl.h +\ No newline at end of file ++../../../../abis/linux/fcntl.h +\ No newline at end of file +diff --git mlibc-clean/sysdeps/aero/include/abi-bits/stat.h mlibc-workdir/sysdeps/aero/include/abi-bits/stat.h +index 82642c3..1f63b41 120000 +--- mlibc-clean/sysdeps/aero/include/abi-bits/stat.h ++++ mlibc-workdir/sysdeps/aero/include/abi-bits/stat.h +@@ -1 +1 @@ +-../../../../abis/mlibc/stat.h +\ No newline at end of file ++../../../../abis/linux/stat.h +\ No newline at end of file diff --git a/recipes/mlibc b/recipes/mlibc index 8c4ed720ee7..db96777c229 100644 --- a/recipes/mlibc +++ b/recipes/mlibc @@ -1,8 +1,8 @@ name=mlibc -version=0dd4dbdd377dc776e6f7d698281ac6781d652922 +version=882fdd99b503ee1b567ccacb75cf4d7b7c9395e1 revision=1 -tarball_url="https://github.com/aero-os/mlibc/archive/${version}.tar.gz" -tarball_blake2b="a4886c2d6a85c781293db9139c0773469c3877e5db2a76f1a735e2cc04ee78fef5b8fc1693b724f9fc8879322464ddf48eac8c018ebfd4f8aa983141013d64e3" +tarball_url="https://github.com/Andy-Python-Programmer/mlibc/archive/${version}.tar.gz" +tarball_blake2b="3dcb34f3e2e2d8b1cbdd5d87e722fe03b23d9f460affd82ea888bcd6dabe96a475a2153f477360b78efcad421f83c534e308e6057c319c78c3bc666a03dbd6a7" imagedeps="meson ninja" hostdeps="gcc pkg-config libgcc-binaries" builddeps="cxxshim frigg linux-headers" diff --git a/src/aero_kernel/src/syscall/process.rs b/src/aero_kernel/src/syscall/process.rs index 72e44389356..f9a41c2fd14 100644 --- a/src/aero_kernel/src/syscall/process.rs +++ b/src/aero_kernel/src/syscall/process.rs @@ -330,7 +330,7 @@ pub fn sigaction( }; let entry = if let Some(new) = new { - Some(SignalEntry::from_sigaction(*new, sigreturn)?) + Some(SignalEntry::from_sigaction(&*new, sigreturn)?) } else { None }; diff --git a/src/aero_kernel/src/userland/signals.rs b/src/aero_kernel/src/userland/signals.rs index 0cf1cf56c96..5d3b2621e67 100644 --- a/src/aero_kernel/src/userland/signals.rs +++ b/src/aero_kernel/src/userland/signals.rs @@ -147,7 +147,7 @@ pub struct SignalEntry { impl SignalEntry { /// Create a new `SignalEntry` with the provided `sigaction` and `sigreturn`. pub fn from_sigaction( - sigaction: SigAction, + sigaction: &SigAction, sigreturn: usize, ) -> Result { Ok(SignalEntry { diff --git a/src/aero_syscall/src/consts.rs b/src/aero_syscall/src/consts.rs index a08796a60b6..e3196cdb41c 100644 --- a/src/aero_syscall/src/consts.rs +++ b/src/aero_syscall/src/consts.rs @@ -104,17 +104,41 @@ pub const SYS_GETSOCKOPT: usize = 80; pub const SYS_SYMLINK_AT: usize = 81; // constants for fcntl()'s command argument: -pub const F_DUPFD: usize = 1; -pub const F_DUPFD_CLOEXEC: usize = 2; -pub const F_GETFD: usize = 3; -pub const F_SETFD: usize = 4; -pub const F_GETFL: usize = 5; -pub const F_SETFL: usize = 6; -pub const F_GETLK: usize = 7; -pub const F_SETLK: usize = 8; -pub const F_SETLKW: usize = 9; -pub const F_GETOWN: usize = 10; -pub const F_SETOWN: usize = 11; +// mlibc/abis/linux/fcntl.h +pub const F_DUPFD: usize = 0; +pub const F_GETFD: usize = 1; +pub const F_SETFD: usize = 2; +pub const F_GETFL: usize = 3; +pub const F_SETFL: usize = 4; + +pub const F_SETOWN: usize = 8; +pub const F_GETOWN: usize = 9; +pub const F_SETSIG: usize = 10; +pub const F_GETSIG: usize = 11; + +pub const F_GETLK: usize = 5; +pub const F_SETLK: usize = 6; +pub const F_SETLKW: usize = 7; + +pub const F_SETOWN_EX: usize = 15; +pub const F_GETOWN_EX: usize = 16; + +pub const F_GETOWNER_UIDS: usize = 17; + +pub const F_DUPFD_CLOEXEC: usize = 1030; +pub const F_ADD_SEALS: usize = 1033; +pub const F_GET_SEALS: usize = 1034; + +pub const F_SEAL_SEAL: usize = 0x0001; +pub const F_SEAL_SHRINK: usize = 0x0002; +pub const F_SEAL_GROW: usize = 0x0004; +pub const F_SEAL_WRITE: usize = 0x0008; + +pub const F_RDLCK: usize = 0; +pub const F_WRLCK: usize = 1; +pub const F_UNLCK: usize = 2; + +pub const FD_CLOEXEC: usize = 1; // constants for fcntl()'s additional argument of F_GETFD and F_SETFD: bitflags::bitflags! { diff --git a/src/aero_syscall/src/lib.rs b/src/aero_syscall/src/lib.rs index d2ecd44102d..cfadcc9ce1e 100644 --- a/src/aero_syscall/src/lib.rs +++ b/src/aero_syscall/src/lib.rs @@ -32,6 +32,7 @@ pub mod time; pub type Result = core::result::Result; +use core::ffi; use core::time::Duration; use byte_endian::BigEndian; @@ -65,33 +66,33 @@ bitflags::bitflags! { bitflags::bitflags! { pub struct OpenFlags: usize { - // reserve 3 bits for the access mode - const O_ACCMODE = 0x0007; - const O_EXEC = 1; - const O_RDONLY = 2; - const O_RDWR = 3; - const O_SEARCH = 4; - const O_WRONLY = 5; - - // these flags get their own bit - const O_APPEND = 0x000008; - const O_CREAT = 0x000010; - const O_DIRECTORY = 0x000020; - const O_EXCL = 0x000040; - const O_NOCTTY = 0x000080; - const O_NOFOLLOW = 0x000100; - const O_TRUNC = 0x000200; - const O_NONBLOCK = 0x000400; - const O_DSYNC = 0x000800; - const O_RSYNC = 0x001000; - const O_SYNC = 0x002000; - const O_CLOEXEC = 0x004000; - const O_PATH = 0x008000; - const O_LARGEFILE = 0x010000; - const O_NOATIME = 0x020000; - const O_ASYNC = 0x040000; - const O_TMPFILE = 0x080000; - const O_DIRECT = 0x100000; + const O_PATH = 0o10000000; + + const O_ACCMODE = (0o3 | Self::O_PATH.bits()); + const O_RDONLY = 0o0; + const O_WRONLY = 0o1; + const O_RDWR = 0o2; + + const O_SEARCH = Self::O_PATH.bits(); + const O_EXEC = Self::O_PATH.bits(); + + const O_CREAT = 0o100; + const O_EXCL = 0o200; + const O_NOCTTY = 0o400; + const O_TRUNC = 0o1000; + const O_APPEND = 0o2000; + const O_NONBLOCK = 0o4000; + const O_DSYNC = 0o10000; + const O_ASYNC = 0o20000; + const O_DIRECT = 0o40000; + const O_DIRECTORY = 0o200000; + const O_NOFOLLOW = 0o400000; + const O_CLOEXEC = 0o2000000; + const O_SYNC = 0o4010000; + const O_RSYNC = 0o4010000; + const O_LARGEFILE = 0o100000; + const O_NOATIME = 0o1000000; + const O_TMPFILE = 0o20000000; } } @@ -672,7 +673,7 @@ pub const AF_UNSPEC: u32 = PF_UNSPEC; pub const AF_NETLINK: u32 = PF_NETLINK; pub const AF_BRIDGE: u32 = PF_BRIDGE; -// sysdeps/aero/include/abi-bits/stat.h +// mlibc/abis/linux/stat.h bitflags::bitflags! { #[derive(Default)] pub struct Mode: u32 { @@ -707,37 +708,43 @@ bitflags::bitflags! { } } -// sysdeps/aero/include/abi-bits/stat.h +// mlibc/abis/linux/stat.h +#[cfg(target_arch = "x86_64")] #[repr(C)] #[derive(Debug, Default)] pub struct Stat { pub st_dev: u64, pub st_ino: u64, - pub st_mode: Mode, pub st_nlink: u32, + pub st_mode: Mode, pub st_uid: u32, pub st_gid: u32, + // FIXME: make this private + pub __pad0: ffi::c_uint, pub st_rdev: u64, pub st_size: i64, + pub st_blksize: u64, + pub st_blocks: u64, pub st_atim: TimeSpec, pub st_mtim: TimeSpec, pub st_ctim: TimeSpec, - pub st_blksize: u64, - pub st_blocks: u64, + // FIXME: make this private + pub __unused: [ffi::c_long; 3], } bitflags::bitflags! { + // mlibc/abis/linux/fcntl.h #[repr(transparent)] pub struct AtFlags: usize { - /// Allow empty relative pathname. - const EMPTY_PATH = 1; - /// Follow symbolic links. - const SYMLINK_FOLLOW = 2; /// Do not follow symbolic links. - const SYMLINK_NOFOLLOW = 4; + const SYMLINK_NOFOLLOW = 0x100; /// Remove directory instead of unlinking file. - const REMOVEDIR = 8; + const REMOVEDIR = 0x200; + /// Follow symbolic links. + const SYMLINK_FOLLOW = 0x400; /// Test access permitted for effective IDs, not real IDs. - const EACCESS = 512; + const EACCESS = 0x200; + /// Allow empty relative pathname. + const EMPTY_PATH = 0x1000; } } diff --git a/src/aero_syscall/src/signal.rs b/src/aero_syscall/src/signal.rs index fe814c5a5b8..f0037aae990 100644 --- a/src/aero_syscall/src/signal.rs +++ b/src/aero_syscall/src/signal.rs @@ -110,18 +110,18 @@ impl From for u64 { #[derive(Copy, Clone, Debug)] pub struct SigAction { pub sa_handler: u64, - pub sa_mask: u64, - pub sa_flags: u32, + pub sa_flags: u64, pub sa_sigaction: u64, + pub sa_mask: u64, } impl SigAction { pub fn new(handler: SignalHandler, mask: u64, flags: SignalFlags) -> SigAction { SigAction { sa_handler: handler.into(), - sa_mask: mask, sa_flags: flags.bits(), sa_sigaction: 0, + sa_mask: mask, } } } @@ -129,7 +129,7 @@ impl SigAction { bitflags::bitflags! { // mlibc/abis/linux/signal.h #[derive(Default)] - pub struct SignalFlags: u32 { + pub struct SignalFlags: u64 { const SA_NOCLDSTOP = 1; const SA_NOCLDWAIT = 2; const SA_SIGINFO = 4; From 37153263a57740433046b688fed2d98c736339f3 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sun, 7 Apr 2024 18:02:10 +1000 Subject: [PATCH 075/112] feat(Makefile): bump Jinx Signed-off-by: Anhad Singh --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 547837bb7e3..15e3c534476 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,9 @@ else endif jinx: + mkdir -p target if [ ! -f "target/jinx" ]; then \ - curl -Lo target/jinx https://github.com/mintsuki/jinx/raw/30e7d5487bff67a66dfba332113157a08a324820/jinx; \ + curl -Lo target/jinx https://github.com/mintsuki/jinx/raw/353c468765dd9404bacba8e5626d0830528e4300/jinx; \ chmod +x target/jinx; \ fi From b2c3fbc63a871c7b2ef75f38fbda2b7863668560 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sun, 7 Apr 2024 18:27:27 +1000 Subject: [PATCH 076/112] ports(mlibc): bump Signed-off-by: Anhad Singh --- patches/mlibc/jinx-working-patch.patch | 75 -------------------------- recipes/mlibc | 6 +-- 2 files changed, 3 insertions(+), 78 deletions(-) diff --git a/patches/mlibc/jinx-working-patch.patch b/patches/mlibc/jinx-working-patch.patch index f646dc2e747..9dfbb982b29 100644 --- a/patches/mlibc/jinx-working-patch.patch +++ b/patches/mlibc/jinx-working-patch.patch @@ -15,78 +15,3 @@ index 3474615..d06f130 100644 } char **backtrace_symbols(void *const *, int) { -diff --git mlibc-clean/sysdeps/aero/generic/filesystem.cpp mlibc-workdir/sysdeps/aero/generic/filesystem.cpp -index b9a812b..95c49b9 100644 ---- mlibc-clean/sysdeps/aero/generic/filesystem.cpp -+++ mlibc-workdir/sysdeps/aero/generic/filesystem.cpp -@@ -89,23 +89,24 @@ int sys_close(int fd) { - return 0; - } - --int sys_access(const char *filename, int mode) { -- auto result = -- syscall(SYS_ACCESS, AT_FDCWD, filename, strlen(filename), mode, 0); -- -- if (result < 0) { -- return -result; -- } -- -+int sys_faccessat(int dirfd, const char *pathname, int mode, int flags) { -+ auto ret = syscall(SYS_ACCESS, dirfd, pathname, strlen(pathname), mode, flags); -+ if(int e = sc_error(ret); e) -+ return e; - return 0; - } - -+int sys_access(const char *filename, int mode) { -+ return sys_faccessat(AT_FDCWD, filename, mode, 0); -+} -+ - int sys_stat(fsfd_target fsfdt, int fd, const char *path, int flags, - struct stat *statbuf) { - switch (fsfdt) { - case fsfd_target::path: - fd = AT_FDCWD; - break; -+ - case fsfd_target::fd: - flags |= AT_EMPTY_PATH; - -@@ -199,14 +200,14 @@ int sys_rmdir(const char *path) { - } - - int sys_unlinkat(int fd, const char *path, int flags) { -- auto ret = syscall(SYS_UNLINK, fd, path, strlen(path), flags); -- if (int e = sc_error(ret); e) -- return e; -- return 0; -+ auto ret = syscall(SYS_UNLINK, fd, path, strlen(path), flags); -+ if (int e = sc_error(ret); e) -+ return e; -+ return 0; - } - - int sys_symlink(const char *target_path, const char *link_path) { -- return sys_symlinkat(target_path, AT_FDCWD, link_path); -+ return sys_symlinkat(target_path, AT_FDCWD, link_path); - } - - int sys_symlinkat(const char *target_path, int dirfd, const char *link_path) { -diff --git mlibc-clean/sysdeps/aero/include/abi-bits/fcntl.h mlibc-workdir/sysdeps/aero/include/abi-bits/fcntl.h -index ea5323a..463e2c9 120000 ---- mlibc-clean/sysdeps/aero/include/abi-bits/fcntl.h -+++ mlibc-workdir/sysdeps/aero/include/abi-bits/fcntl.h -@@ -1 +1 @@ --../../../../abis/mlibc/fcntl.h -\ No newline at end of file -+../../../../abis/linux/fcntl.h -\ No newline at end of file -diff --git mlibc-clean/sysdeps/aero/include/abi-bits/stat.h mlibc-workdir/sysdeps/aero/include/abi-bits/stat.h -index 82642c3..1f63b41 120000 ---- mlibc-clean/sysdeps/aero/include/abi-bits/stat.h -+++ mlibc-workdir/sysdeps/aero/include/abi-bits/stat.h -@@ -1 +1 @@ --../../../../abis/mlibc/stat.h -\ No newline at end of file -+../../../../abis/linux/stat.h -\ No newline at end of file diff --git a/recipes/mlibc b/recipes/mlibc index db96777c229..819d178384e 100644 --- a/recipes/mlibc +++ b/recipes/mlibc @@ -1,8 +1,8 @@ name=mlibc -version=882fdd99b503ee1b567ccacb75cf4d7b7c9395e1 +version=71d6b326e31b88796088690278ce31bb8e9fc994 revision=1 -tarball_url="https://github.com/Andy-Python-Programmer/mlibc/archive/${version}.tar.gz" -tarball_blake2b="3dcb34f3e2e2d8b1cbdd5d87e722fe03b23d9f460affd82ea888bcd6dabe96a475a2153f477360b78efcad421f83c534e308e6057c319c78c3bc666a03dbd6a7" +tarball_url="https://github.com/managarm/mlibc/archive/${version}.tar.gz" +tarball_blake2b="b2fc2178bf9a26191a78866272da2ff6cb2b547cb3fdd5fe28f4280d5bbf98a929e9920e5c05a25ed340af8d29d45265e148eba6d31490a7a6796adfcb2158d6" imagedeps="meson ninja" hostdeps="gcc pkg-config libgcc-binaries" builddeps="cxxshim frigg linux-headers" From f533ab82582ce8e1dda31f6a0ee7f6616fd7bc46 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sun, 7 Apr 2024 19:14:46 +1000 Subject: [PATCH 077/112] feat(ports): add xfe Signed-off-by: Anhad Singh --- build-support/jwm/system.jwmrc | 1 + host-recipes/intltool | 20 +++++ patches/fox/jinx-working-patch.patch | 25 ++++++ patches/xfe/jinx-working-patch.patch | 124 +++++++++++++++++++++++++++ recipes/fox | 27 ++++++ recipes/xcb-util | 26 ++++++ recipes/xfe | 30 +++++++ source-recipes/intltool | 9 ++ 8 files changed, 262 insertions(+) create mode 100644 host-recipes/intltool create mode 100644 patches/fox/jinx-working-patch.patch create mode 100644 patches/xfe/jinx-working-patch.patch create mode 100644 recipes/fox create mode 100644 recipes/xcb-util create mode 100644 recipes/xfe create mode 100644 source-recipes/intltool diff --git a/build-support/jwm/system.jwmrc b/build-support/jwm/system.jwmrc index 88cd55fdfe0..031c5c4a3fa 100644 --- a/build-support/jwm/system.jwmrc +++ b/build-support/jwm/system.jwmrc @@ -5,6 +5,7 @@ xterm + xfe audacious xcalc diff --git a/host-recipes/intltool b/host-recipes/intltool new file mode 100644 index 00000000000..3825495b4d0 --- /dev/null +++ b/host-recipes/intltool @@ -0,0 +1,20 @@ +name=intltool +from_source=intltool +revision=1 +hostdeps="autoconf automake libtool pkg-config" +imagedeps="gcc perl-xml-parser" + +build() { + #cp -rp "${source_dir}"/. ./ + ${source_dir}/configure \ + --prefix="${prefix}" + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + strip_command=strip \ + post_package_strip +} diff --git a/patches/fox/jinx-working-patch.patch b/patches/fox/jinx-working-patch.patch new file mode 100644 index 00000000000..faa04295413 --- /dev/null +++ b/patches/fox/jinx-working-patch.patch @@ -0,0 +1,25 @@ +diff --git fox-clean/configure.ac fox-workdir/configure.ac +index ce0f651..189b5e8 100644 +--- fox-clean/configure.ac ++++ fox-workdir/configure.ac +@@ -9,6 +9,8 @@ AC_INIT(fox,[fox_version],jeroen@fox-toolkit.com) + AC_CONFIG_SRCDIR([include/fx.h]) + AM_INIT_AUTOMAKE([foreign]) + ++PKG_PROG_PKG_CONFIG ++ + # Set version + FOX_MAJOR_VERSION=fox_major + FOX_MINOR_VERSION=fox_minor +@@ -190,8 +192,8 @@ AC_MSG_CHECKING(for Xft support) + AC_ARG_WITH(xft,[ --with-xft enable Xft support]) + AC_MSG_RESULT([$with_xft]) + if test "x$with_xft" != "xno"; then +-XFTCFLAGS="-I/usr/include/freetype2" +-XFTLIBS="-lfreetype -lfontconfig -lXft" ++XFTCFLAGS="$($PKG_CONFIG --cflags freetype2 fontconfig xft)" ++XFTLIBS="$($PKG_CONFIG --libs freetype2 fontconfig xft)" + saved_cppflags="${CXXFLAGS}" + CXXFLAGS="${CXXFLAGS} -DHAVE_XFT_H=1 $XFTCFLAGS" + X_BASE_LIBS="${X_BASE_LIBS} $XFTLIBS" + diff --git a/patches/xfe/jinx-working-patch.patch b/patches/xfe/jinx-working-patch.patch new file mode 100644 index 00000000000..a9b187463eb --- /dev/null +++ b/patches/xfe/jinx-working-patch.patch @@ -0,0 +1,124 @@ +diff --git xfe-clean/configure.ac xfe-workdir/configure.ac +index 0fa6dc9..ecaa037 100644 +--- xfe-clean/configure.ac ++++ xfe-workdir/configure.ac +@@ -69,9 +69,9 @@ AC_FUNC_GETGROUPS + AC_FUNC_GETMNTENT + AC_FUNC_LSTAT + AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK +-AC_FUNC_MALLOC ++#AC_FUNC_MALLOC + AC_FUNC_MKTIME +-AC_FUNC_REALLOC ++#AC_FUNC_REALLOC + AC_FUNC_STAT + AC_FUNC_UTIME_NULL + AC_CHECK_FUNCS([endgrent endpwent gethostname getmntent gettimeofday lchown memset mkdir mkfifo putenv rmdir setlocale sqrt strchr strdup strerror strstr strtol strtoul strtoull utime]) +@@ -87,25 +87,19 @@ AC_CHECK_LIB(FOX-1.6,fxfindfox,,AC_MSG_ERROR("libFOX-1.6 not found")) + + # Check for FOX 1.6 header files + AC_LANG([C++]) +-AC_CHECK_HEADER(fox-1.6/fx.h,,AC_MSG_ERROR("fox-1.6/fx.h not found")) ++#AC_CHECK_HEADER(fox-1.6/fx.h,,AC_MSG_ERROR("fox-1.6/fx.h not found")) + + +-# Check if fox-config exists +-AC_CHECK_PROGS(FOX_CONFIG,fox-config-1.6 fox-1.6-config fox-config) +-if test no"$FOX_CONFIG" = no ; then +- AC_MSG_ERROR("fox-config not found") +-fi +- + + # Include flags for the FOX library +-FOXCFLAGS=`$FOX_CONFIG --cflags` ++FOXCFLAGS=`$PKG_CONFIG --cflags fox` + CXXFLAGS="${CXXFLAGS} $FOXCFLAGS" + + + # Check if FOX was compiled with xft support +-TEST_XFT=`$FOX_CONFIG --libs | grep Xft` ++TEST_XFT=yes + if test "x$TEST_XFT" != "x" ; then +- ++ + echo "checking whether FOX was compiled with Xft support... yes" + + # Check for FreeType2 +@@ -135,7 +129,7 @@ if test "x$TEST_XFT" != "x" ; then + CXXFLAGS="$CXXFLAGS -DHAVE_XFT_H" + ], AC_MSG_ERROR("Xft not found")) + fi +- AC_CHECK_HEADER(X11/Xft/Xft.h,,AC_MSG_ERROR("Xft.h not found")) ++ #AC_CHECK_HEADER(X11/Xft/Xft.h,,AC_MSG_ERROR("Xft.h not found")) + + else + echo "checking whether FOX was compiled with Xft support... no" +@@ -149,28 +143,28 @@ else + echo " sudo make install" + echo "=============================================================================================" + echo "" +- AC_MSG_ERROR("missing Xft support in FOX") ++ AC_MSG_ERROR("missing Xft support in FOX") + fi + + + # Check for Xlib headers +-AC_CHECK_HEADER(X11/Xlib.h,,AC_MSG_ERROR("Xlib.h not found")) ++#AC_CHECK_HEADER(X11/Xlib.h,,AC_MSG_ERROR("Xlib.h not found")) + + # Check for XRandR support + AC_MSG_CHECKING(for xrandr extension) + AC_ARG_WITH(xrandr,[ --with-xrandr compile with XRandR support]) + AC_MSG_RESULT([$with_xrandr]) +-if test "x$with_xrandr" != "xno"; then +-AC_CHECK_HEADERS(X11/extensions/Xrandr.h,CXXFLAGS="${CXXFLAGS} -DHAVE_XRANDR_H=1"; LIBS="${LIBS} -lXrandr") +-fi ++#if test "x$with_xrandr" != "xno"; then ++#AC_CHECK_HEADERS(X11/extensions/Xrandr.h,CXXFLAGS="${CXXFLAGS} -DHAVE_XRANDR_H=1"; LIBS="${LIBS} -lXrandr") ++#fi + + # Check for libPNG + AC_CHECK_LIB(png, png_read_info,,AC_MSG_ERROR("libPNG not found")) +-AC_CHECK_HEADER(png.h,,AC_MSG_ERROR("png.h not found")) ++#AC_CHECK_HEADER(png.h,,AC_MSG_ERROR("png.h not found")) + + # Check for fontconfig + AC_CHECK_LIB(fontconfig, FcInit,, AC_MSG_ERROR("fontconfig not found")) +-AC_CHECK_HEADER(fontconfig/fontconfig.h,,AC_MSG_ERROR("fontconfig.h not found")) ++#AC_CHECK_HEADER(fontconfig/fontconfig.h,,AC_MSG_ERROR("fontconfig.h not found")) + + # Check for startup notification support + AC_MSG_CHECKING(for startup notification) +diff --git xfe-clean/src/ArchInputDialog.cpp xfe-workdir/src/ArchInputDialog.cpp +index f0314bb..4b6e170 100644 +--- xfe-clean/src/ArchInputDialog.cpp ++++ xfe-workdir/src/ArchInputDialog.cpp +@@ -1,5 +1,6 @@ + // Input dialog for the add to archive command + ++#include + #include "config.h" + #include "i18n.h" + +diff --git xfe-clean/src/Bookmarks.cpp xfe-workdir/src/Bookmarks.cpp +index 241ef32..113c503 100644 +--- xfe-clean/src/Bookmarks.cpp ++++ xfe-workdir/src/Bookmarks.cpp +@@ -1,5 +1,6 @@ + // Bookmarks list. Taken from the FOX library (FXRecentFiles) and slightly modified. + ++#include + #include "config.h" + #include "i18n.h" + +diff --git xfe-clean/src/BrowseInputDialog.cpp xfe-workdir/src/BrowseInputDialog.cpp +index 4c64e68..ff0c1ad 100644 +--- xfe-clean/src/BrowseInputDialog.cpp ++++ xfe-workdir/src/BrowseInputDialog.cpp +@@ -1,5 +1,6 @@ + // Input dialog with file browse icon + ++#include + #include "config.h" + #include "i18n.h" + diff --git a/recipes/fox b/recipes/fox new file mode 100644 index 00000000000..9e5eb762a7f --- /dev/null +++ b/recipes/fox @@ -0,0 +1,27 @@ +name=fox +version=1.6.57 +revision=1 +tarball_url="http://fox-toolkit.org/ftp/fox-${version}.tar.gz" +tarball_blake2b="3efbc6188225f9444fbd347359e8b4041a08fe654acb99c48e4966e501a2f72a44863f2e9b60ae810a259951f89cfc27b9a8b6341e029627066712e0dbf20e40" +source_hostdeps="automake autoconf libtool pkg-config" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs libx11 libxft libxext freetype2 glu" + +regenerate() { + autotools_recursive_regen +} + +build() { + cp -rp "${source_dir}"/. ./ + + configure_script_path=./configure \ + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/xcb-util b/recipes/xcb-util new file mode 100644 index 00000000000..690bb6b1390 --- /dev/null +++ b/recipes/xcb-util @@ -0,0 +1,26 @@ +name=xcb-util +version=0.4.1 +revision=1 +tarball_url="https://xcb.freedesktop.org/dist/xcb-util-${version}.tar.xz" +tarball_blake2b="bcde73073590c56771af6233f1a04a692197a756ef9ce70b6e0bd3625ad6d61f99f4c671dcfae39c8dd66e3225f40f7e9b42dd115ffe83a561e48a9808bf00e3" +source_hostdeps="automake autoconf libtool pkg-config" +source_deps="xorg-util-macros" +imagedeps="python" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs xorg-proto libxcb" + +regenerate() { + autotools_recursive_regen +} + +build() { + autotools_configure + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} diff --git a/recipes/xfe b/recipes/xfe new file mode 100644 index 00000000000..67bc76c6b6f --- /dev/null +++ b/recipes/xfe @@ -0,0 +1,30 @@ +name=xfe +version=1.46 +revision=1 +tarball_url="https://downloads.sourceforge.net/sourceforge/xfe/xfe-${version}.tar.xz" +tarball_blake2b="d7b85e5280d1d9d6db3737f8ac14f4248ae4e99b52d843b51468299bdf71581003b21d0fb2be9949c7189481ed5f3fe88bbd146d2185c17dea3a4785edb876b7" +source_hostdeps="autoconf automake libtool pkg-config intltool" +source_deps="xorg-util-macros gettext" +imagedeps="perl-xml-parser" +hostdeps="gcc autoconf automake libtool pkg-config intltool" +deps="core-libs fox libx11 libxft libxcb xcb-util" + +regenerate() { + autotools_recursive_regen +} + +build() { + cp -rp "${source_dir}"/. ./ + + configure_script_path=./configure \ + autotools_configure \ + --with-x + + make -j${parallelism} +} + +package() { + make DESTDIR=${dest_dir} install + + post_package_strip +} diff --git a/source-recipes/intltool b/source-recipes/intltool new file mode 100644 index 00000000000..b0682a9ac59 --- /dev/null +++ b/source-recipes/intltool @@ -0,0 +1,9 @@ +name=intltool +version=0.51.0 +tarball_url="https://launchpad.net/intltool/trunk/${version}/+download/intltool-${version}.tar.gz" +tarball_blake2b="98fe40e4d669fdf65a777152ddee0a9656412b9cf5d1e682d1b4b7bd666f3e5aa623a50481b6df47e16a935550836c66c666229b0bb7ef143f7cde6893b97a69" +hostdeps="autoconf automake libtool pkg-config" + +regenerate() { + autotools_recursive_regen +} From d614cba943908cb53ae9fc76f83d4fca0ed2f785 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sun, 7 Apr 2024 19:25:25 +1000 Subject: [PATCH 078/112] feat(atflags): append the statx flags Signed-off-by: Anhad Singh --- src/aero_syscall/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/aero_syscall/src/lib.rs b/src/aero_syscall/src/lib.rs index cfadcc9ce1e..1c45a870178 100644 --- a/src/aero_syscall/src/lib.rs +++ b/src/aero_syscall/src/lib.rs @@ -746,5 +746,12 @@ bitflags::bitflags! { const EACCESS = 0x200; /// Allow empty relative pathname. const EMPTY_PATH = 0x1000; + + const STATX_FORCE_SYNC = 0x2000; + const STATX_DONT_SYNC = 0x4000; + const STATX_SYNC_TYPE = 0x6000; + + const STATX_SYNC_AS_STAT = 0x0000; + const NO_AUTOMOUNT = 0x800; } } From 126af76fbc4644c704f434af03918b79c5896130 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 10 Apr 2024 19:10:32 +1000 Subject: [PATCH 079/112] feat(ports): add findutils Signed-off-by: Anhad Singh --- recipes/findutils | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 recipes/findutils diff --git a/recipes/findutils b/recipes/findutils new file mode 100644 index 00000000000..8cc615b705d --- /dev/null +++ b/recipes/findutils @@ -0,0 +1,30 @@ +name=findutils +version=4.9.0 +revision=1 +tarball_url="https://ftp.gnu.org/gnu/findutils/findutils-${version}.tar.xz" +tarball_blake2b="3ada8903fc552ad2e580a7b631a4b9d941935b3f4231029564c6f2b7b10ba6f2244e2de57f6d79268c5e0481a193f64edbbae637e7a51ae6f495e3eefabf52c9" +source_hostdeps="automake autoconf libtool pkg-config" +imagedeps="python" +hostdeps="gcc autoconf automake libtool pkg-config" +deps="core-libs" + +regenerate() { + autotools_recursive_regen +} + +build() { + cp -rp "${source_dir}"/. ./ + + configure_script_path=./configure \ + autotools_configure \ + --without-selinux + + make -j${parallelism} +} + +package() { + DESTDIR="${dest_dir}" make install + + post_package_strip +} + From 9105725c5d17206f8d0868bae64ca91b5e6f864b Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 10 Apr 2024 20:39:28 +1000 Subject: [PATCH 080/112] feat(syscall/fs): handle non-cwd fd {open,chdir} * Handle non-AT_FDCWD file descriptors for {open,chdir} system calls. The updated signature and behaviour has also been updated in the mlibc patches. Signed-off-by: Anhad Singh --- patches/mlibc/jinx-working-patch.patch | 55 ++++++++++++++++++++++++++ src/aero_kernel/src/syscall/fs.rs | 53 ++++++++++++++----------- src/aero_kernel/src/syscall/mod.rs | 4 +- 3 files changed, 88 insertions(+), 24 deletions(-) diff --git a/patches/mlibc/jinx-working-patch.patch b/patches/mlibc/jinx-working-patch.patch index 9dfbb982b29..4461b605fb4 100644 --- a/patches/mlibc/jinx-working-patch.patch +++ b/patches/mlibc/jinx-working-patch.patch @@ -15,3 +15,58 @@ index 3474615..d06f130 100644 } char **backtrace_symbols(void *const *, int) { +diff --git mlibc-clean/sysdeps/aero/generic/aero.cpp mlibc-workdir/sysdeps/aero/generic/aero.cpp +index 80f9c6f..897986d 100644 +--- mlibc-clean/sysdeps/aero/generic/aero.cpp ++++ mlibc-workdir/sysdeps/aero/generic/aero.cpp +@@ -200,14 +200,19 @@ int sys_getcwd(char *buffer, size_t size) { + return 0; + } + +-int sys_chdir(const char *path) { +- auto result = syscall(SYS_CHDIR, path, strlen(path)); ++static int sys_chdir_impl(int fd, const char *path) { ++ auto ret = syscall(SYS_CHDIR, fd, path, strlen(path)); ++ if(int e = sc_error(ret); e) ++ return e; ++ return 0; ++} + +- if (result < 0) { +- return -result; +- } ++int sys_chdir(const char *path) { ++ return sys_chdir_impl(AT_FDCWD, path); ++} + +- return 0; ++int sys_fchdir(int fd) { ++ return sys_chdir_impl(fd, ""); + } + + int sys_gethostname(char *buffer, size_t bufsize) { +diff --git mlibc-clean/sysdeps/aero/generic/filesystem.cpp mlibc-workdir/sysdeps/aero/generic/filesystem.cpp +index 95c49b9..9416be7 100644 +--- mlibc-clean/sysdeps/aero/generic/filesystem.cpp ++++ mlibc-workdir/sysdeps/aero/generic/filesystem.cpp +@@ -69,13 +69,14 @@ int sys_seek(int fd, off_t offset, int whence, off_t *new_offset) { + } + + int sys_open(const char *filename, int flags, mode_t mode, int *fd) { +- auto result = syscall(SYS_OPEN, 0, filename, strlen(filename), flags); +- +- if (result < 0) { +- return -result; +- } ++ return sys_openat(AT_FDCWD, filename, flags, mode, fd); ++} + +- *fd = result; ++int sys_openat(int dirfd, const char *path, int flags, mode_t mode, int *fd) { ++ auto ret = syscall(SYS_OPEN, dirfd, path, strlen(path), flags, mode); ++ if (int e = sc_error(ret); e) ++ return e; ++ *fd = ret; + return 0; + } + diff --git a/src/aero_kernel/src/syscall/fs.rs b/src/aero_kernel/src/syscall/fs.rs index f333d3527a0..88b975793f7 100644 --- a/src/aero_kernel/src/syscall/fs.rs +++ b/src/aero_kernel/src/syscall/fs.rs @@ -102,22 +102,19 @@ pub fn read(fd: FileDescriptor, buffer: &mut [u8]) -> Result Result { - let dir = match fd as isize { - 0 => { - if !path.is_absolute() { - scheduler::get_scheduler().current_task().cwd_dirent() - } else { - crate::fs::root_dir().clone() - } - } - - _ => { - todo!() +pub fn open(fd: usize, path: &Path, flags: usize, _mode: usize) -> Result { + let current_thread = scheduler::current_thread(); + let at = match fd as isize { + AT_FDCWD if !path.is_absolute() => current_thread.cwd_dirent(), + _ if !path.is_absolute() => { + let ent = FileDescriptor::from_usize(fd).handle()?.inode.clone(); + assert!(ent.inode().metadata()?.is_directory()); + ent } + _ => fs::root_dir().clone(), }; - let mut flags = OpenFlags::from_bits(mode).ok_or(SyscallError::EINVAL)?; + let mut flags = OpenFlags::from_bits(flags).ok_or(SyscallError::EINVAL)?; if !flags.intersects(OpenFlags::O_RDONLY | OpenFlags::O_RDWR | OpenFlags::O_WRONLY) { flags.insert(OpenFlags::O_RDONLY); @@ -129,7 +126,7 @@ pub fn open(fd: usize, path: &Path, mode: usize) -> Result lookup_mode = LookupMode::Create; } - let inode = fs::lookup_path_with(dir, path, lookup_mode, true)?; + let inode = fs::lookup_path_with(at, path, lookup_mode, true)?; if flags.contains(OpenFlags::O_DIRECTORY) && !inode.inode().metadata()?.is_directory() { return Err(SyscallError::ENOTDIR); @@ -139,9 +136,7 @@ pub fn open(fd: usize, path: &Path, mode: usize) -> Result inode.inode().truncate(0)?; } - Ok(scheduler::current_thread() - .file_table - .open_file(inode.clone(), flags)?) + Ok(current_thread.file_table.open_file(inode.clone(), flags)?) } #[syscall] @@ -183,15 +178,29 @@ pub fn close(fd: FileDescriptor) -> Result { } #[syscall] -pub fn chdir(path: &str) -> Result { - let inode = fs::lookup_path(Path::new(path))?; +pub fn chdir(fd: usize, path: &Path) -> Result { + let current_thread = scheduler::current_thread(); + let at = match fd as isize { + AT_FDCWD if !path.is_absolute() => current_thread.cwd_dirent(), + _ if !path.is_absolute() => { + let ent = FileDescriptor::from_usize(fd).handle()?.inode.clone(); + assert!(ent.inode().metadata()?.is_directory()); + ent + } + _ => fs::root_dir().clone(), + }; - if !inode.inode().metadata()?.is_directory() { - // A component of path is not a directory. + if path.is_empty() { + current_thread.set_cwd(at); + return Ok(0); + } + + let ent = fs::lookup_path_with(at, path, LookupMode::None, true)?; + if !ent.inode().metadata()?.is_directory() { return Err(SyscallError::ENOTDIR); } - scheduler::get_scheduler().current_task().set_cwd(inode); + current_thread.set_cwd(ent); Ok(0) } diff --git a/src/aero_kernel/src/syscall/mod.rs b/src/aero_kernel/src/syscall/mod.rs index 54f7ab9c1b0..492a6da5998 100644 --- a/src/aero_kernel/src/syscall/mod.rs +++ b/src/aero_kernel/src/syscall/mod.rs @@ -207,12 +207,12 @@ pub fn generic_do_syscall( SYS_GETPGID => process::getpgid(b), SYS_READ => fs::read(b, c, d), - SYS_OPEN => fs::open(b, c, d, e), + SYS_OPEN => fs::open(b, c, d, e, f), SYS_CLOSE => fs::close(b), SYS_WRITE => fs::write(b, c, d), SYS_GETDENTS => fs::getdents(b, c, d), SYS_GETCWD => fs::getcwd(b, c), - SYS_CHDIR => fs::chdir(b, c), + SYS_CHDIR => fs::chdir(b, c, d), SYS_MKDIR_AT => fs::mkdirat(b, c, d), SYS_RMDIR => fs::rmdir(b, c), SYS_IOCTL => fs::ioctl(b, c, d), From 31c26248033ac0bb87939e47a0dec70283494533 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 10 Apr 2024 20:59:41 +1000 Subject: [PATCH 081/112] feat(syscall/fs): cleanup rmdir Signed-off-by: Anhad Singh --- src/aero_kernel/src/syscall/fs.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/aero_kernel/src/syscall/fs.rs b/src/aero_kernel/src/syscall/fs.rs index 88b975793f7..c3a527961b1 100644 --- a/src/aero_kernel/src/syscall/fs.rs +++ b/src/aero_kernel/src/syscall/fs.rs @@ -246,9 +246,7 @@ pub fn mkdirat(dfd: usize, path: &Path) -> Result { } #[syscall] -pub fn rmdir(path: &str) -> Result { - let path = Path::new(path); - +pub fn rmdir(path: &Path) -> Result { let (_, child) = path.parent_and_basename(); let inode = fs::lookup_path(path)?; From 045e378177636ad799164ae3cd7e083fe1330d79 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 11 Apr 2024 20:58:11 +1000 Subject: [PATCH 082/112] feat(syscall/process): fix setpgid regression Signed-off-by: Anhad Singh --- src/aero_kernel/src/syscall/process.rs | 51 +++++++++++++------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/aero_kernel/src/syscall/process.rs b/src/aero_kernel/src/syscall/process.rs index f9a41c2fd14..97996c8ced5 100644 --- a/src/aero_kernel/src/syscall/process.rs +++ b/src/aero_kernel/src/syscall/process.rs @@ -17,7 +17,6 @@ use aero_syscall::signal::{SigAction, SigProcMask}; use aero_syscall::*; -use alloc::sync::Arc; use spin::{Mutex, Once}; use crate::acpi::aml; @@ -28,7 +27,7 @@ use crate::mem::paging::VirtAddr; use crate::userland::scheduler::{self, ExitStatus}; use crate::userland::signals::SignalEntry; use crate::userland::task::sessions::SESSIONS; -use crate::userland::task::{Task, TaskId}; +use crate::userland::task::TaskId; use crate::utils::sync::IrqGuard; static HOSTNAME: Once> = Once::new(); @@ -363,31 +362,43 @@ pub fn shutdown() -> Result { unreachable!("aml: failed to shutdown (enter state S5)") } -fn find_task_by_pid(pid: usize) -> Result> { - let current_task = scheduler::get_scheduler().current_task(); +#[syscall] +pub fn getpgid(pid: usize) -> Result { + let current_task = scheduler::current_thread(); // If `pid` is 0, the process ID of the calling process is used. - if pid == 0 || pid == current_task.pid().as_usize() { - Ok(current_task) + let task = if pid == 0 || pid == current_task.pid().as_usize() { + current_task } else { scheduler::get_scheduler() .find_task(TaskId::new(pid)) - .ok_or(SyscallError::ESRCH) - } -} + .ok_or(SyscallError::ESRCH)? + }; -#[syscall] -pub fn getpgid(pid: usize) -> Result { - let task = find_task_by_pid(pid)?; let group = SESSIONS.find_group(&task).unwrap(); - Ok(group.id()) } #[syscall] pub fn setpgid(pid: usize, pgid: usize) -> Result { - let current_task = scheduler::get_scheduler().current_task(); - let task = find_task_by_pid(pid)?; + let current_task = scheduler::current_thread(); + let task = if pid == 0 || pid == current_task.pid().as_usize() { + current_task.clone() + } else { + let task = scheduler::get_scheduler() + .find_task(TaskId::new(pid)) + .ok_or(SyscallError::ESRCH)?; + + if let Some(parent) = task.get_parent() { + if parent.tid() != current_task.tid() { + return Err(SyscallError::EPERM); + } + } else { + return Err(SyscallError::EPERM); + } + + task + }; if task.is_session_leader() || !task.is_process_leader() @@ -396,16 +407,6 @@ pub fn setpgid(pid: usize, pgid: usize) -> Result { return Err(SyscallError::EPERM); } - if let Some(parent) = task.get_parent() { - if parent.tid() != current_task.tid() { - return Err(SyscallError::EPERM); - } - } else { - return Err(SyscallError::EPERM); - } - - // If `pgid` is 0, the process ID of the process specified by the `pid` argument shall - // be used. log::error!("setpgid: is a stub! (pid={pid} pgid={pgid})"); Ok(0) } From 34390320f11ea737092bc779be2f1be2b1fd47bc Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 19 Apr 2024 21:08:07 +1000 Subject: [PATCH 083/112] fix(mouse): fix panic Before the read() function panicked when a buffer with a size > size_of() was provided. This is now fixed and rather returns an error only when the buffer is too small. Signed-off-by: Anhad Singh --- src/aero_kernel/src/drivers/mouse.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/aero_kernel/src/drivers/mouse.rs b/src/aero_kernel/src/drivers/mouse.rs index d761366881f..cd49130391c 100644 --- a/src/aero_kernel/src/drivers/mouse.rs +++ b/src/aero_kernel/src/drivers/mouse.rs @@ -139,13 +139,16 @@ impl Device for Mouse { impl INodeInterface for Mouse { fn read_at(&self, _offset: usize, buffer: &mut [u8]) -> fs::Result { let size = core::mem::size_of::(); + + if buffer.len() < size { + return Err(fs::FileSystemError::NotSupported); + } + let packet = PACKETS .lock_irq() .pop() .ok_or(fs::FileSystemError::WouldBlock)?; - assert_eq!(buffer.len(), size); - unsafe { *(buffer.as_mut_ptr().cast::()) = packet; } @@ -161,7 +164,7 @@ impl INodeInterface for Mouse { if !PACKETS.lock_irq().is_empty() { Ok(PollFlags::IN) } else { - Ok(PollFlags::OUT) + Ok(PollFlags::empty()) } } } From 7dd50be8be91eb960bba7a4f23dd2a2e640dc203 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 21 Jun 2024 17:42:25 +1000 Subject: [PATCH 084/112] misc(unwind): fix compilation on latest rust Signed-off-by: Anhad Singh --- src/aero_kernel/src/unwind.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/aero_kernel/src/unwind.rs b/src/aero_kernel/src/unwind.rs index 7c2886a5560..5c0cb72b024 100644 --- a/src/aero_kernel/src/unwind.rs +++ b/src/aero_kernel/src/unwind.rs @@ -161,7 +161,7 @@ pub fn unwind_stack_trace() { log::trace!("{depth:>2}: 0x{rip:016x} - "); } } else { - log::trace!("{:>2}: 0x{:016x} - ", depth, rip); + log::trace!("{depth:>2}: 0x{rip:016x} - "); } } else { // RBP has been overflowed... @@ -186,7 +186,7 @@ use crate::utils::sync::IrqGuard; fn rust_begin_unwind(info: &PanicInfo) -> ! { prepare_panic(); - let message = info.message().unwrap(); + let message = info.message(); let location = info.location().unwrap(); // Get the CPU ID where this panic happened and if PANIC_HOOK_READY is false From 15ca6281f2fdd867d526b9cbb1ec0419f3dca15e Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 22 Jun 2024 13:29:01 +1000 Subject: [PATCH 085/112] ports(mlibc): tag memory locations on library load Signed-off-by: Anhad Singh --- patches/fox/jinx-working-patch.patch | 18 ++++- patches/mlibc/jinx-working-patch.patch | 98 +++++++++++++++++++++++++- recipes/mlibc | 4 +- userland/tests/utest.cc | 4 +- 4 files changed, 116 insertions(+), 8 deletions(-) diff --git a/patches/fox/jinx-working-patch.patch b/patches/fox/jinx-working-patch.patch index faa04295413..a163bd5781a 100644 --- a/patches/fox/jinx-working-patch.patch +++ b/patches/fox/jinx-working-patch.patch @@ -22,4 +22,20 @@ index ce0f651..189b5e8 100644 saved_cppflags="${CXXFLAGS}" CXXFLAGS="${CXXFLAGS} -DHAVE_XFT_H=1 $XFTCFLAGS" X_BASE_LIBS="${X_BASE_LIBS} $XFTLIBS" - +diff --git fox-clean/include/FXStream.h fox-workdir/include/FXStream.h +index 41fe97a..b483556 100644 +--- fox-clean/include/FXStream.h ++++ fox-workdir/include/FXStream.h +@@ -52,9 +52,9 @@ enum FXStreamStatus { + + /// Stream seeking + enum FXWhence { +- FXFromStart=0, /// Seek from start position +- FXFromCurrent=1, /// Seek from current position +- FXFromEnd=2 /// Seek from end position ++ FXFromStart=3, /// Seek from start position (SEEK_SET) ++ FXFromCurrent=1, /// Seek from current position (SEEK_CUR) ++ FXFromEnd=2 /// Seek from end position (SEEK_END) + }; + + diff --git a/patches/mlibc/jinx-working-patch.patch b/patches/mlibc/jinx-working-patch.patch index 4461b605fb4..e2ea7a45f2a 100644 --- a/patches/mlibc/jinx-working-patch.patch +++ b/patches/mlibc/jinx-working-patch.patch @@ -1,3 +1,16 @@ +diff --git mlibc-clean/meson.build mlibc-workdir/meson.build +index 905fbb9..6da45e0 100644 +--- mlibc-clean/meson.build ++++ mlibc-workdir/meson.build +@@ -213,7 +213,7 @@ elif host_machine.system() == 'aero' + rtld_include_dirs += include_directories('sysdeps/aero/include') + libc_include_dirs += include_directories('sysdeps/aero/include') + internal_conf.set10('MLIBC_MAP_DSO_SEGMENTS', true) +- internal_conf.set10('MLIBC_MAP_FILE_WINDOWS', true) ++ internal_conf.set10('MLIBC_MAP_FILE_WINDOWS', false) + subdir('sysdeps/aero') + elif host_machine.system() == 'managarm' + # TODO: Adopt the include_directories() commands from the managarm meson.build. diff --git mlibc-clean/options/glibc/generic/execinfo.cpp mlibc-workdir/options/glibc/generic/execinfo.cpp index 3474615..d06f130 100644 --- mlibc-clean/options/glibc/generic/execinfo.cpp @@ -15,11 +28,69 @@ index 3474615..d06f130 100644 } char **backtrace_symbols(void *const *, int) { +diff --git mlibc-clean/options/rtld/generic/linker.cpp mlibc-workdir/options/rtld/generic/linker.cpp +index b5f42af..569a8c2 100644 +--- mlibc-clean/options/rtld/generic/linker.cpp ++++ mlibc-workdir/options/rtld/generic/linker.cpp +@@ -27,7 +27,7 @@ uintptr_t libraryBase = 0x41000000; + + constexpr bool verbose = false; + constexpr bool stillSlightlyVerbose = false; +-constexpr bool logBaseAddresses = false; ++constexpr bool logBaseAddresses = true; + constexpr bool logRpath = false; + constexpr bool logLdPath = false; + constexpr bool eagerBinding = true; +@@ -470,6 +470,7 @@ frg::expected ObjectRepository::_fetchFromFile(SharedObject * + __ensure(!(object->baseAddress & (hugeSize - 1))); + + highest_address = (highest_address + mlibc::page_size - 1) & ~(mlibc::page_size - 1); ++ size_t tagSize = highest_address - object->baseAddress; + + #if MLIBC_MMAP_ALLOCATE_DSO + void *mappedAddr = nullptr; +@@ -492,9 +493,12 @@ frg::expected ObjectRepository::_fetchFromFile(SharedObject * + libraryBase += (highest_address + (hugeSize - 1)) & ~(hugeSize - 1); + #endif + +- if(verbose || logBaseAddresses) ++ if(verbose || logBaseAddresses) { ++ mlibc::sys_tag_memory((void *)object->baseAddress, tagSize, object->name.data()); ++ + mlibc::infoLogger() << "rtld: Loading " << object->name + << " at " << (void *)object->baseAddress << frg::endlog; ++ } + + // Load all segments. + constexpr size_t pageSize = 0x1000; +diff --git mlibc-clean/options/rtld/include/mlibc/rtld-sysdeps.hpp mlibc-workdir/options/rtld/include/mlibc/rtld-sysdeps.hpp +index 6f42d41..3e37a1d 100644 +--- mlibc-clean/options/rtld/include/mlibc/rtld-sysdeps.hpp ++++ mlibc-workdir/options/rtld/include/mlibc/rtld-sysdeps.hpp +@@ -5,6 +5,7 @@ namespace [[gnu::visibility("hidden")]] mlibc { + + int sys_tcb_set(void *pointer); + ++[[gnu::weak]] int sys_tag_memory(void *ptr, size_t size, char *tag); + [[gnu::weak]] int sys_vm_readahead(void *pointer, size_t size); + + } // namespace mlibc diff --git mlibc-clean/sysdeps/aero/generic/aero.cpp mlibc-workdir/sysdeps/aero/generic/aero.cpp -index 80f9c6f..897986d 100644 +index 80f9c6f..85031cd 100644 --- mlibc-clean/sysdeps/aero/generic/aero.cpp +++ mlibc-workdir/sysdeps/aero/generic/aero.cpp -@@ -200,14 +200,19 @@ int sys_getcwd(char *buffer, size_t size) { +@@ -62,6 +62,10 @@ static frg::vector create_slice(char *const arg[]) { + } + + namespace mlibc { ++int sys_tag_memory(void *ptr, size_t size, char *tag) { ++ return syscall(SYS_DEBUG, ptr, size, tag, strlen(tag)); ++} ++ + int sys_uname(struct utsname *buf) { + auto result = syscall(SYS_UNAME, buf); + +@@ -200,14 +204,19 @@ int sys_getcwd(char *buffer, size_t size) { return 0; } @@ -46,7 +117,7 @@ index 80f9c6f..897986d 100644 int sys_gethostname(char *buffer, size_t bufsize) { diff --git mlibc-clean/sysdeps/aero/generic/filesystem.cpp mlibc-workdir/sysdeps/aero/generic/filesystem.cpp -index 95c49b9..9416be7 100644 +index 95c49b9..8777468 100644 --- mlibc-clean/sysdeps/aero/generic/filesystem.cpp +++ mlibc-workdir/sysdeps/aero/generic/filesystem.cpp @@ -69,13 +69,14 @@ int sys_seek(int fd, off_t offset, int whence, off_t *new_offset) { @@ -70,3 +141,24 @@ index 95c49b9..9416be7 100644 return 0; } +@@ -124,6 +125,20 @@ int sys_stat(fsfd_target fsfdt, int fd, const char *path, int flags, + return 0; + } + ++int sys_statfs(const char *path, struct statfs *buf) { ++ __ensure(!syscall(SYS_BACKTRACE)); ++ __ensure(!"statfs"); ++ memset(buf, 0, sizeof(struct statfs)); ++ return 0; ++} ++ ++int sys_fstatfs(int fd, struct statfs *buf) { ++ __ensure(!syscall(SYS_BACKTRACE)); ++ mlibc::infoLogger() << "fstatfs" << frg::endlog; ++ memset(buf, 0, sizeof(struct statfs)); ++ return 0; ++} ++ + int sys_ioctl(int fd, unsigned long request, void *arg, int *result) { + auto sys_res = syscall(SYS_IOCTL, fd, request, arg); + diff --git a/recipes/mlibc b/recipes/mlibc index 819d178384e..50648456585 100644 --- a/recipes/mlibc +++ b/recipes/mlibc @@ -1,8 +1,8 @@ name=mlibc -version=71d6b326e31b88796088690278ce31bb8e9fc994 +version=7b67d09bde0be6d53284d1583058483e1687880c revision=1 tarball_url="https://github.com/managarm/mlibc/archive/${version}.tar.gz" -tarball_blake2b="b2fc2178bf9a26191a78866272da2ff6cb2b547cb3fdd5fe28f4280d5bbf98a929e9920e5c05a25ed340af8d29d45265e148eba6d31490a7a6796adfcb2158d6" +tarball_blake2b="a18b4fe6ab839088079f5cdcf1d35831ac9f3d25408118f5ddce280d595b730d1cbf7d4869a2da24f4df4edce7d250042acfea67f20266cc7a157db2e1d7c1ed" imagedeps="meson ninja" hostdeps="gcc pkg-config libgcc-binaries" builddeps="cxxshim frigg linux-headers" diff --git a/userland/tests/utest.cc b/userland/tests/utest.cc index 2abea8f9189..156ac20c6ca 100644 --- a/userland/tests/utest.cc +++ b/userland/tests/utest.cc @@ -762,8 +762,8 @@ void abstract_test_case::register_case(abstract_test_case *tcp) { } int main() { - // Go through all tests and run them. - for(abstract_test_case *tcp : test_case_ptrs()) { + // Go through all tests and run them. + for(abstract_test_case *tcp : test_case_ptrs()) { std::cout << "tests: Running " << tcp->name() << std::endl; tcp->run(); } From 9095737dd036ebf1560acfe221aa00de2e25e44d Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 27 Jun 2024 18:23:53 +1000 Subject: [PATCH 086/112] feat(fork): only copy necessary mappings Do not copy page table entries that can be mapped correctly on-demand when a page fault occurs. Signed-off-by: Anhad Singh --- src/aero_kernel/src/arch/x86_64/task.rs | 8 +- src/aero_kernel/src/fs/file_table.rs | 12 ++ src/aero_kernel/src/fs/procfs.rs | 2 +- src/aero_kernel/src/main.rs | 3 +- src/aero_kernel/src/mem/paging/mapper.rs | 220 +++++------------------ src/aero_kernel/src/syscall/process.rs | 3 +- src/aero_kernel/src/userland/task/mod.rs | 77 ++++---- src/aero_kernel/src/userland/vm.rs | 213 ++++++++++++++++------ 8 files changed, 256 insertions(+), 282 deletions(-) diff --git a/src/aero_kernel/src/arch/x86_64/task.rs b/src/aero_kernel/src/arch/x86_64/task.rs index a903d0fcdd8..e2bdcce9205 100644 --- a/src/aero_kernel/src/arch/x86_64/task.rs +++ b/src/aero_kernel/src/arch/x86_64/task.rs @@ -313,11 +313,9 @@ impl ArchTask { }) } - pub fn fork(&self) -> Result> { + pub fn fork(&self, address_space: AddressSpace) -> Result> { assert!(self.user, "cannot fork a kernel task"); - let new_address_space = AddressSpace::this().offset_page_table().fork()?; - // Since the fork function marks all of the userspace entries in both the forked // and the parent address spaces as read only, we will flush the page table of the // current process to trigger COW. @@ -346,14 +344,14 @@ impl ArchTask { *context = Context::default(); context.rip = fork_init as u64; - context.cr3 = new_address_space.cr3().start_address().as_u64(); + context.cr3 = address_space.cr3().start_address().as_u64(); let fpu_storage = self.fpu_storage.unwrap().clone(); Ok(Self { context: unsafe { Unique::new_unchecked(context) }, context_switch_rsp: VirtAddr::new(switch_stack as u64), - address_space: new_address_space, + address_space, user: true, // The FS and GS bases are inherited from the parent process. diff --git a/src/aero_kernel/src/fs/file_table.rs b/src/aero_kernel/src/fs/file_table.rs index ca86a505f58..b8fb2bffeff 100644 --- a/src/aero_kernel/src/fs/file_table.rs +++ b/src/aero_kernel/src/fs/file_table.rs @@ -57,6 +57,18 @@ impl FileHandle { } } + #[inline] + pub fn is_writable(&self) -> bool { + self.flags() + .intersects(OpenFlags::O_WRONLY | OpenFlags::O_RDWR) + } + + #[inline] + pub fn is_readable(&self) -> bool { + self.flags() + .intersects(OpenFlags::O_RDONLY | OpenFlags::O_RDWR) + } + pub fn flags(&self) -> OpenFlags { *self.flags.read() } diff --git a/src/aero_kernel/src/fs/procfs.rs b/src/aero_kernel/src/fs/procfs.rs index 57a12bae572..6d915b3c8ac 100644 --- a/src/aero_kernel/src/fs/procfs.rs +++ b/src/aero_kernel/src/fs/procfs.rs @@ -200,7 +200,7 @@ impl INodeInterface for LockedProcINode { "start": map.start_addr.as_u64(), "end": map.end_addr.as_u64(), "flags": map.flags.bits(), - "protection": map.protection.bits(), + "protection": map.protection().bits(), })); }); diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index d89e2e40737..ef030da1a4b 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -50,7 +50,8 @@ associated_type_defaults, trait_upcasting, asm_const, - sync_unsafe_cell + sync_unsafe_cell, + // effects )] // TODO(andypython): can we remove the dependency of "prelude_import" and "lang_items"? // `lang_items` => is currently used for the personality function (`rust_eh_personality`). diff --git a/src/aero_kernel/src/mem/paging/mapper.rs b/src/aero_kernel/src/mem/paging/mapper.rs index 2f3caaaba01..715ba1af0e3 100644 --- a/src/aero_kernel/src/mem/paging/mapper.rs +++ b/src/aero_kernel/src/mem/paging/mapper.rs @@ -18,9 +18,7 @@ // Some code borrowed from the x86_64 crate (MIT + Apache) and add support for 5-level paging // and some kernel specific features that cannot be directly done in the crate itself. -use core::ops::Range; - -use crate::mem::AddressSpace; +use core::ops::{Range, RangeInclusive}; use super::addr::{PhysAddr, VirtAddr}; use super::page::{AddressNotAligned, Page, PageSize, PhysFrame, Size1GiB, Size2MiB, Size4KiB}; @@ -1139,187 +1137,53 @@ impl<'a> OffsetPageTable<'a> { Ok(()) } - pub fn fork(&mut self) -> Result> { - let mut address_space = AddressSpace::new()?; // Allocate the new address space - - let offset_table = address_space.offset_page_table(); - let make_next_level = |table: &mut PageTable, - i: usize| - -> Result<(bool, &mut PageTable), MapToError> { - let entry = &mut table[i]; - let created = if !entry.flags().contains(PageTableFlags::PRESENT) { - let frame = FRAME_ALLOCATOR - .allocate_frame() - .ok_or(MapToError::FrameAllocationFailed)?; - - entry.set_frame( - frame, - PageTableFlags::PRESENT - | PageTableFlags::WRITABLE - | PageTableFlags::USER_ACCESSIBLE, - ); - - true - } else { - entry.set_flags( - PageTableFlags::PRESENT - | PageTableFlags::WRITABLE - | PageTableFlags::USER_ACCESSIBLE, - ); - - false - }; - - let page_table_ptr = { - let addr = entry.frame().unwrap().start_address().as_hhdm_virt(); - addr.as_mut_ptr::() - }; - - let page_table: &mut PageTable = unsafe { &mut *page_table_ptr }; - if created { - page_table.zero(); + pub fn copy_page_range(&mut self, src: &mut OffsetPageTable, range: RangeInclusive) { + let mut map_to = |src: &mut OffsetPageTable, addr, frame, flags| match frame { + MappedFrame::Size4KiB(frame) => { + let page = Page::::containing_address(addr); + + unsafe { + self.map_to_with_table_flags( + page, + frame, + flags, + PageTableFlags::PRESENT + | PageTableFlags::USER_ACCESSIBLE + | PageTableFlags::WRITABLE, + ) + } + .unwrap() + // operating on an inactive page table + .ignore(); + + unsafe { src.update_flags(page, flags) } + .unwrap() + // caller is required to invalidate the TLB + .ignore(); } - - Ok((created, page_table)) + _ => todo!(), }; - let last_level_fork = |entry: &mut PageTableEntry, n1: &mut PageTable, i: usize| { - let mut flags = entry.flags(); + let mut addr = *range.start(); - // Check if the mapping is shared. - // if !flags.contains(PageTableFlags::BIT_10) { - // Setup copy on write page. - flags.remove(PageTableFlags::WRITABLE); - // } + while addr != *range.end() { + match src.translate(addr) { + TranslateResult::Mapped { + frame, + offset, + flags, + } => { + assert_eq!(offset, 0, "unaligned page range"); + map_to(src, addr, frame, flags & !PageTableFlags::WRITABLE); + } - entry.set_flags(flags); - n1[i].set_frame(entry.frame().unwrap(), flags); - }; + TranslateResult::NotMapped => {} + TranslateResult::InvalidFrameAddress(addr) => { + panic!("invalid frame address {:#x}", addr); + } + } - // We loop through each of the page table entries in the page table which are user - // accessible and we remove the writeable flag from the entry if present. This will - // make the page table entry copy on the first write. Then we clone the page table entry - // and place it in the new page table. - if self.inner.level_5_paging_enabled { - self.inner.page_table.for_entries_mut( - PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE, - |i, _, table| { - let (_, n4) = make_next_level(offset_table.inner.page_table, i)?; - let mut count_4 = 0; - - table.for_entries_mut( - PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE, - |j, _, table| { - let (w3, n3) = make_next_level(n4, j)?; - let mut count_3 = 0; - - if w3 { - count_4 += 1; - } - - table.for_entries_mut( - PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE, - |k, _, table| { - let (w2, n2) = make_next_level(n3, k)?; - let mut count_2 = 0; - - if w2 { - count_3 += 1; - } - - table.for_entries_mut( - PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE, - |l, _, table| { - let (w1, n1) = make_next_level(n2, l)?; - let mut count_1 = 0; - - if w1 { - count_2 += 1; - } - - table.for_entries_mut( - PageTableFlags::PRESENT - | PageTableFlags::USER_ACCESSIBLE, - |i, entry, _| { - last_level_fork(entry, n1, i); - - count_1 += 1; - Ok(()) - }, - )?; - - n2[l].set_entry_count(count_1); - Ok(()) - }, - )?; - - n3[k].set_entry_count(count_2); - Ok(()) - }, - )?; - - n4[j].set_entry_count(count_3); - Ok(()) - }, - )?; - - offset_table.inner.page_table[i].set_entry_count(count_4); - Ok(()) - }, - )?; - } else { - self.inner.page_table.for_entries_mut( - PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE, - |i, _, table| { - let (_, n3) = make_next_level(offset_table.inner.page_table, i)?; - let mut count_3 = 0; - - table.for_entries_mut( - PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE, - |k, _, table| { - let (w2, n2) = make_next_level(n3, k)?; - let mut count_2 = 0; - - if w2 { - count_3 += 1; - } - - table.for_entries_mut( - PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE, - |l, _, table| { - let (w1, n1) = make_next_level(n2, l)?; - let mut count_1 = 0; - - if w1 { - count_2 += 1; - } - - table.for_entries_mut( - PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE, - |i, entry, _| { - last_level_fork(entry, n1, i); - - count_1 += 1; - Ok(()) - }, - )?; - - n2[l].set_entry_count(count_1); - Ok(()) - }, - )?; - - n3[k].set_entry_count(count_2); - Ok(()) - }, - )?; - - offset_table.inner.page_table[i].set_entry_count(count_3); - Ok(()) - }, - )?; + addr += Size4KiB::SIZE; } - - Ok(address_space) } } diff --git a/src/aero_kernel/src/syscall/process.rs b/src/aero_kernel/src/syscall/process.rs index 97996c8ced5..f02fecb20ad 100644 --- a/src/aero_kernel/src/syscall/process.rs +++ b/src/aero_kernel/src/syscall/process.rs @@ -181,8 +181,7 @@ pub fn mmap( .current_task() .file_table .get_handle(fd) - .ok_or(SyscallError::EBADF)? - .dirnode(), + .ok_or(SyscallError::EBADF)?, ); } diff --git a/src/aero_kernel/src/userland/task/mod.rs b/src/aero_kernel/src/userland/task/mod.rs index f14abd89d8c..cd7d1d7d706 100644 --- a/src/aero_kernel/src/userland/task/mod.rs +++ b/src/aero_kernel/src/userland/task/mod.rs @@ -321,7 +321,25 @@ impl Task { }) } - fn make_child(&self, arch_task: UnsafeCell) -> Arc { + pub fn has_pending_io(&self) -> bool { + self.pending_io.load(Ordering::SeqCst) + } + + pub fn set_pending_io(&self, yes: bool) { + self.pending_io.store(yes, Ordering::SeqCst) + } + + pub fn signals(&self) -> &Signals { + &self.signals + } + + pub fn clone_process(&self, entry: usize, stack: usize) -> Arc { + let arch_task = UnsafeCell::new( + self.arch_task_mut() + .clone_process(entry, stack) + .expect("failed to fork arch task"), + ); + let pid = TaskId::allocate(); let this = Arc::new_cyclic(|sref| Self { @@ -329,9 +347,9 @@ impl Task { zombies: Zombies::new(), arch_task, - file_table: Arc::new(self.file_table.deep_clone()), + file_table: self.process_leader().file_table.clone(), message_queue: MessageQueue::new(), - vm: Arc::new(Vm::new()), + vm: self.process_leader().vm.clone(), state: AtomicU8::new(TaskState::Runnable as _), link: Default::default(), @@ -349,13 +367,19 @@ impl Task { pending_io: AtomicBool::new(false), children: Mutex::new(Default::default()), + // sus? fixme? parent: Mutex::new(None), cwd: RwLock::new(Some(self.cwd.read().as_ref().unwrap().fork())), signals: Signals::new(), - systrace: AtomicBool::new(self.systrace()), - controlling_terminal: Mutex::new(self.controlling_terminal.lock_irq().clone()), + systrace: AtomicBool::new(self.process_leader().systrace()), + controlling_terminal: Mutex::new( + self.process_leader() + .controlling_terminal + .lock_irq() + .clone(), + ), mem_tags: Mutex::new(self.mem_tags.lock().clone()), }); @@ -363,26 +387,16 @@ impl Task { self.add_child(this.clone()); this.signals().copy_from(self.signals()); - this.vm.fork_from(self.vm()); this } - pub fn has_pending_io(&self) -> bool { - self.pending_io.load(Ordering::SeqCst) - } - - pub fn set_pending_io(&self, yes: bool) { - self.pending_io.store(yes, Ordering::SeqCst) - } - - pub fn signals(&self) -> &Signals { - &self.signals - } + pub fn fork(&self) -> Arc { + let vm = Arc::new(Vm::new()); + let address_space = vm.fork_from(self.vm()); - pub fn clone_process(&self, entry: usize, stack: usize) -> Arc { let arch_task = UnsafeCell::new( self.arch_task_mut() - .clone_process(entry, stack) + .fork(address_space) .expect("failed to fork arch task"), ); @@ -393,9 +407,9 @@ impl Task { zombies: Zombies::new(), arch_task, - file_table: self.process_leader().file_table.clone(), + file_table: Arc::new(self.file_table.deep_clone()), message_queue: MessageQueue::new(), - vm: self.process_leader().vm.clone(), + vm, state: AtomicU8::new(TaskState::Runnable as _), link: Default::default(), @@ -413,39 +427,22 @@ impl Task { pending_io: AtomicBool::new(false), children: Mutex::new(Default::default()), - // sus? fixme? parent: Mutex::new(None), cwd: RwLock::new(Some(self.cwd.read().as_ref().unwrap().fork())), signals: Signals::new(), - systrace: AtomicBool::new(self.process_leader().systrace()), - controlling_terminal: Mutex::new( - self.process_leader() - .controlling_terminal - .lock_irq() - .clone(), - ), + systrace: AtomicBool::new(self.systrace()), + controlling_terminal: Mutex::new(self.controlling_terminal.lock_irq().clone()), mem_tags: Mutex::new(self.mem_tags.lock().clone()), }); self.add_child(this.clone()); this.signals().copy_from(self.signals()); - this } - pub fn fork(&self) -> Arc { - let arch_task = UnsafeCell::new( - self.arch_task_mut() - .fork() - .expect("failed to fork arch task"), - ); - - self.make_child(arch_task) - } - fn this(&self) -> Arc { self.sref.upgrade().unwrap() } diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs index cd0d21fa2fd..c74e2e981e2 100644 --- a/src/aero_kernel/src/userland/vm.rs +++ b/src/aero_kernel/src/userland/vm.rs @@ -23,12 +23,14 @@ use alloc::boxed::Box; use alloc::collections::linked_list::CursorMut; use alloc::collections::LinkedList; +use alloc::sync::Arc; use xmas_elf::header::*; use xmas_elf::program::*; use xmas_elf::*; use crate::arch::task::userland_last_address; use crate::fs::cache::{DirCacheImpl, DirCacheItem}; +use crate::fs::file_table::FileHandle; use crate::fs::{FileSystemError, Path}; use crate::mem::paging::*; use crate::mem::AddressSpace; @@ -37,6 +39,47 @@ use crate::{fs, mem}; use crate::syscall::ExecArgs; use crate::utils::sync::BMutex; +bitflags::bitflags! { + #[derive(Debug, Copy, Clone, PartialEq)] + pub struct VmFlag: u8 { + // currently active flags + const READ = MMapProt::PROT_READ.bits() as _; + const WRITE = MMapProt::PROT_WRITE.bits() as _; + const EXEC = MMapProt::PROT_EXEC.bits() as _; + + // limits + const MAY_READ = 1 << 3; + const MAY_WRITE = 1 << 4; + const MAY_EXEC = 1 << 5; + } +} + +const VM_PROT_MASK: VmFlag = + VmFlag::from_bits_retain(VmFlag::READ.bits() | VmFlag::WRITE.bits() | VmFlag::EXEC.bits()); + +impl From for VmFlag { + #[inline] + fn from(value: MMapProt) -> Self { + Self::from_bits_retain(value.bits().try_into().unwrap()) + } +} + +impl From for PageTableFlags { + fn from(flags: VmFlag) -> Self { + let mut value = PageTableFlags::empty(); + + if !flags.contains(VmFlag::EXEC) { + value.insert(PageTableFlags::NO_EXECUTE); + } + + if flags.contains(VmFlag::WRITE) { + value.insert(PageTableFlags::WRITABLE); + } + + value + } +} + const ELF_HEADER_MAGIC: [u8; 4] = [0x7f, b'E', b'L', b'F']; const ELF_PT1_SIZE: usize = core::mem::size_of::(); @@ -283,22 +326,6 @@ impl<'this> Iterator for ProgramHeaderIter<'this> { } } -impl From for PageTableFlags { - fn from(e: MMapProt) -> Self { - let mut res = PageTableFlags::empty(); - - if !e.contains(MMapProt::PROT_EXEC) { - res.insert(PageTableFlags::NO_EXECUTE); - } - - if e.contains(MMapProt::PROT_WRITE) { - res.insert(PageTableFlags::WRITABLE); - } - - res - } -} - enum UnmapResult { None, Partial(Mapping), @@ -333,8 +360,8 @@ impl MMapFile { #[derive(Debug, Clone)] pub struct Mapping { - pub protection: MMapProt, pub flags: MMapFlags, + vm_flags: VmFlag, pub start_addr: VirtAddr, pub end_addr: VirtAddr, @@ -344,6 +371,25 @@ pub struct Mapping { } impl Mapping { + pub fn set_protection(&mut self, protection: MMapProt) -> aero_syscall::Result<()> { + if (protection.contains(MMapProt::PROT_READ) && !self.vm_flags.contains(VmFlag::MAY_READ)) + || (protection.contains(MMapProt::PROT_WRITE) + && !self.vm_flags.contains(VmFlag::MAY_WRITE)) + || (protection.contains(MMapProt::PROT_EXEC) + && !self.vm_flags.contains(VmFlag::MAY_EXEC)) + { + return Err(aero_syscall::SyscallError::EACCES); + } + + self.vm_flags = (self.vm_flags & !VM_PROT_MASK) | protection.into(); + Ok(()) + } + + #[inline] + pub fn protection(&self) -> VmFlag { + self.vm_flags & VM_PROT_MASK + } + /// Handler routine for private anonymous pages. Since its an anonymous page is not /// backed by a file, we have to alloctate a frame and map it at the faulted address. fn handle_pf_private_anon( @@ -367,7 +413,7 @@ impl Mapping { // the mapping gets copied on write. PageTableFlags::USER_ACCESSIBLE | PageTableFlags::PRESENT - | self.protection.into(), + | self.vm_flags.into(), ) } .expect("Failed to identity map userspace private mapping") @@ -390,7 +436,7 @@ impl Mapping { page, PageTableFlags::USER_ACCESSIBLE | PageTableFlags::PRESENT - | self.protection.into(), + | self.vm_flags.into(), ) .unwrap() .flush(); @@ -430,9 +476,9 @@ impl Mapping { .mmap(offset as _, size as _, self.flags) .expect("handle_pf_file: file does not support mmap"); - let mut flags = PageTableFlags::PRESENT + let flags = PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE - | self.protection.into(); + | self.vm_flags.into(); // if self.flags.contains(MMapFlags::MAP_SHARED) { // flags |= PageTableFlags::BIT_10; @@ -459,7 +505,7 @@ impl Mapping { fn map_copied( offset_table: &mut OffsetPageTable, page: Page, - protection: MMapProt, + flags: VmFlag, ) -> Result<(), MapToError> { // Allocate a new frame to hold the contents. let new_frame: PhysFrame = FRAME_ALLOCATOR @@ -486,7 +532,7 @@ impl Mapping { .map_to( page, new_frame, - PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE | protection.into(), + PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE | flags.into(), )? .flush(); } @@ -517,7 +563,7 @@ impl Mapping { if let Some(vm_frame) = phys_addr.as_vm_frame() { if vm_frame.ref_count() > 1 || copy { // This page is used by more then one process, so make it a private copy. - Self::map_copied(offset_table, page, self.protection).unwrap(); + Self::map_copied(offset_table, page, self.vm_flags).unwrap(); } else { // This page is used by only one process, so make it writable. unsafe { @@ -525,7 +571,7 @@ impl Mapping { page, PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE - | self.protection.into(), + | self.vm_flags.into(), ) } .unwrap() @@ -574,12 +620,12 @@ impl Mapping { }); let new_mapping = Mapping { - protection: self.protection, flags: self.flags, start_addr: end, end_addr: end + (self.end_addr - end), file: new_file, refresh_flags: true, + vm_flags: self.vm_flags, }; self.end_addr = start; @@ -662,18 +708,18 @@ impl VmProtected { .iter_mut() .find(|e| accessed_address >= e.start_addr && accessed_address < e.end_addr) { - if map.protection.is_empty() { + if map.protection().is_empty() { return false; } if reason.contains(PageFaultErrorCode::CAUSED_BY_WRITE) - && !map.protection.contains(MMapProt::PROT_WRITE) + && !map.vm_flags.contains(VmFlag::WRITE) { return false; } if reason.contains(PageFaultErrorCode::INSTRUCTION_FETCH) - && !map.protection.contains(MMapProt::PROT_EXEC) + && !map.vm_flags.contains(VmFlag::EXEC) { return false; } @@ -697,6 +743,7 @@ impl VmProtected { } } else { log::trace!("mapping not found for address: {:#x}", accessed_address); + self.log(); // else the mapping does not exist, so return false. false @@ -774,11 +821,14 @@ impl VmProtected { &mut self, address: VirtAddr, size: usize, - protection: MMapProt, flags: MMapFlags, offset: usize, file: Option, + vm_flags: VmFlag, ) -> Option { + // TODO: Check file permissions: + // * Do not allow writing to an {read, append}-only file. + let z = file.clone(); // Offset is required to be a multiple of page size. @@ -810,6 +860,7 @@ impl VmProtected { } } + // TODO: align_up may overflow. return if size_aligned == 0 let size_aligned = align_up(size as _, Size4KiB::SIZE); let x = if address == VirtAddr::zero() { @@ -837,7 +888,7 @@ impl VmProtected { if let Some(prev) = cursor.peek_prev() { if prev.end_addr == addr && prev.flags == flags - && prev.protection == protection + && prev.protection() == (vm_flags & VM_PROT_MASK) && prev.file.is_none() { prev.end_addr = addr + size_aligned; @@ -847,7 +898,6 @@ impl VmProtected { } cursor.insert_before(Mapping { - protection, flags, start_addr: addr, @@ -855,6 +905,7 @@ impl VmProtected { file: file.map(|f| MMapFile::new(f, offset, size)), refresh_flags: true, + vm_flags, }); addr @@ -867,7 +918,7 @@ impl VmProtected { dbg!( address, size, - protection, + vm_flags, flags, offset, z.map(|f| f.absolute_path()) @@ -886,7 +937,7 @@ impl VmProtected { "{:?}..{:?} => {:?}, {:?} (offset={:#x}, size={:#x})", mmap.start_addr, mmap.end_addr, - mmap.protection, + mmap.vm_flags, mmap.flags, file.offset, file.size, @@ -896,7 +947,7 @@ impl VmProtected { "{:?}..{:?} => {:?}, {:?}", mmap.start_addr, mmap.end_addr, - mmap.protection, + mmap.vm_flags, mmap.flags, ); } @@ -979,18 +1030,18 @@ impl VmProtected { let file_offset = align_down(header.offset(), Size4KiB::SIZE); - let mut prot = MMapProt::empty(); + let mut flags = VmFlag::MAY_READ | VmFlag::MAY_WRITE | VmFlag::MAY_EXEC; if header_flags.is_read() { - prot.insert(MMapProt::PROT_READ); + flags.insert(VmFlag::READ); } if header_flags.is_write() { - prot.insert(MMapProt::PROT_WRITE); + flags.insert(VmFlag::WRITE); } if header_flags.is_execute() { - prot.insert(MMapProt::PROT_EXEC); + flags.insert(VmFlag::EXEC); } #[rustfmt::skip] @@ -1021,10 +1072,10 @@ impl VmProtected { .mmap( virtual_start, data_size as usize, - prot, MMapFlags::MAP_PRIVATE | MMapFlags::MAP_FIXED, file_offset as usize, Some(bin.clone()), + flags ) .ok_or(ElfLoadError::MemoryMapError)?; @@ -1036,10 +1087,10 @@ impl VmProtected { self.mmap( virtual_fend, bss_size as usize, - prot, MMapFlags::MAP_PRIVATE | MMapFlags::MAP_ANONYOMUS | MMapFlags::MAP_FIXED, 0, None, + flags, ) .ok_or(ElfLoadError::MemoryMapError)?; } @@ -1112,7 +1163,12 @@ impl VmProtected { success } - fn mprotect(&mut self, addr: VirtAddr, size: usize, prot: MMapProt) -> bool { + fn mprotect( + &mut self, + addr: VirtAddr, + size: usize, + prot: MMapProt, + ) -> aero_syscall::Result<()> { let start = addr.align_up(Size4KiB::SIZE); let end = (addr + size).align_up(Size4KiB::SIZE); @@ -1127,7 +1183,7 @@ impl VmProtected { // The address we want to unmap is in the middle of the region. So we // will need to split the mapping and update the end address accordingly. let (left, mut mid, right) = map.split(start, end); - mid.protection = prot; + mid.set_protection(prot)?; cursor.insert_after(right); cursor.insert_after(mid); @@ -1136,13 +1192,13 @@ impl VmProtected { break; } else if start <= map.start_addr && end >= map.end_addr { // full - map.protection = prot; + map.set_protection(prot)?; cursor.move_next(); } else if start <= map.start_addr && end < map.end_addr { // start let mut mapping = map.clone(); mapping.end_addr = end; - mapping.protection = prot; + mapping.set_protection(prot)?; map.start_addr = end; cursor.insert_before(mapping); @@ -1151,7 +1207,7 @@ impl VmProtected { // end let mut mapping = map.clone(); mapping.start_addr = start; - mapping.protection = prot; + mapping.set_protection(prot)?; map.end_addr = start; cursor.insert_after(mapping); @@ -1159,14 +1215,30 @@ impl VmProtected { } } - true + Ok(()) } - fn fork_from(&mut self, parent: &Vm) { - let data = parent.inner.lock(); + #[must_use] + fn fork_from(&mut self, parent: &Vm) -> AddressSpace { + { + let parent = parent.inner.lock(); + self.mappings.clone_from(&parent.mappings); + } + + let mut address_space = AddressSpace::new().unwrap(); + let mut offset_table = address_space.offset_page_table(); + + let mut current = AddressSpace::this(); + let mut current = current.offset_page_table(); + + for map in self.mappings.iter().filter(|map| { + // Do not copy page table entries where a page fault can map them correctly. + !map.flags.contains(MMapFlags::MAP_SHARED) && map.vm_flags.contains(VmFlag::MAY_WRITE) + }) { + offset_table.copy_page_range(&mut current, map.start_addr..=map.end_addr); + } - // Copy over all of the mappings from the parent into the child. - self.mappings.clone_from(&data.mappings); + address_space } } @@ -1189,11 +1261,38 @@ impl Vm { protection: MMapProt, flags: MMapFlags, offset: usize, - file: Option, + file: Option>, ) -> Option { + let vm_flags = + VmFlag::from(protection) | VmFlag::MAY_READ | VmFlag::MAY_WRITE | VmFlag::MAY_EXEC; + + let map_type = flags & (MMapFlags::MAP_SHARED | MMapFlags::MAP_PRIVATE); + + match (map_type, file.as_ref()) { + (MMapFlags::MAP_SHARED, Some(file)) => { + if protection.contains(MMapProt::PROT_WRITE) && !file.is_writable() { + return None; // EACCES + } + + // TODO: check for append-only files. + } + + (MMapFlags::MAP_PRIVATE, Some(file)) => { + if !file.is_readable() { + // return None; // EACCES + } + + // TODO: * check if the filsystem is noexec mounted and remove the MAY_EXEC flag. + // * error out if prot contains PROT_EXEC & filesystem is noexec. + } + + _ => {} + } + + let file = file.map(|file| file.dirnode()); self.inner .lock() - .mmap(address, size, protection, flags, offset, file) + .mmap(address, size, flags, offset, file, vm_flags) } pub fn munmap(&self, address: VirtAddr, size: usize) -> bool { @@ -1201,13 +1300,17 @@ impl Vm { } pub fn mprotect(&self, ptr: VirtAddr, size: usize, prot: MMapProt) { - assert!(self.inner.lock().mprotect(ptr, size, prot)) + self.inner.lock().mprotect(ptr, size, prot).unwrap() } - pub(super) fn fork_from(&self, parent: &Vm) { + pub(super) fn fork_from(&self, parent: &Vm) -> AddressSpace { self.inner.lock().fork_from(parent) } + pub fn log(&self) { + self.inner.lock().log() + } + /// Mapping the provided `bin` file into the VM. pub fn load_bin( &self, From beb3cc5cffeb06238c63090dd71668deb91d5725 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sun, 30 Jun 2024 13:08:05 +1000 Subject: [PATCH 087/112] feat(vm): handle shared files properly Signed-off-by: Anhad Singh --- src/aero_kernel/src/fs/block/mod.rs | 93 ++++++++--- src/aero_kernel/src/fs/devfs.rs | 26 ++- src/aero_kernel/src/fs/ext2/mod.rs | 26 ++- src/aero_kernel/src/fs/inode.rs | 14 ++ src/aero_kernel/src/fs/ramfs.rs | 17 +- src/aero_kernel/src/mem/paging/addr.rs | 2 +- src/aero_kernel/src/userland/vm.rs | 219 ++++++++++++++++++++----- userland/Makefile | 9 +- userland/tests/f.c | 47 ++++++ 9 files changed, 387 insertions(+), 66 deletions(-) create mode 100644 userland/tests/f.c diff --git a/src/aero_kernel/src/fs/block/mod.rs b/src/aero_kernel/src/fs/block/mod.rs index 7c5b3f4beb0..049e8833ef5 100644 --- a/src/aero_kernel/src/fs/block/mod.rs +++ b/src/aero_kernel/src/fs/block/mod.rs @@ -32,32 +32,46 @@ use crate::fs::{FileSystem, Result}; use crate::fs::ext2::Ext2; use crate::mem::paging::*; +use crate::mem::AddressSpace; use crate::utils::sync::Mutex; use super::cache::{Cache, CacheArc, CacheItem, Cacheable}; use super::devfs::{alloc_device_marker, Device}; use super::inode::INodeInterface; -type PageCacheKey = (usize, usize); // (block device pointer, offset) -type PageCacheItem = CacheArc>; +type PageCacheKey = (usize, usize); // (owner ptr, index) +pub type PageCacheItem = CacheArc>; -struct CachedPage { - device: Weak, +struct DirtyMapping { + addr_space: AddressSpace, + addr: VirtAddr, +} + +pub struct CachedPage { + owner: Weak, offset: usize, page: PhysFrame, dirty: AtomicBool, + dirty_mappings: Mutex>, } impl CachedPage { - fn new(device: Weak, offset: usize) -> Self { - Self { - device, + fn new(owner: Weak, offset: usize) -> Self { + let k = Self { + owner, offset, page: FRAME_ALLOCATOR .allocate_frame() .expect("page_cache: out of memory"), dirty: AtomicBool::new(false), - } + dirty_mappings: Mutex::new(Vec::new()), + }; + // TODO: temporary hack. i mean this is fine but is there a cleaner way to do this. this is + // required since when the VM for the process umaps a page that contains a cached page, it + // will unmap this page which will decrease the refcnt to 0 and deallocate it. + get_vm_frames().unwrap()[k.page.start_address().as_u64() as usize / 4096usize] + .inc_ref_count(); + k } fn data_mut(&self) -> &mut [MaybeUninit] { @@ -72,10 +86,14 @@ impl CachedPage { unsafe { core::slice::from_raw_parts_mut(data_ptr, Size4KiB::SIZE as usize) } } - fn data_addr(&self) -> PhysAddr { + pub fn data_addr(&self) -> PhysAddr { self.page.start_address() } + pub fn page(&self) -> PhysFrame { + self.page + } + fn make_key(device: &Weak, offset: usize) -> PageCacheKey { (device.as_ptr().addr(), offset) } @@ -85,12 +103,13 @@ impl CachedPage { self.dirty.load(Ordering::SeqCst) } - fn mark_dirty(&self) { + pub fn mark_dirty(&self) { + log::error!("marking dirty --------------------------------------"); self.dirty.store(true, Ordering::SeqCst); } fn device(&self) -> Arc { - self.device.upgrade().unwrap() + self.owner.upgrade().unwrap() } fn sync(&self) { @@ -98,13 +117,21 @@ impl CachedPage { return; } - // Commit the changes made to the cache to the disk. - let disk = self.device(); - + // Commit the changes made to the cache to the owner. + let owner = self.device(); let offset_bytes = self.offset * Size4KiB::SIZE as usize; - let sector = offset_bytes / disk.block_size(); + owner.write_direct(offset_bytes, self.page); + + for mut mapping in self.dirty_mappings.lock_irq().drain(..) { + let mut offset_table = mapping.addr_space.offset_page_table(); + offset_table + .unmap(Page::::containing_address(mapping.addr)) + .unwrap() + .1 + .flush(); + } - disk.write_dma(sector, self.data_addr(), Size4KiB::SIZE as usize); + self.dirty.store(false, Ordering::SeqCst); } } @@ -116,12 +143,12 @@ impl Drop for CachedPage { impl Cacheable for CachedPage { fn cache_key(&self) -> PageCacheKey { - Self::make_key(&self.device, self.offset) + Self::make_key(&self.owner, self.offset) } } lazy_static::lazy_static! { - static ref PAGE_CACHE: Arc> = Cache::new(); + pub(in crate::fs) static ref PAGE_CACHE: Arc> = Cache::new(); } impl Cache { @@ -145,16 +172,16 @@ impl Cache { let device = device.upgrade().expect("page_cache: device dropped"); let aligned_offset = align_down(offset as u64, Size4KiB::SIZE) as usize; - let sector = aligned_offset / device.block_size(); - device - .read_dma(sector, page.data_addr(), Size4KiB::SIZE as usize) + .read_direct(aligned_offset, page.page()) .expect("page_cache: failed to read block"); PAGE_CACHE.make_item_cached(page) } } +// TODO: cache hit miss stats + pub struct DirtyRef { cache: PageCacheItem, ptr: *mut T, @@ -202,9 +229,12 @@ pub trait BlockDeviceInterface: Send + Sync { fn write_block(&self, sector: usize, buf: &[u8]) -> Option; } -pub trait CachedAccess: BlockDeviceInterface { +pub trait CachedAccess: Send + Sync { fn sref(&self) -> Weak; + fn read_direct(&self, offset: usize, dest: PhysFrame) -> Option; + fn write_direct(&self, offset: usize, src: PhysFrame) -> Option; + fn read(&self, mut offset: usize, dest: &mut [MaybeUninit]) -> Option { let mut loc = 0; @@ -236,6 +266,9 @@ pub trait CachedAccess: BlockDeviceInterface { let mut loc = 0; while loc < buffer.len() { + // TODO: If it is not found in the page cache, then, when the write perfectly falls on + // page size boundaries, the page is not even read from disk, but allocated and + // immediately marked dirty. let page = PAGE_CACHE.get_page(&self.sref(), offset); let page_offset = offset % Size4KiB::SIZE as usize; @@ -318,6 +351,22 @@ impl CachedAccess for BlockDevice { fn sref(&self) -> Weak { self.sref.clone() } + + fn read_direct(&self, offset: usize, dest: PhysFrame) -> Option { + self.dev.read_dma( + offset / self.dev.block_size(), + dest.start_address(), + Size4KiB::SIZE as _, + ) + } + + fn write_direct(&self, offset: usize, src: PhysFrame) -> Option { + self.dev.write_dma( + offset / self.dev.block_size(), + src.start_address(), + Size4KiB::SIZE as _, + ) + } } impl INodeInterface for BlockDevice {} diff --git a/src/aero_kernel/src/fs/devfs.rs b/src/aero_kernel/src/fs/devfs.rs index d59c6dd3581..39bf4cbde6a 100644 --- a/src/aero_kernel/src/fs/devfs.rs +++ b/src/aero_kernel/src/fs/devfs.rs @@ -31,7 +31,7 @@ use crate::mem::paging::*; use crate::rendy::RendyInfo; use super::cache::{DirCacheItem, INodeCacheItem}; -use super::inode::{INodeInterface, PollFlags, PollTable}; +use super::inode::{INodeInterface, MMapPage, PollFlags, PollTable}; use super::ramfs::RamFs; use super::{FileSystem, FileSystemError, Result, MOUNT_MANAGER}; @@ -132,6 +132,10 @@ impl INodeInterface for DevINode { fn open(&self, handle: Arc) -> Result> { self.0.inode().open(handle) } + + fn mmap_v2(&self, offset: usize) -> Result { + self.0.inode().mmap_v2(offset) + } } /// Implementation of dev filesystem. (See the module-level documentation for more @@ -357,6 +361,26 @@ impl INodeInterface for DevFb { .expect("/dev/fb: terminal not initialized") } + fn mmap_v2(&self, offset: usize) -> Result { + let rinfo = crate::rendy::get_rendy_info(); + + // Make sure we are in bounds. + if offset > rinfo.byte_len || offset + Size4KiB::SIZE as usize > rinfo.byte_len { + return Err(FileSystemError::NotSupported); + } + + let mut lock = crate::rendy::DEBUG_RENDY.get().unwrap().lock_irq(); + let fb = lock.get_framebuffer(); + + let fb_ptr = fb.as_ptr().cast::(); + let fb_ptr = unsafe { fb_ptr.add(offset) }; + let fb_phys_ptr = unsafe { fb_ptr.sub(crate::PHYSICAL_MEMORY_OFFSET.as_u64() as usize) }; + + Ok(MMapPage::Direct(PhysFrame::containing_address(unsafe { + PhysAddr::new_unchecked(fb_phys_ptr as u64) + }))) + } + fn ioctl(&self, command: usize, arg: usize) -> Result { match command { FBIOGET_VSCREENINFO => { diff --git a/src/aero_kernel/src/fs/ext2/mod.rs b/src/aero_kernel/src/fs/ext2/mod.rs index 74d70ccc821..337fa3c4acf 100644 --- a/src/aero_kernel/src/fs/ext2/mod.rs +++ b/src/aero_kernel/src/fs/ext2/mod.rs @@ -37,13 +37,13 @@ use crate::socket::SocketAddrRef; use self::group_desc::GroupDescriptors; -use super::block::{self, BlockDevice, CachedAccess}; +use super::block::{self, BlockDevice, CachedAccess, PAGE_CACHE}; use super::cache::{DirCacheItem, INodeCacheItem}; use super::path::PathBuf; use super::{cache, FileSystemError, Path}; -use super::inode::{self, INodeInterface, Metadata, PollFlags, PollTable}; +use super::inode::{self, INodeInterface, MMapPage, Metadata, PollFlags, PollTable}; use super::FileSystem; pub struct INode { @@ -358,6 +358,20 @@ impl INode { } } +impl CachedAccess for INode { + fn sref(&self) -> Weak { + self.sref.clone() + } + + fn read_direct(&self, offset: usize, dest: PhysFrame) -> Option { + INodeInterface::read_at(self, offset, dest.as_slice_mut()).ok() + } + + fn write_direct(&self, offset: usize, src: PhysFrame) -> Option { + INodeInterface::write_at(self, offset, src.as_slice_mut()).ok() + } +} + impl INodeInterface for INode { fn weak_filesystem(&self) -> Option> { Some(self.fs.clone()) @@ -587,6 +601,14 @@ impl INodeInterface for INode { Ok(private_cp) } + // TODO: cleanup + fn mmap_v2(&self, offset: usize) -> super::Result { + Ok(MMapPage::PageCache(PAGE_CACHE.get_page( + &(self.sref.clone() as Weak), + offset, + ))) + } + fn listen(&self, backlog: usize) -> Result<(), SyscallError> { if let Some(proxy) = self.proxy.as_ref() { return proxy.listen(backlog); diff --git a/src/aero_kernel/src/fs/inode.rs b/src/aero_kernel/src/fs/inode.rs index 01c621c00ec..930cb3eb3d8 100644 --- a/src/aero_kernel/src/fs/inode.rs +++ b/src/aero_kernel/src/fs/inode.rs @@ -33,6 +33,7 @@ use crate::socket::{SocketAddr, SocketAddrRef}; use crate::userland::scheduler; use crate::utils::sync::{BMutex, Mutex, WaitQueue}; +use super::block::PageCacheItem; use super::cache::{Cacheable, CachedINode, DirCacheItem, INodeCacheItem}; use super::devfs::DevINode; use super::file_table::FileHandle; @@ -109,6 +110,11 @@ impl From for PollEventFlags { } } +pub enum MMapPage { + Direct(PhysFrame), + PageCache(PageCacheItem), +} + /// An inode describes a file. An inode structure holds metadata of the /// inode which includes its type, size, the number of links referring to it, /// and the list of blocks holding the file's content. For example device files, @@ -234,6 +240,14 @@ pub trait INodeInterface: Send + Sync { Err(FileSystemError::NotSupported) } + fn mmap_v2(&self, _offset: usize) -> Result { + log::error!( + "{} does not support mmap_v2!", + core::any::type_name_of_val(self), + ); + Err(FileSystemError::NotSupported) + } + // Socket operations: fn bind(&self, _address: SocketAddrRef, _length: usize) -> Result<()> { Err(FileSystemError::NotSocket) diff --git a/src/aero_kernel/src/fs/ramfs.rs b/src/aero_kernel/src/fs/ramfs.rs index 822b3531aba..54d61d777f2 100644 --- a/src/aero_kernel/src/fs/ramfs.rs +++ b/src/aero_kernel/src/fs/ramfs.rs @@ -33,7 +33,7 @@ use super::cache::{ }; use super::devfs::DevINode; use super::inode::{ - DirEntry, FileContents, FileType, INodeInterface, Metadata, PollFlags, PollTable, + DirEntry, FileContents, FileType, INodeInterface, MMapPage, Metadata, PollFlags, PollTable, }; use super::{FileSystem, FileSystemError, Result}; @@ -384,6 +384,21 @@ impl INodeInterface for LockedRamINode { } } + fn mmap_v2(&self, offset: usize) -> Result { + let this = self.0.read(); + + match &this.contents { + FileContents::Device(dev) => { + let device = dev.clone(); + drop(this); + + device.mmap_v2(offset) + } + + _ => todo!(), + } + } + fn lookup(&self, dir: DirCacheItem, name: &str) -> Result { let this = self.0.read(); let child = this diff --git a/src/aero_kernel/src/mem/paging/addr.rs b/src/aero_kernel/src/mem/paging/addr.rs index 2d97f2592aa..11713f48cc0 100644 --- a/src/aero_kernel/src/mem/paging/addr.rs +++ b/src/aero_kernel/src/mem/paging/addr.rs @@ -35,7 +35,7 @@ use bit_field::BitField; /// [`TryFrom`](https://doc.rust-lang.org/std/convert/trait.TryFrom.html) trait can be used for performing conversions /// between `u64` and `usize`. -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(transparent)] pub struct VirtAddr(u64); diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs index c74e2e981e2..ea6b77d0102 100644 --- a/src/aero_kernel/src/userland/vm.rs +++ b/src/aero_kernel/src/userland/vm.rs @@ -24,13 +24,16 @@ use alloc::collections::linked_list::CursorMut; use alloc::collections::LinkedList; use alloc::sync::Arc; +use hashbrown::HashMap; use xmas_elf::header::*; use xmas_elf::program::*; use xmas_elf::*; use crate::arch::task::userland_last_address; +use crate::fs::block::PageCacheItem; use crate::fs::cache::{DirCacheImpl, DirCacheItem}; use crate::fs::file_table::FileHandle; +use crate::fs::inode::MMapPage; use crate::fs::{FileSystemError, Path}; use crate::mem::paging::*; use crate::mem::AddressSpace; @@ -344,21 +347,27 @@ pub struct LoadedBinary<'header> { pub envv: Option, } -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct MMapFile { offset: usize, file: DirCacheItem, size: usize, + mappings: HashMap, } impl MMapFile { #[inline] fn new(file: DirCacheItem, offset: usize, size: usize) -> Self { - Self { offset, file, size } + Self { + offset, + file, + size, + mappings: HashMap::new(), + } } } -#[derive(Debug, Clone)] +#[derive(Clone)] pub struct Mapping { pub flags: MMapFlags, vm_flags: VmFlag, @@ -454,52 +463,189 @@ impl Mapping { &mut self, offset_table: &mut OffsetPageTable, reason: PageFaultErrorCode, - address: VirtAddr, + addr: VirtAddr, ) -> bool { - if let Some(mmap_file) = self.file.as_mut() { + if let Some(file) = self.file.as_ref() { let offset = align_down( - (address - self.start_addr) + mmap_file.offset as u64, + (addr - self.start_addr) + file.offset as u64, Size4KiB::SIZE, ); - let address = address.align_down(Size4KiB::SIZE); - let size = core::cmp::min( - Size4KiB::SIZE, - mmap_file.size as u64 - (address - self.start_addr), - ); + let addr = addr.align_down(Size4KiB::SIZE); + let size = Size4KiB::SIZE.min(file.size as u64 - (addr - self.start_addr)); - if !reason.contains(PageFaultErrorCode::PROTECTION_VIOLATION) { - // We are writing to private file mapping so copy the content of the page. - let frame = mmap_file - .file - .inode() - .mmap(offset as _, size as _, self.flags) - .expect("handle_pf_file: file does not support mmap"); + return if self.flags.contains(MMapFlags::MAP_SHARED) { + self.handle_pf_shared_file(offset_table, reason, addr, offset as _, size as _) + } else { + self.handle_pf_private_file(offset_table, reason, addr, offset as _, size as _) + }; + } - let flags = PageTableFlags::PRESENT - | PageTableFlags::USER_ACCESSIBLE - | self.vm_flags.into(); + false + } - // if self.flags.contains(MMapFlags::MAP_SHARED) { - // flags |= PageTableFlags::BIT_10; - // } + fn handle_pf_private_file( + &mut self, + offset_table: &mut OffsetPageTable, + reason: PageFaultErrorCode, - unsafe { offset_table.map_to(Page::containing_address(address), frame, flags) } - .expect("failed to map allocated frame for private file read") - .flush(); + addr: VirtAddr, + offset: usize, + size: usize, + ) -> bool { + let mmap_file = self.file.as_mut().unwrap(); + let page_cache = if let MMapPage::PageCache(page_cache) = + mmap_file.file.inode().mmap_v2(offset).unwrap() + { + page_cache + } else { + todo!() + }; - true - } else if reason.contains(PageFaultErrorCode::CAUSED_BY_WRITE) { - self.handle_cow(offset_table, address, true) + if !reason.contains(PageFaultErrorCode::PROTECTION_VIOLATION) + && !reason.contains(PageFaultErrorCode::CAUSED_BY_WRITE) + { + let frame = if size == Size4KiB::SIZE as usize { + page_cache.page() } else { - log::error!(" - present page read failed"); - false + // The end needs to be zeroed out so we cannot directly map the cached page. + let page: Page = Page::containing_address(page_cache.data_addr().as_hhdm_virt()); + + let new_frame: PhysFrame = PhysFrame::containing_address( + FRAME_ALLOCATOR + .alloc_zeroed(Size4KiB::SIZE as usize) + .unwrap(), + ); + + let new_slice = new_frame.as_slice_mut::(); + new_slice[..size].copy_from_slice(unsafe { + core::slice::from_raw_parts(page.start_address().as_ptr::(), size) + }); + + new_frame + }; + + unsafe { + offset_table.map_to( + Page::containing_address(addr), + frame, + PageTableFlags::PRESENT + | PageTableFlags::USER_ACCESSIBLE + | (self.vm_flags & !VmFlag::WRITE).into(), + ) + } + .expect("failed to map allocated frame for private file read") + .flush(); + + true + } else if !reason.contains(PageFaultErrorCode::PROTECTION_VIOLATION) + && reason.contains(PageFaultErrorCode::CAUSED_BY_WRITE) + { + // We are writing to private file mapping so copy the content of the page. + let frame = mmap_file + .file + .inode() + .mmap(offset, size, self.flags) + .expect("handle_pf_file: file does not support mmap"); + + unsafe { + offset_table.map_to( + Page::containing_address(addr), + frame, + PageTableFlags::PRESENT + | PageTableFlags::USER_ACCESSIBLE + | self.vm_flags.into(), + ) + } + .expect("failed to map allocated frame for private file read") + .flush(); + + assert!(mmap_file.mappings.get(&addr).is_none()); + true + } else if reason.contains(PageFaultErrorCode::CAUSED_BY_WRITE) + && reason.contains(PageFaultErrorCode::PROTECTION_VIOLATION) + { + if self.handle_cow(offset_table, addr, true) { + self.file.as_mut().unwrap().mappings.remove(&addr); + return true; } + + false } else { + log::error!(" - present page read failed"); false } } + fn handle_pf_shared_file( + &mut self, + offset_table: &mut OffsetPageTable, + reason: PageFaultErrorCode, + + addr: VirtAddr, + offset: usize, + _size: usize, + ) -> bool { + let mmap_file = self.file.as_mut().unwrap(); + let mmap_page = mmap_file.file.inode().mmap_v2(offset).unwrap(); + + if reason.contains(PageFaultErrorCode::PROTECTION_VIOLATION) { + if reason.contains(PageFaultErrorCode::CAUSED_BY_WRITE) { + return false; + } + } else if let MMapPage::PageCache(page_cache) = &mmap_page { + mmap_file.mappings.insert(addr, page_cache.clone()); + } + + match mmap_page { + MMapPage::PageCache(page_cache) => { + if reason.contains(PageFaultErrorCode::CAUSED_BY_WRITE) { + unsafe { + offset_table.map_to( + Page::containing_address(addr), + page_cache.page(), + PageTableFlags::PRESENT + | PageTableFlags::USER_ACCESSIBLE + | self.vm_flags.into(), + ) + } + .unwrap() + .flush(); + + page_cache.mark_dirty(); + } else { + unsafe { + offset_table.map_to( + Page::containing_address(addr), + page_cache.page(), + PageTableFlags::PRESENT + | PageTableFlags::USER_ACCESSIBLE + | (self.vm_flags & !VmFlag::WRITE).into(), + ) + } + .unwrap() + .flush(); + } + } + + MMapPage::Direct(frame) => { + unsafe { + offset_table.map_to( + Page::containing_address(addr), + frame, + PageTableFlags::PRESENT + | PageTableFlags::USER_ACCESSIBLE + | self.vm_flags.into(), + ) + } + .unwrap() + .flush(); + } + } + + true + } + /// Copies the contents of the `page` page to a newly allocated frame and maps it to /// the `page` page with the provided `protection` protection flags. fn map_copied( @@ -578,13 +724,11 @@ impl Mapping { .flush(); } - true - } else { - false + return true; } - } else { - false } + + false } fn unmap( @@ -867,7 +1011,6 @@ impl VmProtected { // We need to find a free mapping above 0x7000_0000_0000. self.find_any_above(VirtAddr::new(0x7000_0000_0000), size_aligned as _) } else if flags.contains(MMapFlags::MAP_FIXED) { - // SAFETY: The provided address should be page aligned. if !address.is_aligned(Size4KiB::SIZE) { log::warn!("mmap: fixed mapping address is not page aligned"); return None; diff --git a/userland/Makefile b/userland/Makefile index efbbbf40bf8..e38cbe8ba90 100644 --- a/userland/Makefile +++ b/userland/Makefile @@ -8,10 +8,12 @@ override SYSTRACE_TARGET := $(TARGET_DIR)/systrace override TEST_DIR := tests override TEST_TARGET = $(TARGET_DIR)/utest +override F_TARGET := $(TARGET_DIR)/f + override INIT_DIR := init override INIT_TARGET := $(TARGET_DIR)/init -all: $(INIT_TARGET) $(SYSTRACE_TARGET) $(TEST_TARGET) +all: $(INIT_TARGET) $(SYSTRACE_TARGET) $(TEST_TARGET) $(F_TARGET) $(INIT_TARGET): $(INIT_DIR)/init.c mkdir -p $(TARGET_DIR) @@ -26,6 +28,10 @@ $(TEST_TARGET): $(TEST_DIR)/utest.cc mkdir -p $(TARGET_DIR) $(CXX) -o $@ $^ +$(F_TARGET): $(TEST_DIR)/f.c + mkdir -p $(TARGET_DIR) + $(CC) -o $@ $^ + clean: rm -rf $(INIT_TARGET) rm -rf $(SYSTRACE_TARGET) @@ -35,3 +41,4 @@ install: install $(INIT_TARGET) "$(DESTDIR)$(PREFIX)/bin/" install $(SYSTRACE_TARGET) "$(DESTDIR)$(PREFIX)/bin/" install $(TEST_TARGET) "$(DESTDIR)$(PREFIX)/bin/" + install $(F_TARGET) "$(DESTDIR)$(PREFIX)/bin/" diff --git a/userland/tests/f.c b/userland/tests/f.c new file mode 100644 index 00000000000..b96bfc81526 --- /dev/null +++ b/userland/tests/f.c @@ -0,0 +1,47 @@ +#include +#include +#include +#include +#include +#include +#include + +#define INITIAL_MSG "Hello, world!" +#define MSG_LEN (sizeof(INITIAL_MSG) - 1) + +#define NEXT_MSG "Bye, world!" + +int main() { + int fd = open("/tmp/shared_file", O_CREAT | O_RDWR, 0644); + write(fd, INITIAL_MSG, MSG_LEN); + + char *p = mmap(NULL, MSG_LEN, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + pid_t pid = fork(); + + if (!pid) { + strncpy(p, NEXT_MSG, MSG_LEN); + return EXIT_SUCCESS; + } + + int wstatus; + waitpid(pid, &wstatus, 0); + assert(WIFEXITED(wstatus) && WEXITSTATUS(wstatus) == EXIT_SUCCESS); + + // ensure changes presist across processes + assert(!strncmp(p, NEXT_MSG, MSG_LEN)); + munmap(p, MSG_LEN); + + // synchronize mapped region with its underlying file + // msync(p, MSG_LEN, MS_SYNC); + + // ensure changes presist in the file + char buf[MSG_LEN]; + lseek(fd, 0, SEEK_SET); + read(fd, buf, MSG_LEN); + assert(!strncmp(buf, NEXT_MSG, MSG_LEN)); + + // cleanup + close(fd); + unlink("/tmp/shared_file"); + return EXIT_SUCCESS; +} From dc8a6f0e612eac219806de5f213f0974caba3524 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 3 Jul 2024 14:22:38 +1000 Subject: [PATCH 088/112] misc(vm): collate mmap flags into vm flags Signed-off-by: Anhad Singh --- src/aero_kernel/src/arch/x86_64/task.rs | 14 +++---- src/aero_kernel/src/fs/block/mod.rs | 1 - src/aero_kernel/src/fs/procfs.rs | 3 +- src/aero_kernel/src/mem/paging/addr.rs | 13 ++++++ src/aero_kernel/src/unwind.rs | 9 ++--- src/aero_kernel/src/userland/vm.rs | 53 +++++++++++++------------ 6 files changed, 54 insertions(+), 39 deletions(-) diff --git a/src/aero_kernel/src/arch/x86_64/task.rs b/src/aero_kernel/src/arch/x86_64/task.rs index e2bdcce9205..4160e28f582 100644 --- a/src/aero_kernel/src/arch/x86_64/task.rs +++ b/src/aero_kernel/src/arch/x86_64/task.rs @@ -80,15 +80,15 @@ pub enum AuxvType { /// Returns the first address outside the user range. /// /// ## Notes -/// * On Intel CPUs, if a SYSCALL instruction is at the highest canonical address, then -/// that syscall will enter the kernel with a non-canonical return address, and SYSRET will -/// explode dangerously. We avoid this particular problem by preventing anything from -/// being mapped at the maximum canonical address. +/// * On Intel CPUs, if a SYSCALL instruction is at the highest canonical address, then that syscall +/// will enter the kernel with a non-canonical return address, and SYSRET will explode +/// dangerously. We avoid this particular problem by preventing anything from being mapped at the +/// maximum canonical address. /// /// * On AMD CPUs in the Ryzen family, there's a nasty bug in which the CPUs malfunction if they -/// execute code from the highest canonical page. They'll speculate right off the end of the -/// canonical space and bad things happen. This is worked around in the same way as the Intel -/// problem. +/// execute code from the highest canonical page. They'll speculate right off the end of the +/// canonical space and bad things happen. This is worked around in the same way as the Intel +/// problem. pub fn userland_last_address() -> VirtAddr { // Reference: https://elixir.bootlin.com/linux/latest/source/arch/x86/include/asm/page_64.h#L61 static CACHED: spin::Once = spin::Once::new(); diff --git a/src/aero_kernel/src/fs/block/mod.rs b/src/aero_kernel/src/fs/block/mod.rs index 049e8833ef5..de037d41a1e 100644 --- a/src/aero_kernel/src/fs/block/mod.rs +++ b/src/aero_kernel/src/fs/block/mod.rs @@ -104,7 +104,6 @@ impl CachedPage { } pub fn mark_dirty(&self) { - log::error!("marking dirty --------------------------------------"); self.dirty.store(true, Ordering::SeqCst); } diff --git a/src/aero_kernel/src/fs/procfs.rs b/src/aero_kernel/src/fs/procfs.rs index 6d915b3c8ac..e20cce54aa4 100644 --- a/src/aero_kernel/src/fs/procfs.rs +++ b/src/aero_kernel/src/fs/procfs.rs @@ -199,7 +199,8 @@ impl INodeInterface for LockedProcINode { maps.push(serde_json::json!({ "start": map.start_addr.as_u64(), "end": map.end_addr.as_u64(), - "flags": map.flags.bits(), + // "flags": map.flags.bits(), + // do we need to tell if is shared? "protection": map.protection().bits(), })); }); diff --git a/src/aero_kernel/src/mem/paging/addr.rs b/src/aero_kernel/src/mem/paging/addr.rs index 11713f48cc0..5b46141cd80 100644 --- a/src/aero_kernel/src/mem/paging/addr.rs +++ b/src/aero_kernel/src/mem/paging/addr.rs @@ -113,6 +113,19 @@ impl VirtAddr { self.0 == 0 } + pub fn is_canonical(self) -> bool { + let virtual_mask_shift = if super::level_5_paging_enabled() { + 56 + } else { + 47 + }; + + let shift = 64 - (virtual_mask_shift + 1); + + // By doing the right shift as a signed operation will sign extend the value. + ((self.as_u64() << shift) as i64 >> shift) as u64 == self.as_u64() + } + /// Validate reads `sizeof(T)` bytes from the virtual address and returns a mutable /// reference to the value (`&mut T`). /// diff --git a/src/aero_kernel/src/unwind.rs b/src/aero_kernel/src/unwind.rs index 5c0cb72b024..a6e7a4e7d7d 100644 --- a/src/aero_kernel/src/unwind.rs +++ b/src/aero_kernel/src/unwind.rs @@ -112,15 +112,14 @@ pub fn unwind_stack_trace() { for depth in 0../*64*/16 { if let Some(rip_rbp) = rbp.checked_add(core::mem::size_of::()) { - if offset_table - .translate_addr(VirtAddr::new(rip_rbp as u64)) - .is_none() - { + let rip_rbp = VirtAddr::new(rip_rbp as u64); + + if offset_table.translate_addr(rip_rbp).is_none() || !rip_rbp.is_canonical() { log::trace!("{:>2}: ", depth); break; } - let rip = unsafe { *(rip_rbp as *const usize) }; + let rip = unsafe { *(rip_rbp.as_ptr::()) }; if rip == 0 { break; diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs index ea6b77d0102..f109040fc9a 100644 --- a/src/aero_kernel/src/userland/vm.rs +++ b/src/aero_kernel/src/userland/vm.rs @@ -54,6 +54,8 @@ bitflags::bitflags! { const MAY_READ = 1 << 3; const MAY_WRITE = 1 << 4; const MAY_EXEC = 1 << 5; + + const SHARED = 1 << 6; } } @@ -369,7 +371,6 @@ impl MMapFile { #[derive(Clone)] pub struct Mapping { - pub flags: MMapFlags, vm_flags: VmFlag, pub start_addr: VirtAddr, @@ -474,7 +475,7 @@ impl Mapping { let addr = addr.align_down(Size4KiB::SIZE); let size = Size4KiB::SIZE.min(file.size as u64 - (addr - self.start_addr)); - return if self.flags.contains(MMapFlags::MAP_SHARED) { + return if self.vm_flags.contains(VmFlag::SHARED) { self.handle_pf_shared_file(offset_table, reason, addr, offset as _, size as _) } else { self.handle_pf_private_file(offset_table, reason, addr, offset as _, size as _) @@ -545,7 +546,7 @@ impl Mapping { let frame = mmap_file .file .inode() - .mmap(offset, size, self.flags) + .mmap(offset, size, MMapFlags::empty()) .expect("handle_pf_file: file does not support mmap"); unsafe { @@ -764,7 +765,6 @@ impl Mapping { }); let new_mapping = Mapping { - flags: self.flags, start_addr: end, end_addr: end + (self.end_addr - end), file: new_file, @@ -868,13 +868,10 @@ impl VmProtected { return false; } - let is_private = map.flags.contains(MMapFlags::MAP_PRIVATE); - let is_annon = map.flags.contains(MMapFlags::MAP_ANONYOMUS); - let mut address_space = AddressSpace::this(); let mut offset_table = address_space.offset_page_table(); - match (is_private, is_annon) { + match (!map.vm_flags.contains(VmFlag::SHARED), map.file.is_none()) { (true, true) => { map.handle_pf_private_anon(&mut offset_table, reason, accessed_address) } @@ -970,9 +967,6 @@ impl VmProtected { file: Option, vm_flags: VmFlag, ) -> Option { - // TODO: Check file permissions: - // * Do not allow writing to an {read, append}-only file. - let z = file.clone(); // Offset is required to be a multiple of page size. @@ -1030,19 +1024,16 @@ impl VmProtected { // Merge same mappings instead of creating a new one. if let Some(prev) = cursor.peek_prev() { if prev.end_addr == addr - && prev.flags == flags - && prev.protection() == (vm_flags & VM_PROT_MASK) + && prev.vm_flags == vm_flags && prev.file.is_none() + && file.is_none() { prev.end_addr = addr + size_aligned; - return addr; } } cursor.insert_before(Mapping { - flags, - start_addr: addr, end_addr: addr + size_aligned, @@ -1077,21 +1068,19 @@ impl VmProtected { for mmap in &self.mappings { if let Some(file) = mmap.file.as_ref() { log::debug!( - "{:?}..{:?} => {:?}, {:?} (offset={:#x}, size={:#x})", + "{:?}..{:?} => {:?} (offset={:#x}, size={:#x})", mmap.start_addr, mmap.end_addr, mmap.vm_flags, - mmap.flags, file.offset, file.size, ); } else { log::debug!( - "{:?}..{:?} => {:?}, {:?}", + "{:?}..{:?} => {:?}", mmap.start_addr, mmap.end_addr, mmap.vm_flags, - mmap.flags, ); } } @@ -1376,7 +1365,7 @@ impl VmProtected { for map in self.mappings.iter().filter(|map| { // Do not copy page table entries where a page fault can map them correctly. - !map.flags.contains(MMapFlags::MAP_SHARED) && map.vm_flags.contains(VmFlag::MAY_WRITE) + !map.vm_flags.contains(VmFlag::SHARED) && map.vm_flags.contains(VmFlag::MAY_WRITE) }) { offset_table.copy_page_range(&mut current, map.start_addr..=map.end_addr); } @@ -1406,18 +1395,31 @@ impl Vm { offset: usize, file: Option>, ) -> Option { - let vm_flags = + let mut vm_flags = VmFlag::from(protection) | VmFlag::MAY_READ | VmFlag::MAY_WRITE | VmFlag::MAY_EXEC; let map_type = flags & (MMapFlags::MAP_SHARED | MMapFlags::MAP_PRIVATE); match (map_type, file.as_ref()) { (MMapFlags::MAP_SHARED, Some(file)) => { - if protection.contains(MMapProt::PROT_WRITE) && !file.is_writable() { - return None; // EACCES + vm_flags.insert(VmFlag::SHARED); + + if !file.is_writable() { + if protection.contains(MMapProt::PROT_WRITE) { + return None; // EACCES + } + + // The mapping is going to be read-only forever so, it can be converted into a + // private mapping. + vm_flags.remove(VmFlag::MAY_WRITE | VmFlag::SHARED); } - // TODO: check for append-only files. + if !file.is_readable() { + // return None; // EACCES + } + + // TODO: * check if the filsystem is noexec mounted and remove the MAY_EXEC flag. + // * error out if prot contains PROT_EXEC & filesystem is noexec. } (MMapFlags::MAP_PRIVATE, Some(file)) => { @@ -1429,6 +1431,7 @@ impl Vm { // * error out if prot contains PROT_EXEC & filesystem is noexec. } + (MMapFlags::MAP_SHARED, None) => vm_flags.insert(VmFlag::SHARED), _ => {} } From c806cd2e88c81b028480476a70d110db7b8dc6f8 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 3 Jul 2024 14:25:25 +1000 Subject: [PATCH 089/112] misc(main): panic_info_message has been stabilized Signed-off-by: Anhad Singh --- src/aero_kernel/src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index ef030da1a4b..8395b1186f2 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -29,7 +29,6 @@ custom_test_frameworks, // https://github.com/rust-lang/rust/issues/50297 alloc_error_handler, // https://github.com/rust-lang/rust/issues/51540 lang_items, // No tracking issue - panic_info_message, // https://github.com/rust-lang/rust/issues/66745 decl_macro, // https://github.com/rust-lang/rust/issues/39412 ptr_internals, // No tracking issue linked_list_cursors, // https://github.com/rust-lang/rust/issues/58533 From 773565fa5072cff67a710326b8e304ec0e30a87b Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 3 Jul 2024 14:29:28 +1000 Subject: [PATCH 090/112] misc(docs): cleanup Signed-off-by: Anhad Singh --- src/aero_kernel/src/arch/x86_64/apic.rs | 8 ++++---- src/aero_kernel/src/arch/x86_64/controlregs.rs | 10 ++++------ src/aero_kernel/src/cmdline.rs | 3 +-- src/aero_kernel/src/rendy.rs | 2 +- src/aero_kernel/src/userland/signals.rs | 9 +++------ 5 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/aero_kernel/src/arch/x86_64/apic.rs b/src/aero_kernel/src/arch/x86_64/apic.rs index 5330a9930b1..eca596b90c7 100644 --- a/src/aero_kernel/src/arch/x86_64/apic.rs +++ b/src/aero_kernel/src/arch/x86_64/apic.rs @@ -288,11 +288,11 @@ impl LocalApic { /// This function works for both XAPIC and X2APIC. /// /// ## Safety - /// * The provided `register` must be a valid APIC register and the `value` must - /// be a valid value for the provided APIC register. + /// * The provided `register` must be a valid APIC register and the `value` must be a valid + /// value for the provided APIC register. /// - /// * If the `register` is 64-bit wide, then the [`Self::write_long`] function must - /// be used instead. + /// * If the `register` is 64-bit wide, then the [`Self::write_long`] function must be used + /// instead. unsafe fn write(&mut self, register: u32, value: u32) { match self.apic_type { ApicType::X2apic => { diff --git a/src/aero_kernel/src/arch/x86_64/controlregs.rs b/src/aero_kernel/src/arch/x86_64/controlregs.rs index 601a192bae5..204a7fc9861 100644 --- a/src/aero_kernel/src/arch/x86_64/controlregs.rs +++ b/src/aero_kernel/src/arch/x86_64/controlregs.rs @@ -335,9 +335,8 @@ pub unsafe fn write_xcr0(value: XCr0Flags) { /// Write the given set of CR4 flags. /// /// ## Safety -/// - This function does not preserve the current value of the CR4 flags and -/// reserved fields. -/// - Its possible to violate memory safety by swapping CR4 flags. +/// * This function does not preserve the current value of the CR4 flags and reserved fields. +/// * Its possible to violate memory safety by swapping CR4 flags. pub unsafe fn write_cr4(value: Cr4Flags) { asm!("mov cr4, {}", in(reg) value.bits(), options(nostack, preserves_flags)); } @@ -345,9 +344,8 @@ pub unsafe fn write_cr4(value: Cr4Flags) { /// Write the given set of CR0 flags. /// /// ## Safety -/// - This function does not preserve the current value of the CR0 flags and -/// reserved fields. -/// - Its possible to violate memory safety by swapping CR0 flags. +/// * This function does not preserve the current value of the CR0 flags and reserved fields. +/// * Its possible to violate memory safety by swapping CR0 flags. pub unsafe fn write_cr0(value: Cr0Flags) { asm!("mov cr0, {}", in(reg) value.bits(), options(nostack, preserves_flags)); } diff --git a/src/aero_kernel/src/cmdline.rs b/src/aero_kernel/src/cmdline.rs index cbcc33ef639..0cd47c1fe8e 100644 --- a/src/aero_kernel/src/cmdline.rs +++ b/src/aero_kernel/src/cmdline.rs @@ -126,8 +126,7 @@ pub fn parse(cmdline: &'static str, modules: &[&File]) -> CommandLine { /// Returns the raw kernel command line string. /// /// ## Panics -/// * If this function was invoked before the kernel command line was -/// parsed using [`self::parse`]. +/// * If this function was invoked before the kernel command line was parsed using [`self::parse`]. pub fn get_raw_cmdline() -> &'static str { RAW_CMDLINE_STR .get() diff --git a/src/aero_kernel/src/rendy.rs b/src/aero_kernel/src/rendy.rs index 9181e71417c..4555cfa9122 100644 --- a/src/aero_kernel/src/rendy.rs +++ b/src/aero_kernel/src/rendy.rs @@ -17,10 +17,10 @@ use core::fmt::Write; +use core::fmt; use core::ops::{Index, IndexMut}; use core::ptr::NonNull; use core::time::Duration; -use core::{fmt, u8}; use alloc::boxed::Box; diff --git a/src/aero_kernel/src/userland/signals.rs b/src/aero_kernel/src/userland/signals.rs index 5d3b2621e67..52e030b7915 100644 --- a/src/aero_kernel/src/userland/signals.rs +++ b/src/aero_kernel/src/userland/signals.rs @@ -395,12 +395,9 @@ impl Signals { /// Used to update or read the signal mask of a task. /// /// ## Notes - /// * If `old_set` is not `None`, the previous value of the signal mask is - /// stored in oldset. - /// - /// * If `set` is `None`, then the signal mask is unchanged (i.e., `how` is - /// ignored), but the current value of the signal mask is returned in `old_set` - /// (if it is not `None`). + /// * If `old_set` is not `None`, the previous value of the signal mask is stored in oldset. + /// * If `set` is `None`, then the signal mask is unchanged (i.e., `how` is ignored), but the + /// current value of the signal mask is returned in `old_set` (if it is not `None`). pub fn set_mask(&self, how: SigProcMask, set: Option, old_set: Option<&mut u64>) { if let Some(old) = old_set { *old = self.blocked_mask.load(Ordering::SeqCst); From 08f1190df7ce841124febfc61f8dbd673b775ddc Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 3 Jul 2024 14:29:51 +1000 Subject: [PATCH 091/112] misc(vm): `vm_flags` -> `flags` Signed-off-by: Anhad Singh --- src/aero_kernel/src/userland/vm.rs | 55 ++++++++++++++---------------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs index f109040fc9a..fe7ab496486 100644 --- a/src/aero_kernel/src/userland/vm.rs +++ b/src/aero_kernel/src/userland/vm.rs @@ -371,7 +371,7 @@ impl MMapFile { #[derive(Clone)] pub struct Mapping { - vm_flags: VmFlag, + flags: VmFlag, pub start_addr: VirtAddr, pub end_addr: VirtAddr, @@ -382,22 +382,21 @@ pub struct Mapping { impl Mapping { pub fn set_protection(&mut self, protection: MMapProt) -> aero_syscall::Result<()> { - if (protection.contains(MMapProt::PROT_READ) && !self.vm_flags.contains(VmFlag::MAY_READ)) + if (protection.contains(MMapProt::PROT_READ) && !self.flags.contains(VmFlag::MAY_READ)) || (protection.contains(MMapProt::PROT_WRITE) - && !self.vm_flags.contains(VmFlag::MAY_WRITE)) - || (protection.contains(MMapProt::PROT_EXEC) - && !self.vm_flags.contains(VmFlag::MAY_EXEC)) + && !self.flags.contains(VmFlag::MAY_WRITE)) + || (protection.contains(MMapProt::PROT_EXEC) && !self.flags.contains(VmFlag::MAY_EXEC)) { return Err(aero_syscall::SyscallError::EACCES); } - self.vm_flags = (self.vm_flags & !VM_PROT_MASK) | protection.into(); + self.flags = (self.flags & !VM_PROT_MASK) | protection.into(); Ok(()) } #[inline] pub fn protection(&self) -> VmFlag { - self.vm_flags & VM_PROT_MASK + self.flags & VM_PROT_MASK } /// Handler routine for private anonymous pages. Since its an anonymous page is not @@ -421,9 +420,7 @@ impl Mapping { // NOTE: We dont need to remove the writeable flag from this mapping, since // the writeable flag will be removed from the parent and child on fork so, // the mapping gets copied on write. - PageTableFlags::USER_ACCESSIBLE - | PageTableFlags::PRESENT - | self.vm_flags.into(), + PageTableFlags::USER_ACCESSIBLE | PageTableFlags::PRESENT | self.flags.into(), ) } .expect("Failed to identity map userspace private mapping") @@ -446,7 +443,7 @@ impl Mapping { page, PageTableFlags::USER_ACCESSIBLE | PageTableFlags::PRESENT - | self.vm_flags.into(), + | self.flags.into(), ) .unwrap() .flush(); @@ -475,7 +472,7 @@ impl Mapping { let addr = addr.align_down(Size4KiB::SIZE); let size = Size4KiB::SIZE.min(file.size as u64 - (addr - self.start_addr)); - return if self.vm_flags.contains(VmFlag::SHARED) { + return if self.flags.contains(VmFlag::SHARED) { self.handle_pf_shared_file(offset_table, reason, addr, offset as _, size as _) } else { self.handle_pf_private_file(offset_table, reason, addr, offset as _, size as _) @@ -532,7 +529,7 @@ impl Mapping { frame, PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE - | (self.vm_flags & !VmFlag::WRITE).into(), + | (self.flags & !VmFlag::WRITE).into(), ) } .expect("failed to map allocated frame for private file read") @@ -553,9 +550,7 @@ impl Mapping { offset_table.map_to( Page::containing_address(addr), frame, - PageTableFlags::PRESENT - | PageTableFlags::USER_ACCESSIBLE - | self.vm_flags.into(), + PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE | self.flags.into(), ) } .expect("failed to map allocated frame for private file read") @@ -607,7 +602,7 @@ impl Mapping { page_cache.page(), PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE - | self.vm_flags.into(), + | self.flags.into(), ) } .unwrap() @@ -621,7 +616,7 @@ impl Mapping { page_cache.page(), PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE - | (self.vm_flags & !VmFlag::WRITE).into(), + | (self.flags & !VmFlag::WRITE).into(), ) } .unwrap() @@ -636,7 +631,7 @@ impl Mapping { frame, PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE - | self.vm_flags.into(), + | self.flags.into(), ) } .unwrap() @@ -710,7 +705,7 @@ impl Mapping { if let Some(vm_frame) = phys_addr.as_vm_frame() { if vm_frame.ref_count() > 1 || copy { // This page is used by more then one process, so make it a private copy. - Self::map_copied(offset_table, page, self.vm_flags).unwrap(); + Self::map_copied(offset_table, page, self.flags).unwrap(); } else { // This page is used by only one process, so make it writable. unsafe { @@ -718,7 +713,7 @@ impl Mapping { page, PageTableFlags::PRESENT | PageTableFlags::USER_ACCESSIBLE - | self.vm_flags.into(), + | self.flags.into(), ) } .unwrap() @@ -769,7 +764,7 @@ impl Mapping { end_addr: end + (self.end_addr - end), file: new_file, refresh_flags: true, - vm_flags: self.vm_flags, + flags: self.flags, }; self.end_addr = start; @@ -857,13 +852,13 @@ impl VmProtected { } if reason.contains(PageFaultErrorCode::CAUSED_BY_WRITE) - && !map.vm_flags.contains(VmFlag::WRITE) + && !map.flags.contains(VmFlag::WRITE) { return false; } if reason.contains(PageFaultErrorCode::INSTRUCTION_FETCH) - && !map.vm_flags.contains(VmFlag::EXEC) + && !map.flags.contains(VmFlag::EXEC) { return false; } @@ -871,7 +866,7 @@ impl VmProtected { let mut address_space = AddressSpace::this(); let mut offset_table = address_space.offset_page_table(); - match (!map.vm_flags.contains(VmFlag::SHARED), map.file.is_none()) { + match (!map.flags.contains(VmFlag::SHARED), map.file.is_none()) { (true, true) => { map.handle_pf_private_anon(&mut offset_table, reason, accessed_address) } @@ -1024,7 +1019,7 @@ impl VmProtected { // Merge same mappings instead of creating a new one. if let Some(prev) = cursor.peek_prev() { if prev.end_addr == addr - && prev.vm_flags == vm_flags + && prev.flags == vm_flags && prev.file.is_none() && file.is_none() { @@ -1039,7 +1034,7 @@ impl VmProtected { file: file.map(|f| MMapFile::new(f, offset, size)), refresh_flags: true, - vm_flags, + flags: vm_flags, }); addr @@ -1071,7 +1066,7 @@ impl VmProtected { "{:?}..{:?} => {:?} (offset={:#x}, size={:#x})", mmap.start_addr, mmap.end_addr, - mmap.vm_flags, + mmap.flags, file.offset, file.size, ); @@ -1080,7 +1075,7 @@ impl VmProtected { "{:?}..{:?} => {:?}", mmap.start_addr, mmap.end_addr, - mmap.vm_flags, + mmap.flags, ); } } @@ -1365,7 +1360,7 @@ impl VmProtected { for map in self.mappings.iter().filter(|map| { // Do not copy page table entries where a page fault can map them correctly. - !map.vm_flags.contains(VmFlag::SHARED) && map.vm_flags.contains(VmFlag::MAY_WRITE) + !map.flags.contains(VmFlag::SHARED) && map.flags.contains(VmFlag::MAY_WRITE) }) { offset_table.copy_page_range(&mut current, map.start_addr..=map.end_addr); } From a35528bb2b76ae68508deef4b4c72b2e3cb54716 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 3 Jul 2024 14:49:56 +1000 Subject: [PATCH 092/112] feat(mmap): ensure the file is readable Signed-off-by: Anhad Singh --- src/aero_kernel/src/fs/file_table.rs | 6 ++++-- src/aero_kernel/src/userland/vm.rs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/aero_kernel/src/fs/file_table.rs b/src/aero_kernel/src/fs/file_table.rs index b8fb2bffeff..fe76cf14e38 100644 --- a/src/aero_kernel/src/fs/file_table.rs +++ b/src/aero_kernel/src/fs/file_table.rs @@ -65,8 +65,10 @@ impl FileHandle { #[inline] pub fn is_readable(&self) -> bool { - self.flags() - .intersects(OpenFlags::O_RDONLY | OpenFlags::O_RDWR) + // FIXME: switch to Linux ABI for fcntl. mlibc defines O_RDONLY as 0 so, we have to infer + // the read-only flag. + let flags = self.flags(); + flags.contains(OpenFlags::O_RDWR) || !flags.contains(OpenFlags::O_WRONLY) } pub fn flags(&self) -> OpenFlags { diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs index fe7ab496486..92ebb78032a 100644 --- a/src/aero_kernel/src/userland/vm.rs +++ b/src/aero_kernel/src/userland/vm.rs @@ -1410,7 +1410,7 @@ impl Vm { } if !file.is_readable() { - // return None; // EACCES + return None; // EACCES } // TODO: * check if the filsystem is noexec mounted and remove the MAY_EXEC flag. @@ -1419,7 +1419,7 @@ impl Vm { (MMapFlags::MAP_PRIVATE, Some(file)) => { if !file.is_readable() { - // return None; // EACCES + return None; // EACCES } // TODO: * check if the filsystem is noexec mounted and remove the MAY_EXEC flag. From beca7e7d7d6dba32d0fa8592c206f6ad753b551c Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 3 Jul 2024 17:05:07 +1000 Subject: [PATCH 093/112] fix(vm): fix unmap silently not fully unmapping Bug description: offset.unmap_range() bailed out if unmap() internally returned an error. The original intention was that the caller may choose to ignore the page not mapped errors as of demand paging. This obviously due to bad API design decision bailed out early instead of unmapping the rest of the address range aswell. Causing all sorts of bugs. Now its fixed, yay! (xfe also works now) Signed-off-by: Anhad Singh --- src/aero_kernel/src/mem/paging/mapper.rs | 9 --------- src/aero_kernel/src/userland/vm.rs | 20 +++++++++++--------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/aero_kernel/src/mem/paging/mapper.rs b/src/aero_kernel/src/mem/paging/mapper.rs index 715ba1af0e3..2c218a5e5d3 100644 --- a/src/aero_kernel/src/mem/paging/mapper.rs +++ b/src/aero_kernel/src/mem/paging/mapper.rs @@ -1128,15 +1128,6 @@ impl<'a> Translate for OffsetPageTable<'a> { } impl<'a> OffsetPageTable<'a> { - pub fn unmap_range(&mut self, range: Range, step: u64) -> Result<(), UnmapError> { - for addr in range.step_by(step as usize) { - let page: Page = Page::containing_address(addr); - self.inner.unmap(page)?.1.flush(); - } - - Ok(()) - } - pub fn copy_page_range(&mut self, src: &mut OffsetPageTable, range: RangeInclusive) { let mut map_to = |src: &mut OffsetPageTable, addr, frame, flags| match frame { MappedFrame::Size4KiB(frame) => { diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs index 92ebb78032a..8251431e557 100644 --- a/src/aero_kernel/src/userland/vm.rs +++ b/src/aero_kernel/src/userland/vm.rs @@ -16,6 +16,7 @@ // along with Aero. If not, see . use core::fmt::Write; +use core::ops::Range; use aero_syscall::{MMapFlags, MMapProt}; @@ -733,16 +734,17 @@ impl Mapping { start: VirtAddr, end: VirtAddr, ) -> Result { - let mut unmap_range_inner = |range| -> Result<(), UnmapError> { - match offset_table.unmap_range(range, Size4KiB::SIZE) { - Ok(_) => Ok(()), - - // its fine since technically we are not actually allocating the range - // and they are just allocated on faults. So there might be a chance where we - // try to unmap a region that is mapped but not actually allocated. - Err(UnmapError::PageNotMapped) => Ok(()), - Err(err) => Err(err), + let mut unmap_range_inner = |range: Range| -> Result<(), UnmapError> { + for addr in range.step_by(Size4KiB::SIZE as usize) { + let page: Page = Page::containing_address(addr); + match offset_table.unmap(page) { + Ok((_, flusher)) => flusher.flush(), + Err(UnmapError::PageNotMapped) => {} + Err(e) => return Err(e), + } } + + Ok(()) }; if end <= self.start_addr || start >= self.end_addr { From 6874ab39af93b39abe47f15768136d176cd0bb2a Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 4 Jul 2024 13:31:56 +1000 Subject: [PATCH 094/112] feat(kdbg): for serial debugging Signed-off-by: Anhad Singh --- src/aero_kernel/src/drivers/uart_16550.rs | 72 +++++++++++++++++++---- src/aero_kernel/src/main.rs | 61 ++++++++++++++++++- 2 files changed, 118 insertions(+), 15 deletions(-) diff --git a/src/aero_kernel/src/drivers/uart_16550.rs b/src/aero_kernel/src/drivers/uart_16550.rs index 328adaa134b..b646c2d8635 100644 --- a/src/aero_kernel/src/drivers/uart_16550.rs +++ b/src/aero_kernel/src/drivers/uart_16550.rs @@ -20,10 +20,15 @@ use core::fmt::Write; use spin::Once; +use crate::arch::interrupts::{self, InterruptStack}; use crate::arch::io; +use crate::userland::task::Task; use crate::utils::sync::Mutex; -static COM_1: Once> = Once::new(); +use alloc::sync::Arc; +use alloc::vec::Vec; + +pub static COM_1: Once> = Once::new(); bitflags::bitflags! { pub struct InterruptEnable: u8 { @@ -95,25 +100,35 @@ impl SerialPort { } pub fn send_byte(&mut self, byte: u8) { - unsafe { - match byte { - 8 | 0x7F => { - self.wait_for_line_status(LineStatus::OUTPUT_EMPTY); + match byte { + 8 | 0x7F => { + self.wait_for_line_status(LineStatus::OUTPUT_EMPTY); + unsafe { io::outb(self.0, 8); + } - self.wait_for_line_status(LineStatus::OUTPUT_EMPTY); + self.wait_for_line_status(LineStatus::OUTPUT_EMPTY); + unsafe { io::outb(self.0, b' '); + } - self.wait_for_line_status(LineStatus::OUTPUT_EMPTY); + self.wait_for_line_status(LineStatus::OUTPUT_EMPTY); + unsafe { io::outb(self.0, 8); } - _ => { - self.wait_for_line_status(LineStatus::OUTPUT_EMPTY); - io::outb(self.0, byte) + } + _ => { + self.wait_for_line_status(LineStatus::OUTPUT_EMPTY); + unsafe { + io::outb(self.0, byte); } } } } + + pub fn read_byte(&mut self) -> u8 { + unsafe { io::inb(self.0) } + } } impl fmt::Write for SerialPort { @@ -126,15 +141,44 @@ impl fmt::Write for SerialPort { } } +fn irq_handler(_stack: &mut InterruptStack) { + if !unsafe { COM_1.get_unchecked() } + .lock_irq() + .line_status() + .contains(LineStatus::INPUT_FULL) + { + return; + } + + (*LISTENERS) + .lock_irq() + .iter() + .for_each(|task| task.wake_up()); +} + +lazy_static::lazy_static! { + static ref LISTENERS: Mutex>> = Mutex::new(Vec::new()); +} + +pub fn register_listener(task: Arc) { + (*LISTENERS).lock_irq().push(task); +} + /// Initialize the serial ports if available. pub fn init() { unsafe { - let com_1 = SerialPort::new(0x3F8).init(); - + let com_1 = SerialPort::new(0x3f8).init(); COM_1.call_once(move || Mutex::new(com_1)); } } +pub fn setup_interrupts() { + let vector = interrupts::allocate_vector(); + interrupts::register_handler(vector, irq_handler); + + crate::arch::apic::io_apic_setup_legacy_irq(4, vector, 1); +} + pub macro serial_print($($arg:tt)*) { crate::drivers::uart_16550::_serial_print(format_args!($($arg)*)) } @@ -147,6 +191,8 @@ pub macro serial_println { #[doc(hidden)] pub fn _serial_print(args: fmt::Arguments) { if let Some(c) = COM_1.get() { - c.lock().write_fmt(args).expect("failed to write to COM1") + c.lock_irq() + .write_fmt(args) + .expect("failed to write to COM1") } } diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index 8395b1186f2..33dacc5ce39 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -49,8 +49,7 @@ associated_type_defaults, trait_upcasting, asm_const, - sync_unsafe_cell, - // effects + sync_unsafe_cell )] // TODO(andypython): can we remove the dependency of "prelude_import" and "lang_items"? // `lang_items` => is currently used for the personality function (`rust_eh_personality`). @@ -171,7 +170,9 @@ fn aero_main() -> ! { // Now that all of the essential initialization is done we are going to schedule // the kernel main thread. let init = Task::new_kernel(kernel_main_thread, true); + let kdbg = Task::new_kernel(kernel_dbg_thread, true); scheduler::get_scheduler().register_task(init); + scheduler::get_scheduler().register_task(kdbg); unsafe { interrupts::enable_interrupts(); @@ -212,6 +213,62 @@ fn kernel_main_thread() { unreachable!() } +fn kernel_dbg_thread() { + use core::fmt::Write; + + use crate::drivers::uart::{self, LineStatus, COM_1}; + use crate::userland::task::TaskId; + use crate::utils::sync::WaitQueue; + + uart::setup_interrupts(); + + let input_wq = WaitQueue::new(); + let this_task = scheduler::current_thread(); + uart::register_listener(this_task.clone()); + + let com_1 = COM_1.get().unwrap(); + + loop { + let mut input = String::new(); + + loop { + let mut com_1 = input_wq + .block_on(com_1, |com_1| { + com_1.line_status().contains(LineStatus::INPUT_FULL) + }) + .unwrap(); + + let c = com_1.read_byte() as char; + + if c == '\r' { + writeln!(com_1).unwrap(); + break; + } + + input.push(c); + write!(com_1, "{c}").unwrap(); + } + + let mut commands = input.split_whitespace(); + + if let Some(name) = commands.next() { + match name { + "ps" => scheduler::get_scheduler().log_ptable(), + "wake" => { + log::warn!("kdbg: forcefully waking up task"); + let id = commands.next().unwrap().parse::().unwrap(); + scheduler::get_scheduler() + .find_task(TaskId::new(id)) + .unwrap() + .wake_up(); + } + + _ => log::warn!("kdbg: unknown command {name:?}"), + } + } + } +} + extern "C" fn aero_ap_main(ap_id: usize) -> ! { log::info!("AP{}: Loaded userland", ap_id); From 85c7cbdffb2f0a98004bf9f8b45bcb16e4445faa Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Wed, 3 Jul 2024 12:57:21 -0400 Subject: [PATCH 095/112] misc(kernel): use load fence before swapgs Avoid potential speculative execution issues with swapgs, such as swapgs being speculatively missed. Signed-off-by: Ian Moffett --- src/aero_kernel/src/arch/x86_64/interrupts/handlers.asm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/aero_kernel/src/arch/x86_64/interrupts/handlers.asm b/src/aero_kernel/src/arch/x86_64/interrupts/handlers.asm index 3e339fbaad0..2b1fa600ed7 100644 --- a/src/aero_kernel/src/arch/x86_64/interrupts/handlers.asm +++ b/src/aero_kernel/src/arch/x86_64/interrupts/handlers.asm @@ -39,6 +39,7 @@ interrupt_handler_%1: test qword [rsp + 16], 0x3 ; skip the SWAPGS instruction if CS & 0b11 == 0b00. jz .dont_swapgs + lfence swapgs .dont_swapgs: @@ -70,6 +71,7 @@ interrupt_handler_%1: test qword [rsp + 8], 0x3 ; skip the SWAPGS instruction if CS & 0b11 == 0b00. jz .dont_swapgs_again + lfence swapgs .dont_swapgs_again: From 27c2eb12df8173a5c313fb04f0852e7488fdfce7 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sun, 14 Jul 2024 20:53:57 +1000 Subject: [PATCH 096/112] fix(actions): formatting check Signed-off-by: Anhad Singh --- .github/workflows/build.yml | 5 ++--- Makefile | 6 ++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index af2d62b065b..947ca175b6c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,13 +25,12 @@ jobs: run: | sudo apt-get update sudo apt-get install -y nasm make - python3 -m pip install requests xbstrap - name: Build Documentation run: make doc - name: Formatting Check run: | - ./aero.py --fmt - git diff-index --quiet HEAD -- || (printf "${RED}error${NOCOLOR}: formatting check failed, run \`./aero.py --fmt\`\n" && exit 1) + make check_fmt + git diff-index --quiet HEAD -- || (printf "${RED}error${NOCOLOR}: formatting check failed, run \`make fmt\`\n" && exit 1) - name: Deploy documentation uses: peaceiris/actions-gh-pages@v3 if: github.ref == 'refs/heads/master' && (github.event_name == 'push' || github.event_name == 'schedule') diff --git a/Makefile b/Makefile index 15e3c534476..f5146f3db34 100644 --- a/Makefile +++ b/Makefile @@ -86,3 +86,9 @@ doc: ifeq ($(open),yes) xdg-open target/doc/index.html endif + +fmt: + cd $(SOURCE_DIR) && cargo fmt + +check_fmt: + cd $(SOURCE_DIR) && cargo fmt -- --check From f275662af6e2128d92dcbe7c6df3e5f72c02e5cb Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sun, 14 Jul 2024 20:59:36 +1000 Subject: [PATCH 097/112] fix(actions): docs publish dir Signed-off-by: Anhad Singh --- .github/workflows/build.yml | 6 ++++-- Makefile | 4 ++-- web/CNAME | 1 - web/index.html | 1 - 4 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 web/CNAME delete mode 100644 web/index.html diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 947ca175b6c..6cd2246677d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,9 @@ jobs: sudo apt-get update sudo apt-get install -y nasm make - name: Build Documentation - run: make doc + run: | + make doc + find ./target -type d -name .git -prune -exec rm -rf {} \; - name: Formatting Check run: | make check_fmt @@ -36,4 +38,4 @@ jobs: if: github.ref == 'refs/heads/master' && (github.event_name == 'push' || github.event_name == 'schedule') with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./build/web/ + publish_dir: ./target/doc/ diff --git a/Makefile b/Makefile index f5146f3db34..990748f7183 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ qemu: $(KERNEL_TARGET) $(USERLAND_TARGET) -cpu host,+vmx \ -drive file=target/disk.img,if=none,id=NVME1,format=raw \ -device nvme,drive=NVME1,serial=nvme \ - ${QEMU_FLAGS} + ${QEMU_FLAGS} # "qemu_perf" options: # delay (default: 30) - the amount of microseconds between each sample. @@ -82,7 +82,7 @@ qemu_p: .PHONY: doc doc: cd src && cargo doc --package aero_kernel --release --target-dir=../target/doc/ - cp web/index.html target/doc/index.html + echo "" > target/doc/index.html ifeq ($(open),yes) xdg-open target/doc/index.html endif diff --git a/web/CNAME b/web/CNAME deleted file mode 100644 index f6dad86016f..00000000000 --- a/web/CNAME +++ /dev/null @@ -1 +0,0 @@ -aero.andypy.dev \ No newline at end of file diff --git a/web/index.html b/web/index.html deleted file mode 100644 index acc3e9a4cd5..00000000000 --- a/web/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file From c5f81142d8996044730436349d3b005bbb0b9b9e Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Sat, 7 Sep 2024 13:39:57 +1000 Subject: [PATCH 098/112] fix(kernel): unbreak compilation on latest nightly Signed-off-by: Anhad Singh --- src/aero_kernel/src/main.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index 33dacc5ce39..0ed1fae7937 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -33,7 +33,6 @@ ptr_internals, // No tracking issue linked_list_cursors, // https://github.com/rust-lang/rust/issues/58533 extern_types, // https://github.com/rust-lang/rust/issues/43467 - new_uninit, // https://github.com/rust-lang/rust/issues/63291 step_trait, // https://github.com/rust-lang/rust/issues/42168 prelude_import, // No tracking issue allocator_api, // https://github.com/rust-lang/rust/issues/32838 @@ -48,7 +47,7 @@ strict_provenance, associated_type_defaults, trait_upcasting, - asm_const, + new_zeroed_alloc, // https://github.com/rust-lang/rust/issues/129396 sync_unsafe_cell )] // TODO(andypython): can we remove the dependency of "prelude_import" and "lang_items"? From b83aa1d6d5735a0aa46deb9a2d51c2f8aa72568e Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 2 Apr 2025 17:47:17 +1100 Subject: [PATCH 099/112] feat(kern): remove const_ptr_is_null, strict_provenance as they have been stabilised Signed-off-by: Anhad Singh --- src/aero_kernel/src/main.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index 0ed1fae7937..816120f3a67 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -41,10 +41,8 @@ maybe_uninit_as_bytes, // https://github.com/rust-lang/rust/issues/93092 const_trait_impl, // https://github.com/rust-lang/rust/issues/67792 int_roundings, // https://github.com/rust-lang/rust/issues/88581 - const_ptr_is_null, // https://github.com/rust-lang/rust/issues/74939 naked_functions, // https://github.com/rust-lang/rust/issues/32408 cfg_match, // https://github.com/rust-lang/rust/issues/115585 - strict_provenance, associated_type_defaults, trait_upcasting, new_zeroed_alloc, // https://github.com/rust-lang/rust/issues/129396 From a42e74ce2bd84c1786d2ea71cf59cb1fe1685ddf Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 2 Apr 2025 17:58:06 +1100 Subject: [PATCH 100/112] fix: new cfg_match syntax Signed-off-by: Anhad Singh --- src/aero_kernel/src/drivers/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/aero_kernel/src/drivers/mod.rs b/src/aero_kernel/src/drivers/mod.rs index 8cbab02c810..edb23988a46 100644 --- a/src/aero_kernel/src/drivers/mod.rs +++ b/src/aero_kernel/src/drivers/mod.rs @@ -36,12 +36,12 @@ pub mod pty; pub mod tty; cfg_match! { - cfg(target_arch = "x86_64") => { + target_arch = "x86_64" => { pub mod uart_16550; pub use self::uart_16550 as uart; } - cfg(target_arch = "aarch64") => { + target_arch = "aarch64" => { pub mod uart_pl011; pub use self::uart_pl011 as uart; } From c877021155937bb7312c4a046a1c741a9b158d57 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 2 Apr 2025 17:59:33 +1100 Subject: [PATCH 101/112] fix: steps_between Signed-off-by: Anhad Singh --- src/aero_kernel/src/mem/paging/addr.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/aero_kernel/src/mem/paging/addr.rs b/src/aero_kernel/src/mem/paging/addr.rs index 5b46141cd80..b5193b30e63 100644 --- a/src/aero_kernel/src/mem/paging/addr.rs +++ b/src/aero_kernel/src/mem/paging/addr.rs @@ -354,11 +354,12 @@ impl Sub for VirtAddr { impl Step for VirtAddr { #[inline] - fn steps_between(start: &Self, end: &Self) -> Option { + fn steps_between(start: &Self, end: &Self) -> (usize, Option) { if start < end { - Some((end.as_u64() - start.as_u64()) as _) + let n = (end.as_u64() - start.as_u64()) as usize; + (n, Some(n)) } else { - None + (0, None) } } From fe38d28067f3964724220a223a3c3f92d879c23f Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 2 Apr 2025 18:00:34 +1100 Subject: [PATCH 102/112] fix: naked_asm! Signed-off-by: Anhad Singh --- src/aero_kernel/src/arch/x86_64/mem.rs | 17 +++++++---------- src/aero_kernel/src/arch/x86_64/syscall.rs | 7 +++---- src/aero_kernel/src/arch/x86_64/task.rs | 16 +++++++--------- src/aero_kernel/src/arch/x86_64/user_copy.rs | 4 ++-- 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/aero_kernel/src/arch/x86_64/mem.rs b/src/aero_kernel/src/arch/x86_64/mem.rs index c89f15e0648..5f439f1d5c3 100644 --- a/src/aero_kernel/src/arch/x86_64/mem.rs +++ b/src/aero_kernel/src/arch/x86_64/mem.rs @@ -15,6 +15,8 @@ // You should have received a copy of the GNU General Public License // along with Aero. If not, see . +use core::arch::naked_asm; + fn should_store_by_byte() -> bool { let cpuid = raw_cpuid::CpuId::new(); if let Some(features) = cpuid.get_extended_feature_info() { @@ -32,7 +34,7 @@ unsafe extern "C" fn memcpy_movsq(dest: *mut u8, src: *const u8, len: usize) -> // %rdi = argument 1, `dest` // %rsi = argument 2, `src` // %rdx = argument 3, `len` - asm!( + naked_asm!( // Save the return value. "mov rax, rdi", // Copy in 8 byte chunks. @@ -44,7 +46,6 @@ unsafe extern "C" fn memcpy_movsq(dest: *mut u8, src: *const u8, len: usize) -> "and rcx, 0x7", "rep movsb", "ret", - options(noreturn) ); } @@ -55,14 +56,13 @@ unsafe extern "C" fn memcpy_movsb(dest: *mut u8, src: *const u8, len: usize) -> // %rdi = argument 1, `dest` // %rsi = argument 2, `src` // %rdx = argument 3, `len` - asm!( + naked_asm!( // Save the return value. "mov rax, rdi", // Copy! "mov rcx, rdx", "rep movsb", "ret", - options(noreturn) ) } @@ -82,7 +82,7 @@ unsafe extern "C" fn memset_stosq(dest: *mut u8, byte: i32, len: usize) -> *mut // %rdi = argument 1, `dest` // %rsi = argument 2, `byte` // %rdx = argument 3, `len` - asm!( + naked_asm!( // Save the return value. "mov r11, rdi", // Create an 8-byte copy of the pattern. @@ -101,7 +101,6 @@ unsafe extern "C" fn memset_stosq(dest: *mut u8, byte: i32, len: usize) -> *mut // Restore the return value. "mov rax, r11", "ret", - options(noreturn) ) } @@ -112,7 +111,7 @@ unsafe extern "C" fn memset_stosb(dest: *mut u8, byte: i32, len: usize) -> *mut // %rdi = argument 1, `dest` // %rsi = argument 2, `byte` // %rdx = argument 3, `len` - asm!( + naked_asm!( // Save the return value. "mov r11, rdi", "mov al, sil", @@ -120,7 +119,6 @@ unsafe extern "C" fn memset_stosb(dest: *mut u8, byte: i32, len: usize) -> *mut "rep stosb", "mov rax, r11", "ret", - options(noreturn) ) } @@ -141,7 +139,7 @@ unsafe extern "C" fn memmove_erms(dest: *mut u8, src: *const u8, len: usize) -> // %rdi = argument 1, `dest` // %rsi = argument 2, `src` // %rdx = argument 3, `len` - asm!( + naked_asm!( "mov rax, rdi", // Skip zero length. "test rdx, rdx", @@ -167,7 +165,6 @@ unsafe extern "C" fn memmove_erms(dest: *mut u8, src: *const u8, len: usize) -> "rep movsb", "cld", "ret", - options(noreturn) ) } diff --git a/src/aero_kernel/src/arch/x86_64/syscall.rs b/src/aero_kernel/src/arch/x86_64/syscall.rs index e8ed006ac7c..2391a3b3e8b 100644 --- a/src/aero_kernel/src/arch/x86_64/syscall.rs +++ b/src/aero_kernel/src/arch/x86_64/syscall.rs @@ -9,6 +9,7 @@ use crate::utils::sync::IrqGuard; use super::interrupts::InterruptErrorStack; use super::{asm_macros, io}; +use core::arch::naked_asm; use core::mem::offset_of; const ARCH_SET_GS: usize = 0x1001; @@ -39,7 +40,7 @@ const ARCH_GET_GS: usize = 0x1004; /// The instruction also does not save anything on the stack and does *not* change the `RSP`. #[naked] unsafe extern "C" fn x86_64_syscall_handler() { - asm!( + naked_asm!( // make the GS base point to the kernel TLS "swapgs", // save the user stack pointer @@ -89,7 +90,6 @@ unsafe extern "C" fn x86_64_syscall_handler() { tss_temp_ustack_off = const offset_of!(Tss, reserved2) + core::mem::size_of::(), tss_rsp0_off = const offset_of!(Tss, rsp) + core::mem::size_of::(), x86_64_do_syscall = sym x86_64_do_syscall, - options(noreturn) ) } @@ -107,7 +107,7 @@ unsafe extern "C" fn x86_64_syscall_handler() { /// The instruction expects the call number and arguments in the same registers as for SYSCALL. #[naked] unsafe extern "C" fn x86_64_sysenter_handler() { - asm!( + naked_asm!( "swapgs", // Build the interrupt frame expected by the kernel. "push {userland_ss}", @@ -155,7 +155,6 @@ unsafe extern "C" fn x86_64_sysenter_handler() { userland_ss = const USER_SS.bits(), x86_64_check_sysenter = sym x86_64_check_sysenter, x86_64_do_syscall = sym x86_64_do_syscall, - options(noreturn) ) } diff --git a/src/aero_kernel/src/arch/x86_64/task.rs b/src/aero_kernel/src/arch/x86_64/task.rs index 4160e28f582..fa57318ba88 100644 --- a/src/aero_kernel/src/arch/x86_64/task.rs +++ b/src/aero_kernel/src/arch/x86_64/task.rs @@ -37,6 +37,7 @@ use alloc::vec::Vec; use raw_cpuid::CpuId; use core::alloc::Layout; +use core::arch::naked_asm; use core::ptr::Unique; use crate::arch::interrupts::InterruptErrorStack; @@ -115,7 +116,8 @@ const USERLAND_STACK_BOTTOM: VirtAddr = USERLAND_STACK_TOP.const_sub_u64(USERLAN #[naked] unsafe extern "C" fn jump_userland_exec(stack: VirtAddr, rip: VirtAddr, rflags: u64) { - asm!( + #[rustfmt::skip] + naked_asm!( "push rdi", // stack "push rsi", // rip "push rdx", // rflags @@ -124,14 +126,13 @@ unsafe extern "C" fn jump_userland_exec(stack: VirtAddr, rip: VirtAddr, rflags: "pop rcx", "pop rsp", "swapgs", - "sysretq", - options(noreturn) + "sysretq" ); } #[naked] unsafe extern "C" fn task_spinup(prev: &mut Unique, next: &Context) { - asm!( + naked_asm!( // save callee-saved registers "push rbp", "push rbx", @@ -158,26 +159,24 @@ unsafe extern "C" fn task_spinup(prev: &mut Unique, next: &Context) { "pop rbp", // resume the next thread "ret", - options(noreturn) ); } #[naked] unsafe extern "C" fn iretq_init() { - asm!( + naked_asm!( "cli", // pop the error code "add rsp, 8", asm_macros::pop_preserved!(), asm_macros::pop_scratch!(), "iretq", - options(noreturn) ) } #[naked] unsafe extern "C" fn fork_init() { - asm!( + naked_asm!( "cli", // pop the error code "add rsp, 8", @@ -185,7 +184,6 @@ unsafe extern "C" fn fork_init() { asm_macros::pop_scratch!(), "swapgs", "iretq", - options(noreturn) ) } diff --git a/src/aero_kernel/src/arch/x86_64/user_copy.rs b/src/aero_kernel/src/arch/x86_64/user_copy.rs index 630fd2a062a..5922b3fb2ce 100644 --- a/src/aero_kernel/src/arch/x86_64/user_copy.rs +++ b/src/aero_kernel/src/arch/x86_64/user_copy.rs @@ -15,6 +15,7 @@ // You should have received a copy of the GNU General Public License // along with Aero. If not, see . +use core::arch::naked_asm; use core::fmt::{Debug, Display}; use core::mem::MaybeUninit; use core::ops::{Deref, DerefMut}; @@ -52,7 +53,7 @@ unsafe extern "C" fn copy_to_from_user( // %rsi = argument 2, `src` // %rdx = argument 3, `size` // %rcx = argument 4, `fault_resume` (copied to %r10) - asm!( + naked_asm!( // Copy `fault_resume` out of %rcx because it will be utilized by `rep movsb` latter. "mov r10, rcx", // Setup the page fault resume. @@ -82,7 +83,6 @@ unsafe extern "C" fn copy_to_from_user( "1:", "xor eax, eax", "jmp 3b", - options(noreturn) ) } From 4e8013aeb131afcc5dfde79203d0a8de7c9a632d Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 2 Apr 2025 18:03:42 +1100 Subject: [PATCH 103/112] fix(scheduler): awaiting tasks * Correctly set a sleep duration of 0 for tasks that do not have a deadline. * Look in the `deadline_awaiting` queue if the task trying to wake up has a non-zero duration. Signed-off-by: Anhad Singh --- .../src/userland/scheduler/round_robin.rs | 8 +++++++- src/aero_kernel/src/utils/sync.rs | 12 ++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/aero_kernel/src/userland/scheduler/round_robin.rs b/src/aero_kernel/src/userland/scheduler/round_robin.rs index 8dcc68fefe4..1f592b5eb61 100644 --- a/src/aero_kernel/src/userland/scheduler/round_robin.rs +++ b/src/aero_kernel/src/userland/scheduler/round_robin.rs @@ -90,6 +90,8 @@ impl TaskQueue { debug_assert!(!task.link.is_linked()); // Make sure the task is not already linked task.update_state(TaskState::AwaitingIo); + task.set_sleep_duration(0); + self.awaiting.push_back(task); } } @@ -213,7 +215,11 @@ impl SchedulerInterface for RoundRobin { let queue = self.queue.get_mut(); if task.state() == TaskState::AwaitingIo { - let mut cursor = unsafe { queue.awaiting.cursor_mut_from_ptr(task.as_ref()) }; + let mut cursor = if task.load_sleep_duration() > 0 { + unsafe { queue.deadline_awaiting.cursor_mut_from_ptr(task.as_ref()) } + } else { + unsafe { queue.awaiting.cursor_mut_from_ptr(task.as_ref()) } + }; if let Some(task) = cursor.remove() { queue.push_runnable(task); diff --git a/src/aero_kernel/src/utils/sync.rs b/src/aero_kernel/src/utils/sync.rs index 67ef642bd37..3168ec27068 100644 --- a/src/aero_kernel/src/utils/sync.rs +++ b/src/aero_kernel/src/utils/sync.rs @@ -178,7 +178,7 @@ pub struct BMutexGuard<'a, T: ?Sized + 'a> { mutex: &'a BMutex, } -impl<'a, T: ?Sized> core::ops::Deref for BMutexGuard<'a, T> { +impl core::ops::Deref for BMutexGuard<'_, T> { type Target = T; #[inline] @@ -187,14 +187,14 @@ impl<'a, T: ?Sized> core::ops::Deref for BMutexGuard<'a, T> { } } -impl<'a, T: ?Sized> core::ops::DerefMut for BMutexGuard<'a, T> { +impl core::ops::DerefMut for BMutexGuard<'_, T> { #[inline] fn deref_mut(&mut self) -> &mut T { self.guard.deref_mut() } } -impl<'a, T: ?Sized> Drop for BMutexGuard<'a, T> { +impl Drop for BMutexGuard<'_, T> { fn drop(&mut self) { self.mutex.wq.notify(); } @@ -261,7 +261,7 @@ pub struct MutexGuard<'a, T: ?Sized + 'a> { irq_lock: bool, } -impl<'a, T: ?Sized> core::ops::Deref for MutexGuard<'a, T> { +impl core::ops::Deref for MutexGuard<'_, T> { type Target = T; #[inline] @@ -270,14 +270,14 @@ impl<'a, T: ?Sized> core::ops::Deref for MutexGuard<'a, T> { } } -impl<'a, T: ?Sized> core::ops::DerefMut for MutexGuard<'a, T> { +impl core::ops::DerefMut for MutexGuard<'_, T> { #[inline] fn deref_mut(&mut self) -> &mut T { &mut self.guard } } -impl<'a, T: ?Sized> Drop for MutexGuard<'a, T> { +impl Drop for MutexGuard<'_, T> { #[inline] fn drop(&mut self) { unsafe { From adbe0ad6e0f168111a0cda81fe48ef089727bc8a Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 2 Apr 2025 18:05:45 +1100 Subject: [PATCH 104/112] cleanup Signed-off-by: Anhad Singh --- src/aero_kernel/src/drivers/pci.rs | 2 +- src/aero_kernel/src/drivers/pty.rs | 2 +- src/aero_kernel/src/rendy.rs | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/aero_kernel/src/drivers/pci.rs b/src/aero_kernel/src/drivers/pci.rs index c44dc4ee6f3..91851f76d29 100644 --- a/src/aero_kernel/src/drivers/pci.rs +++ b/src/aero_kernel/src/drivers/pci.rs @@ -184,7 +184,7 @@ impl<'a> CapabilityIter<'a> { } } -impl<'a> Iterator for CapabilityIter<'a> { +impl Iterator for CapabilityIter<'_> { type Item = (u32, Capability); fn next(&mut self) -> Option { diff --git a/src/aero_kernel/src/drivers/pty.rs b/src/aero_kernel/src/drivers/pty.rs index d75dd81d7b1..eac7ab4a899 100644 --- a/src/aero_kernel/src/drivers/pty.rs +++ b/src/aero_kernel/src/drivers/pty.rs @@ -297,7 +297,7 @@ impl INodeInterface for Slave { for b in buffer.iter() { if *b == b'\n' { // ONLCR: Convert NL to CR + NL - master.extend_from_slice(&[b'\r', b'\n']); + master.extend_from_slice(b"\r\n"); continue; } diff --git a/src/aero_kernel/src/rendy.rs b/src/aero_kernel/src/rendy.rs index 4555cfa9122..24b85a97ff3 100644 --- a/src/aero_kernel/src/rendy.rs +++ b/src/aero_kernel/src/rendy.rs @@ -309,7 +309,7 @@ pub struct Inner<'this> { color_list: ColorList, } -impl<'a> Inner<'a> { +impl Inner<'_> { fn genloop( &mut self, image: &Image, @@ -793,13 +793,13 @@ impl<'a> core::ops::Deref for DebugRendy<'a> { } } -impl<'a> core::ops::DerefMut for DebugRendy<'a> { +impl core::ops::DerefMut for DebugRendy<'_> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.inner } } -impl<'this> fmt::Write for DebugRendy<'this> { +impl fmt::Write for DebugRendy<'_> { fn write_str(&mut self, string: &str) -> fmt::Result { for b in string.bytes() { self.performer.advance(&mut self.inner, b); @@ -808,7 +808,7 @@ impl<'this> fmt::Write for DebugRendy<'this> { } } -impl<'a> vte::ansi::Handler for Inner<'a> { +impl vte::ansi::Handler for Inner<'_> { fn input(&mut self, c: char) { self.write_character(c); @@ -883,8 +883,8 @@ impl<'a> vte::ansi::Handler for Inner<'a> { } } -unsafe impl<'this> Send for DebugRendy<'this> {} -unsafe impl<'this> Sync for DebugRendy<'this> {} +unsafe impl Send for DebugRendy<'_> {} +unsafe impl Sync for DebugRendy<'_> {} pub static DEBUG_RENDY: Once> = Once::new(); From bf8121c682827deb240d8b059f12851ad9832e0e Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 2 Apr 2025 18:15:51 +1100 Subject: [PATCH 105/112] fix(epoll): timeout Signed-off-by: Anhad Singh --- src/aero_kernel/src/fs/epoll.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/aero_kernel/src/fs/epoll.rs b/src/aero_kernel/src/fs/epoll.rs index ed967f6779f..390ec60139f 100644 --- a/src/aero_kernel/src/fs/epoll.rs +++ b/src/aero_kernel/src/fs/epoll.rs @@ -15,6 +15,9 @@ // You should have received a copy of the GNU General Public License // along with Aero. If not, see . +// TODO: The reason why XFE did not run was because of the FXSleep function which uses select() to +// sleep. + use aero_syscall::prelude::{EPollEvent, EPollEventFlags}; use aero_syscall::SyscallError; @@ -170,7 +173,7 @@ impl EPoll { } // If all events are ready, we can return now. - if n > 0 { + if n > 0 || fds.is_empty() { debug_assert!(fds.is_empty()); return Ok(n); } @@ -181,9 +184,22 @@ impl EPoll { return Ok(0); } + if timeout > 0 { + scheduler::get_scheduler() + .inner + .sleep(Some(timeout * 1_000_000))?; + } else { + scheduler::get_scheduler().inner.sleep(None)?; + } + 'search: loop { scheduler::get_scheduler().inner.await_io()?; + if current_task.load_sleep_duration() == 0 && timeout > 0 { + // Timeout has expired. + return Ok(0); + } + for (fd, event, flags) in fds.iter_mut() { // If the event mask does not contain any poll(2) events, the event // descriptor is disabled. From 2c46ee99d78144ff2a8cb56c6670b0d096c0c1f2 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 2 Apr 2025 18:17:32 +1100 Subject: [PATCH 106/112] cleanup: remove trait_upcasting as it is stable now Signed-off-by: Anhad Singh --- src/aero_kernel/src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index 816120f3a67..ec917a72daa 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -44,7 +44,6 @@ naked_functions, // https://github.com/rust-lang/rust/issues/32408 cfg_match, // https://github.com/rust-lang/rust/issues/115585 associated_type_defaults, - trait_upcasting, new_zeroed_alloc, // https://github.com/rust-lang/rust/issues/129396 sync_unsafe_cell )] From e045934978037590e2483d49999029884e774b54 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Wed, 2 Apr 2025 18:34:55 +1100 Subject: [PATCH 107/112] fix(epoll) TODO: Cleanup the task state enum. Signed-off-by: Anhad Singh --- src/aero_kernel/src/fs/epoll.rs | 10 +++++++--- src/aero_kernel/src/userland/scheduler/round_robin.rs | 6 +++--- src/aero_kernel/src/userland/task/mod.rs | 2 ++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/aero_kernel/src/fs/epoll.rs b/src/aero_kernel/src/fs/epoll.rs index 390ec60139f..8cf37ceb333 100644 --- a/src/aero_kernel/src/fs/epoll.rs +++ b/src/aero_kernel/src/fs/epoll.rs @@ -25,6 +25,7 @@ use alloc::sync::Arc; use hashbrown::HashMap; use crate::userland::scheduler; +use crate::userland::task::TaskState; use crate::utils::sync::Mutex; use super::inode::{INodeInterface, PollTable}; @@ -193,9 +194,10 @@ impl EPoll { } 'search: loop { - scheduler::get_scheduler().inner.await_io()?; - - if current_task.load_sleep_duration() == 0 && timeout > 0 { + if current_task.state() == TaskState::AwaitingIoDeadline + && current_task.load_sleep_duration() == 0 + && timeout > 0 + { // Timeout has expired. return Ok(0); } @@ -224,6 +226,8 @@ impl EPoll { n = 1; break 'search; } + + scheduler::get_scheduler().inner.await_io()?; } } diff --git a/src/aero_kernel/src/userland/scheduler/round_robin.rs b/src/aero_kernel/src/userland/scheduler/round_robin.rs index 1f592b5eb61..2f61eebb4ba 100644 --- a/src/aero_kernel/src/userland/scheduler/round_robin.rs +++ b/src/aero_kernel/src/userland/scheduler/round_robin.rs @@ -80,7 +80,7 @@ impl TaskQueue { fn push_deadline_awaiting(&mut self, task: Arc, duration: usize) { debug_assert!(!task.link.is_linked()); // Make sure the task is not already linked - task.update_state(TaskState::AwaitingIo); + task.update_state(TaskState::AwaitingIoDeadline); task.set_sleep_duration(crate::arch::time::get_uptime_ticks() + duration); self.deadline_awaiting.push_back(task); @@ -214,8 +214,8 @@ impl SchedulerInterface for RoundRobin { let _guard = IrqGuard::new(); let queue = self.queue.get_mut(); - if task.state() == TaskState::AwaitingIo { - let mut cursor = if task.load_sleep_duration() > 0 { + if task.state() == TaskState::AwaitingIo || task.state() == TaskState::AwaitingIoDeadline { + let mut cursor = if task.state() == TaskState::AwaitingIoDeadline { unsafe { queue.deadline_awaiting.cursor_mut_from_ptr(task.as_ref()) } } else { unsafe { queue.awaiting.cursor_mut_from_ptr(task.as_ref()) } diff --git a/src/aero_kernel/src/userland/task/mod.rs b/src/aero_kernel/src/userland/task/mod.rs index cd7d1d7d706..b0b81e2f0ab 100644 --- a/src/aero_kernel/src/userland/task/mod.rs +++ b/src/aero_kernel/src/userland/task/mod.rs @@ -73,6 +73,7 @@ pub enum TaskState { Runnable, Zombie, AwaitingIo, + AwaitingIoDeadline, } impl From for TaskState { @@ -81,6 +82,7 @@ impl From for TaskState { 0 => TaskState::Runnable, 1 => TaskState::Zombie, 2 => TaskState::AwaitingIo, + 3 => TaskState::AwaitingIoDeadline, _ => panic!("invalid task state"), } } From 9d04caa36281e62f527d7ca7940e696662da7ad2 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 4 Apr 2025 17:29:04 +1100 Subject: [PATCH 108/112] fix: a few warnings Signed-off-by: Anhad Singh --- src/aero_kernel/src/arch/x86_64/gdt.rs | 4 ++-- src/aero_kernel/src/fs/ext2/group_desc.rs | 7 +------ src/aero_kernel/src/fs/ext2/mod.rs | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/aero_kernel/src/arch/x86_64/gdt.rs b/src/aero_kernel/src/arch/x86_64/gdt.rs index 7e8df0e6707..36c42f4c07c 100644 --- a/src/aero_kernel/src/arch/x86_64/gdt.rs +++ b/src/aero_kernel/src/arch/x86_64/gdt.rs @@ -25,8 +25,8 @@ //! * use core::alloc::Layout; -use core::mem; use core::ptr::addr_of; +use core::{mem, ptr}; use alloc::alloc::alloc_zeroed; @@ -271,7 +271,7 @@ impl GdtEntry { fn set_raw(&mut self, value: T) { unsafe { - *(self as *mut _ as *mut T) = value; + *(ptr::addr_of_mut!(*self).cast::()) = value; } } } diff --git a/src/aero_kernel/src/fs/ext2/group_desc.rs b/src/aero_kernel/src/fs/ext2/group_desc.rs index 97c5ff113c8..af3578d735d 100644 --- a/src/aero_kernel/src/fs/ext2/group_desc.rs +++ b/src/aero_kernel/src/fs/ext2/group_desc.rs @@ -15,8 +15,6 @@ // You should have received a copy of the GNU General Public License // along with Aero. If not, see . -use core::mem::MaybeUninit; - use alloc::boxed::Box; use alloc::sync::{Arc, Weak}; @@ -53,10 +51,7 @@ impl GroupDescriptors { let bgdt_len = superblock.bgdt_len(); let mut bgdt = Box::<[disk::GroupDescriptor]>::new_uninit_slice(bgdt_len); - device.read( - superblock.bgdt_block(), - MaybeUninit::slice_as_bytes_mut(&mut bgdt), - )?; + device.read(superblock.bgdt_block(), bgdt.as_bytes_mut())?; // SAFETY: We have initialized the BGD (Block Group Descriptor Table) above. let bgdt = unsafe { bgdt.assume_init() }; diff --git a/src/aero_kernel/src/fs/ext2/mod.rs b/src/aero_kernel/src/fs/ext2/mod.rs index 337fa3c4acf..d37189b80e0 100644 --- a/src/aero_kernel/src/fs/ext2/mod.rs +++ b/src/aero_kernel/src/fs/ext2/mod.rs @@ -557,7 +557,7 @@ impl INodeInterface for INode { Ok(path.into()) } else { let mut buffer = Box::<[u8]>::new_uninit_slice(path_len); - self.read(0, MaybeUninit::slice_as_bytes_mut(&mut buffer))?; + self.read(0, buffer.as_bytes_mut())?; let path_bytes = unsafe { buffer.assume_init() }; let path = core::str::from_utf8(&path_bytes).or(Err(FileSystemError::InvalidPath))?; From 3a42546a834c6be4d17e3ad56baeaffe6db75a47 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 4 Apr 2025 17:43:49 +1100 Subject: [PATCH 109/112] misc: bump crates Signed-off-by: Anhad Singh --- src/Cargo.lock | 299 ++++++++++++++++------------------- src/aero_kernel/Cargo.toml | 26 +-- src/aero_kernel/src/rendy.rs | 4 +- 3 files changed, 151 insertions(+), 178 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index 1e136f7b711..0b3a1ec588b 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "aero_kernel" @@ -9,7 +9,7 @@ dependencies = [ "aero_proc", "aero_syscall", "bit_field", - "bitflags 2.5.0", + "bitflags 2.9.0", "byte_endian", "bytemuck", "cpio_reader", @@ -27,7 +27,7 @@ dependencies = [ "raw-cpuid", "rustc-demangle", "serde_json", - "spin 0.9.8", + "spin 0.10.0", "static_assertions", "uapi", "vte", @@ -55,35 +55,23 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - [[package]] name = "allocator-api2" -version = "0.2.16" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "autocfg" -version = "1.2.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "bit_field" @@ -99,9 +87,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "byte_endian" @@ -110,15 +98,18 @@ source = "git+https://github.com/aero-os/byte_endian#540be6149cd9408088a9e45be2d [[package]] name = "bytemuck" -version = "1.15.0" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" +checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540" [[package]] name = "cc" -version = "1.0.90" +version = "1.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" +checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -140,7 +131,7 @@ version = "0.1.0" source = "git+https://github.com/aero-os/crabnet#58a74ea76fb9586ac1c33fd0adbda497ebdaac43" dependencies = [ "bit_field", - "bitflags 2.5.0", + "bitflags 2.9.0", "byte_endian", "static_assertions", ] @@ -155,66 +146,70 @@ dependencies = [ ] [[package]] -name = "crossbeam-deque" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.18" +name = "cursor-icon" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" -dependencies = [ - "crossbeam-utils", -] +checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991" [[package]] -name = "crossbeam-utils" -version = "0.8.19" +name = "equivalent" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] -name = "cursor-icon" -version = "1.1.0" +name = "foldhash" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" [[package]] -name = "either" -version = "1.10.0" +name = "getrandom" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi", +] [[package]] name = "hashbrown" -version = "0.14.3" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ - "ahash", "allocator-api2", + "equivalent", + "foldhash", ] [[package]] name = "intrusive-collections" -version = "0.9.6" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b694dc9f70c3bda874626d2aed13b780f137aab435f4e9814121955cf706122e" +checksum = "189d0897e4cbe8c75efedf3502c18c887b05046e59d28404d4d8e46cbc4d1e86" dependencies = [ "memoffset", ] [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "jobserver" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" +dependencies = [ + "getrandom", + "libc", +] [[package]] name = "lai" @@ -227,37 +222,49 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" dependencies = [ - "spin 0.5.2", + "spin 0.9.8", ] +[[package]] +name = "libc" +version = "0.2.171" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" + [[package]] name = "limine" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "846c87e24d089e8717a61098cba72b378e3525c46a87cf75b71352dcf668e68c" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.9.0", ] [[package]] name = "log" -version = "0.4.21" +version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" [[package]] name = "lru" -version = "0.12.3" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3262e75e648fce39813cb56ac41f3c3e3f65217ebf3844d818d1f9398cfb0dc" +checksum = "227748d55f2f0ab4735d87fd623798cb6b664512fe979705f829c9f81c934465" dependencies = [ "hashbrown", ] +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + [[package]] name = "memoffset" version = "0.9.1" @@ -269,11 +276,11 @@ dependencies = [ [[package]] name = "nasm-rs" -version = "0.2.5" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe4d98d0065f4b1daf164b3eafb11974c94662e5e2396cf03f32d0bb5c17da51" +checksum = "12fcfa1bd49e0342ec1d07ed2be83b59963e7acbeb9310e1bb2c07b69dadd959" dependencies = [ - "rayon", + "jobserver", ] [[package]] @@ -289,19 +296,13 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.18" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - [[package]] name = "proc-macro-error" version = "1.0.4" @@ -328,99 +329,86 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.79" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" dependencies = [ "proc-macro2", ] [[package]] -name = "raw-cpuid" -version = "11.0.1" +name = "r-efi" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d86a7c4638d42c44551f4791a20e687dbb4c3de1f33c43dd71e355cd429def1" -dependencies = [ - "bitflags 2.5.0", -] +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" [[package]] -name = "rayon" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.12.1" +name = "raw-cpuid" +version = "11.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +checksum = "c6df7ab838ed27997ba19a4664507e6f82b41fe6e20be42929332156e5e85146" dependencies = [ - "crossbeam-deque", - "crossbeam-utils", + "bitflags 2.9.0", ] [[package]] name = "rustc-demangle" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "ryu" -version = "1.0.17" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "serde" -version = "1.0.197" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.219" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.55", + "syn 2.0.100", ] [[package]] name = "serde_json" -version = "1.0.115" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] [[package]] -name = "spin" -version = "0.5.2" +name = "shlex" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "spin" @@ -428,6 +416,12 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +[[package]] +name = "spin" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5fe4ccb98d9c292d56fec89a5e07da7fc4cf0dc11e156b41793132775d3e591" + [[package]] name = "static_assertions" version = "1.1.0" @@ -447,9 +441,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.55" +version = "2.0.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" dependencies = [ "proc-macro2", "quote", @@ -462,77 +456,58 @@ version = "0.1.0" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "utf8parse" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "vte" -version = "0.13.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40eb22ae96f050e0c0d6f7ce43feeae26c348fc4dea56928ca81537cfaa6188b" +checksum = "a5924018406ce0063cd67f8e008104968b74b563ee1b85dde3ed1f7cb87d3dbd" dependencies = [ "arrayvec", - "bitflags 2.5.0", + "bitflags 2.9.0", "cursor-icon", "log", - "utf8parse", - "vte_generate_state_changes", + "memchr", ] [[package]] -name = "vte_generate_state_changes" -version = "0.1.1" +name = "wasi" +version = "0.14.2+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d257817081c7dffcdbab24b9e62d2def62e2ff7d00b1c20062551e6cccc145ff" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" dependencies = [ - "proc-macro2", - "quote", + "wit-bindgen-rt", ] [[package]] -name = "xmas-elf" -version = "0.9.1" +name = "wit-bindgen-rt" +version = "0.39.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42c49817e78342f7f30a181573d82ff55b88a35f86ccaf07fc64b3008f56d1c6" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" dependencies = [ - "zero", + "bitflags 2.9.0", ] [[package]] -name = "zero" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fe21bcc34ca7fe6dd56cc2cb1261ea59d6b93620215aefb5ea6032265527784" - -[[package]] -name = "zerocopy" -version = "0.7.32" +name = "xmas-elf" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" +checksum = "18245fcbb8b3de8dd198ce7944fdd4096986fd6cd306b0fcfa27df817bd545d6" dependencies = [ - "zerocopy-derive", + "zero", ] [[package]] -name = "zerocopy-derive" -version = "0.7.32" +name = "zero" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.55", -] +checksum = "2fe21bcc34ca7fe6dd56cc2cb1261ea59d6b93620215aefb5ea6032265527784" diff --git a/src/aero_kernel/Cargo.toml b/src/aero_kernel/Cargo.toml index 720e47c8360..8c6c5489d33 100644 --- a/src/aero_kernel/Cargo.toml +++ b/src/aero_kernel/Cargo.toml @@ -21,30 +21,30 @@ kmemleak = [] default = ["round-robin"] [dependencies] -spin = { version = "0.9.8", default-features = false, features = [ +spin = { version = "0.10.0", default-features = false, features = [ "spin_mutex", "rwlock", "once", ] } -bitflags = "2.4.2" +bitflags = "2.9.0" bit_field = "0.10.2" -log = "0.4.21" -xmas-elf = "0.9.1" -hashbrown = "0.14.3" -rustc-demangle = "0.1.23" +log = "0.4.27" +xmas-elf = "0.10.0" +hashbrown = "0.15.2" +rustc-demangle = "0.1.24" # intrusive-collections: # `nightly`: Get access to const variants of the functions. -intrusive-collections = { version = "0.9.6", features = ["nightly"] } +intrusive-collections = { version = "0.9.7", features = ["nightly"] } serde_json = { version = "1.0", default-features = false, features = ["alloc"] } lai = { git = "https://github.com/aero-os/lai-rs" } uapi = { path = "../uapi" } cpio_reader = { git = "https://github.com/Andy-Python-Programmer/cpio_reader" } static_assertions = "1.1.0" -lru = "0.12.3" -bytemuck = "1.15.0" +lru = "0.13.0" +bytemuck = "1.22.0" limine = "0.2.0" num-traits = { version = "0.2", default-features = false } -vte = { version = "0.13.0", features = ["ansi"] } +vte = { version = "0.15.0", default-features = false, features = ["ansi"] } byte_endian = { git = "https://github.com/aero-os/byte_endian" } crabnet = { git = "https://github.com/aero-os/crabnet" } @@ -54,10 +54,10 @@ crabnet_tcp = { git = "https://github.com/aero-os/crabnet", default-features = f # X86_64 specific dependencies: [target.'cfg(target_arch = "x86_64")'.dependencies] -raw-cpuid = "11.0.1" +raw-cpuid = "11.5.0" [dependencies.lazy_static] -version = "1.4.0" +version = "1.5.0" features = ["spin_no_std"] [dependencies.aero_proc] @@ -67,4 +67,4 @@ path = "../aero_proc" path = "../aero_syscall" [build-dependencies] -nasm-rs = { version = "0.2", features = ["parallel"] } +nasm-rs = { version = "0.3", features = ["parallel"] } diff --git a/src/aero_kernel/src/rendy.rs b/src/aero_kernel/src/rendy.rs index 24b85a97ff3..29e3a8513e2 100644 --- a/src/aero_kernel/src/rendy.rs +++ b/src/aero_kernel/src/rendy.rs @@ -801,9 +801,7 @@ impl core::ops::DerefMut for DebugRendy<'_> { impl fmt::Write for DebugRendy<'_> { fn write_str(&mut self, string: &str) -> fmt::Result { - for b in string.bytes() { - self.performer.advance(&mut self.inner, b); - } + self.performer.advance(&mut self.inner, string.as_bytes()); Ok(()) } } From 515bd5ba0e45a417fac4225791054c39dbb0b23f Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 4 Apr 2025 17:49:32 +1100 Subject: [PATCH 110/112] misc: cleanup Signed-off-by: Anhad Singh --- src/aero_kernel/src/drivers/e1000.rs | 2 +- src/aero_kernel/src/drivers/lai.rs | 1 - src/aero_kernel/src/fs/epoll.rs | 8 +++----- src/aero_kernel/src/logger.rs | 2 +- src/aero_kernel/src/syscall/fs.rs | 2 +- src/aero_kernel/src/syscall/futex.rs | 2 +- src/aero_kernel/src/syscall/time.rs | 2 +- src/aero_kernel/src/userland/scheduler/mod.rs | 12 +++++++++++- src/aero_kernel/src/userland/task/mod.rs | 2 +- src/aero_kernel/src/utils/sync.rs | 8 ++++---- 10 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/aero_kernel/src/drivers/e1000.rs b/src/aero_kernel/src/drivers/e1000.rs index 27cca5d9700..3c1dca5c2c5 100644 --- a/src/aero_kernel/src/drivers/e1000.rs +++ b/src/aero_kernel/src/drivers/e1000.rs @@ -617,7 +617,7 @@ impl NetworkDriver for Device { return data; } else { drop(e1000); - scheduler::get_scheduler().inner.await_io().unwrap(); + scheduler::get_scheduler().await_io().unwrap(); } } } diff --git a/src/aero_kernel/src/drivers/lai.rs b/src/aero_kernel/src/drivers/lai.rs index 08c6a0114b4..1d67c694d0b 100644 --- a/src/aero_kernel/src/drivers/lai.rs +++ b/src/aero_kernel/src/drivers/lai.rs @@ -51,7 +51,6 @@ impl lai::Host for LaiHost { fn sleep(&self, ms: u64) { scheduler::get_scheduler() - .inner .sleep(Some(ms as usize / 1000)) .expect("lai: unexpected signal during sleep") } diff --git a/src/aero_kernel/src/fs/epoll.rs b/src/aero_kernel/src/fs/epoll.rs index 8cf37ceb333..8cbf9675c67 100644 --- a/src/aero_kernel/src/fs/epoll.rs +++ b/src/aero_kernel/src/fs/epoll.rs @@ -186,11 +186,9 @@ impl EPoll { } if timeout > 0 { - scheduler::get_scheduler() - .inner - .sleep(Some(timeout * 1_000_000))?; + scheduler::get_scheduler().sleep(Some(timeout * 1_000_000))?; } else { - scheduler::get_scheduler().inner.sleep(None)?; + scheduler::get_scheduler().sleep(None)?; } 'search: loop { @@ -227,7 +225,7 @@ impl EPoll { break 'search; } - scheduler::get_scheduler().inner.await_io()?; + scheduler::get_scheduler().await_io()?; } } diff --git a/src/aero_kernel/src/logger.rs b/src/aero_kernel/src/logger.rs index 988f0814786..19d43533ec0 100644 --- a/src/aero_kernel/src/logger.rs +++ b/src/aero_kernel/src/logger.rs @@ -69,7 +69,7 @@ impl log::Log for AeroLogger { if scheduler::is_initialized() { // fetch the current task, grab the TID and PID. - if let Some(task) = scheduler::get_scheduler().inner.current_task_optional() { + if let Some(task) = scheduler::get_scheduler().current_task_optional() { serial_print!( "(tid={}, pid={}) ", task.tid().as_usize(), diff --git a/src/aero_kernel/src/syscall/fs.rs b/src/aero_kernel/src/syscall/fs.rs index c3a527961b1..bbd6839389d 100644 --- a/src/aero_kernel/src/syscall/fs.rs +++ b/src/aero_kernel/src/syscall/fs.rs @@ -697,7 +697,7 @@ fn do_poll(fds: &mut [PollFd], timeout: Option<&TimeSpec>) -> Result Result { let duration = (timespec.tv_nsec as usize).div_ceil(1000000000) + timespec.tv_sec as usize; - scheduler::get_scheduler().inner.sleep(Some(duration))?; + scheduler::get_scheduler().sleep(Some(duration))?; Ok(0x00) } diff --git a/src/aero_kernel/src/userland/scheduler/mod.rs b/src/aero_kernel/src/userland/scheduler/mod.rs index 692bf81a06e..3b7ce6adb22 100644 --- a/src/aero_kernel/src/userland/scheduler/mod.rs +++ b/src/aero_kernel/src/userland/scheduler/mod.rs @@ -18,6 +18,8 @@ #[cfg(feature = "round-robin")] pub mod round_robin; +use core::ops; + use alloc::sync::Arc; use crate::arch::interrupts::{self, InterruptStack}; @@ -86,7 +88,7 @@ pub enum ExitStatus { pub struct Scheduler { tasks: TaskContainer, - pub inner: Arc, + inner: Arc, } impl Scheduler { @@ -155,6 +157,14 @@ impl Scheduler { } } +impl ops::Deref for Scheduler { + type Target = dyn SchedulerInterface; + + fn deref(&self) -> &Self::Target { + &*self.inner + } +} + /// Get a reference to the active scheduler. pub fn get_scheduler() -> &'static Scheduler { SCHEDULER diff --git a/src/aero_kernel/src/userland/task/mod.rs b/src/aero_kernel/src/userland/task/mod.rs index b0b81e2f0ab..0da42760f96 100644 --- a/src/aero_kernel/src/userland/task/mod.rs +++ b/src/aero_kernel/src/userland/task/mod.rs @@ -667,7 +667,7 @@ impl Task { } pub fn wake_up(&self) { - scheduler::get_scheduler().inner.wake_up(self.this()) + scheduler::get_scheduler().wake_up(self.this()) } pub fn is_process_leader(&self) -> bool { diff --git a/src/aero_kernel/src/utils/sync.rs b/src/aero_kernel/src/utils/sync.rs index 3168ec27068..9914c885586 100644 --- a/src/aero_kernel/src/utils/sync.rs +++ b/src/aero_kernel/src/utils/sync.rs @@ -58,7 +58,7 @@ impl WaitQueue { // Wait until the future is completed. while !future(&mut lock) { core::mem::drop(lock); // Drop the IRQ lock and await for IO to complete. - scheduler.inner.await_io()?; + scheduler.await_io()?; // Re-acquire the lock. lock = mutex.lock_irq(); @@ -94,7 +94,7 @@ impl WaitQueue { let this = self.queue.lock_irq(); for task in this.iter() { - scheduler.inner.wake_up(task.clone()); + scheduler.wake_up(task.clone()); } } @@ -104,7 +104,7 @@ impl WaitQueue { let this: MutexGuard>> = self.queue.lock_irq(); if let Some(task) = this.first() { - scheduler.inner.wake_up(task.clone()); + scheduler.wake_up(task.clone()); } } @@ -168,7 +168,7 @@ impl BMutex { return BMutexGuard { guard, mutex: self }; } - let _ = scheduler::get_scheduler().inner.await_io(); + let _ = scheduler::get_scheduler().await_io(); } } } From bf0f4969f52eb61f5c6c32ec520e27649609f09e Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Fri, 4 Apr 2025 19:31:54 +1100 Subject: [PATCH 111/112] fix: read and recv Handles were stored on open(). Obvious that this is wrong as with other fd pointing to the same file would be different. This was totally wrong. Pass open flags for now as thats what we need. May pass &fd or smth in the future. Signed-off-by: Anhad Singh --- src/aero_kernel/src/drivers/keyboard.rs | 3 +- src/aero_kernel/src/drivers/mouse.rs | 3 +- src/aero_kernel/src/drivers/pty.rs | 7 ++--- src/aero_kernel/src/drivers/tty/ctty.rs | 6 ++-- src/aero_kernel/src/drivers/tty/vtty.rs | 3 +- src/aero_kernel/src/fs/devfs.rs | 12 ++++---- src/aero_kernel/src/fs/eventfd.rs | 7 ++++- src/aero_kernel/src/fs/ext2/mod.rs | 24 ++++++++++----- src/aero_kernel/src/fs/file_table.rs | 2 +- src/aero_kernel/src/fs/inode.rs | 9 ++++-- src/aero_kernel/src/fs/pipe.rs | 12 ++------ src/aero_kernel/src/fs/procfs.rs | 3 +- src/aero_kernel/src/fs/ramfs.rs | 8 ++--- src/aero_kernel/src/socket/netlink.rs | 5 ++-- src/aero_kernel/src/socket/tcp.rs | 39 +++++++++++-------------- src/aero_kernel/src/socket/udp.rs | 7 ++++- src/aero_kernel/src/socket/unix.rs | 34 +++++++++------------ src/aero_kernel/src/syscall/net.rs | 2 +- src/aero_kernel/src/userland/vm.rs | 14 +++++---- src/aero_kernel/src/utils/mod.rs | 4 +-- src/aero_syscall/src/lib.rs | 6 ++++ 21 files changed, 114 insertions(+), 96 deletions(-) diff --git a/src/aero_kernel/src/drivers/keyboard.rs b/src/aero_kernel/src/drivers/keyboard.rs index c5e819665f3..2379c934b3a 100644 --- a/src/aero_kernel/src/drivers/keyboard.rs +++ b/src/aero_kernel/src/drivers/keyboard.rs @@ -15,6 +15,7 @@ // You should have received a copy of the GNU General Public License // along with Aero. If not, see . +use aero_syscall::OpenFlags; use alloc::sync::{Arc, Weak}; use alloc::vec::Vec; use spin::RwLock; @@ -228,7 +229,7 @@ impl KeyboardListener for KeyboardDevice { } impl INodeInterface for KeyboardDevice { - fn read_at(&self, _offset: usize, buffer: &mut [u8]) -> fs::Result { + fn read_at(&self, _flags: OpenFlags, _offset: usize, buffer: &mut [u8]) -> fs::Result { if self.buffer.lock_irq().is_empty() { return Ok(0); } diff --git a/src/aero_kernel/src/drivers/mouse.rs b/src/aero_kernel/src/drivers/mouse.rs index cd49130391c..591cbeabbdb 100644 --- a/src/aero_kernel/src/drivers/mouse.rs +++ b/src/aero_kernel/src/drivers/mouse.rs @@ -15,6 +15,7 @@ // You should have received a copy of the GNU General Public License // along with Aero. If not, see . +use aero_syscall::OpenFlags; use alloc::sync::Arc; use alloc::vec::Vec; @@ -137,7 +138,7 @@ impl Device for Mouse { } impl INodeInterface for Mouse { - fn read_at(&self, _offset: usize, buffer: &mut [u8]) -> fs::Result { + fn read_at(&self, _flags: OpenFlags, _offset: usize, buffer: &mut [u8]) -> fs::Result { let size = core::mem::size_of::(); if buffer.len() < size { diff --git a/src/aero_kernel/src/drivers/pty.rs b/src/aero_kernel/src/drivers/pty.rs index eac7ab4a899..973740f2d49 100644 --- a/src/aero_kernel/src/drivers/pty.rs +++ b/src/aero_kernel/src/drivers/pty.rs @@ -17,8 +17,7 @@ use core::sync::atomic::{AtomicU32, Ordering}; -use aero_syscall as libc; -use aero_syscall::{Termios, WinSize}; +use aero_syscall::{self as libc, OpenFlags, Termios, WinSize}; use alloc::collections::BTreeMap; use alloc::string::ToString; @@ -128,7 +127,7 @@ impl Master { } impl INodeInterface for Master { - fn read_at(&self, _offset: usize, buffer: &mut [u8]) -> fs::Result { + fn read_at(&self, _flags: OpenFlags, _offset: usize, buffer: &mut [u8]) -> fs::Result { let mut pty_buffer = self.buffer.lock_irq(); if pty_buffer.is_empty() { @@ -280,7 +279,7 @@ impl INodeInterface for Slave { Ok(flags) } - fn read_at(&self, _offset: usize, buffer: &mut [u8]) -> fs::Result { + fn read_at(&self, _flags: OpenFlags, _offset: usize, buffer: &mut [u8]) -> fs::Result { Ok(self.master.discipline.read(buffer)?) } diff --git a/src/aero_kernel/src/drivers/tty/ctty.rs b/src/aero_kernel/src/drivers/tty/ctty.rs index 5ad2a3880b2..dfe8345909d 100644 --- a/src/aero_kernel/src/drivers/tty/ctty.rs +++ b/src/aero_kernel/src/drivers/tty/ctty.rs @@ -17,7 +17,7 @@ //! `/dev/tty`: Controlling terminal of the current process. -use aero_syscall::TIOCNOTTY; +use aero_syscall::{OpenFlags, TIOCNOTTY}; use alloc::sync::{Arc, Weak}; use crate::fs::devfs::Device; @@ -64,8 +64,8 @@ impl INodeInterface for Ctty { }) } - fn read_at(&self, offset: usize, buffer: &mut [u8]) -> fs::Result { - Self::controlling_terminal()?.read_at(offset, buffer) + fn read_at(&self, flags: OpenFlags, offset: usize, buffer: &mut [u8]) -> fs::Result { + Self::controlling_terminal()?.read_at(flags, offset, buffer) } fn write_at(&self, offset: usize, buffer: &[u8]) -> fs::Result { diff --git a/src/aero_kernel/src/drivers/tty/vtty.rs b/src/aero_kernel/src/drivers/tty/vtty.rs index 4174cc2ace9..489c7708fbd 100644 --- a/src/aero_kernel/src/drivers/tty/vtty.rs +++ b/src/aero_kernel/src/drivers/tty/vtty.rs @@ -19,6 +19,7 @@ use core::sync::atomic::{AtomicUsize, Ordering}; +use aero_syscall::OpenFlags; use alloc::sync::{Arc, Weak}; use alloc::vec::Vec; @@ -246,7 +247,7 @@ impl INodeInterface for Tty { self.connected.fetch_sub(1, Ordering::SeqCst); } - fn read_at(&self, _offset: usize, buffer: &mut [u8]) -> fs::Result { + fn read_at(&self, _flags: OpenFlags, _offset: usize, buffer: &mut [u8]) -> fs::Result { self.block_queue .block_on(&self.stdin, |future| future.is_complete())?; diff --git a/src/aero_kernel/src/fs/devfs.rs b/src/aero_kernel/src/fs/devfs.rs index 39bf4cbde6a..016364ddb20 100644 --- a/src/aero_kernel/src/fs/devfs.rs +++ b/src/aero_kernel/src/fs/devfs.rs @@ -36,7 +36,7 @@ use super::ramfs::RamFs; use super::{FileSystem, FileSystemError, Result, MOUNT_MANAGER}; use aero_syscall::prelude::*; -use aero_syscall::MMapFlags; +use aero_syscall::{MMapFlags, OpenFlags}; lazy_static::lazy_static! { pub static ref DEV_FILESYSTEM: Arc = DevFs::new(); @@ -113,8 +113,8 @@ impl INodeInterface for DevINode { self.0.inode().write_at(offset, buffer) } - fn read_at(&self, offset: usize, buffer: &mut [u8]) -> Result { - self.0.inode().read_at(offset, buffer) + fn read_at(&self, flags: OpenFlags, offset: usize, buffer: &mut [u8]) -> Result { + self.0.inode().read_at(flags, offset, buffer) } fn mmap(&self, offset: usize, size: usize, flags: MMapFlags) -> Result { @@ -178,7 +178,7 @@ impl Device for DevNull { } impl INodeInterface for DevNull { - fn read_at(&self, _offset: usize, _buffer: &mut [u8]) -> Result { + fn read_at(&self, _flags: OpenFlags, _offset: usize, _buffer: &mut [u8]) -> Result { Ok(0x00) } @@ -214,7 +214,7 @@ impl Device for DevKmsg { } impl INodeInterface for DevKmsg { - fn read_at(&self, offset: usize, buffer: &mut [u8]) -> Result { + fn read_at(&self, _flags: OpenFlags, offset: usize, buffer: &mut [u8]) -> Result { let buf = logger::get_log_buffer(); let size = core::cmp::min(buffer.len(), buf.len()); @@ -448,7 +448,7 @@ impl Device for DevUrandom { } impl INodeInterface for DevUrandom { - fn read_at(&self, _offset: usize, buffer: &mut [u8]) -> Result { + fn read_at(&self, _flags: OpenFlags, _offset: usize, buffer: &mut [u8]) -> Result { for (_, b) in buffer.iter_mut().enumerate() { *b = 0; } diff --git a/src/aero_kernel/src/fs/eventfd.rs b/src/aero_kernel/src/fs/eventfd.rs index a919f6d5c6f..ec8a11bd291 100644 --- a/src/aero_kernel/src/fs/eventfd.rs +++ b/src/aero_kernel/src/fs/eventfd.rs @@ -54,7 +54,12 @@ impl INodeInterface for EventFd { Ok(None) } - fn read_at(&self, _offset: usize, buffer: &mut [u8]) -> super::Result { + fn read_at( + &self, + _flags: OpenFlags, + _offset: usize, + buffer: &mut [u8], + ) -> super::Result { let size = core::mem::size_of::(); assert!(buffer.len() >= size); diff --git a/src/aero_kernel/src/fs/ext2/mod.rs b/src/aero_kernel/src/fs/ext2/mod.rs index d37189b80e0..e4f5fa17f1d 100644 --- a/src/aero_kernel/src/fs/ext2/mod.rs +++ b/src/aero_kernel/src/fs/ext2/mod.rs @@ -21,7 +21,7 @@ mod group_desc; use core::mem::MaybeUninit; use aero_syscall::socket::{MessageFlags, MessageHeader}; -use aero_syscall::{MMapFlags, SyscallError}; +use aero_syscall::{MMapFlags, OpenFlags, SyscallError}; use alloc::boxed::Box; use alloc::string::ToString; use alloc::sync::{Arc, Weak}; @@ -364,7 +364,7 @@ impl CachedAccess for INode { } fn read_direct(&self, offset: usize, dest: PhysFrame) -> Option { - INodeInterface::read_at(self, offset, dest.as_slice_mut()).ok() + INodeInterface::read_at(self, OpenFlags::empty(), offset, dest.as_slice_mut()).ok() } fn write_direct(&self, offset: usize, src: PhysFrame) -> Option { @@ -440,9 +440,14 @@ impl INodeInterface for INode { Ok(self.make_dirent(parent, entry.name(), entry).unwrap()) } - fn read_at(&self, offset: usize, usr_buffer: &mut [u8]) -> super::Result { + fn read_at( + &self, + flags: OpenFlags, + offset: usize, + usr_buffer: &mut [u8], + ) -> super::Result { if let Some(proxy) = self.proxy.as_ref() { - return proxy.read_at(offset, usr_buffer); + return proxy.read_at(flags, offset, usr_buffer); } if !self.metadata()?.is_file() { @@ -596,7 +601,7 @@ impl INodeInterface for INode { private_cp.as_slice_mut().fill(0); let buffer = &mut private_cp.as_slice_mut()[..size]; - self.read_at(offset, buffer)?; + self.read_at(OpenFlags::empty(), offset, buffer)?; Ok(private_cp) } @@ -644,9 +649,14 @@ impl INodeInterface for INode { } } - fn recv(&self, message_hdr: &mut MessageHeader, flags: MessageFlags) -> super::Result { + fn recv( + &self, + fd_flags: OpenFlags, + message_hdr: &mut MessageHeader, + flags: MessageFlags, + ) -> super::Result { if let Some(proxy) = self.proxy.as_ref() { - proxy.recv(message_hdr, flags) + proxy.recv(fd_flags, message_hdr, flags) } else { Err(FileSystemError::NotSupported) } diff --git a/src/aero_kernel/src/fs/file_table.rs b/src/aero_kernel/src/fs/file_table.rs index fe76cf14e38..d8d0c84f9f1 100644 --- a/src/aero_kernel/src/fs/file_table.rs +++ b/src/aero_kernel/src/fs/file_table.rs @@ -81,7 +81,7 @@ impl FileHandle { pub fn read(&self, buffer: &mut [u8]) -> super::Result { let offset = self.offset.load(Ordering::SeqCst); - let new_offset = self.inode.inode().read_at(offset, buffer)?; + let new_offset = self.inode.inode().read_at(self.flags(), offset, buffer)?; self.offset.fetch_add(new_offset, Ordering::SeqCst); Ok(new_offset) diff --git a/src/aero_kernel/src/fs/inode.rs b/src/aero_kernel/src/fs/inode.rs index 930cb3eb3d8..68caab948f4 100644 --- a/src/aero_kernel/src/fs/inode.rs +++ b/src/aero_kernel/src/fs/inode.rs @@ -137,7 +137,7 @@ pub trait INodeInterface: Send + Sync { } /// Read at the provided `offset` to the given `buffer`. - fn read_at(&self, _offset: usize, _buffer: &mut [u8]) -> Result { + fn read_at(&self, _flags: OpenFlags, _offset: usize, _buffer: &mut [u8]) -> Result { Err(FileSystemError::NotSupported) } @@ -269,7 +269,12 @@ pub trait INodeInterface: Send + Sync { Err(FileSystemError::NotSupported) } - fn recv(&self, _message_hdr: &mut MessageHeader, _flags: MessageFlags) -> Result { + fn recv( + &self, + _fd_flags: OpenFlags, + _message_hdr: &mut MessageHeader, + _flags: MessageFlags, + ) -> Result { Err(FileSystemError::NotSocket) } diff --git a/src/aero_kernel/src/fs/pipe.rs b/src/aero_kernel/src/fs/pipe.rs index be0021f0de7..b47d458a7ee 100644 --- a/src/aero_kernel/src/fs/pipe.rs +++ b/src/aero_kernel/src/fs/pipe.rs @@ -37,8 +37,6 @@ pub struct Pipe { /// The number of writers currently connected to the pipe. num_writers: AtomicUsize, - - handle: Once>, } impl Pipe { @@ -50,8 +48,6 @@ impl Pipe { writers: WaitQueue::new(), num_writers: AtomicUsize::new(0), - - handle: Once::new(), }) } @@ -66,7 +62,6 @@ impl INodeInterface for Pipe { // Write end of the pipe: if handle.flags().contains(OpenFlags::O_WRONLY) { self.num_writers.fetch_add(1, Ordering::SeqCst); - self.handle.call_once(|| handle); } Ok(None) @@ -84,11 +79,8 @@ impl INodeInterface for Pipe { } } - fn read_at(&self, _offset: usize, buf: &mut [u8]) -> super::Result { - let flags = self.handle.get().expect("pipe: internal error").flags(); - - let nonblock = flags.contains(OpenFlags::O_NONBLOCK); - if nonblock && !self.queue.lock_irq().has_data() { + fn read_at(&self, flags: OpenFlags, _offset: usize, buf: &mut [u8]) -> super::Result { + if flags.is_nonblock() && !self.queue.lock_irq().has_data() { return Err(FileSystemError::WouldBlock); } diff --git a/src/aero_kernel/src/fs/procfs.rs b/src/aero_kernel/src/fs/procfs.rs index e20cce54aa4..35d4245e88d 100644 --- a/src/aero_kernel/src/fs/procfs.rs +++ b/src/aero_kernel/src/fs/procfs.rs @@ -17,6 +17,7 @@ use core::sync::atomic::{AtomicUsize, Ordering}; +use aero_syscall::OpenFlags; use alloc::borrow::ToOwned; use alloc::collections::BTreeMap; use alloc::string::ToString; @@ -183,7 +184,7 @@ impl LockedProcINode { } impl INodeInterface for LockedProcINode { - fn read_at(&self, offset: usize, buffer: &mut [u8]) -> fs::Result { + fn read_at(&self, _flags: OpenFlags, offset: usize, buffer: &mut [u8]) -> fs::Result { let this = self.0.read(); let data = match &this.contents { diff --git a/src/aero_kernel/src/fs/ramfs.rs b/src/aero_kernel/src/fs/ramfs.rs index 54d61d777f2..8db73c92cc8 100644 --- a/src/aero_kernel/src/fs/ramfs.rs +++ b/src/aero_kernel/src/fs/ramfs.rs @@ -17,7 +17,7 @@ use core::sync::atomic::{AtomicUsize, Ordering}; -use aero_syscall::MMapFlags; +use aero_syscall::{MMapFlags, OpenFlags}; use alloc::collections::BTreeMap; use alloc::string::ToString; use alloc::sync::{Arc, Weak}; @@ -261,7 +261,7 @@ impl INodeInterface for LockedRamINode { } } - fn read_at(&self, offset: usize, buffer: &mut [u8]) -> Result { + fn read_at(&self, flags: OpenFlags, offset: usize, buffer: &mut [u8]) -> Result { let this = self.0.read(); match &this.contents { @@ -294,10 +294,10 @@ impl INodeInterface for LockedRamINode { let device = device.clone(); drop(this); - device.read_at(offset, buffer) + device.read_at(flags, offset, buffer) } - FileContents::Socket(e) => e.read_at(offset, buffer), + FileContents::Socket(e) => e.read_at(flags, offset, buffer), FileContents::None => Err(FileSystemError::NotSupported), } } diff --git a/src/aero_kernel/src/socket/netlink.rs b/src/aero_kernel/src/socket/netlink.rs index e91d5c3c7ff..2113f5a4dfd 100644 --- a/src/aero_kernel/src/socket/netlink.rs +++ b/src/aero_kernel/src/socket/netlink.rs @@ -27,7 +27,7 @@ use aero_syscall::netlink::{MessageFlags, MessageType, RtAttrType}; use aero_syscall::socket::{self, MessageHeader}; -use aero_syscall::{netlink, AF_INET, AF_NETLINK, AF_UNSPEC}; +use aero_syscall::{netlink, OpenFlags, AF_INET, AF_NETLINK, AF_UNSPEC}; use alloc::sync::Arc; use alloc::vec::Vec; use crabnet::network::Ipv4Addr; @@ -211,7 +211,7 @@ impl INodeInterface for NetLinkSocket { unimplemented!() } - fn read_at(&self, _offset: usize, _buffer: &mut [u8]) -> fs::Result { + fn read_at(&self, _flags: OpenFlags, _offset: usize, _buffer: &mut [u8]) -> fs::Result { unimplemented!() } @@ -221,6 +221,7 @@ impl INodeInterface for NetLinkSocket { fn recv( &self, + _fd_flags: OpenFlags, message_hdr: &mut MessageHeader, flags: socket::MessageFlags, ) -> fs::Result { diff --git a/src/aero_kernel/src/socket/tcp.rs b/src/aero_kernel/src/socket/tcp.rs index 6b79aa10976..e1c9ba23093 100644 --- a/src/aero_kernel/src/socket/tcp.rs +++ b/src/aero_kernel/src/socket/tcp.rs @@ -27,7 +27,6 @@ use crabnet::data_link::{Eth, EthType, MacAddr}; use crabnet::transport::{Tcp, TcpOptions}; use crabnet_tcp::{Address, Error as TcpError, Packet as TcpPacket, State}; -use crate::fs::file_table::FileHandle; use crate::fs::inode::{FileType, INodeInterface, Metadata, PollFlags, PollTable}; use crate::fs::{self, FileSystemError}; use crate::net; @@ -59,7 +58,6 @@ impl crabnet_tcp::NetworkDevice for DeviceShim { pub struct TcpSocket { tcp: Mutex>>, wq: WaitQueue, - handle: Once>, sref: Weak, peer: Once, } @@ -70,7 +68,6 @@ impl TcpSocket { tcp: Mutex::new(None), wq: WaitQueue::new(), sref: sref.clone(), - handle: Once::new(), peer: Once::new(), }) } @@ -89,27 +86,20 @@ impl TcpSocket { self.sref.upgrade().unwrap() } - /// Returns whether the socket is in non-blocking mode. - pub fn non_blocking(&self) -> bool { - self.handle - .get() - .is_some_and(|handle| handle.flags().contains(OpenFlags::O_NONBLOCK)) - } - - pub fn do_recv(&self, buf: &mut [u8]) -> Result { + pub fn do_recv(&self, flags: OpenFlags, buf: &mut [u8]) -> Result { let mut tcp = self.tcp.lock_irq(); let socket = tcp.as_mut().ok_or(FileSystemError::NotConnected)?; match socket.recv(buf) { Ok(bytes_read) => Ok(bytes_read), - Err(TcpError::WouldBlock) if self.non_blocking() => Err(FileSystemError::WouldBlock), + Err(TcpError::WouldBlock) if flags.is_nonblock() => Err(FileSystemError::WouldBlock), Err(TcpError::WouldBlock) => { drop(tcp); let mut socket = self.wq.block_on(&self.tcp, |tcp| { tcp.as_ref() - .map_or(true, |socket| !socket.recv_queue.is_empty()) + .is_none_or(|socket| !socket.recv_queue.is_empty()) })?; if let Some(socket) = socket.as_mut() { @@ -162,19 +152,19 @@ impl INodeInterface for TcpSocket { Ok(()) } - fn open(&self, handle: Arc) -> fs::Result> { - self.handle.call_once(|| handle); - Ok(None) - } - #[inline] fn metadata(&self) -> Result { Ok(Metadata::with_file_type(FileType::Socket)) } #[inline] - fn read_at(&self, _offset: usize, buf: &mut [u8]) -> Result { - self.do_recv(buf) + fn read_at( + &self, + flags: OpenFlags, + _offset: usize, + buf: &mut [u8], + ) -> Result { + self.do_recv(flags, buf) } #[inline] @@ -230,13 +220,18 @@ impl INodeInterface for TcpSocket { } } - fn recv(&self, message_hdr: &mut MessageHeader, _flags: MessageFlags) -> fs::Result { + fn recv( + &self, + fd_flags: OpenFlags, + message_hdr: &mut MessageHeader, + _flags: MessageFlags, + ) -> fs::Result { Ok(message_hdr .iovecs_mut() .iter_mut() .map(|iovec| { let iovec = iovec.as_slice_mut(); - self.do_recv(iovec).unwrap() + self.do_recv(fd_flags, iovec).unwrap() }) .sum::()) } diff --git a/src/aero_kernel/src/socket/udp.rs b/src/aero_kernel/src/socket/udp.rs index 453279e7398..c346255bc94 100644 --- a/src/aero_kernel/src/socket/udp.rs +++ b/src/aero_kernel/src/socket/udp.rs @@ -185,7 +185,12 @@ impl INodeInterface for UdpSocket { Ok(data.len()) } - fn recv(&self, message_hdr: &mut MessageHeader, _flags: MessageFlags) -> fs::Result { + fn recv( + &self, + _fd_flags: OpenFlags, + message_hdr: &mut MessageHeader, + _flags: MessageFlags, + ) -> fs::Result { // assert!(flags.is_empty()); if self.inner.lock_irq().incoming.is_empty() && self.is_non_block() { diff --git a/src/aero_kernel/src/socket/unix.rs b/src/aero_kernel/src/socket/unix.rs index bc243f4f0dc..97e766e1807 100644 --- a/src/aero_kernel/src/socket/unix.rs +++ b/src/aero_kernel/src/socket/unix.rs @@ -22,7 +22,6 @@ use aero_syscall::socket::{MessageFlags, MessageHeader}; use alloc::collections::VecDeque; use alloc::sync::{Arc, Weak}; use alloc::vec::Vec; -use spin::Once; use crate::arch::user_copy::UserRef; use crate::fs; @@ -194,7 +193,6 @@ pub struct UnixSocket { buffer: Mutex, wq: WaitQueue, weak: Weak, - handle: Once>, } impl UnixSocket { @@ -205,7 +203,6 @@ impl UnixSocket { buffer: Mutex::new(MessageQueue::default()), wq: WaitQueue::new(), weak: weak.clone(), - handle: Once::new(), }) } @@ -228,14 +225,6 @@ impl UnixSocket { pub fn sref(&self) -> Arc { self.weak.upgrade().unwrap() } - - pub fn is_non_block(&self) -> bool { - self.handle - .get() - .expect("unix: not bound to an fd") - .flags() - .contains(OpenFlags::O_NONBLOCK) - } } impl INodeInterface for UnixSocket { @@ -248,13 +237,13 @@ impl INodeInterface for UnixSocket { }) } - fn open(&self, handle: Arc) -> fs::Result> { - self.handle.call_once(|| handle); - Ok(None) - } - - fn read_at(&self, _offset: usize, user_buffer: &mut [u8]) -> fs::Result { - if self.buffer.lock_irq().is_empty() && self.is_non_block() { + fn read_at( + &self, + flags: OpenFlags, + _offset: usize, + user_buffer: &mut [u8], + ) -> fs::Result { + if self.buffer.lock_irq().is_empty() && flags.is_nonblock() { return Err(FileSystemError::WouldBlock); } @@ -383,7 +372,12 @@ impl INodeInterface for UnixSocket { Ok(sock) } - fn recv(&self, header: &mut MessageHeader, flags: MessageFlags) -> fs::Result { + fn recv( + &self, + fd_flags: OpenFlags, + header: &mut MessageHeader, + flags: MessageFlags, + ) -> fs::Result { // assert!(flags.is_empty()); let inner = self.inner.lock_irq(); @@ -393,7 +387,7 @@ impl INodeInterface for UnixSocket { _ => return Err(FileSystemError::NotConnected), }; - if self.buffer.lock_irq().is_empty() && self.is_non_block() { + if self.buffer.lock_irq().is_empty() && fd_flags.is_nonblock() { return Err(FileSystemError::WouldBlock); } diff --git a/src/aero_kernel/src/syscall/net.rs b/src/aero_kernel/src/syscall/net.rs index aecdd5af984..9f36d796db5 100644 --- a/src/aero_kernel/src/syscall/net.rs +++ b/src/aero_kernel/src/syscall/net.rs @@ -117,7 +117,7 @@ pub fn sock_recv(sockfd: usize, header: &mut MessageHeader, flags: usize) -> Res .get_handle(sockfd) .ok_or(SyscallError::EINVAL)?; - Ok(socket.inode().recv(header, flags)?) + Ok(socket.inode().recv(socket.flags(), header, flags)?) } #[syscall] diff --git a/src/aero_kernel/src/userland/vm.rs b/src/aero_kernel/src/userland/vm.rs index 8251431e557..458c3dc6142 100644 --- a/src/aero_kernel/src/userland/vm.rs +++ b/src/aero_kernel/src/userland/vm.rs @@ -18,7 +18,7 @@ use core::fmt::Write; use core::ops::Range; -use aero_syscall::{MMapFlags, MMapProt}; +use aero_syscall::{MMapFlags, MMapProt, OpenFlags}; use alloc::boxed::Box; use alloc::collections::linked_list::CursorMut; @@ -111,7 +111,7 @@ fn parse_elf_header<'header>(file: &DirCacheItem) -> Result, Elf let pt1_hdr_slice = Box::leak(mem::alloc_boxed_buffer::(ELF_PT1_SIZE)); file.inode() - .read_at(0, pt1_hdr_slice) + .read_at(OpenFlags::empty(), 0, pt1_hdr_slice) .map_err(ElfLoadError::IOError)?; let pt1_header: &'header _ = unsafe { &*pt1_hdr_slice.as_ptr().cast::() }; @@ -127,7 +127,7 @@ fn parse_elf_header<'header>(file: &DirCacheItem) -> Result, Elf let pt2_hdr_slice = Box::leak(mem::alloc_boxed_buffer::(ELF_PT2_64_SIZE)); file.inode() - .read_at(ELF_PT1_SIZE, pt2_hdr_slice) + .read_at(OpenFlags::empty(), ELF_PT1_SIZE, pt2_hdr_slice) .map_err(ElfLoadError::IOError)?; let pt2_header_ptr = pt2_hdr_slice.as_ptr(); @@ -171,7 +171,7 @@ fn parse_program_header<'pheader>( let phdr_buffer = Box::leak(mem::alloc_boxed_buffer::(size)); file.inode() - .read_at(start, phdr_buffer) + .read_at(OpenFlags::empty(), start, phdr_buffer) .map_err(ElfLoadError::IOError)?; let phdr_ptr = phdr_buffer.as_ptr(); @@ -216,7 +216,7 @@ fn contains_shebang(bin: &DirCacheItem) -> Result { let shebang = &mut [0u8; 2]; bin.inode() - .read_at(0, shebang) + .read_at(OpenFlags::empty(), 0, shebang) .map_err(ElfLoadError::IOError)?; Ok(shebang[0] == b'#' && shebang[1] == b'!') @@ -235,7 +235,9 @@ fn parse_shebang(bin: &DirCacheItem) -> Result, ElfLoadError> { let read_at_index = |idx: usize| -> Result { let c = &mut [0u8; 1]; - bin.inode().read_at(idx, c).map_err(ElfLoadError::IOError)?; + bin.inode() + .read_at(OpenFlags::empty(), idx, c) + .map_err(ElfLoadError::IOError)?; Ok(c[0] as char) }; diff --git a/src/aero_kernel/src/utils/mod.rs b/src/aero_kernel/src/utils/mod.rs index e2ce5a60da5..029d1457ee5 100644 --- a/src/aero_kernel/src/utils/mod.rs +++ b/src/aero_kernel/src/utils/mod.rs @@ -231,9 +231,9 @@ macro_rules! extern_sym { static $sym: ::core::ffi::c_void; } - // SAFETY: The value is not accessed, we only take its address. The `addr_of!()` ensures + // The value is not accessed, we only take its address. The `addr_of!()` ensures // that no intermediate references is created. - unsafe { ::core::ptr::addr_of!($sym) } + ::core::ptr::addr_of!($sym) }}; } diff --git a/src/aero_syscall/src/lib.rs b/src/aero_syscall/src/lib.rs index 1c45a870178..03c7132aaf5 100644 --- a/src/aero_syscall/src/lib.rs +++ b/src/aero_syscall/src/lib.rs @@ -96,6 +96,12 @@ bitflags::bitflags! { } } +impl OpenFlags { + pub fn is_nonblock(&self) -> bool { + self.contains(Self::O_NONBLOCK) + } +} + bitflags::bitflags! { pub struct WaitPidFlags: usize { const WNOHANG = 1; From be57ae00e122c5710d449314f828352bbc7164d2 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Mon, 7 Apr 2025 15:50:08 +1000 Subject: [PATCH 112/112] feat(wq): non interruptable and non blocking Signed-off-by: Anhad Singh --- src/aero_kernel/src/drivers/tty/vtty.rs | 13 +- src/aero_kernel/src/fs/eventfd.rs | 9 +- src/aero_kernel/src/fs/pipe.rs | 4 +- src/aero_kernel/src/main.rs | 7 +- src/aero_kernel/src/socket/netlink.rs | 4 +- src/aero_kernel/src/socket/tcp.rs | 7 +- src/aero_kernel/src/socket/udp.rs | 9 +- src/aero_kernel/src/socket/unix.rs | 29 +++-- src/aero_kernel/src/syscall/fs.rs | 11 +- src/aero_kernel/src/syscall/ipc.rs | 6 +- src/aero_kernel/src/userland/task/mod.rs | 8 +- src/aero_kernel/src/userland/terminal.rs | 9 +- src/aero_kernel/src/utils/sync.rs | 150 ++++++++++++++++++++--- 13 files changed, 186 insertions(+), 80 deletions(-) diff --git a/src/aero_kernel/src/drivers/tty/vtty.rs b/src/aero_kernel/src/drivers/tty/vtty.rs index 489c7708fbd..f86eb80de83 100644 --- a/src/aero_kernel/src/drivers/tty/vtty.rs +++ b/src/aero_kernel/src/drivers/tty/vtty.rs @@ -32,7 +32,7 @@ use crate::mem::paging::VirtAddr; use crate::userland::scheduler; use crate::userland::task::Task; use crate::userland::terminal::TerminalDevice; -use crate::utils::sync::{Mutex, WaitQueue}; +use crate::utils::sync::{Mutex, WaitQueue, WaitQueueFlags}; #[cfg(target_arch = "x86_64")] use crate::drivers::keyboard::KeyCode; @@ -247,11 +247,12 @@ impl INodeInterface for Tty { self.connected.fetch_sub(1, Ordering::SeqCst); } - fn read_at(&self, _flags: OpenFlags, _offset: usize, buffer: &mut [u8]) -> fs::Result { - self.block_queue - .block_on(&self.stdin, |future| future.is_complete())?; - - let mut stdin = self.stdin.lock_irq(); + fn read_at(&self, flags: OpenFlags, _offset: usize, buffer: &mut [u8]) -> fs::Result { + let mut stdin = self.block_queue.wait( + WaitQueueFlags::from(flags) | WaitQueueFlags::DISABLE_IRQ, + &self.stdin, + |future| future.is_complete(), + )?; // record the back buffer size before swapping stdin.swap_buffer(); diff --git a/src/aero_kernel/src/fs/eventfd.rs b/src/aero_kernel/src/fs/eventfd.rs index ec8a11bd291..46b1fdd0abe 100644 --- a/src/aero_kernel/src/fs/eventfd.rs +++ b/src/aero_kernel/src/fs/eventfd.rs @@ -54,19 +54,14 @@ impl INodeInterface for EventFd { Ok(None) } - fn read_at( - &self, - _flags: OpenFlags, - _offset: usize, - buffer: &mut [u8], - ) -> super::Result { + fn read_at(&self, flags: OpenFlags, _offset: usize, buffer: &mut [u8]) -> super::Result { let size = core::mem::size_of::(); assert!(buffer.len() >= size); // SAFETY: We have above verified that it is safe to dereference // the value. let value = unsafe { &mut *(buffer.as_mut_ptr().cast::()) }; - let mut count = self.wq.block_on(&self.count, |e| **e != 0)?; + let mut count = self.wq.wait(flags.into(), &self.count, |e| **e != 0)?; *value = *count; *count = 0; // reset the counter diff --git a/src/aero_kernel/src/fs/pipe.rs b/src/aero_kernel/src/fs/pipe.rs index b47d458a7ee..d55b4b5d3af 100644 --- a/src/aero_kernel/src/fs/pipe.rs +++ b/src/aero_kernel/src/fs/pipe.rs @@ -22,7 +22,7 @@ use alloc::sync::Arc; use spin::Once; use crate::utils::buffer::Buffer; -use crate::utils::sync::{Mutex, WaitQueue}; +use crate::utils::sync::{Mutex, WaitQueue, WaitQueueFlags}; use super::cache::DirCacheItem; use super::file_table::FileHandle; @@ -84,7 +84,7 @@ impl INodeInterface for Pipe { return Err(FileSystemError::WouldBlock); } - let mut buffer = self.readers.block_on(&self.queue, |lock| { + let mut buffer = self.readers.wait(flags.into(), &self.queue, |lock| { lock.has_data() || self.active_writers() == 0 })?; diff --git a/src/aero_kernel/src/main.rs b/src/aero_kernel/src/main.rs index ec917a72daa..4330c930589 100644 --- a/src/aero_kernel/src/main.rs +++ b/src/aero_kernel/src/main.rs @@ -45,7 +45,7 @@ cfg_match, // https://github.com/rust-lang/rust/issues/115585 associated_type_defaults, new_zeroed_alloc, // https://github.com/rust-lang/rust/issues/129396 - sync_unsafe_cell + sync_unsafe_cell, )] // TODO(andypython): can we remove the dependency of "prelude_import" and "lang_items"? // `lang_items` => is currently used for the personality function (`rust_eh_personality`). @@ -59,6 +59,7 @@ #![reexport_test_harness_main = "test_main"] #![warn(clippy::needless_pass_by_value)] #![deny(clippy::ptr_as_ptr)] +#![allow(binary_asm_labels)] #[macro_use] extern crate aero_proc; @@ -214,7 +215,7 @@ fn kernel_dbg_thread() { use crate::drivers::uart::{self, LineStatus, COM_1}; use crate::userland::task::TaskId; - use crate::utils::sync::WaitQueue; + use crate::utils::sync::{WaitQueue, WaitQueueFlags}; uart::setup_interrupts(); @@ -229,7 +230,7 @@ fn kernel_dbg_thread() { loop { let mut com_1 = input_wq - .block_on(com_1, |com_1| { + .wait(WaitQueueFlags::empty(), com_1, |com_1| { com_1.line_status().contains(LineStatus::INPUT_FULL) }) .unwrap(); diff --git a/src/aero_kernel/src/socket/netlink.rs b/src/aero_kernel/src/socket/netlink.rs index 2113f5a4dfd..55240f2adbf 100644 --- a/src/aero_kernel/src/socket/netlink.rs +++ b/src/aero_kernel/src/socket/netlink.rs @@ -221,7 +221,7 @@ impl INodeInterface for NetLinkSocket { fn recv( &self, - _fd_flags: OpenFlags, + fd_flags: OpenFlags, message_hdr: &mut MessageHeader, flags: socket::MessageFlags, ) -> fs::Result { @@ -239,7 +239,7 @@ impl INodeInterface for NetLinkSocket { let mut queue = self .recv_wq - .block_on(&self.recv_queue, |queue| !queue.is_empty())?; + .wait(fd_flags.into(), &self.recv_queue, |queue| !queue.is_empty())?; let mut bytes_copied = 0; dbg!(message_hdr.iovecs_mut()); diff --git a/src/aero_kernel/src/socket/tcp.rs b/src/aero_kernel/src/socket/tcp.rs index e1c9ba23093..f135fe7d3fa 100644 --- a/src/aero_kernel/src/socket/tcp.rs +++ b/src/aero_kernel/src/socket/tcp.rs @@ -32,7 +32,7 @@ use crate::fs::{self, FileSystemError}; use crate::net; use crate::net::shim::PacketSend; use crate::net::{tcp, NetworkDevice}; -use crate::utils::sync::{Mutex, WaitQueue}; +use crate::utils::sync::{Mutex, WaitQueue, WaitQueueFlags}; // ./aero.py -- -netdev user,id=mynet0 -device e1000,netdev=mynet0,id=ck_nic0 -object // filter-dump,id=mynet0,netdev=mynet0,file=qemulog.log @@ -97,7 +97,7 @@ impl TcpSocket { Err(TcpError::WouldBlock) => { drop(tcp); - let mut socket = self.wq.block_on(&self.tcp, |tcp| { + let mut socket = self.wq.wait(flags.into(), &self.tcp, |tcp| { tcp.as_ref() .is_none_or(|socket| !socket.recv_queue.is_empty()) })?; @@ -145,7 +145,8 @@ impl INodeInterface for TcpSocket { *tcp = Some(socket); } - let _ = self.wq.block_on(&self.tcp, |x| { + // FIXME: connect() should pass the fd. + let _ = self.wq.wait(WaitQueueFlags::empty(), &self.tcp, |x| { x.as_ref().unwrap().state() == State::Established }); diff --git a/src/aero_kernel/src/socket/udp.rs b/src/aero_kernel/src/socket/udp.rs index c346255bc94..83934c8484c 100644 --- a/src/aero_kernel/src/socket/udp.rs +++ b/src/aero_kernel/src/socket/udp.rs @@ -187,17 +187,16 @@ impl INodeInterface for UdpSocket { fn recv( &self, - _fd_flags: OpenFlags, + fd_flags: OpenFlags, message_hdr: &mut MessageHeader, _flags: MessageFlags, ) -> fs::Result { // assert!(flags.is_empty()); - if self.inner.lock_irq().incoming.is_empty() && self.is_non_block() { - return Err(FileSystemError::WouldBlock); - } + let mut this = self + .wq + .wait(fd_flags.into(), &self.inner, |e| !e.incoming.is_empty())?; - let mut this = self.wq.block_on(&self.inner, |e| !e.incoming.is_empty())?; let packet = this.incoming.pop().expect("recv: someone was greedy"); let mut data = packet.as_slice().to_vec(); diff --git a/src/aero_kernel/src/socket/unix.rs b/src/aero_kernel/src/socket/unix.rs index 97e766e1807..749cfce3e46 100644 --- a/src/aero_kernel/src/socket/unix.rs +++ b/src/aero_kernel/src/socket/unix.rs @@ -32,7 +32,7 @@ use crate::fs::inode::{DirEntry, FileType, INodeInterface, Metadata, PollFlags, use crate::fs::{FileSystemError, Path}; use crate::mem::paging::VirtAddr; -use crate::utils::sync::{Mutex, WaitQueue}; +use crate::utils::sync::{Mutex, WaitQueue, WaitQueueFlags}; use super::SocketAddrRef; @@ -243,14 +243,11 @@ impl INodeInterface for UnixSocket { _offset: usize, user_buffer: &mut [u8], ) -> fs::Result { - if self.buffer.lock_irq().is_empty() && flags.is_nonblock() { - return Err(FileSystemError::WouldBlock); - } - - let mut buffer = self.wq.block_on(&self.buffer, |e| !e.is_empty())?; + let mut buf = self + .wq + .wait(flags.into(), &self.buffer, |e| !e.is_empty())?; - let read = buffer.read(user_buffer); - Ok(read) + Ok(buf.read(user_buffer)) } fn write_at(&self, _offset: usize, buffer: &[u8]) -> fs::Result { @@ -325,12 +322,16 @@ impl INodeInterface for UnixSocket { target.wq.notify_all(); core::mem::drop(itarget); // release the lock - let _ = self.wq.block_on(&self.inner, |e| e.state.is_connected())?; + // FIXME: connect() should pass fd. + let _ = self.wq.wait(WaitQueueFlags::empty(), &self.inner, |e| { + e.state.is_connected() + })?; Ok(()) } fn accept(&self, address: Option<(VirtAddr, &mut u32)>) -> fs::Result> { - let mut inner = self.wq.block_on(&self.inner, |e| { + // TODO: accept + let mut inner = self.wq.wait(WaitQueueFlags::empty(), &self.inner, |e| { e.state.queue().is_some_and(|x| !x.is_empty()) })?; @@ -387,11 +388,9 @@ impl INodeInterface for UnixSocket { _ => return Err(FileSystemError::NotConnected), }; - if self.buffer.lock_irq().is_empty() && fd_flags.is_nonblock() { - return Err(FileSystemError::WouldBlock); - } - - let mut buffer = self.wq.block_on(&self.buffer, |e| !e.is_empty())?; + let mut buffer = self + .wq + .wait(fd_flags.into(), &self.buffer, |e| !e.is_empty())?; if let Some(addr) = header.name_mut::() { *addr = peer.inner.lock_irq().address.as_ref().cloned().unwrap(); diff --git a/src/aero_kernel/src/syscall/fs.rs b/src/aero_kernel/src/syscall/fs.rs index bbd6839389d..415ed0d3d30 100644 --- a/src/aero_kernel/src/syscall/fs.rs +++ b/src/aero_kernel/src/syscall/fs.rs @@ -56,7 +56,6 @@ impl fmt::Display for FileDescriptor { let path = file_handle.inode.absolute_path(); write!(f, "{{ {} -> {} }}", self.0, path) } else { - // invalid file descriptor write!(f, "{{ {} -> INVALID }}", self.0) } } @@ -164,10 +163,7 @@ pub fn getdents(fd: FileDescriptor, buffer: &mut [u8]) -> Result Result { - let res = scheduler::get_scheduler() - .current_task() - .file_table - .close_file(fd.into()); + let res = scheduler::current_thread().file_table.close_file(fd.into()); if res { Ok(0) @@ -218,11 +214,10 @@ pub fn mkdirat(dfd: usize, path: &Path) -> Result { // pathname is interpreted relative to the current working directory of the // calling task. if dfd as isize == aero_syscall::AT_FDCWD { - let cwd = scheduler::get_scheduler().current_task().cwd_dirent(); + let cwd = scheduler::current_thread().cwd_dirent(); (cwd.inode(), path.as_str()) } else { - let handle = scheduler::get_scheduler() - .current_task() + let handle = scheduler::current_thread() .file_table .get_handle(dfd) .ok_or(SyscallError::EBADFD)?; diff --git a/src/aero_kernel/src/syscall/ipc.rs b/src/aero_kernel/src/syscall/ipc.rs index f6471c44bcd..d1bede83519 100644 --- a/src/aero_kernel/src/syscall/ipc.rs +++ b/src/aero_kernel/src/syscall/ipc.rs @@ -18,7 +18,7 @@ use crate::userland::scheduler::get_scheduler; use crate::userland::task::TaskId; -use crate::utils::sync::{Mutex, WaitQueue}; +use crate::utils::sync::{Mutex, WaitQueue, WaitQueueFlags}; use aero_syscall::SyscallError; use alloc::collections::VecDeque; @@ -103,7 +103,9 @@ pub fn recv(pid_ptr: &mut usize, output: &mut [u8], block: usize) -> Result SignalResult { + ) -> Result { let mut captured = None; - self.block.block_on(&self.list, |l| { + self.block.wait(WaitQueueFlags::empty(), &self.list, |l| { let mut cursor = l.front_mut(); while let Some(t) = cursor.get() { @@ -488,7 +488,7 @@ impl Task { pid: isize, status: &mut u32, flags: WaitPidFlags, - ) -> SignalResult { + ) -> Result { if pid == -1 { // wait for any child process if no specific process is requested. // diff --git a/src/aero_kernel/src/userland/terminal.rs b/src/aero_kernel/src/userland/terminal.rs index 5d1313f3a81..7d568d788a3 100644 --- a/src/aero_kernel/src/userland/terminal.rs +++ b/src/aero_kernel/src/userland/terminal.rs @@ -22,8 +22,9 @@ use alloc::vec::Vec; use spin::RwLock; +use crate::fs; use crate::fs::inode::INodeInterface; -use crate::utils::sync::{Mutex, WaitQueue}; +use crate::utils::sync::{Mutex, WaitQueue, WaitQueueFlags}; use super::signals::SignalError; use super::task::sessions::{Group, SESSIONS}; @@ -114,8 +115,10 @@ impl LineDiscipline { *self.termios.lock() = termios; } - pub fn read(&self, target: &mut [u8]) -> Result { - let mut buffer = self.wq.block_on(&self.buffer, |buf| !buf.is_empty())?; + pub fn read(&self, target: &mut [u8]) -> fs::Result { + let mut buffer = self + .wq + .wait(WaitQueueFlags::empty(), &self.buffer, |buf| !buf.is_empty())?; let size = core::cmp::min(target.len(), buffer.len()); target[..size].copy_from_slice(&buffer.drain(..size).collect::>()); diff --git a/src/aero_kernel/src/utils/sync.rs b/src/aero_kernel/src/utils/sync.rs index 9914c885586..8254e338c9d 100644 --- a/src/aero_kernel/src/utils/sync.rs +++ b/src/aero_kernel/src/utils/sync.rs @@ -15,59 +15,163 @@ // You should have received a copy of the GNU General Public License // along with Aero. If not, see . +use aero_syscall::{OpenFlags, SyscallError}; use alloc::sync::Arc; use alloc::vec::Vec; use crate::arch::interrupts; +use crate::fs::FileSystemError; use crate::userland::scheduler; -use crate::userland::signals::SignalResult; +use crate::userland::signals::SignalError; use crate::userland::task::Task; -/// Used to manage and block threads that are waiting for a condition to be true. +bitflags::bitflags! { + #[derive(Debug, Copy, Clone)] + pub struct WaitQueueFlags: u32 { + const DISABLE_IRQ = 1 << 1; + const NON_BLOCK = 1 << 2; + } +} + +impl WaitQueueFlags { + pub const fn is_nonblock(&self) -> bool { + self.contains(WaitQueueFlags::NON_BLOCK) + } +} + +impl From for WaitQueueFlags { + fn from(flags: OpenFlags) -> Self { + let mut result = WaitQueueFlags::empty(); + if flags.contains(OpenFlags::O_NONBLOCK) { + result.insert(WaitQueueFlags::NON_BLOCK); + } + result + } +} + +#[derive(Debug, Copy, Clone)] +pub enum WaitQueueError { + Interrupted, + WouldBlock, +} + +impl From for FileSystemError { + fn from(err: WaitQueueError) -> Self { + match err { + WaitQueueError::Interrupted => FileSystemError::Interrupted, + WaitQueueError::WouldBlock => FileSystemError::WouldBlock, + } + } +} + +impl From for SyscallError { + fn from(err: WaitQueueError) -> Self { + match err { + WaitQueueError::Interrupted => SyscallError::EINTR, + WaitQueueError::WouldBlock => SyscallError::EAGAIN, + } + } +} + +/// Queue of tasks waiting for an event to occur. pub struct WaitQueue { queue: Mutex>>, } impl WaitQueue { - /// Creates a new block queue. + /// Create a new wait queue. pub const fn new() -> Self { Self { queue: Mutex::new(Vec::new()), } } - /// Run a future to completion on the current task. This function will block - /// the caller until the given future has completed. - pub fn block_on<'future, T, F: FnMut(&mut MutexGuard) -> bool>( + fn _wait<'a, T, F>( &self, - mutex: &'future Mutex, - mut future: F, - ) -> SignalResult> { - let mut lock = mutex.lock_irq(); + mutex: &'a Mutex, + mut cond: F, + interruptable: bool, + flags: WaitQueueFlags, + ) -> Result, WaitQueueError> + where + F: FnMut(&mut MutexGuard) -> bool, + { + let acquire = || { + if flags.contains(WaitQueueFlags::DISABLE_IRQ) { + mutex.lock() + } else { + mutex.lock_irq() + } + }; - // Check if the future was already completed. - if future(&mut lock) { + let mut lock = acquire(); + if cond(&mut lock) { + // Condition is already satisfied. return Ok(lock); } + if flags.is_nonblock() { + return Err(WaitQueueError::WouldBlock); + } + let scheduler = scheduler::get_scheduler(); - let task = scheduler.current_task(); + let task = scheduler::current_thread(); - self.queue.lock_irq().push(task.clone()); + // If no IRQs was requested, the above lock would have disabled them so, + // `lock_irq` is not required here. + self.queue.lock().push(task.clone()); - // Wait until the future is completed. - while !future(&mut lock) { - core::mem::drop(lock); // Drop the IRQ lock and await for IO to complete. - scheduler.await_io()?; + while !cond(&mut lock) { + drop(lock); - // Re-acquire the lock. - lock = mutex.lock_irq(); + match scheduler.await_io() { + Ok(()) => lock = mutex.lock_irq(), + Err(SignalError::Interrupted) if !interruptable => lock = acquire(), + + Err(SignalError::Interrupted) => { + self.remove(&task); + return Err(WaitQueueError::Interrupted); + } + } } self.remove(&task); Ok(lock) } + /// Sleeps until a condition is met. + /// + /// Should be used when waiting for events such as completion of disk I/O. Any signals sent + /// while waiting shall not be delivered until the condition is met and the wait is over. + pub fn wait_uninterruptible<'a, T, F>( + &self, + flags: WaitQueueFlags, + mutex: &'a Mutex, + cond: F, + ) -> MutexGuard<'a, T> + where + F: FnMut(&mut MutexGuard) -> bool, + { + unsafe { + self._wait(mutex, cond, false, flags) + // SAFETY: [`SignalError`] cannot occur on non-interruptible wait. + .unwrap_unchecked() + } + } + + /// Sleeps until a condition is met. + /// + /// Should be used when waiting for events such as data being written to a pipe. Returns + /// [`SignalError::Interrupted`] if the wait was interrupted by a signal. + pub fn wait<'a, T, F: FnMut(&mut MutexGuard) -> bool>( + &self, + flags: WaitQueueFlags, + mutex: &'a Mutex, + cond: F, + ) -> Result, WaitQueueError> { + self._wait(mutex, cond, true, flags) + } + pub fn insert(&self, task: Arc) { self.queue.lock_irq().push(task); } @@ -113,6 +217,12 @@ impl WaitQueue { } } +impl Default for WaitQueue { + fn default() -> Self { + Self::new() + } +} + /// Helper guard structure used to lock interrupts. When dropped, interrupts /// are enabled again. This is useful for volatile operations where we don't /// want to be interrupted.